Example usage for javafx.scene.control SeparatorMenuItem SeparatorMenuItem

List of usage examples for javafx.scene.control SeparatorMenuItem SeparatorMenuItem

Introduction

In this page you can find the example usage for javafx.scene.control SeparatorMenuItem SeparatorMenuItem.

Prototype

public SeparatorMenuItem() 

Source Link

Document

Creates a default SeparatorMenuItem instance.

Usage

From source file:jviewmda.JViewMda.java

@Override
public void start(Stage primaryStage) {
    m_stage = primaryStage;/*  w  w  w . jav  a 2 s . c om*/

    String array_path = "";
    Parameters params = getParameters();
    List<String> unnamed_params = params.getUnnamed();
    if (unnamed_params.size() > 0) {
        array_path = unnamed_params.get(0);
    }
    // FOR DEBUGING PURPOSES
    if (array_path.length() == 0) {
        //String debug_path = "/home/magland/wisdm/www/wisdmfileserver/files/fetalmri/sessions/SESSION1/crops/FNP001A-coronal.crop.mda";
        String debug_path = "/home/magland/data/LesionProbe/Images/ID001_FLAIR.nii";
        if ((new File(debug_path)).exists()) {
            array_path = debug_path;
        }
    }

    Menu menu;
    MenuItem item;

    MenuBar menubar = new MenuBar();

    //file menu
    menu = new Menu("File");
    menubar.getMenus().add(menu);
    item = new MenuItem("Open...");
    item.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_file_open());
    menu.getItems().add(item);
    item = new MenuItem("Save As...");
    item.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_file_saveas());
    menu.getItems().add(item);
    menu.getItems().add(new SeparatorMenuItem()); /////////////////////////////////////////////
    item = new MenuItem("Exit");
    item.setAccelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_file_exit());
    menu.getItems().add(item);

    //view menu
    menu = new Menu("View");
    menubar.getMenus().add(menu);
    item = new MenuItem("Zoom In");
    item.setAccelerator(new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_zoom_in());
    menu.getItems().add(item);
    item = new MenuItem("Zoom Out");
    item.setAccelerator(
            new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
    item.setOnAction(e -> on_zoom_out());
    menu.getItems().add(item);
    menu.getItems().add(new SeparatorMenuItem()); /////////////////////////////////////////////
    {
        CheckMenuItem item0 = new CheckMenuItem("Top Controls");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setTopControlsVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }
    {
        CheckMenuItem item0 = new CheckMenuItem("Bottom Controls");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setBottomControlsVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }
    {
        CheckMenuItem item0 = new CheckMenuItem("Brightness/Contrast");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setBrightnessContrastVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }
    {
        CheckMenuItem item0 = new CheckMenuItem("Slice Slider");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setSliceSliderVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }

    //selection menu
    menu = new Menu("Selection");
    menubar.getMenus().add(menu);
    Map<String, CheckMenuItem> mode_items = new HashMap<>();
    m_selection_mode_items = mode_items;
    mode_items.put("rectangle", new CheckMenuItem("Rectangle"));
    mode_items.put("ellipse", new CheckMenuItem("Ellipse"));
    Set<String> keys = mode_items.keySet();
    for (String key : keys) {
        CheckMenuItem item0 = mode_items.get(key);
        menu.getItems().add(item0);
        item0.setOnAction(evt -> {
            on_selection_mode_changed(key);
        });

    }
    mode_items.get("rectangle").setSelected(true);

    VBox root = new VBox();
    root.getChildren().addAll(menubar, m_widget);

    Scene scene = new Scene(root, 500, 450);

    primaryStage.setTitle("JViewMda");
    primaryStage.setScene(scene);
    primaryStage.show();

    if (array_path.length() > 0) {
        open_file(array_path);
    }

    m_prefs = Preferences.userNodeForPackage(this.getClass());

}

From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    file = new File("");
    csvFormat = CSVFormat.DEFAULT.withIgnoreEmptyLines(false);

    ContextMenu contextMenu = new ContextMenu();
    contextMenu.setAutoHide(true);//from   ww  w  .  ja v  a2 s.co  m
    MenuItem inserirLinha = new MenuItem("Inserir linha");
    inserirLinha.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent t) {
            addNewRow();
            setNotSaved();
        }
    });

    contextMenu.getItems().add(inserirLinha);
    MenuItem removerLinha = new MenuItem("Remover linha");
    removerLinha.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent t) {
            deleteRow();
            setNotSaved();
        }
    });
    contextMenu.getItems().add(removerLinha);

    contextMenu.getItems().add(new SeparatorMenuItem());

    MenuItem inserirColuna = new MenuItem("Inserir coluna");
    inserirColuna.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            addNewColumn();
            setNotSaved();
        }
    });
    contextMenu.getItems().add(inserirColuna);

    MenuItem removerColuna = new MenuItem("Remover coluna");
    removerColuna.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            deleteColumn();
            setNotSaved();
        }
    });
    contextMenu.getItems().add(removerColuna);

    tableView.setContextMenu(contextMenu);
}

From source file:org.pdfsam.ui.selection.single.SingleSelectionPane.java

