View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.element;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.uif.component.Component;
21  import org.kuali.rice.krad.uif.container.Group;
22  
23  import java.util.List;
24  
25  /**
26   * Component that renders a navigation bar, including a branding and navigation group.
27   *
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  @BeanTag(name = "navbar", parent = "Uif-NavigationBar")
31  public class NavigationBar extends ContentElementBase {
32      private static final long serialVersionUID = -2061519100931559642L;
33  
34      private String brandText;
35      private Image brandImage;
36      private String brandUrl;
37  
38      private Group navigationBarGroup;
39  
40      public NavigationBar() {
41          super();
42          this.brandUrl = "#";
43      }
44  
45      /**
46       * Header text to use for the application branding.
47       *
48       * <p>Note either the branding text, or the {@link NavigationBar#getBrandImage()} should be set, but
49       * not both</p>
50       *
51       * @return String text to use for branding
52       */
53      @BeanTagAttribute
54      public String getBrandText() {
55          return brandText;
56      }
57  
58      /**
59       * @see NavigationBar#getBrandText()
60       */
61      public void setBrandText(String brandText) {
62          this.brandText = brandText;
63      }
64  
65      /**
66       * Image component instance to use for the application branding.
67       *
68       * <p>Note either the branding image, or the {@link NavigationBar#getBrandText()} should be set, but
69       * not both</p>
70       *
71       * @return Image component to use for branding
72       */
73      @BeanTagAttribute
74      public Image getBrandImage() {
75          return brandImage;
76      }
77  
78      /**
79       * @see NavigationBar#getBrandImage()
80       */
81      public void setBrandImage(Image brandImage) {
82          this.brandImage = brandImage;
83      }
84  
85      /**
86       * String of URL set in rendering the navigation component.
87       *
88       * @return String of the URL
89       */
90      @BeanTagAttribute
91      public String getBrandUrl() {
92          return brandUrl;
93      }
94  
95      /**
96       * @see NavigationBar#getBrandUrl()
97       */
98      public void setBrandUrl(String brandUrl) {
99          this.brandUrl = brandUrl;
100     }
101 
102     /**
103      * Group instance that holds the navigation items (such as links) for the navigation bar.
104      *
105      * @return Group instance for navigation
106      */
107     @BeanTagAttribute
108     public Group getNavigationBarGroup() {
109         return navigationBarGroup;
110     }
111 
112     /**
113      * @see NavigationBar#getNavigationBarGroup()
114      */
115     public void setNavigationBarGroup(Group navigationBarGroup) {
116         this.navigationBarGroup = navigationBarGroup;
117     }
118 
119     /**
120      * Convenience getter for the navigation group items.
121      *
122      * @return list of components for the navigation bar group
123      */
124     @BeanTagAttribute
125     public List<? extends Component> getItems() {
126         if (this.navigationBarGroup != null) {
127             return this.navigationBarGroup.getItems();
128         }
129 
130         return null;
131     }
132 
133     /**
134      * Convenience setter that sets the given items onto the {@link NavigationBar#getNavigationBarGroup()}.
135      *
136      * @param items list of items for the navigation group
137      */
138     public void setItems(List<Component> items) {
139         if (this.navigationBarGroup == null) {
140             throw new RuntimeException("Unable to set navigation items because navigation group is null");
141         } else {
142             this.navigationBarGroup.setItems(items);
143         }
144     }
145 }