private void updateRecentFilesMenu() { List<MenuItem> items = new ArrayList<>(); List<File> filesToClear = new ArrayList<>(); for (final File f : recentFiles) { if (f.exists() && f.isFile()) { CustomMenuItem item = new CustomMenuItem(new Label(f.getName())); item.setOnAction(e -> loadSourceFromFile(f)); item.setMnemonicParsing(false); Tooltip.install(item.getContent(), new Tooltip(f.getAbsolutePath())); items.add(item); } else { filesToClear.add(f); } } recentFiles.removeAll(filesToClear); if (items.isEmpty()) { openRecentMenu.setDisable(true); return; } Collections.reverse(items); items.add(new SeparatorMenuItem()); MenuItem clearItem = new MenuItem(); clearItem.setText("Clear menu"); clearItem.setOnAction(e -> { recentFiles.clear(); openRecentMenu.setDisable(true); }); items.add(clearItem); openRecentMenu.getItems().setAll(items); }
public ClearButton(String ownerModule) { this.ownerModule = defaultString(ownerModule); getStyleClass().addAll(Style.BUTTON.css()); getStyleClass().add("pdfsam-split-button"); setTooltip(new Tooltip(DefaultI18nContext.getInstance().i18n("Removes every document"))); setText(DefaultI18nContext.getInstance().i18n("_Clear")); setOnAction(this::clear); MenuItem clearAllSettings = new MenuItem(); clearAllSettings.setText(DefaultI18nContext.getInstance().i18n("C_lear all settings")); clearAllSettings.setOnAction(this::clearAll); getItems().add(clearAllSettings); }
public MenuItem createShowFormMenuItem() { MenuItem menuItem = new MenuItem(); menuItem.setText(title); menuItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createForm().show(); } }); menuItem.setDisable(!enabled); return menuItem; }
private static void updateLabeled(@Nonnull final MenuItem node, @Nonnull final GriffonApplication application) { runInsideUIThread(() -> { String key = getI18nKey(node); String args = getI18nArgs(node); String defaultValue = getI18nDefaultValue(node); Object[] argArray = isBlank(args) ? EMPTY_OBJECT_ARRAY : args.split(","); if (isBlank(defaultValue)) { node.setText(application.getMessageSource().getMessage(key, argArray, application.getLocale())); } else { node.setText(application.getMessageSource().getMessage(key, argArray, application.getLocale(), defaultValue)); } }); }
/** * Generates an hyperlink from a component * * @param controller * @param actionDefinition * @return Button */ public static MenuItem menuItemFrom(final AbstractViewController controller, final VLViewComponentXML actionDefinition) { final MenuItem menuItem = new MenuItem(); menuItem.setId(actionDefinition.getId()); final String title = actionDefinition.getPropertyValue(XMLConstants.LABEL); if (!StringUtils.isEmpty(title)) { menuItem.setText(controller.getLocalised(title)); } Label label = new Label(); IconUtils.setIcon(label, actionDefinition); menuItem.setGraphic(label); setOnAction(actionDefinition, menuItem, controller); return menuItem; } }
calledMenuItem.setOnAction(e -> { showCalled = !showCalled; calledMenuItem.setText(getCalledMenuText()); runButton.setText(getRunButtonText()); });