private void initContextMenu() {
    MenuItem infoItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Document properties"),
            AwesomeIcon.INFO);//  w  ww  .  jav a  2  s.c  o m
    infoItem.setOnAction(e -> Platform.runLater(() -> {
        eventStudio().broadcast(new ShowPdfDescriptorRequest(descriptor));
    }));

    MenuItem setDestinationItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set output"),
            AwesomeIcon.PENCIL_SQUARE_ALT);
    setDestinationItem.setOnAction(e -> {
        eventStudio().broadcast(new SetDestinationRequest(descriptor.getFile().getParentFile()),
                getOwnerModule());
    });

    MenuItem openFileItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open"), AwesomeIcon.FILE_ALT);
    openFileItem.setOnAction(e -> {
        eventStudio().broadcast(new OpenFileRequest(descriptor.getFile()));
    });

    MenuItem openFolderItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open Folder"),
            AwesomeIcon.FOLDER_OPEN);
    openFolderItem.setOnAction(e -> {
        eventStudio().broadcast(new OpenFileRequest(descriptor.getFile().getParentFile()));
    });

    field.getTextField().setContextMenu(new ContextMenu(setDestinationItem, new SeparatorMenuItem(), infoItem,
            openFileItem, openFolderItem));
}

From source file:org.nmrfx.processor.gui.MainApp.java

