com.vaadin.shared.ui.ComponentStateUtil Java Examples
The following examples show how to use
com.vaadin.shared.ui.ComponentStateUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
/** * Updates style names in suggestion popup to help theme building. * * @param componentState * shared state of the combo box */ public void updateStyleNames(AbstractComponentState componentState) { debug("VComboBoxMultiselect.SP: updateStyleNames()"); setStyleName(VComboBoxMultiselect.this.getStylePrimaryName() + "-suggestpopup"); this.menu.setStyleName(VComboBoxMultiselect.this.getStylePrimaryName() + "-suggestmenu"); this.status.setClassName(VComboBoxMultiselect.this.getStylePrimaryName() + "-status"); if (ComponentStateUtil.hasStyles(componentState)) { for (String style : componentState.styles) { if (!"".equals(style)) { addStyleDependentName(style); } } } }
Example #2
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
/** * Updates style names in suggestion popup to help theme building. * * @param componentState * shared state of the combo box */ public void updateStyleNames(AbstractComponentState componentState) { debug("VComboBoxMultiselect.SP: updateStyleNames()"); setStyleName(VComboBoxMultiselect.this.getStylePrimaryName() + "-suggestpopup"); this.menu.setStyleName(VComboBoxMultiselect.this.getStylePrimaryName() + "-suggestmenu"); this.status.setClassName(VComboBoxMultiselect.this.getStylePrimaryName() + "-status"); if (ComponentStateUtil.hasStyles(componentState)) { for (String style : componentState.styles) { if (!"".equals(style)) { addStyleDependentName(style); } } } }
Example #3
Source File: SliderPanelConnector.java From vaadin-sliderpanel with MIT License | 5 votes |
@Override public void onStateChanged(final StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); getWidget().configure(getState().mode, getState().flowInContent, getState().tabPosition, getState().pixel); if (stateChangeEvent.hasPropertyChanged("animationDuration")) { getWidget().setAnimationDuration(getState().animationDuration); } if (stateChangeEvent.hasPropertyChanged("caption")) { getWidget().setCaption(getState().caption, false); } if (stateChangeEvent.hasPropertyChanged("pixel")) { getWidget().setFixedContentSize(getState().pixel); } if (stateChangeEvent.hasPropertyChanged("autoCollapseSlider")) { getWidget().setAutoCollapseSlider(getState().autoCollapseSlider); } if (stateChangeEvent.hasPropertyChanged("zIndex")) { getWidget().setZIndex(getState().zIndex); } if (stateChangeEvent.hasPropertyChanged("enabled") || stateChangeEvent.hasPropertyChanged("enableToggle")) { getWidget().setEnabled(getState().enabled && getState().enableToggle); } if (ComponentStateUtil.hasStyles(getState())) { String extraStyles = ""; for (String style : getState().styles) { extraStyles += " " + style; } getWidget().setStyles(extraStyles); } }
Example #4
Source File: ContextMenuConnector.java From cuba with Apache License 2.0 | 4 votes |
protected void updateFromState(ContextMenuState state) { contextMenu.enabled = state.enabled; contextMenu.htmlContentAllowed = state.htmlContentAllowed; Stack<Iterator<ContextMenuItemState>> iteratorStack = new Stack<>(); Stack<VMenuBar> menuStack = new Stack<>(); VMenuBar currentMenu = contextMenuRoot.getSubMenu(); currentMenu.clearItems(); if (state.menuItems != null && !state.menuItems.isEmpty()) { Iterator<ContextMenuItemState> itr = state.menuItems.iterator(); while (itr.hasNext()) { ContextMenuItemState menuItemState = itr.next(); VMenuBar.CustomMenuItem currentItem; boolean itemHasCommand = menuItemState.command; boolean itemIsCheckable = menuItemState.checkable; String iconUrl = menuItemState.icon == null ? null : menuItemState.icon.getURL(); boolean subMenu = menuItemState.childItems != null && !menuItemState.childItems.isEmpty(); String itemHTML = contextMenu.buildItemHTML( menuItemState.separator, subMenu, iconUrl, menuItemState.text); Command cmd = null; if (!menuItemState.separator) { if (itemHasCommand || itemIsCheckable) { // Construct a command that fires onMenuClick(int) with // the // item's id-number cmd = () -> contextMenu.onMenuClick(menuItemState.id); } } currentItem = currentMenu.addItem(itemHTML, cmd); currentItem.setId("" + menuItemState.id); updateItemFromState(currentItem, menuItemState); if (subMenu) { menuStack.push(currentMenu); iteratorStack.push(itr); itr = menuItemState.childItems.iterator(); currentMenu = new VContextMenu(true, currentMenu); getConnection().getVTooltip() .connectHandlersToWidget(currentMenu); // this is the top-level style that also propagates to items // - // any item specific styles are set above in // currentItem.updateFromUIDL(item, client) if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { currentMenu.addStyleDependentName(style); } } currentItem.setSubMenu(currentMenu); } while (!itr.hasNext() && !iteratorStack.empty()) { boolean hasCheckableItem = false; for (VMenuBar.CustomMenuItem menuItem : currentMenu .getItems()) { hasCheckableItem = hasCheckableItem || menuItem.isCheckable(); } if (hasCheckableItem) { currentMenu.addStyleDependentName("check-column"); } else { currentMenu.removeStyleDependentName("check-column"); } itr = iteratorStack.pop(); currentMenu = menuStack.pop(); } } } }
Example #5
Source File: ContextMenuConnector.java From context-menu with Apache License 2.0 | 4 votes |
protected void updateFromState(ContextMenuState state) { contextMenu.enabled = state.enabled; contextMenu.htmlContentAllowed = state.htmlContentAllowed; Stack<Iterator<ContextMenuItemState>> iteratorStack = new Stack<>(); Stack<VMenuBar> menuStack = new Stack<>(); VMenuBar currentMenu = contextMenuRoot.getSubMenu(); currentMenu.clearItems(); if (state.menuItems != null && !state.menuItems.isEmpty()) { Iterator<ContextMenuItemState> itr = state.menuItems.iterator(); while (itr.hasNext()) { ContextMenuItemState menuItemState = itr.next(); VMenuBar.CustomMenuItem currentItem; boolean itemHasCommand = menuItemState.command; boolean itemIsCheckable = menuItemState.checkable; String iconUrl = menuItemState.icon == null ? null : menuItemState.icon.getURL(); boolean subMenu = menuItemState.childItems != null && !menuItemState.childItems.isEmpty(); String itemHTML = contextMenu.buildItemHTML( menuItemState.separator, subMenu, iconUrl, menuItemState.text); Command cmd = null; if (!menuItemState.separator) { if (itemHasCommand || itemIsCheckable) { // Construct a command that fires onMenuClick(int) with // the // item's id-number cmd = () -> contextMenu.onMenuClick(menuItemState.id); } } currentItem = currentMenu.addItem(itemHTML, cmd); currentItem.setId("" + menuItemState.id); updateItemFromState(currentItem, menuItemState); if (subMenu) { menuStack.push(currentMenu); iteratorStack.push(itr); itr = menuItemState.childItems.iterator(); currentMenu = new VContextMenu(true, currentMenu); getConnection().getVTooltip() .connectHandlersToWidget(currentMenu); // this is the top-level style that also propagates to items // - // any item specific styles are set above in // currentItem.updateFromUIDL(item, client) if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { currentMenu.addStyleDependentName(style); } } currentItem.setSubMenu(currentMenu); } while (!itr.hasNext() && !iteratorStack.empty()) { boolean hasCheckableItem = false; for (VMenuBar.CustomMenuItem menuItem : currentMenu .getItems()) { hasCheckableItem = hasCheckableItem || menuItem.isCheckable(); } if (hasCheckableItem) { currentMenu.addStyleDependentName("check-column"); } else { currentMenu.removeStyleDependentName("check-column"); } itr = iteratorStack.pop(); currentMenu = menuStack.pop(); } } } }