Java Code Examples for javafx.scene.control.MenuItem#setDisable()

The following examples show how to use javafx.scene.control.MenuItem#setDisable() . 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: ButtonChecker.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check whether the edit or remove buttons should be set to enabled or
 * disabled.
 *
 * @param editSongButton the edit button to check.
 * @param removeSongButton the remove button to check.
 */
public void checkEditRemoveButtons(MenuItem editSongButton, MenuItem removeSongButton) {
    final MainPanel mainPanel = QueleaApp.get().getMainWindow().getMainPanel();
    final ScheduleList scheduleList = mainPanel.getSchedulePanel().getScheduleList();
    if(!scheduleList.focusedProperty().get()) {
        editSongButton.setDisable(true);
        removeSongButton.setDisable(true);
        return;
    }
    if(scheduleList.getSelectionModel().getSelectedIndex() == -1) {
        editSongButton.setDisable(true);
        removeSongButton.setDisable(true);
    }
    else {
        if(scheduleList.getSelectionModel().getSelectedItem() instanceof SongDisplayable) {
            editSongButton.setDisable(false);
        }
        else {
            editSongButton.setDisable(true);
        }
        removeSongButton.setDisable(false);
    }
}
 
Example 2
Source File: SelectionTable.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
private void initTopSectionContextMenu(ContextMenu contextMenu, boolean hasRanges) {
    MenuItem setDestinationItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set destination"),
            MaterialDesignIcon.AIRPLANE_LANDING);
    setDestinationItem.setOnAction(e -> eventStudio().broadcast(
            requestDestination(getSelectionModel().getSelectedItem().descriptor().getFile(), getOwnerModule()),
            getOwnerModule()));
    setDestinationItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.ALT_DOWN));

    selectionChangedConsumer = e -> setDestinationItem.setDisable(!e.isSingleSelection());
    contextMenu.getItems().add(setDestinationItem);

    if (hasRanges) {
        MenuItem setPageRangesItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set as range for all"),
                MaterialDesignIcon.FORMAT_INDENT_INCREASE);
        setPageRangesItem.setOnAction(e -> eventStudio().broadcast(
                new SetPageRangesRequest(getSelectionModel().getSelectedItem().pageSelection.get()),
                getOwnerModule()));
        setPageRangesItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
        selectionChangedConsumer = selectionChangedConsumer
                .andThen(e -> setPageRangesItem.setDisable(!e.isSingleSelection()));
        contextMenu.getItems().add(setPageRangesItem);
    }
    contextMenu.getItems().add(new SeparatorMenuItem());
}
 
Example 3
Source File: ACEEditor.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private void createURLLink(String pattern, String id, String icon) {
    MenuItem tmsMenuItem = new MenuItem(id, FXUIUtils.getIcon(icon));
    if (pattern != null && pattern.length() > 0) {
        String url = String.format(pattern, id);
        tmsMenuItem.setOnAction((event) -> {
            try {
                Desktop.getDesktop().browse(new URI(url));
            } catch (IOException | URISyntaxException e) {
                e.printStackTrace();
            }
        });
    } else {
        tmsMenuItem.setDisable(true);
    }
    infoButton.getItems().add(tmsMenuItem);
}
 
Example 4
Source File: ButtonChecker.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check whether the add to schedule button should be set enabled or
 * disabled.
 *
 * @param addSongButton the button to check.
 */
public void checkAddButton(MenuItem addSongButton) {
    final MainPanel mainPanel = QueleaApp.get().getMainWindow().getMainPanel();
    final LibrarySongList songList = mainPanel.getLibraryPanel().getLibrarySongPanel().getSongList();
    if(!songList.focusedProperty().get()) {
        addSongButton.setDisable(true);
        return;
    }
    if(songList.getListView().getSelectionModel().getSelectedIndex() == -1) {
        addSongButton.setDisable(true);
    }
    else {
        addSongButton.setDisable(false);
    }
}
 
Example 5
Source File: AbstractSimpleAction.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void setEnabled(boolean b) {
    for (Button button : buttons) {
        button.setDisable(!b);
    }
    for (MenuItem menuItem : menuItems) {
        menuItem.setDisable(!b);
    }
}
 