MenuBar makeMenuBar(String appName) {
    MenuToolkit tk = null;/*from   www  .  j ava2 s .c o m*/
    if (isMac()) {
        tk = MenuToolkit.toolkit();
    }
    MenuBar menuBar = new MenuBar();

    // Application Menu
    // TBD: services menu
    Menu appMenu = new Menu(appName); // Name for appMenu can't be set at
    // Runtime
    MenuItem aboutItem = null;
    Stage aboutStage = makeAbout(appName);
    if (tk != null) {
        aboutItem = tk.createAboutMenuItem(appName, aboutStage);
    } else {
        aboutItem = new MenuItem("About...");
        aboutItem.setOnAction(e -> aboutStage.show());
    }
    MenuItem prefsItem = new MenuItem("Preferences...");
    MenuItem quitItem;
    prefsItem.setOnAction(e -> showPreferences(e));
    if (tk != null) {
        quitItem = tk.createQuitMenuItem(appName);
        appMenu.getItems().addAll(aboutItem, new SeparatorMenuItem(), prefsItem, new SeparatorMenuItem(),
                tk.createHideMenuItem(appName), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(),
                new SeparatorMenuItem(), quitItem);
        // createQuitMeneItem doesn't result in stop or quit being called
        //  therefore we can't check for waiting till a commit is done before leaving
        // so explicitly set action to quit
        quitItem.setOnAction(e -> quit());
    } else {
        quitItem = new MenuItem("Quit");
        quitItem.setOnAction(e -> quit());
    }
    // File Menu (items TBD)
    Menu fileMenu = new Menu("File");
    MenuItem openMenuItem = new MenuItem("Open and Draw...");
    openMenuItem.setOnAction(e -> FXMLController.getActiveController().openAction(e));
    MenuItem addMenuItem = new MenuItem("Open...");
    addMenuItem.setOnAction(e -> FXMLController.getActiveController().addNoDrawAction(e));
    MenuItem newMenuItem = new MenuItem("New Window...");
    newMenuItem.setOnAction(e -> newGraphics(e));
    Menu recentMenuItem = new Menu("Open and Draw Recent");

    List<Path> recentDatasets = PreferencesController.getRecentDatasets();
    for (Path path : recentDatasets) {
        int count = path.getNameCount();
        int first = count - 3;
        first = first >= 0 ? first : 0;
        Path subPath = path.subpath(first, count);

        MenuItem datasetMenuItem = new MenuItem(subPath.toString());
        datasetMenuItem
                .setOnAction(e -> FXMLController.getActiveController().openFile(path.toString(), false, false));
        recentMenuItem.getItems().add(datasetMenuItem);
    }
    MenuItem pdfMenuItem = new MenuItem("Export PDF...");
    pdfMenuItem.setOnAction(e -> FXMLController.getActiveController().exportPDFAction(e));
    MenuItem svgMenuItem = new MenuItem("Export SVG...");
    svgMenuItem.setOnAction(e -> FXMLController.getActiveController().exportSVGAction(e));
    MenuItem loadPeakListMenuItem = new MenuItem("Load PeakLists");
    loadPeakListMenuItem.setOnAction(e -> loadPeakLists());

    Menu projectMenu = new Menu("Projects");

    MenuItem projectOpenMenuItem = new MenuItem("Open...");
    projectOpenMenuItem.setOnAction(e -> loadProject());

    MenuItem projectSaveAsMenuItem = new MenuItem("Save As...");
    projectSaveAsMenuItem.setOnAction(e -> saveProjectAs());

    MenuItem projectSaveMenuItem = new MenuItem("Save");
    projectSaveMenuItem.setOnAction(e -> saveProject());
    Menu recentProjectMenuItem = new Menu("Open Recent");

    List<Path> recentProjects = PreferencesController.getRecentProjects();
    for (Path path : recentProjects) {
        int count = path.getNameCount();
        int first = count - 3;
        first = first >= 0 ? first : 0;
        Path subPath = path.subpath(first, count);

        MenuItem projectMenuItem = new MenuItem(subPath.toString());
        projectMenuItem.setOnAction(e -> loadProject(path));
        recentProjectMenuItem.getItems().add(projectMenuItem);
    }

    projectMenu.getItems().addAll(projectOpenMenuItem, recentProjectMenuItem, projectSaveMenuItem,
            projectSaveAsMenuItem);

    fileMenu.getItems().addAll(openMenuItem, addMenuItem, newMenuItem, recentMenuItem, new SeparatorMenuItem(),
            pdfMenuItem, svgMenuItem, loadPeakListMenuItem);

    Menu spectraMenu = new Menu("Spectra");
    MenuItem deleteItem = new MenuItem("Delete Spectrum");
    deleteItem.setOnAction(e -> FXMLController.getActiveController().removeChart());
    MenuItem syncMenuItem = new MenuItem("Sync Axes");
    syncMenuItem.setOnAction(e -> PolyChart.activeChart.syncSceneMates());

    Menu arrangeMenu = new Menu("Arrange");
    MenuItem horizItem = new MenuItem("Horizontal");
    horizItem.setOnAction(
            e -> FXMLController.getActiveController().arrange(FractionPane.ORIENTATION.HORIZONTAL));
    MenuItem vertItem = new MenuItem("Vertical");
    vertItem.setOnAction(e -> FXMLController.getActiveController().arrange(FractionPane.ORIENTATION.VERTICAL));
    MenuItem gridItem = new MenuItem("Grid");
    gridItem.setOnAction(e -> FXMLController.getActiveController().arrange(FractionPane.ORIENTATION.GRID));
    MenuItem overlayItem = new MenuItem("Overlay");
    overlayItem.setOnAction(e -> FXMLController.getActiveController().overlay());
    MenuItem minimizeItem = new MenuItem("Minimize Borders");
    minimizeItem.setOnAction(e -> FXMLController.getActiveController().setBorderState(true));
    MenuItem normalizeItem = new MenuItem("Normal Borders");
    normalizeItem.setOnAction(e -> FXMLController.getActiveController().setBorderState(false));

    arrangeMenu.getItems().addAll(horizItem, vertItem, gridItem, overlayItem, minimizeItem, normalizeItem);
    MenuItem alignMenuItem = new MenuItem("Align Spectra");
    alignMenuItem.setOnAction(e -> FXMLController.getActiveController().alignCenters());
    MenuItem analyzeMenuItem = new MenuItem("Analyzer...");
    analyzeMenuItem.setOnAction(e -> showAnalyzer(e));

    spectraMenu.getItems().addAll(deleteItem, arrangeMenu, syncMenuItem, alignMenuItem, analyzeMenuItem);

    // Format (items TBD)
    //        Menu formatMenu = new Menu("Format");
    //        formatMenu.getItems().addAll(new MenuItem("TBD"));
    // View Menu (items TBD)
    Menu viewMenu = new Menu("View");
    MenuItem dataMenuItem = new MenuItem("Show Datasets");
    dataMenuItem.setOnAction(e -> showDatasetsTable(e));

    MenuItem consoleMenuItem = new MenuItem("Show Console");
    consoleMenuItem.setOnAction(e -> showConsole(e));

    MenuItem attrMenuItem = new MenuItem("Show Attributes");
    attrMenuItem.setOnAction(e -> FXMLController.getActiveController().showSpecAttrAction(e));

    MenuItem procMenuItem = new MenuItem("Show Processor");
    procMenuItem.setOnAction(e -> FXMLController.getActiveController().showProcessorAction(e));

    MenuItem scannerMenuItem = new MenuItem("Show Scanner");
    scannerMenuItem.setOnAction(e -> FXMLController.getActiveController().showScannerAction(e));

    viewMenu.getItems().addAll(consoleMenuItem, dataMenuItem, attrMenuItem, procMenuItem, scannerMenuItem);

    Menu peakMenu = new Menu("Peaks");

    MenuItem peakAttrMenuItem = new MenuItem("Show Peak Tool");
    peakAttrMenuItem.setOnAction(e -> FXMLController.getActiveController().showPeakAttrAction(e));

    MenuItem peakNavigatorMenuItem = new MenuItem("Show Peak Navigator");
    peakNavigatorMenuItem.setOnAction(e -> FXMLController.getActiveController().showPeakNavigator());

    MenuItem linkPeakDimsMenuItem = new MenuItem("Link by Labels");
    linkPeakDimsMenuItem.setOnAction(e -> FXMLController.getActiveController().linkPeakDims());

    MenuItem peakSliderMenuItem = new MenuItem("Show Peak Slider");
    peakSliderMenuItem.setOnAction(e -> FXMLController.getActiveController().showPeakSlider());

    peakMenu.getItems().addAll(peakAttrMenuItem, peakNavigatorMenuItem, linkPeakDimsMenuItem,
            peakSliderMenuItem);

    // Window Menu
    // TBD standard window menu items
    // Help Menu (items TBD)
    Menu helpMenu = new Menu("Help");

    MenuItem webSiteMenuItem = new MenuItem("NMRFx Web Site");
    webSiteMenuItem.setOnAction(e -> showWebSiteAction(e));

    MenuItem docsMenuItem = new MenuItem("Online Documentation");
    docsMenuItem.setOnAction(e -> showDocAction(e));

    MenuItem versionMenuItem = new MenuItem("Check Version");
    versionMenuItem.setOnAction(e -> showVersionAction(e));

    MenuItem mailingListItem = new MenuItem("Mailing List Site");
    mailingListItem.setOnAction(e -> showMailingListAction(e));

    MenuItem refMenuItem = new MenuItem("NMRFx Publication");
    refMenuItem.setOnAction(e -> {
        MainApp.hostServices.showDocument("http://link.springer.com/article/10.1007/s10858-016-0049-6");
    });

    // home
    // mailing list
    //
    helpMenu.getItems().addAll(docsMenuItem, webSiteMenuItem, mailingListItem, versionMenuItem, refMenuItem);

    if (tk != null) {
        Menu windowMenu = new Menu("Window");
        windowMenu.getItems().addAll(tk.createMinimizeMenuItem(), tk.createZoomMenuItem(),
                tk.createCycleWindowsItem(), new SeparatorMenuItem(), tk.createBringAllToFrontItem());
        menuBar.getMenus().addAll(appMenu, fileMenu, projectMenu, spectraMenu, viewMenu, peakMenu, windowMenu,
                helpMenu);
        tk.autoAddWindowMenuItems(windowMenu);
        tk.setGlobalMenuBar(menuBar);
    } else {
        fileMenu.getItems().add(prefsItem);
        fileMenu.getItems().add(quitItem);
        menuBar.getMenus().addAll(fileMenu, projectMenu, spectraMenu, viewMenu, peakMenu, helpMenu);
        helpMenu.getItems().add(0, aboutItem);
    }
    return menuBar;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("Menu Sample");
    Scene scene = new Scene(new VBox(), 400, 350);
    scene.setFill(Color.OLDLACE);

    name.setFont(new Font("Verdana Bold", 22));
    binName.setFont(new Font("Arial Italic", 10));
    pic.setFitHeight(150);//www . j  a  va 2  s .com
    pic.setPreserveRatio(true);
    description.setWrapText(true);
    description.setTextAlignment(TextAlignment.JUSTIFY);

    shuffle();

    MenuBar menuBar = new MenuBar();

    // --- Graphical elements
    final VBox vbox = new VBox();
    vbox.setAlignment(Pos.CENTER);
    vbox.setSpacing(10);
    vbox.setPadding(new Insets(0, 10, 0, 10));
    vbox.getChildren().addAll(name, binName, pic, description);

    // --- Menu File
    Menu menuFile = new Menu("File");
    MenuItem add = new MenuItem("Shuffle", new ImageView(new Image("src/menusample/new.png")));
    add.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            shuffle();
            vbox.setVisible(true);
        }
    });

    MenuItem clear = new MenuItem("Clear");
    clear.setAccelerator(KeyCombination.keyCombination("Ctrl+X"));
    clear.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            vbox.setVisible(false);
        }
    });

    MenuItem exit = new MenuItem("Exit");
    exit.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            System.exit(0);
        }
    });

    menuFile.getItems().addAll(add, clear, new SeparatorMenuItem(), exit);

    // --- Menu Edit
    Menu menuEdit = new Menu("Edit");
    Menu menuEffect = new Menu("Picture Effect");

    final ToggleGroup groupEffect = new ToggleGroup();
    for (Entry effect : effects) {
        RadioMenuItem itemEffect = new RadioMenuItem((String) effect.getKey());
        itemEffect.setUserData(effect.getValue());
        itemEffect.setToggleGroup(groupEffect);
        menuEffect.getItems().add(itemEffect);
    }

    final MenuItem noEffects = new MenuItem("No Effects");
    noEffects.setDisable(true);
    noEffects.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            pic.setEffect(null);
            groupEffect.getSelectedToggle().setSelected(false);
            noEffects.setDisable(true);
        }
    });

    groupEffect.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) {
            if (groupEffect.getSelectedToggle() != null) {
                Effect effect = (Effect) groupEffect.getSelectedToggle().getUserData();
                pic.setEffect(effect);
                noEffects.setDisable(false);
            } else {
                noEffects.setDisable(true);
            }
        }
    });

    menuEdit.getItems().addAll(menuEffect, noEffects);

    // --- Menu View
    Menu menuView = new Menu("View");
    CheckMenuItem titleView = createMenuItem("Title", name);
    CheckMenuItem binNameView = createMenuItem("Binomial name", binName);
    CheckMenuItem picView = createMenuItem("Picture", pic);
    CheckMenuItem descriptionView = createMenuItem("Decsription", description);

    menuView.getItems().addAll(titleView, binNameView, picView, descriptionView);
    menuBar.getMenus().addAll(menuFile, menuEdit, menuView);

    // --- Context Menu
    final ContextMenu cm = new ContextMenu();
    MenuItem cmItem1 = new MenuItem("Copy Image");
    cmItem1.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Clipboard clipboard = Clipboard.getSystemClipboard();
            ClipboardContent content = new ClipboardContent();
            content.putImage(pic.getImage());
            clipboard.setContent(content);
        }
    });

    cm.getItems().add(cmItem1);
    pic.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent e) {
            if (e.getButton() == MouseButton.SECONDARY)
                cm.show(pic, e.getScreenX(), e.getScreenY());
        }
    });

    ((VBox) scene.getRoot()).getChildren().addAll(menuBar, vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:org.pdfsam.ui.selection.multiple.SelectionTable.java

private void initContextMenu() {
    MenuItem infoItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Document properties"),
            AwesomeIcon.INFO);/*from w w w .j av  a  2 s.  c  o m*/
    infoItem.setOnAction(e -> Platform.runLater(() -> {
        eventStudio().broadcast(
                new ShowPdfDescriptorRequest(getSelectionModel().getSelectedItem().getPdfDocumentDescriptor()));
    }));
    MenuItem setDestinationItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set output"),
            AwesomeIcon.PENCIL_SQUARE_ALT);

    setDestinationItem.setOnAction(e -> {
        File outFile = new File(
                getSelectionModel().getSelectedItem().getPdfDocumentDescriptor().getFile().getParent(),
                "out.pdf");
        eventStudio().broadcast(new SetDestinationRequest(outFile), getOwnerModule());
    });

    MenuItem removeSelected = createMenuItem(DefaultI18nContext.getInstance().i18n("Remove"),
            AwesomeIcon.MINUS_SQUARE_ALT);

    removeSelected.setOnAction(e -> eventStudio().broadcast(new RemoveSelectedEvent(), getOwnerModule()));

    MenuItem moveTopSelected = createMenuItem(DefaultI18nContext.getInstance().i18n("Move to Top"),
            AwesomeIcon.ANGLE_DOUBLE_UP);
    moveTopSelected
            .setOnAction(e -> eventStudio().broadcast(new MoveSelectedEvent(MoveType.TOP), getOwnerModule()));

    MenuItem moveUpSelected = createMenuItem(DefaultI18nContext.getInstance().i18n("Move Up"),
            AwesomeIcon.ANGLE_UP);
    moveUpSelected
            .setOnAction(e -> eventStudio().broadcast(new MoveSelectedEvent(MoveType.UP), getOwnerModule()));

    MenuItem moveDownSelected = createMenuItem(DefaultI18nContext.getInstance().i18n("Move Down"),
            AwesomeIcon.ANGLE_DOWN);
    moveDownSelected
            .setOnAction(e -> eventStudio().broadcast(new MoveSelectedEvent(MoveType.DOWN), getOwnerModule()));

    MenuItem moveBottomSelected = createMenuItem(DefaultI18nContext.getInstance().i18n("Move to Bottom"),
            AwesomeIcon.ANGLE_DOUBLE_DOWN);
    moveBottomSelected.setOnAction(
            e -> eventStudio().broadcast(new MoveSelectedEvent(MoveType.BOTTOM), getOwnerModule()));

    MenuItem openFileItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open"), AwesomeIcon.FILE_ALT);
    openFileItem.setOnAction(e -> {
        eventStudio().broadcast(new OpenFileRequest(
                getSelectionModel().getSelectedItem().getPdfDocumentDescriptor().getFile()));
    });

    MenuItem openFolderItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open Folder"),
            AwesomeIcon.FOLDER_OPEN);
    openFolderItem.setOnAction(e -> {
        eventStudio().broadcast(new OpenFileRequest(
                getSelectionModel().getSelectedItem().getPdfDocumentDescriptor().getFile().getParentFile()));
    });
    // https://javafx-jira.kenai.com/browse/RT-28136
    // infoItem.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN));
    // setDestinationItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.ALT_DOWN));
    // removeSelected.setAccelerator(new KeyCodeCombination(KeyCode.CANCEL));
    // moveBottomSelected.setAccelerator(new KeyCodeCombination(KeyCode.END, KeyCombination.ALT_DOWN));
    // moveDownSelected.setAccelerator(new KeyCodeCombination(KeyCode.DOWN, KeyCombination.ALT_DOWN));
    // moveUpSelected.setAccelerator(new KeyCodeCombination(KeyCode.UP, KeyCombination.ALT_DOWN));
    // moveTopSelected.setAccelerator(new KeyCodeCombination(KeyCode.HOME, KeyCombination.ALT_DOWN));

    eventStudio().add(SelectionChangedEvent.class, (SelectionChangedEvent e) -> {
        setDestinationItem.setDisable(!e.isSingleSelection());
        infoItem.setDisable(!e.isSingleSelection());
        openFileItem.setDisable(!e.isSingleSelection());
        openFolderItem.setDisable(!e.isSingleSelection());
        removeSelected.setDisable(e.isClearSelection());
        moveTopSelected.setDisable(!e.canMove(MoveType.TOP));
        moveUpSelected.setDisable(!e.canMove(MoveType.UP));
        moveDownSelected.setDisable(!e.canMove(MoveType.DOWN));
        moveBottomSelected.setDisable(!e.canMove(MoveType.BOTTOM));

    }, getOwnerModule());
    setContextMenu(new ContextMenu(setDestinationItem, new SeparatorMenuItem(), removeSelected, moveTopSelected,
            moveUpSelected, moveDownSelected, moveBottomSelected, new SeparatorMenuItem(), infoItem,
            openFileItem, openFolderItem));
}

