closeContextMenu.add(new MenuItem(getMessages().closeTab(), new SelectionHandler<MenuItem>() { @Override public void onSelection(SelectionEvent<MenuItem> event) { closeContextMenu.add(new MenuItem(getMessages().closeOtherTabs(), new SelectionHandler<MenuItem>() { @Override public void onSelection(SelectionEvent<MenuItem> event) {
public SystemMenu(AppCache appCache) { MenuItem versionItem = new MenuItem(); versionItem.setText(I18N.CONSTANTS.appVersion() + " " + appCache.getCurrentVersion()); versionItem.setHideOnClick(false); appCacheStatusItem = new MenuItem(); appCacheStatusItem.addSelectionHandler(this::loadUpdatedAppCache); MenuItem logoutItem = new MenuItem(); logoutItem.setText(I18N.CONSTANTS.logout()); logoutItem.addSelectionHandler(this::logout); Menu menu = new Menu(); menu.add(versionItem); menu.add(appCacheStatusItem); menu.add(new SeparatorMenuItem()); menu.add(logoutItem); icon = new InlineHTML(ChromeBundle.BUNDLE.settingsIcon().getText()); icon.addStyleName(ChromeBundle.BUNDLE.style().appBarButton()); icon.addClickHandler(event -> menu.show(icon.getElement(), new Style.AnchorAlignment(Style.Anchor.TOP, Style.Anchor.BOTTOM))); icon.addClickHandler(event -> appCache.checkForUpdates()); appCache.getStatus().subscribe(this::updateAppCacheView); }
/** * Creates a context menu for the given column, including sort menu items and column visibility sub-menu. * * @param colIndex the column index * @return the context menu for the given column */ protected Menu createContextMenu(final int colIndex) { final Menu menu = new Menu(); if (cm.isSortable(colIndex)) { MenuItem item = new MenuItem(); item.setText(DefaultMessages.getMessages().gridView_sortAscText()); item.setIcon(header.getAppearance().sortAscendingIcon()); item.addSelectionHandler(event -> doSort(colIndex, SortDir.ASC)); menu.add(item); item = new MenuItem(); item.setText(DefaultMessages.getMessages().gridView_sortDescText()); item.setIcon(header.getAppearance().sortDescendingIcon()); item.addSelectionHandler(event -> doSort(colIndex, SortDir.DESC)); menu.add(item); item = new MenuItem(); item.setText(I18N.CONSTANTS.clearSort()); item.addSelectionHandler(event -> fireEvent(new SortChangeEvent())); menu.add(item); } return menu; }
public OfflineMenu(HttpBus bus, OfflineStore offlineStore) { this.offlineStore = offlineStore; pendingChangesItem = new MenuItem(); pendingChangesItem.setHideOnClick(false); syncNowItem = new MenuItem(I18N.CONSTANTS.syncNow()); syncNowItem.addSelectionHandler(event -> offlineStore.syncChanges()); clearMenuItem = new MenuItem(I18N.CONSTANTS.clearOfflineMode()); clearMenuItem.addSelectionHandler(this::confirmOfflineDelete); Menu menu = new Menu(); menu.add(pendingChangesItem); menu.add(new SeparatorMenuItem()); menu.add(syncNowItem); menu.add(new SeparatorMenuItem()); menu.add(clearMenuItem); icon = new InlineHTML(ChromeBundle.BUNDLE.offlineIcon().getText()); icon.addStyleName(ChromeBundle.BUNDLE.style().appBarButton()); icon.setVisible(false); icon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { menu.show(icon.getElement(), new Style.AnchorAlignment(Style.Anchor.TOP, Style.Anchor.BOTTOM)); } }); offlineStore.getOfflineForms().subscribe(this::onOfflineFormSetChanged); offlineStore.getStatus().subscribe(this::onStatusChanged); }
private void showMenu(Element element, MeasureListItem item) { MeasureModel measure = item.getModel(); Menu contextMenu = new Menu(); // Edit the alias MenuItem editLabel = new MenuItem(); editLabel.setText("Edit Label..."); editLabel.addSelectionHandler(event -> editLabel(measure)); contextMenu.add(editLabel); // Edit the formula... MenuItem editFormula = new MenuItem(); editFormula.setText("Edit Formula..."); editFormula.addSelectionHandler(event -> editFormula(measure)); contextMenu.add(editFormula); contextMenu.add(new SeparatorMenuItem()); // Choose the aggregation for (Statistic statistic : Statistic.values()) { CheckMenuItem aggregationItem = new CheckMenuItem(statistic.getLabel()); aggregationItem.setChecked(measure.getStatistics().contains(statistic)); aggregationItem.addCheckChangeHandler(event -> updateStatistic(measure, statistic, event.getChecked())); contextMenu.add(aggregationItem); } contextMenu.add(new SeparatorMenuItem()); // Remove the dimension MenuItem remove = new MenuItem(); remove.setText(I18N.CONSTANTS.remove()); remove.addSelectionHandler(event -> removeMeasure(measure.getId())); contextMenu.add(remove); contextMenu.show(element, new Style.AnchorAlignment(Style.Anchor.BOTTOM, Style.Anchor.BOTTOM, true)); }
MenuItem editLabel = new MenuItem(); editLabel.setText("Edit Label..."); editLabel.addSelectionHandler(event -> editLabel(dim.getModel())); contextMenu.add(percentagesItem); MenuItem totalsLabel = new MenuItem("Total Label..."); totalsLabel.addSelectionHandler(event -> editTotalLabel(dim)); totalsLabel.setEnabled(canTotal); MenuItem remove = new MenuItem(); remove.setText(I18N.CONSTANTS.remove()); remove.addSelectionHandler(event -> removeDimension(dim.getId()));