Example usage for javafx.scene.control Menu Menu

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

Introduction

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

Prototype

public Menu(String text) 

Source Link

Document

Constructs a Menu and sets the display text with the specified text.

Usage

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

private ContextMenu createContextMenu() {

    menu = new ContextMenu();

    Menu export = new Menu("Export As");

    MenuItem pngItem = new MenuItem("PNG...");
    pngItem.setOnAction((ActionEvent e) -> {
        handleExportToPNG();//from   ww w  .  jav a  2s .  c  o m
    });
    export.getItems().add(pngItem);

    MenuItem jpegItem = new MenuItem("JPEG...");
    jpegItem.setOnAction((ActionEvent e) -> {
        handleExportToJPEG();
    });
    export.getItems().add(jpegItem);

    MenuItem pdfItem = new MenuItem("PDF...");
    pdfItem.setOnAction((ActionEvent e) -> {
        handleExportToPDF();
    });
    export.getItems().add(pdfItem);

    if (ExportUtils.isJFreeSVGAvailable()) {
        MenuItem svgItem = new MenuItem("SVG...");
        svgItem.setOnAction((ActionEvent e) -> {
            handleExportToSVG();
        });
        export.getItems().add(svgItem);
    }
    menu.getItems().add(export);
    return menu;
}

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

MenuBar makeMenuBar(String appName) {
    MenuToolkit tk = null;//  ww w  .  j  a  v  a  2  s.  co  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);/*from   w ww. ja  v a 2  s.  c om*/
    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:com.bdb.weather.display.day.DayXYPlotPane.java

private void createChartElements() {
    ////from w ww. j a  v a  2 s  . c o  m
    // Set up the Domain Axis (X)
    //
    plot = new XYPlot();
    dateAxis = new DateAxis("Time");
    dateAxis.setAutoRange(false);
    dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 1, new SimpleDateFormat("h a")));
    dateAxis.setVerticalTickLabels(true);
    plot.setDomainAxis(dateAxis);
    plot.setRangeAxis(leftAxis);
    plot.setDataset(0, datasetLeft);
    if (rightAxis != null) {
        plot.setRangeAxis(1, rightAxis);
        plot.mapDatasetToRangeAxis(1, 1);
        plot.setDataset(1, datasetRight);
    }
    plot.setNoDataMessage("There is no data for the specified day");

    //
    // Set up the renderer to generate tool tips, not show shapes
    //
    XYLineAndShapeRenderer renderer = new XYLine3DRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    //renderer.setDefaultEntityRadius(1);
    plot.setRenderer(0, renderer);

    renderer = new XYLine3DRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    //renderer.setDefaultEntityRadius(1);
    plot.setRenderer(1, renderer);

    //
    // Setup the cross hairs that are displayed when the user clicks on the plot
    //
    plot.setRangeCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setDomainCrosshairVisible(true);

    //
    // Create the chart that contains the plot and the panel that contains the chart
    //
    chart = new JFreeChart(plot);
    ChartFactory.getChartTheme().apply(chart);
    chartViewer = new ChartViewer(chart);

    chartViewer.setMaxHeight(500);
    chartViewer.setMaxWidth(800);

    //
    // Add the Day/Night indicator option to the chart panels context menu
    //
    ContextMenu menu = chartViewer.getContextMenu();

    displayMenu = new Menu("Display");

    dayNightItem = new CheckMenuItem("Day/Night Indicators");
    dayNightItem.setSelected(true);
    displayMenu.getItems().add(dayNightItem);
    dayNightItem.setOnAction(this);
    menu.getItems().add(displayMenu);
}

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  w  w w.  j a  va 2s . c  o  m*/
            });
            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:de.hs.mannheim.modUro.controller.diagram.fx.ChartViewer.java

/**
 * Creates the context menu./*w w  w. j a  v a  2  s. com*/
 *
 * @return The context menu.
 */