From source file:de.pixida.logtest.designer.MainWindow.java

private void createAndAppendFileMenuItems(final Menu menu) {
    final Menu newDocument = new Menu("New");
    final Menu open = new Menu("Open");
    for (final Type type : Editor.Type.values()) {
        final MenuItem newFile = new MenuItem(type.getName());
        newFile.setOnAction(event -> this.handleCreateNewDocument(type));
        newDocument.getItems().add(newFile);

        if (type.supportsFilesProperty().get()) {
            final MenuItem openFile = new MenuItem(type.getName());
            openFile.setOnAction(event -> {
                final FileChooser fileChooser = this.createFileDialog(type, "Open");
                final File selectedFile = fileChooser.showOpenDialog(this.primaryStage);
                if (selectedFile != null) {
                    this.applyFolderOfSelectedFileInOpenOrSaveAsFileDialog(selectedFile);
                    this.handleLoadDocument(type, selectedFile);
                }/*from  www .  ja v a 2  s .com*/
            });
            open.getItems().add(openFile);
        }
    }

    this.menuItemSave = new MenuItem("Save");
    this.menuItemSave.setGraphic(Icons.getIconGraphics("disk"));
    this.menuItemSave.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
    this.menuItemSave.setOnAction(event -> this.handleSaveDocument());

    this.menuItemSaveAs = new MenuItem("Save as");
    this.menuItemSaveAs.setOnAction(event -> this.handleSaveDocumentAs());

    final MenuItem exit = new MenuItem("Exit");
    exit.setOnAction(event -> this.handleExitApplication());

    menu.getItems().addAll(newDocument, open, this.menuItemSave, this.menuItemSaveAs, new SeparatorMenuItem(),
            exit);
}

