@Override public void onClick(ClickEvent event) { refreshManager.setCurrentRefreshRate(refreshRate); removeActiveStyles(); refreshRateItem.addStyleName(Styles.ACTIVE); }
@Override public void addContextMenuItem( final String menuItemId, final String id, final String label, final String parentId, final Command command, final MenuPosition position) { final AnchorListItem menuItem = GWT.create(AnchorListItem.class); menuItem.setText(label); if (parentId == null) { menuItem.addStyleName(UF_PERSPECTIVE_CONTEXT_MENU); } if (command != null) { menuItem.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { command.execute(); } }); } final ComplexPanel contextContainer = getMenuItemContextWidgetMap().get(parentId); if (contextContainer != null) { contextContainer.add(menuItem); } else { menuItemContextMenus.get(menuItemId).add(menuItem); } getMenuItemContextWidgetMap().put(id, menuItem); }
@Override public void addContextMenuItem( final String menuItemId, final String id, final String label, final String parentId, final Command command, final MenuPosition position) { final AnchorListItem menuItem = GWT.create(AnchorListItem.class); menuItem.setText(label); if (parentId == null) { menuItem.addStyleName(UF_PERSPECTIVE_CONTEXT_MENU); } if (command != null) { menuItem.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { command.execute(); } }); } final ComplexPanel contextContainer = getMenuItemContextWidgetMap().get(parentId); if (contextContainer != null) { contextContainer.add(menuItem); } else { menuItemContextMenus.get(menuItemId).add(menuItem); } getMenuItemContextWidgetMap().put(id, menuItem); }
@PostConstruct public void init() { link.setTitle(CommonConstants.INSTANCE.AppsLauncher()); link.setIcon(IconType.TH); link.addStyleName("dropdown"); link.setDataToggle(Toggle.DROPDOWN); link.setVisible(false); link.add(appLauncher.getView()); }
private Widget makeMenuItemCommand(final MenuItemCommand cmdItem, final boolean isRoot) { if (isRoot) { final Button button = GWT.create(Button.class); button.setText(cmdItem.getCaption()); button.setSize(ButtonSize.SMALL); button.setEnabled(cmdItem.isEnabled()); button.addClickHandler(event -> cmdItem.getCommand().execute()); cmdItem.addEnabledStateChangeListener(button::setEnabled); return button; } else { final AnchorListItem navbarLink = GWT.create(AnchorListItem.class); navbarLink.setText(cmdItem.getCaption()); if (!cmdItem.isEnabled()) { navbarLink.addStyleName("disabled"); } navbarLink.addClickHandler(event -> cmdItem.getCommand().execute()); cmdItem.addEnabledStateChangeListener(enabled -> { if (enabled) { navbarLink.removeStyleName("disabled"); } else { navbarLink.addStyleName("disabled"); } }); return navbarLink; } }
private Widget makeMenuItemCommand(final MenuItemCommand cmdItem, final boolean isRoot) { if (isRoot) { final Button button = GWT.create(Button.class); button.setText(cmdItem.getCaption()); button.setSize(ButtonSize.SMALL); button.setEnabled(cmdItem.isEnabled()); button.addClickHandler(event -> cmdItem.getCommand().execute()); cmdItem.addEnabledStateChangeListener(button::setEnabled); return button; } else { final AnchorListItem navbarLink = GWT.create(AnchorListItem.class); navbarLink.setText(cmdItem.getCaption()); if (!cmdItem.isEnabled()) { navbarLink.addStyleName("disabled"); } navbarLink.addClickHandler(event -> cmdItem.getCommand().execute()); cmdItem.addEnabledStateChangeListener(enabled -> { if (enabled) { navbarLink.removeStyleName("disabled"); } else { navbarLink.addStyleName("disabled"); } }); return navbarLink; } }
/** * Adds a new tab to this panel that doesn't have any contents itself, but can contain multiple items that appear in * a dropdown menu when the tab is clicked. This dropdown menu is initially empty. Items can be added and removed * using the {@link DropDownTab#addItem(String, Widget)} and * {@link DropDownTab#removeItem(String, Widget)} methods. * @param label The text that should appear on the dropdown tab. * @return the container for the items that appear when the tab is clicked. */ public DropDownTab addDropdownTab(String label) { AnchorListItem tab = new AnchorListItem(label); // FIXME should actually subclass AnchorListItem and add a <b class=caret/> to the anchor elem tab.setIcon(IconType.ANGLE_DOWN); tab.setIconPosition(IconPosition.RIGHT); tab.addStyleName(Styles.DROPDOWN_TOGGLE); tab.setDataToggle(Toggle.DROPDOWN); DropDownTab dropDownTab = new DropDownTab(tab); tab.add(dropDownTab); addDropdownTab(dropDownTab); return dropDownTab; }
/** * Adds a new tab to this panel that doesn't have any contents itself, but can contain multiple items that appear in * a dropdown menu when the tab is clicked. This dropdown menu is initially empty. Items can be added and removed * using the {@link DropDownTab#addItem(String, Widget)} and * {@link DropDownTab#removeItem(String, Widget)} methods. * @param label The text that should appear on the dropdown tab. * @return the container for the items that appear when the tab is clicked. */ public DropDownTab addDropdownTab(String label) { AnchorListItem tab = new AnchorListItem(label); // FIXME should actually subclass AnchorListItem and add a <b class=caret/> to the anchor elem tab.setIcon(IconType.ANGLE_DOWN); tab.setIconPosition(IconPosition.RIGHT); tab.addStyleName(Styles.DROPDOWN_TOGGLE); tab.setDataToggle(Toggle.DROPDOWN); DropDownTab dropDownTab = new DropDownTab(tab); tab.add(dropDownTab); addDropdownTab(dropDownTab); return dropDownTab; }
private void createDropdownMenu() { dropdownMenu = new DropDownMenu(); dropdownMenu.setPull(Pull.LEFT); Set<Integer> refreshRates = AbstractRefreshManager.getRefreshRates(); for (Integer refreshRate : refreshRates) { AnchorListItem refreshRateItem = new AnchorListItem(); refreshRateItem.setText(MillisecondRenderer.getInstance().render(refreshRate)); refreshRateItem.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { refreshManager.setCurrentRefreshRate(refreshRate); removeActiveStyles(); refreshRateItem.addStyleName(Styles.ACTIVE); } }); if (refreshManager.getCurrentRefreshRate() == refreshRate) { refreshRateItem.addStyleName(Styles.ACTIVE); } dropdownMenu.add(refreshRateItem); } }