Example 6
Source File: MorphWidgetsMenu.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public MorphWidgetsMenu(final DisplayEditor editor)
{
    super(Messages.ReplaceWith,
          ImageCache.getImageView(DisplayEditor.class, "/icons/replace.png"));

    this.editor = editor;

    // Create menu that lists all widget types
    final ObservableList<MenuItem> items = getItems();
    WidgetCategory category = null;
    for (WidgetDescriptor descriptor : WidgetFactory.getInstance().getWidgetDescriptions())
    {
        if (Preferences.hidden_widget_types.contains(descriptor.getType()))
            continue;
        // Header for start of each category
        if (descriptor.getCategory() != category)
        {
            category = descriptor.getCategory();
            // Use disabled, empty action to show category name
            final MenuItem info = new MenuItem(category.getDescription());
            info.setDisable(true);
            items.add(new SeparatorMenuItem());
            items.add(info);
        }
        items.add(new MorphAction(descriptor));
    }
}
 
Example 7
Source File: EditRedoAction.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
public EditRedoAction(MenuItem editRedoMenuItem) {
	this.editRedoMenuItem = editRedoMenuItem;
	editRedoMenuItem.setDisable(true);
	final Changelog changelog = Changelog.getInstance();
	changelog.getChangeUpdateGroup().addListener(new UpdateGroupListener<ChangelogUpdate>() {
		@Override
		public void update(@NotNull UpdateListenerGroup<ChangelogUpdate> group, @NotNull ChangelogUpdate newChange) {
			switch (newChange.getType()) {
				case CHANGE_ADDED: {
					editRedoMenuItem.setDisable(true);
					editRedoMenuItem.setText(bundle.getString("edit_redo"));
					break;
				}
				case REDO: //intentional fall through
				case UNDO: {
					if (changelog.getToRedo() == null) {
						editRedoMenuItem.setText(bundle.getString("edit_redo"));
					} else {
						editRedoMenuItem.setText(String.format(bundle.getString("edit_redo_f"), changelog.getToRedo().getShortName()));
					}
					editRedoMenuItem.setDisable(changelog.getToRedo() == null);
					break;
				}
				default: {
					throw new IllegalArgumentException("unknown update type:" + newChange.getType());
				}
			}
		}
	});
}
 
Example 8
Source File: CommandManagerFX.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * update the enable state
 */
public void updateEnableState() {
    if (SwingUtilities.isEventDispatchThread())
        super.updateEnableState();

    for (MenuItem menuItem : menuItem2CommandFX.keySet()) {
        ICommand command = menuItem2CommandFX.get(menuItem);
        menuItem.setDisable(!command.isApplicable());
        if (command instanceof ICheckBoxCommand) {
            ((CheckMenuItem) menuItem).setSelected(((ICheckBoxCommand) command).isSelected());
        }
    }
}
 
Example 9
Source File: CommandManagerFX.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * update the enable state for only the FX menu items
 */
public void updateEnableStateFXItems() {
    for (MenuItem menuItem : menuItem2CommandFX.keySet()) {
        ICommand command = menuItem2CommandFX.get(menuItem);
        menuItem.setDisable(!command.isApplicable());
        if (command instanceof ICheckBoxCommand) {
            ((CheckMenuItem) menuItem).setSelected(((ICheckBoxCommand) command).isSelected());
        }
    }
}
 
Example 10
Source File: CommandManagerFX.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * update the enable state
 */
public void updateEnableState(String commandName) {
    if (SwingUtilities.isEventDispatchThread())
        super.updateEnableState(commandName);

    for (MenuItem menuItem : menuItem2CommandFX.keySet()) {
        ICommand command = menuItem2CommandFX.get(menuItem);
        if (command.getName().equals(commandName)) {
            menuItem.setDisable(!command.isApplicable());
            if (command instanceof ICheckBoxCommand) {
                ((CheckMenuItem) menuItem).setSelected(((ICheckBoxCommand) command).isSelected());
            }
        }
    }
}
 
Example 11
Source File: CommandManagerFX.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * get a menu item for the named command
 *
 * @param commandName
 * @return menu item
 */
public MenuItem getMenuItemFX(String commandName) {
    ICommand command = getCommand(commandName);
    MenuItem item = getMenuItemFX(command);
    if (item != null && command != null)
        item.setDisable(!command.isApplicable());
    return item;
}
 