From source file:com.cdd.bao.editor.EditSchema.java

private void createMenuItems() {
    final KeyCombination.Modifier cmd = KeyCombination.SHORTCUT_DOWN, shift = KeyCombination.SHIFT_DOWN,
            alt = KeyCombination.ALT_DOWN;

    addMenu(menuFile, "_New", new KeyCharacterCombination("N", cmd)).setOnAction(event -> actionFileNew());
    addMenu(menuFile, "_Open", new KeyCharacterCombination("O", cmd)).setOnAction(event -> actionFileOpen());
    addMenu(menuFile, "_Save", new KeyCharacterCombination("S", cmd))
            .setOnAction(event -> actionFileSave(false));
    addMenu(menuFile, "Save _As", new KeyCharacterCombination("S", cmd, shift))
            .setOnAction(event -> actionFileSave(true));
    addMenu(menuFile, "_Export Dump", new KeyCharacterCombination("E", cmd))
            .setOnAction(event -> actionFileExportDump());
    addMenu(menuFile, "_Merge", null).setOnAction(event -> actionFileMerge());
    menuFile.getItems().add(new SeparatorMenuItem());
    addMenu(menuFile, "Confi_gure", new KeyCharacterCombination(",", cmd))
            .setOnAction(event -> actionFileConfigure());
    addMenu(menuFile, "_Browse Endpoint", new KeyCharacterCombination("B", cmd, shift))
            .setOnAction(event -> actionFileBrowse());
    if (false) {/*ww  w .  j a  v  a  2  s  . co  m*/
        addMenu(menuFile, "_Upload Endpoint", new KeyCharacterCombination("U", cmd, shift))
                .setOnAction(event -> actionFileUpload());
    }
    Menu menuFileGraphics = new Menu("Graphics");
    addMenu(menuFileGraphics, "_Template", null).setOnAction(event -> actionFileGraphicsTemplate());
    addMenu(menuFileGraphics, "_Assay", null).setOnAction(event -> actionFileGraphicsAssay());
    addMenu(menuFileGraphics, "_Properties", null).setOnAction(event -> actionFileGraphicsProperties());
    addMenu(menuFileGraphics, "_Values", null).setOnAction(event -> actionFileGraphicsValues());
    menuFile.getItems().add(menuFileGraphics);
    addMenu(menuFile, "Assay Stats", null).setOnAction(event -> actionFileAssayStats());
    menuFile.getItems().add(new SeparatorMenuItem());
    addMenu(menuFile, "_Close", new KeyCharacterCombination("W", cmd)).setOnAction(event -> actionFileClose());
    addMenu(menuFile, "_Quit", new KeyCharacterCombination("Q", cmd)).setOnAction(event -> actionFileQuit());

    addMenu(menuEdit, "Add _Group", new KeyCharacterCombination("G", cmd, shift))
            .setOnAction(event -> actionGroupAdd());
    addMenu(menuEdit, "Add _Assignment", new KeyCharacterCombination("A", cmd, shift))
            .setOnAction(event -> actionAssignmentAdd());
    addMenu(menuEdit, "Add Assa_y", new KeyCharacterCombination("Y", cmd, shift))
            .setOnAction(event -> actionAssayAdd());
    menuEdit.getItems().add(new SeparatorMenuItem());
    addMenu(menuEdit, "Cu_t", new KeyCharacterCombination("X", cmd)).setOnAction(event -> actionEditCopy(true));
    addMenu(menuEdit, "_Copy", new KeyCharacterCombination("C", cmd))
            .setOnAction(event -> actionEditCopy(false));
    Menu menuCopyAs = new Menu("Copy As");
    menuEdit.getItems().add(menuCopyAs);
    addMenu(menuEdit, "_Paste", new KeyCharacterCombination("V", cmd)).setOnAction(event -> actionEditPaste());
    menuEdit.getItems().add(new SeparatorMenuItem());
    addMenu(menuEdit, "_Delete", new KeyCodeCombination(KeyCode.DELETE, cmd, shift))
            .setOnAction(event -> actionEditDelete());
    addMenu(menuEdit, "_Undo", new KeyCharacterCombination("Z", cmd, shift))
            .setOnAction(event -> actionEditUndo());
    addMenu(menuEdit, "_Redo", new KeyCharacterCombination("Z", cmd, shift, alt))
            .setOnAction(event -> actionEditRedo());
    menuEdit.getItems().add(new SeparatorMenuItem());
    addMenu(menuEdit, "Move _Up", new KeyCharacterCombination("[", cmd))
            .setOnAction(event -> actionEditMove(-1));
    addMenu(menuEdit, "Move _Down", new KeyCharacterCombination("]", cmd))
            .setOnAction(event -> actionEditMove(1));

    addMenu(menuCopyAs, "Layout Tab-Separated", null).setOnAction(event -> actionEditCopyLayoutTSV());

    addMenu(menuValue, "_Add Value", new KeyCharacterCombination("V", cmd, shift))
            .setOnAction(event -> detail.actionValueAdd());
    addMenu(menuValue, "Add _Multiple Values", new KeyCharacterCombination("M", cmd, shift))
            .setOnAction(event -> detail.actionValueMultiAdd());
    addMenu(menuValue, "_Delete Value", new KeyCodeCombination(KeyCode.DELETE, cmd))
            .setOnAction(event -> detail.actionValueDelete());
    addMenu(menuValue, "Move _Up", new KeyCodeCombination(KeyCode.UP, cmd))
            .setOnAction(event -> detail.actionValueMove(-1));
    addMenu(menuValue, "Move _Down", new KeyCodeCombination(KeyCode.DOWN, cmd))
            .setOnAction(event -> detail.actionValueMove(1));
    menuValue.getItems().add(new SeparatorMenuItem());
    addMenu(menuValue, "_Lookup URI", new KeyCharacterCombination("U", cmd))
            .setOnAction(event -> detail.actionLookupURI());
    addMenu(menuValue, "Lookup _Name", new KeyCharacterCombination("L", cmd))
            .setOnAction(event -> detail.actionLookupName());
    menuValue.getItems().add(new SeparatorMenuItem());
    addMenu(menuValue, "_Sort Values", null).setOnAction(event -> actionValueSort());
    addMenu(menuValue, "_Remove Duplicates", null).setOnAction(event -> actionValueDuplicates());
    addMenu(menuValue, "Cleanup Values", null).setOnAction(event -> actionValueCleanup());

    (menuViewSummary = addCheckMenu(menuView, "_Summary Values", new KeyCharacterCombination("-", cmd)))
            .setOnAction(event -> actionViewToggleSummary());
    addMenu(menuView, "_Template", new KeyCharacterCombination("1", cmd))
            .setOnAction(event -> actionViewTemplate());
    addMenu(menuView, "_Assays", new KeyCharacterCombination("2", cmd))
            .setOnAction(event -> actionViewAssays());
    addMenu(menuView, "_Derived Tree", new KeyCharacterCombination("3", cmd))
            .setOnAction(event -> detail.actionShowTree());
}

