001/** 002 * Copyright 2005-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.uif.element; 017 018import org.kuali.rice.krad.datadictionary.parse.BeanTag; 019import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 020import org.kuali.rice.krad.uif.component.Component; 021import org.kuali.rice.krad.uif.container.Group; 022 023import java.util.List; 024 025/** 026 * Component that renders a navigation bar, including a branding and navigation group. 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030@BeanTag(name = "navbar", parent = "Uif-NavigationBar") 031public class NavigationBar extends ContentElementBase { 032 private static final long serialVersionUID = -2061519100931559642L; 033 034 private String brandText; 035 private Image brandImage; 036 private String brandUrl; 037 038 private Group navigationBarGroup; 039 040 public NavigationBar() { 041 super(); 042 this.brandUrl = "#"; 043 } 044 045 /** 046 * Header text to use for the application branding. 047 * 048 * <p>Note either the branding text, or the {@link NavigationBar#getBrandImage()} should be set, but 049 * not both</p> 050 * 051 * @return String text to use for branding 052 */ 053 @BeanTagAttribute 054 public String getBrandText() { 055 return brandText; 056 } 057 058 /** 059 * @see NavigationBar#getBrandText() 060 */ 061 public void setBrandText(String brandText) { 062 this.brandText = brandText; 063 } 064 065 /** 066 * Image component instance to use for the application branding. 067 * 068 * <p>Note either the branding image, or the {@link NavigationBar#getBrandText()} should be set, but 069 * not both</p> 070 * 071 * @return Image component to use for branding 072 */ 073 @BeanTagAttribute 074 public Image getBrandImage() { 075 return brandImage; 076 } 077 078 /** 079 * @see NavigationBar#getBrandImage() 080 */ 081 public void setBrandImage(Image brandImage) { 082 this.brandImage = brandImage; 083 } 084 085 /** 086 * String of URL set in rendering the navigation component. 087 * 088 * @return String of the URL 089 */ 090 @BeanTagAttribute 091 public String getBrandUrl() { 092 return brandUrl; 093 } 094 095 /** 096 * @see NavigationBar#getBrandUrl() 097 */ 098 public void setBrandUrl(String brandUrl) { 099 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}