copyItem.disableProperty().bind(new BooleanBinding() { clearItem.setOnAction(e -> logView.getItems().clear()); clearItem.disableProperty().bind(new BooleanBinding() { selectAllItem.setOnAction(e -> logView.getSelectionModel().selectAll()); selectAllItem.disableProperty().bind(clearItem.disableProperty()); saveItem.setOnAction(e -> saveLog()); saveItem.disableProperty().bind(clearItem.disableProperty()); SeparatorMenuItem separator = new SeparatorMenuItem(); logView.setContextMenu(new ContextMenu(copyItem, clearItem, selectAllItem, separator, saveItem));
/** * Setup of bindings for the menu items and toolbar buttons. There is an action*Disabled property * for each action which is bound to the disabled property of the appropriate controls. So the * status of all similar action controls can be controlled by one action*Disabled property. */ private void setupActionBindings() { miSave.disableProperty().bind(actionSaveDisabled); btSave.disableProperty().bind(actionSaveDisabled); miEditEntry.disableProperty().bind(actionEditEntryDisabled); btEditEntry.disableProperty().bind(actionEditEntryDisabled); miCopyEntry.disableProperty().bind(actionEditEntryDisabled); btCopyEntry.disableProperty().bind(actionEditEntryDisabled); miDeleteEntry.disableProperty().bind(actionDeleteEntryDisabled); btDeleteEntry.disableProperty().bind(actionDeleteEntryDisabled); miViewHrm.disableProperty().bind(actionViewHrmDisabled); btViewHrm.disableProperty().bind(actionViewHrmDisabled); miCalendarView.disableProperty().bind(actionCalendarViewDisabled); btCalendarView.disableProperty().bind(actionCalendarViewDisabled); miExerciseListView.disableProperty().bind(actionExerciseListViewDisabled); btExerciseListView.disableProperty().bind(actionExerciseListViewDisabled); miNoteListView.disableProperty().bind(actionNoteListViewDisabled); btNoteListView.disableProperty().bind(actionNoteListViewDisabled); miWeightListView.disableProperty().bind(actionWeightListViewDisabled); btWeightListView.disableProperty().bind(actionWeightListViewDisabled); miFilterDisable.disableProperty().bind(actionFilterDisableDisabled); btFilterDisable.disableProperty().bind(actionFilterDisableDisabled); }
@Override public Node createValueListVisualisation() { CheckComboBox<T> comboBox = new CheckComboBox<>(); possibleValuesProvider.get().stream().distinct().forEach(comboBox.getItems()::add); CheckComboBoxHelper.addOpenCloseListener(comboBox, this::updateCheckComboBox); comboBox.setConverter(new DataStringConverter<>()); comboBox.setMinWidth(300); comboBox.disableProperty().bind(readOnly); ContextMenu contextMenu = new ContextMenu(menuItem(selectAll, comboBox, true), menuItem(selectNon, comboBox, false)); contextMenu.getItems().forEach(m->m.disableProperty().bind(readOnly)); comboBox.setContextMenu(contextMenu); updateCheckComboBox(comboBox); return comboBox; }
private static <T> void addContextMenu(CheckListView<T> listView) { listView.setOnContextMenuRequested(event -> { ContextMenu contextMenu = new ContextMenu(); MenuItem selectAll = new MenuItem(RESOURCE_BUNDLE.getString("SelectAll")); selectAll.disableProperty().bind(Bindings.equal(listView.getItems().size(), Bindings.size(listView.getCheckModel().getCheckedIndices()))); selectAll.setOnAction(event2 -> listView.getCheckModel().checkAll()); MenuItem deselectAll = new MenuItem(RESOURCE_BUNDLE.getString("DeselectAll")); deselectAll.disableProperty().bind(Bindings.isEmpty(listView.getCheckModel().getCheckedIndices())); deselectAll.setOnAction(event2 -> listView.getCheckModel().clearChecks()); contextMenu.getItems().addAll(selectAll, deselectAll); contextMenu.show(listView, event.getScreenX(), event.getScreenY()); }); }
public PerspectiveButton(PerspectiveSwitcherNode container, GraphicsLoader loader, MPerspective perspective, EPartService service, boolean toggled) { setSelected(toggled); getStyleClass().add("perspective-button"); //$NON-NLS-1$ // FIXME React on perspective renaming and locale changes! setText(perspective.getLocalizedLabel()); // FIXME React in URL change if (perspective.getIconURI() != null) { URI uri = URI.createURI(perspective.getIconURI()); setGraphic(loader.getGraphicsNode(new EMFUri(uri))); } this.perspective = perspective; setOnAction(e -> { service.switchPerspective(perspective); }); ContextMenu m = new ContextMenu(); MenuItem item = new MenuItem("Remove"); item.disableProperty().bind(selectedProperty()); item.setOnAction( e -> { container.getChildren().remove(this); container.publishNewPerspectiveList(perspective.getElementId(), false); }); m.getItems().add(item); setContextMenu(m); } }
/** * Sets up the context menu for the calendar control. Unfortunately it can't be defined in * FXML, the Pane classes does not support context menus directly. */ private void setupCalendarContextMenu() { final BooleanBinding bindingNoEntrySelected = Bindings.isNull(calendarControl.selectedEntryProperty()); final MenuItem miCtxAddExercise = createContextMenuItem( // "miCtxAddExercise", "st.view.exercise_add.Action.text", // event -> addExerciseForDate(calendarControl.dateOfContextMenuProperty().get())); final MenuItem miCtxAddNote = createContextMenuItem( // "miCtxAddNote", "st.view.note_add.Action.text", // event -> addNoteForDate(calendarControl.dateOfContextMenuProperty().get())); final MenuItem miCtxAddWeight = createContextMenuItem( // "miCtxAddWeight", "st.view.weight_add.Action.text", // event -> addWeightForDate(calendarControl.dateOfContextMenuProperty().get())); final MenuItem miCtxEditEntry = createContextMenuItem( // "miCtxEditEntry", "st.view.entry_edit.Action.text", // event -> getEventHandler().onEditEntry(event)); miCtxEditEntry.disableProperty().bind(bindingNoEntrySelected); final MenuItem miCtxCopyEntry = createContextMenuItem( // "miCtxCopyEntry", "st.view.entry_copy.Action.text", // event -> getEventHandler().onCopyEntry(event)); miCtxCopyEntry.disableProperty().bind(bindingNoEntrySelected); final MenuItem miCtxDeleteEntry = createContextMenuItem( // "miCtxDeleteEntry", "st.view.entry_delete.Action.text", // event -> getEventHandler().onDeleteEntry(event)); miCtxDeleteEntry.disableProperty().bind(bindingNoEntrySelected); calendarControl.setContextMenu(new ContextMenu( // miCtxAddExercise, miCtxAddNote, miCtxAddWeight, miCtxEditEntry, miCtxCopyEntry, miCtxDeleteEntry)); }
copy.disableProperty().bind(treeView.getSelectionModel().selectedItemProperty().isNull()); contextMenu.getItems().add(copy); treeView.setContextMenu(contextMenu);
/** * Configures a {@link MenuItem} with the specified action. * * @param menuItem the menu item to configre * @param action the action * @param iconSize the icon size */ public static void configureMenuItem(MenuItem menuItem, FXAction action, int iconSize) { menuItem.setMnemonicParsing(true); menuItem.textProperty().bind(action.displayNameProperty()); menuItem.acceleratorProperty().bind(action.acceleratorProperty()); menuItem.setOnAction(action); menuItem.disableProperty().bind(action.enabledProperty().not()); if (action.getGraphicFactory() != null) { Node graphic = action.getGraphicFactory().createGraphic(iconSize); if (graphic != null) { menuItem.setGraphic(graphic); } } }
private static void unconfigure(final MenuItem menuItem) { if (menuItem == null || !(menuItem.getOnAction() instanceof Action)) { return; } Action action = (Action) menuItem.getOnAction(); menuItem.styleProperty().unbind(); menuItem.textProperty().unbind(); menuItem.disableProperty().unbind(); menuItem.acceleratorProperty().unbind(); menuItem.graphicProperty().unbind(); action.getProperties().removeListener(new MenuItemPropertiesMapChangeListener<>(menuItem, action)); if (menuItem instanceof RadioMenuItem) { ((RadioMenuItem) menuItem).selectedProperty().unbindBidirectional(action.selectedProperty()); } else if (menuItem instanceof CheckMenuItem) { ((CheckMenuItem) menuItem).selectedProperty().unbindBidirectional(action.selectedProperty()); } menuItem.setOnAction(null); }
closeTab.disableProperty().bind(selectionTab.getSelectedItem().closableProperty().not());
menuItem.disableProperty().bind(action.disabledProperty()); menuItem.acceleratorProperty().bind(action.acceleratorProperty());
menuItem.disableProperty().bind(resultTable.getSelectionModel().selectedItemProperty().isNull()); contextMenu.getItems().add(menuItem);
detailMenuItem.disableProperty().bind(resultTable.getSelectionModel().selectedItemProperty().isNull()); contextMenu.getItems().add(detailMenuItem); MenuItem audittrailMenuItem = new MenuItem("AuditTrail"); audittrailMenuItem.disableProperty().bind(resultTable.getSelectionModel().selectedItemProperty().isNull()); contextMenu.getItems().add(audittrailMenuItem);