From source file:net.sourceforge.pmd.util.fxdesigner.MainDesignerController.java

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);//from   w w  w .  j a  v  a 2  s  .c o  m
        } 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);
}

From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java

private void setupTableWithChanges(TableView<Change> tv, Dataset tp) {
    tv.setEditable(true);// w  w w  .  j  ava2 s .c  om
    tv.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    tv.getColumns().clear();

    TableColumn<Change, ChangeType> colChangeType = new TableColumn<>("Type");
    colChangeType.setCellFactory(ComboBoxTableCell.forTableColumn(new ChangeTypeStringConverter(),
            ChangeType.ADDITION, ChangeType.DELETION, ChangeType.RENAME, ChangeType.LUMP, ChangeType.SPLIT,
            ChangeType.COMPLEX, ChangeType.ERROR));
    colChangeType.setCellValueFactory(new PropertyValueFactory<>("type"));
    colChangeType.setPrefWidth(100.0);
    colChangeType.setEditable(true);
    tv.getColumns().add(colChangeType);

    TableColumn<Change, ObservableSet<Name>> colChangeFrom = new TableColumn<>("From");
    colChangeFrom.setCellFactory(TextFieldTableCell.forTableColumn(new NameSetStringConverter()));
    colChangeFrom.setCellValueFactory(new PropertyValueFactory<>("from"));
    colChangeFrom.setPrefWidth(200.0);
    colChangeFrom.setEditable(true);
    tv.getColumns().add(colChangeFrom);

    TableColumn<Change, ObservableSet<Name>> colChangeTo = new TableColumn<>("To");
    colChangeTo.setCellFactory(TextFieldTableCell.forTableColumn(new NameSetStringConverter()));
    colChangeTo.setCellValueFactory(new PropertyValueFactory<>("to"));
    colChangeTo.setPrefWidth(200.0);
    colChangeTo.setEditable(true);
    tv.getColumns().add(colChangeTo);

    TableColumn<Change, String> colExplicit = new TableColumn<>("Explicit or implicit?");
    colExplicit.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    features.getValue().getDataset().isChangeImplicit(features.getValue()) ? "Implicit"
                            : "Explicit"));
    tv.getColumns().add(colExplicit);

    ChangeFilter cf = datasetView.getProjectView().getProject().getChangeFilter();
    TableColumn<Change, String> colFiltered = new TableColumn<>("Eliminated by filter?");
    colFiltered.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    cf.test(features.getValue()) ? "Allowed" : "Eliminated"));
    tv.getColumns().add(colFiltered);

    TableColumn<Change, String> colNote = new TableColumn<>("Note");
    colNote.setCellFactory(TextFieldTableCell.forTableColumn());
    colNote.setCellValueFactory(new PropertyValueFactory<>("note"));
    colNote.setPrefWidth(100.0);
    colNote.setEditable(true);
    tv.getColumns().add(colNote);

    TableColumn<Change, String> colCitations = new TableColumn<>("Citations");
    colCitations.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    features.getValue().getCitationStream().map(citation -> citation.getCitation()).sorted()
                            .collect(Collectors.joining("; "))));
    tv.getColumns().add(colCitations);

    TableColumn<Change, String> colGenera = new TableColumn<>("Genera");
    colGenera.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    String.join(", ", features.getValue().getAllNames().stream().map(n -> n.getGenus())
                            .distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colGenera);

    TableColumn<Change, String> colSpecificEpithet = new TableColumn<>("Specific epithets");
    colSpecificEpithet.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(String
                    .join(", ", features.getValue().getAllNames().stream().map(n -> n.getSpecificEpithet())
                            .filter(s -> s != null).distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colSpecificEpithet);

    // The infraspecific string.
    TableColumn<Change, String> colInfraspecificEpithet = new TableColumn<>("Infraspecific epithets");
    colInfraspecificEpithet.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    String.join(", ",
                            features.getValue().getAllNames().stream()
                                    .map(n -> n.getInfraspecificEpithetsAsString()).filter(s -> s != null)
                                    .distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colInfraspecificEpithet);

    // The very last epithet of all
    TableColumn<Change, String> colTerminalEpithet = new TableColumn<>("Terminal epithet");
    colTerminalEpithet.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    String.join(", ", features.getValue().getAllNames().stream().map(n -> {
                        List<Name.InfraspecificEpithet> infraspecificEpithets = n.getInfraspecificEpithets();
                        if (!infraspecificEpithets.isEmpty()) {
                            return infraspecificEpithets.get(infraspecificEpithets.size() - 1).getValue();
                        } else {
                            return n.getSpecificEpithet();
                        }
                    }).filter(s -> s != null).distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colTerminalEpithet);

    // Properties
    TableColumn<Change, String> colProperties = new TableColumn<>("Properties");
    colProperties.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    features.getValue().getProperties().entrySet().stream()
                            .map(entry -> entry.getKey() + ": " + entry.getValue()).sorted()
                            .collect(Collectors.joining("; "))));
    tv.getColumns().add(colProperties);

    fillTableWithChanges(tv, tp);

    // When someone selects a cell in the Table, try to select the appropriate data in the
    // additional data view.
    tv.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Change>) lcl -> {
        AdditionalData aData = additionalDataCombobox.getSelectionModel().getSelectedItem();

        if (aData != null) {
            aData.onSelectChange(tv.getSelectionModel().getSelectedItems());
        }
    });

    // Create a right-click menu for table rows.
    changesTableView.setRowFactory(table -> {
        TableRow<Change> row = new TableRow<>();

        row.setOnContextMenuRequested(event -> {
            if (row.isEmpty())
                return;

            // We don't currently use the clicked change, since currently all options
            // change *all* the selected changes, but this may change in the future.
            Change change = row.getItem();

            ContextMenu changeMenu = new ContextMenu();

            Menu searchForName = new Menu("Search for name");
            searchForName.getItems().addAll(
                    change.getAllNames().stream().sorted().map(n -> createMenuItem(n.getFullName(), action -> {
                        datasetView.getProjectView().openDetailedView(n);
                    })).collect(Collectors.toList()));
            changeMenu.getItems().add(searchForName);
            changeMenu.getItems().add(new SeparatorMenuItem());

            changeMenu.getItems().add(createMenuItem("Edit note", action -> {
                List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems());

                String combinedNotes = changes.stream().map(ch -> ch.getNote().orElse("").trim()).distinct()
                        .collect(Collectors.joining("\n")).trim();

                Optional<String> result = askUserForTextArea(
                        "Modify the note for these " + changes.size() + " changes:", combinedNotes);

                if (result.isPresent()) {
                    String note = result.get().trim();
                    LOGGER.info("Using 'Edit note' to set note to '" + note + "' on changes " + changes);
                    changes.forEach(ch -> ch.noteProperty().set(note));
                }
            }));
            changeMenu.getItems().add(new SeparatorMenuItem());

            // Create a submenu for tags and urls.
            String note = change.noteProperty().get();

            Menu removeTags = new Menu("Tags");
            removeTags.getItems().addAll(change.getTags().stream().sorted()
                    .map(tag -> new MenuItem(tag.getName())).collect(Collectors.toList()));

            Menu lookupURLs = new Menu("Lookup URL");
            change.getURIs().stream().sorted().map(uri -> {
                return createMenuItem(uri.toString(), evt -> {
                    try {
                        Desktop.getDesktop().browse(uri);
                    } catch (IOException ex) {
                        LOGGER.warning("Could not open URL '" + uri + "': " + ex);
                    }
                });
            }).forEach(mi -> lookupURLs.getItems().add(mi));
            changeMenu.getItems().add(lookupURLs);

            changeMenu.getItems().add(new SeparatorMenuItem());
            changeMenu.getItems().add(createMenuItem("Prepend text to all notes", action -> {
                List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems());

                Optional<String> result = askUserForTextField(
                        "Enter tags to prepend to notes in " + changes.size() + " changes:");

                if (result.isPresent()) {
                    String tags = result.get().trim();
                    changes.forEach(ch -> {
                        String prevValue = change.getNote().orElse("").trim();

                        LOGGER.info("Prepending tags '" + tags + "' to previous value '" + prevValue
                                + "' for change " + ch);

                        ch.noteProperty().set((tags + " " + prevValue).trim());
                    });
                }
            }));
            changeMenu.getItems().add(createMenuItem("Append text to all notes", action -> {
                List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems());
                Optional<String> result = askUserForTextField(
                        "Enter tags to append to notes in " + changes.size() + " changes:");

                if (result.isPresent()) {
                    String tags = result.get().trim();
                    changes.forEach(ch -> {
                        String prevValue = ch.getNote().orElse("").trim();

                        LOGGER.info("Appending tags '" + tags + "' to previous value '" + prevValue
                                + "' for change " + ch);

                        ch.noteProperty().setValue((prevValue + " " + tags).trim());
                    });
                }
            }));

            changeMenu.show(datasetView.getScene().getWindow(), event.getScreenX(), event.getScreenY());

        });

        return row;
    });

    LOGGER.info("setupTableWithChanges() completed");
}