private ContextMenu createContextMenu() {
    final ContextMenu menu = new ContextMenu();

    Menu export = new Menu("Export As");

    MenuItem pngItem = new MenuItem("PNG ...");
    pngItem.setOnAction((ActionEvent e) -> {
        handleExportToPNG();
    });
    export.getItems().add(pngItem);

    MenuItem jpegItem = new MenuItem("JPEG ...");
    jpegItem.setOnAction((ActionEvent e) -> {
        handleExportToJPEG();
    });
    export.getItems().add(jpegItem);

    MenuItem tikzItem = new MenuItem("Tikz ...");
    tikzItem.setOnAction((ActionEvent e) -> {
        handleExportToTikz();
    });
    export.getItems().add(tikzItem);

    MenuItem wsvItem = new MenuItem("Text  ...");
    wsvItem.setOnAction((ActionEvent e) -> {
        handleExportToWSV();
    });
    export.getItems().add(wsvItem);

    if (ExportUtils.isOrsonPDFAvailable()) {
        MenuItem pdfItem = new MenuItem("PDF ...");
        pdfItem.setOnAction((ActionEvent e) -> {
            handleExportToPDF();
        });
        export.getItems().add(pdfItem);
    }
    if (ExportUtils.isJFreeSVGAvailable()) {
        MenuItem svgItem = new MenuItem("SVG...");
        svgItem.setOnAction((ActionEvent e) -> {
            handleExportToSVG();
        });
        export.getItems().add(svgItem);
    }
    menu.getItems().add(export);
    return menu;
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.EChartViewer.java

/**
 * Adds the GraphicsExportDialog menu and the data export menu
 *//*ww  w  . j ava2s. c o m*/
protected void addExportMenu(boolean graphics, boolean data) {
    if (graphics) {
        // Graphics Export
        addMenuItem(getContextMenu(), "Export graphics...", e -> GraphicsExportDialog.openDialog(getChart()));
    }
    if (data) {
        // General data export
        Menu export = new Menu("Export data ...");
        // Excel XY
        MenuExportToExcel exportXY = new MenuExportToExcel(new XSSFExcelWriterReader(), "to Excel", this);
        export.getItems().add(exportXY);
        // clip board
        MenuExportToClipboard exportXYClipboard = new MenuExportToClipboard("to Clipboard", this);
        export.getItems().add(exportXYClipboard);
        // add to panel
        addMenu(getContextMenu(), export);
    }
}

From source file:com.neuronrobotics.bowlerstudio.MainController.java

private void setToLoggedIn(final String name) {
    // new Exception().printStackTrace();
    FxTimer.runLater(Duration.ofMillis(100), () -> {
        logoutGithub.disableProperty().set(false);
        logoutGithub.setText("Log out " + name);
        new Thread() {
            public void run() {

                GitHub github = ScriptingEngine.getGithub();
                while (github == null) {
                    github = ScriptingEngine.getGithub();
                    ThreadUtil.wait(20);
                }//from   w w  w  . j a v a  2 s.c o m
                try {
                    GHMyself myself = github.getMyself();
                    PagedIterable<GHGist> gists = myself.listGists();
                    Platform.runLater(() -> {
                        myGists.getItems().clear();
                    });
                    ThreadUtil.wait(20);
                    for (GHGist gist : gists) {
                        String desc = gist.getDescription();
                        if (desc == null || desc.length() == 0) {
                            desc = gist.getFiles().keySet().toArray()[0].toString();
                        }
                        Menu tmpGist = new Menu(desc);

                        MenuItem loadWebGist = new MenuItem("Show Web Gist...");
                        loadWebGist.setOnAction(event -> {
                            String webURL = gist.getHtmlUrl();
                            try {
                                BowlerStudio.openUrlInNewTab(new URL(webURL));
                            } catch (MalformedURLException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        });
                        MenuItem addFile = new MenuItem("Add file to Gist...");
                        addFile.setOnAction(event -> {
                            new Thread() {
                                public void run() {

                                }
                            }.start();
                        });
                        Platform.runLater(() -> {
                            tmpGist.getItems().addAll(addFile, loadWebGist);
                        });
                        EventHandler<Event> loadFiles = new EventHandler<Event>() {
                            @Override
                            public void handle(Event ev) {

                                // for(ScriptingEngine.)
                                new Thread() {
                                    public void run() {
                                        System.out.println("Loading files");
                                        ArrayList<String> listofFiles = ScriptingEngine
                                                .filesInGit(gist.getGitPushUrl(), "master", null);
                                        for (String s : listofFiles) {
                                            MenuItem tmp = new MenuItem(s);
                                            tmp.setOnAction(event -> {
                                                new Thread() {
                                                    public void run() {
                                                        try {
                                                            File fileSelected = ScriptingEngine
                                                                    .fileFromGit(gist.getGitPushUrl(), s);
                                                            BowlerStudio.createFileTab(fileSelected);
                                                        } catch (Exception e) {
                                                            // TODO
                                                            // Auto-generated
                                                            // catch block
                                                            e.printStackTrace();
                                                        }
                                                    }
                                                }.start();

                                            });
                                            Platform.runLater(() -> {
                                                tmpGist.getItems().add(tmp);
                                                tmpGist.setOnShowing(null);

                                            });
                                        }
                                        Platform.runLater(() -> {
                                            tmpGist.hide();
                                            Platform.runLater(() -> {
                                                tmpGist.show();
                                            });
                                        });
                                    }
                                }.start();
                            }
                        };

                        tmpGist.setOnShowing(loadFiles);
                        Platform.runLater(() -> {
                            myGists.getItems().add(tmpGist);
                        });

                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }.start();

    });
}

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) {//from   w w w  .j  a  va 2s.com
        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:com.ggvaidya.scinames.dataset.DatasetSceneController.java

private void setupTableWithChanges(TableView<Change> tv, Dataset tp) {
    tv.setEditable(true);// w  ww.j  a v  a  2 s.  c o  m
    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");
}