Package com.jbstrap.ui.components.navbar
Class NavBar
- All Implemented Interfaces:
Animatable<NavBar>
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition -
Constructor Summary
ConstructorsConstructorDescriptionNavBar()Creates a navbar component.NavBar(NavBarTheme theme) Creates a navbar component based on the specified theme.Creates a navbar component using the specified language.Creates a navbar component using the specified unique ID and language code.NavBar(String id, String language, NavBarTheme theme) Creates a navbar component using the specified unique ID, language code and theme. -
Method Summary
Modifier and TypeMethodDescriptionaddComponent(Component<?> component) Adds the specified component as a subcomponent, and redraws the component immediatelyaddFooterButton(NavBarFooterButton button) Adds a footer button to the navbar component.addFooterButtons(NavBarFooterButton... buttons) Adds multiple footer buttons to the component.addMenu(String menuName, String title, CurrentUser user) Adds an entire menu to the navbar with the specified header text.addSearch(NavBarSeachHandler searchHandler) Adds a generic search component to the navbar.createHeaderItem(String headerText) Adds a header type menu item to the component.createItem(String name, Icon icon, String title) Adds a new main menu item to the component.findByName(String name) Looks up a menu item in the navbar based on its name.Gets the relative URL of the navbar’s background image.getBrand()Gets the text on the top of the navbar component.getIcon()Gets the icon before the text on the top of the navbar.getRole()Gets the user role assigned to the navbar.Gets the user status text in the navbar.getTheme()Gets the navbar’s theme.Gets the username displayed on the navbar.Gets the user’s avatar image.booleanChecks whether automatic component resizing is enabled.booleanChecks if the border radius functionality is enabled for the navbar component.booleanisPinned()Checks if the component is displayed in full size.booleanChecks if a search component is placed on the navbar.booleanChecks if the navbar component is visible.protected voidonOpenPage(String pageId) pin()Sets the navbar component’s size.removeFooterButton(NavBarFooterButton button) Removes a footer button from the navbar.removeItem(String name) Removes a menu item from the navbar component by its name.Removes the search component from the navbar.setAutoPin(boolean autoPin) Sets whether the navbar component should be automatically minimized.setBackgroundImageUrl(String imageUrl) Sets the background image for the navbar component.setBorderRadius(boolean radiusOn) Sets the border radius for navbar component elements.Sets the text on the top of the navbar component.setBrand(Icon icon, String brand, ClickEventHandler clickHandler) Sets the text on the top of the navbar component.Sets the text on the top of the navbar component.setBrand(String brand, ClickEventHandler clickHandler) Sets the text on the top of the navbar component.Sets the role for navbar component elements.Sets the navbar component’s displayed user status.setTheme(NavBarTheme theme) Sets the display theme for the navbar.setUsername(String username) Sets the username on the navbar.setUserPicture(String pictureUrl) Sets the avatar image displayed in the navbar header.toggle()Hides or makes the navbar component visible.booleanwriteHTML(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, init, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, onShow, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClassMethods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
-
Constructor Details
-
NavBar
public NavBar()Creates a navbar component. -
NavBar
Creates a navbar component using the specified language.- Parameters:
language- Language code for the component If not specified ornullis set, the application’s default language is used. The default language of the framework is set via the JBStrap parameterJBStrapParamType.DEFAULT_LANGUAGE.
-
NavBar
Creates a navbar component using the specified unique ID and language code.- Parameters:
id- Unique component IDlanguage- Language code for the component If not specified ornullis set, the component is created using the application’s default language. The default language of the framework is set via the JBStrap parameterJBStrapParamType.DEFAULT_LANGUAGE.
-
-
Method Details
-
getTheme
Gets the navbar’s theme.- Returns:
- Navbar theme
-
setBorderRadius
Sets the border radius for navbar component elements. If the border radius is enabled, icons, the user’s avatar, the search field and corners of images in popup windows will be rounded. If disabled, all the above elements will be displayed as having square corners. By default, component border radius is disabled.- Parameters:
radiusOn- Iftrueis set, the border radius functionality is enabled for the component, otherwise it is disabled.- Returns:
- Navbar component
-
isBorderRadius
public boolean isBorderRadius()Checks if the border radius functionality is enabled for the navbar component.- Returns:
- If
trueis set, the navbar’s border radius is enabled, otherwise it is disabled.
-
setAutoPin
Sets whether the navbar component should be automatically minimized. If the user opens the application on a device with a small screen (e.g. a cell phone) or reduces the application windows size, the navbar component should be automatically minimized. If this happens, only icons are displayed instead of whole menu items. By default, this functionality is disabled.- Parameters:
autoPin- Iftrueis specified, the navbar component is minimized for a smaller screen size, otherwise the component is not resized- Returns:
- Navbar component
-
isAutoPin
public boolean isAutoPin()Checks whether automatic component resizing is enabled.- Returns:
- If
trueis specified, the functionality is enabled, otherwise it is disabled.
-
writeHTML
Description copied from class:ComponentCreates the component's HTML equivalentThis method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (
StringWriterclass) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return withfalse. Otherwise, it must return withtrue. -
setBrand
Sets the text on the top of the navbar component.- Parameters:
brand- Text on the top of the navbar component Ifnullis set, no text is displayed on the top of the navbar component.- Returns:
- Navbar component
-
setBrand
Sets the text on the top of the navbar component.- Parameters:
icon- The icon appearing before the text on the top of the navbar Ifnullis specified, no navbar text icon is displayed. Available icons are listed in the enumIcon.brand- Text on the top of the navbar component Ifnullis set, no text is displayed on the top of the navbar component.- Returns:
- Navbar component
-
setBrand
Sets the text on the top of the navbar component.- Parameters:
brand- Text on the top of the navbar component Ifnullis set, no text is displayed on the top of the navbar component.clickHandler- Text click event handler implementation If not specified ornullis set, the click event for the navbar top text is not handled.- Returns:
- Navbar component
-
setBrand
Sets the text on the top of the navbar component.- Parameters:
icon- The icon appearing before the text on the top of the navbar Ifnullis set, no icon is displayed before the navbar component text. Available icons are listed in the enumIcon.brand- Text on the top of the navbar component Ifnullis set, no text is displayed on the top of the navbar component.clickHandler- Text click event handler implementation If not specified ornullis set, the click event for the navbar top text is not handled.- Returns:
- Navbar component
-
getBrand
Gets the text on the top of the navbar component.- Returns:
- The text on the top of the navbar or
nullif no text is displayed on the top of the navbar
-
getIcon
Gets the icon before the text on the top of the navbar.- Returns:
- Navbar icon or
nullif no icon is displayed before the text on the top of the navbar
-
setUserPicture
Sets the avatar image displayed in the navbar header.- Parameters:
pictureUrl- Relative URL for navbar header image The URL specified here must be relative to the application URL.- Returns:
- Navbar component
-
getUserPicture
Gets the user’s avatar image.- Returns:
- Relative URL of the user’s avatar image or
nullif there is no avatar set
-
setUsername
Sets the username on the navbar.- Parameters:
username- Username Ifnullis set, no username is displayed on the component.- Returns:
- Navbar component
-
getUsername
Gets the username displayed on the navbar.- Returns:
- Username displayed in the navbar or
nullif no username is displayed in the navbar
-
setRole
Sets the role for navbar component elements.- Parameters:
role- User role Ifnullis set, no user role is set in the navbar.- Returns:
- Navbar component
-
getRole
Gets the user role assigned to the navbar.- Returns:
- The user role or
nullif no user role is present in the navbar
-
setStatus
Sets the navbar component’s displayed user status.- Parameters:
status- Text status Ifnullis set, no user status text is displayed in the navbar component.- Returns:
- Navbar component
-
getStatus
Gets the user status text in the navbar.- Returns:
- User status text or
nullif no user status text is displayed
-
setBackgroundImageUrl
Sets the background image for the navbar component. If you specify a background image for the component, the theme’s default background becomes transparent and it shows the specified image.- Parameters:
imageUrl- URL of the background image The specified URL must be different from the application’s default URL. Ifnullis specified, no background image is set for the component and the default background color will not be transparent.- Returns:
- Navbar component
-
getBackgroundImageUrl
Gets the relative URL of the navbar’s background image.- Returns:
- Relative URL of the navbar’s background image or
nullif no background image is set
-
removeSearch
Removes the search component from the navbar.- Returns:
- Navbar component
-
isSearchVisible
public boolean isSearchVisible()Checks if a search component is placed on the navbar.- Returns:
- If
trueis returned, there is a search component placed on the navbar, otherwise not.
-
toggle
Hides or makes the navbar component visible. If the navbar component is visible, the method hides it. If it is hidden, it will be made visible.- Returns:
- Navbar component
-
isToggled
public boolean isToggled()Checks if the navbar component is visible.- Returns:
- If
trueis set, the navbar component is visible. Iffalseis set, it is hidden.
-
pin
Sets the navbar component’s size. If the navbar component is full-size, the method minimizes it. In this case you will see only icons instead of menu items. If the user moves the mouse over the component, it will return to full-size. If the user moves the mouse pointer elsewhere, the component will be minimized again. If the component is already minimized, the method will restore its original size.- Returns:
- Navbar component
-
isPinned
public boolean isPinned()Checks if the component is displayed in full size.- Returns:
- If
trueis returned, the component is displayed minimized. Iffalseis set, it is displayed in full size.
-
createHeaderItem
Adds a header type menu item to the component. Such menu items cannot be clicked, they are only for grouping other menu items.- Parameters:
headerText- The header text to be displayed. Ifnullis set, an empty header is displayed in the menu.- Returns:
- Navbar component
-
createItem
Adds a new main menu item to the component.- Parameters:
name- Menu item name (mandatory)icon- Menu item icon Ifnullis specified, no icon is displayed on the menu item. Available icons are listed in the enumIcon.title- Menu item text Ifnullis specified, no text will appear on the menu item.- Returns:
- The created menu item component
-
findByName
Looks up a menu item in the navbar based on its name. The method checks not also main menu items, but also returns sub menu items. If names in the navbar are not unique and there are more menu items by the specified name, the method returns the first menu item match.- Parameters:
name- The menu item name searched for- Returns:
- The first menu item match or
nullif there is no menu item by that name
-
removeItem
Removes a menu item from the navbar component by its name.- Parameters:
name- The name of the menu item to be removed- Returns:
- Navbar component
-
onOpenPage
- Parameters:
pageId- The page id
-
addMenu
Adds an entire menu to the navbar with the specified header text. Use this method to add a menu created in theStartupclass to the component by specifying its name. In this case all menu items are placed on the component and previous settings also take effect, such as navigation or click event handlers.- Parameters:
menuName- Menu name to be added to the component Ifnullis set or a non-existing (undefined) name is specified, the method does not work.title- Header text above the menu Ifnullis specified, no text will appear above the menu.user- Logged in user Ifnullis specified, only public menu items are displayed. If you specify a user, all menu items in the menu are displayed to which the user has access.- Returns:
- Navbar component
-
addComponent
Description copied from class:ComponentAdds the specified component as a subcomponent, and redraws the component immediately- Overrides:
addComponentin classComponent<NavBar>- Parameters:
component- The component to be added- Returns:
- The component