Example 12
Source File: CommandManagerFX.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * get a menu item for the named command
 *
 * @param commandName
 * @param enabled
 * @return menu item
 */
public MenuItem getMenuItemFX(String commandName, boolean enabled) {
    ICommand command = getCommand(commandName);
    MenuItem item = getMenuItemFX(command);
    if (item != null)
        item.setDisable(!enabled || !command.isApplicable());
    return item;
}
 
Example 13
Source File: SelectionTable.java    From pdfsam with GNU Affero General Public License v3.0 4 votes vote down vote up
private MenuItem createMenuItem(String text, MaterialDesignIcon icon) {
    MenuItem item = new MenuItem(text);
    MaterialDesignIconFactory.get().setIcon(item, icon, "1.1em");
    item.setDisable(true);
    return item;
}
 
Example 14
Source File: QueryPhasePane.java    From constellation with Apache License 2.0 4 votes vote down vote up
public void enableGraphDependentMenuItems(boolean enabled) {
    for (MenuItem menuItem : graphDependentMenuItems) {
        menuItem.setDisable(!enabled);
    }
}
 
Example 15
Source File: SingleSelectionPane.java    From pdfsam with GNU Affero General Public License v3.0 4 votes vote down vote up
private MenuItem createMenuItem(String text, MaterialDesignIcon icon) {
    MenuItem item = new MenuItem(text);
    MaterialDesignIconFactory.get().setIcon(item, icon, "1.1em");
    item.setDisable(true);
    return item;
}
 
Example 16
Source File: ToolsMenu.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create the tools menu.
 */
public ToolsMenu() {
    super(LabelGrabber.INSTANCE.getLabel("tools.menu"));
    boolean darkTheme = QueleaProperties.get().getUseDarkTheme();

    viewBibleItem = new MenuItem(LabelGrabber.INSTANCE.getLabel("view.bible.button"), new ImageView(new Image(darkTheme ? "file:icons/bible-light.png" : "file:icons/bible.png", 20, 20, false, true)));
    viewBibleItem.setOnAction(new ViewBibleActionHandler());
    getItems().add(viewBibleItem);

    searchBibleItem = new MenuItem(LabelGrabber.INSTANCE.getLabel("search.bible.button"), new ImageView(new Image(darkTheme ? "file:icons/bible-light.png" : "file:icons/bible.png", 20, 20, false, true)));
    searchBibleItem.setOnAction(new SearchBibleActionHandler());
    getItems().add(searchBibleItem);

    testItem = new MenuItem(LabelGrabber.INSTANCE.getLabel("test.patterns.text"), new ImageView(new Image("file:icons/testbars.png", 20, 20, false, true)));
    testItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            TestPaneDialog dialog = testDialog.get();
            if (dialog == null) {
                dialog = new TestPaneDialog();
                testDialog = new SoftReference<>(dialog);
            }
            dialog.show();
        }
    });
    getItems().add(testItem);

    liveTextItem = new MenuItem(LabelGrabber.INSTANCE.getLabel("send.live.text"), new ImageView(new Image(darkTheme ? "file:icons/live_text-light.png" : "file:icons/live_text.png", 20, 20, false, true)));
    liveTextItem.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
    liveTextItem.setOnAction(new LiveTextActionHandler());
    if (QueleaApp.get().getMobileLyricsServer() == null) {
        liveTextItem.setDisable(true);
    }
    getItems().add(liveTextItem);

    optionsItem = new MenuItem(LabelGrabber.INSTANCE.getLabel("options.button"), new ImageView(new Image("file:icons/options.png", 20, 20, false, true)));
    optionsItem.setAccelerator(new KeyCodeCombination(KeyCode.T, KeyCombination.SHORTCUT_DOWN));
    optionsItem.setOnAction(new ShowOptionsActionHandler());

    getItems().add(optionsItem);
}
 
Example 17
Source File: QueryPhasePane.java    From constellation with Apache License 2.0 4 votes vote down vote up
public void enablePluginDependentMenuItems(boolean enabled) {
    for (MenuItem menuItem : pluginDependentMenuItems) {
        menuItem.setDisable(!enabled);
    }
}