Example usage for javafx.scene.input KeyCombination SHORTCUT_DOWN

List of usage examples for javafx.scene.input KeyCombination SHORTCUT_DOWN

Introduction

In this page you can find the example usage for javafx.scene.input KeyCombination SHORTCUT_DOWN.

Prototype

Modifier SHORTCUT_DOWN

To view the source code for javafx.scene.input KeyCombination SHORTCUT_DOWN.

Click Source Link

Document

Modifier which specifies that the shortcut key must be down.

Usage

From source file:org.pdfsam.App.java

@Override
public void start(Stage primaryStage) {
    STOPWATCH.start();/* w w  w . j a  va2s  .  c  o  m*/
    LOG.info(DefaultI18nContext.getInstance().i18n("Starting pdfsam"));
    List<String> styles = (List<String>) ApplicationContextHolder.getContext().getBean("styles");
    Map<String, Image> logos = ApplicationContextHolder.getContext().getBeansOfType(Image.class);
    MainPane mainPane = ApplicationContextHolder.getContext().getBean(MainPane.class);

    NotificationsContainer notifications = ApplicationContextHolder.getContext()
            .getBean(NotificationsContainer.class);
    StackPane main = new StackPane();
    StackPane.setAlignment(notifications, Pos.BOTTOM_RIGHT);
    StackPane.setAlignment(mainPane, Pos.TOP_LEFT);
    main.getChildren().addAll(mainPane, notifications);

    Scene scene = new Scene(main);
    scene.getStylesheets().addAll(styles);
    primaryStage.setScene(scene);
    primaryStage.getIcons().addAll(logos.values());
    primaryStage.setTitle(ApplicationContextHolder.getContext().getBean("appName", String.class));
    scene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN),
            () -> eventStudio().broadcast(new ShowStageRequest(), "LogStage"));
    primaryStage.show();
    eventStudio().add(new TitleController(primaryStage));
    requestCheckForUpdateIfNecessary();
    eventStudio().addAnnotatedListeners(this);
    STOPWATCH.stop();
    LOG.info(DefaultI18nContext.getInstance().i18n("Started in {0}",
            DurationFormatUtils.formatDurationWords(STOPWATCH.getTime(), true, true)));
}

From source file:io.bitsquare.app.gui.BitsquareApp.java

@Override
public void start(Stage primaryStage) throws IOException {
    bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
    injector = Guice.createInjector(bitsquareAppModule);
    injector.getInstance(GuiceControllerFactory.class).setInjector(injector);

    // route uncaught exceptions to a user-facing dialog

    Thread.currentThread().setUncaughtExceptionHandler(
            (thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));

    // initialize the application data directory (if necessary)

    initAppDir(env.getRequiredProperty(APP_DATA_DIR_KEY));

    // load and apply any stored settings

    User user = injector.getInstance(User.class);
    AccountSettings accountSettings = injector.getInstance(AccountSettings.class);
    Persistence persistence = injector.getInstance(Persistence.class);
    persistence.init();/*  ww  w. java  2  s  . c o  m*/

    User persistedUser = (User) persistence.read(user);
    user.applyPersistedUser(persistedUser);

    accountSettings.applyPersistedAccountSettings(
            (AccountSettings) persistence.read(accountSettings.getClass().getName()));

    // load the main view and create the main scene

    ViewLoader viewLoader = injector.getInstance(ViewLoader.class);
    ViewLoader.Item loaded = viewLoader.load(Navigation.Item.MAIN.getFxmlUrl(), false);

    Scene scene = new Scene((Parent) loaded.view, 1000, 600);
    scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css");

    // configure the system tray

    SystemTray systemTray = new SystemTray(primaryStage, this::stop);
    primaryStage.setOnCloseRequest(e -> stop());
    scene.setOnKeyReleased(keyEvent -> {
        // For now we exit when closing/quit the app.
        // Later we will only hide the window (systemTray.hideStage()) and use the exit item in the system tray for
        // shut down.
        if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                || new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent))
            stop();
    });

    // configure the primary stage

    primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY));
    primaryStage.setScene(scene);
    primaryStage.setMinWidth(75);
    primaryStage.setMinHeight(50);

    // on windows the title icon is also used as task bar icon in a larger size
    // on Linux no title icon is supported but also a large task bar icon is derived form that title icon
    String iconPath;
    if (Utilities.isOSX())
        iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png";
    else if (Utilities.isWindows())
        iconPath = "/images/task_bar_icon_windows.png";
    else
        iconPath = "/images/task_bar_icon_linux.png";

    if (iconPath != null)
        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));

    // make the UI visible

    primaryStage.show();
}

From source file:org.pdfsam.PdfsamApp.java

private void initScene() {
    MainPane mainPane = ApplicationContextHolder.getContext().getBean(MainPane.class);

    NotificationsContainer notifications = ApplicationContextHolder.getContext()
            .getBean(NotificationsContainer.class);
    StackPane main = new StackPane();
    StackPane.setAlignment(notifications, Pos.BOTTOM_RIGHT);
    StackPane.setAlignment(mainPane, Pos.TOP_LEFT);
    main.getChildren().addAll(mainPane, notifications);

    StylesConfig styles = ApplicationContextHolder.getContext().getBean(StylesConfig.class);

    mainScene = new Scene(main);
    mainScene.getStylesheets().addAll(styles.styles());
    mainScene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN),
            () -> eventStudio().broadcast(new ShowStageRequest(), "LogStage"));
}

From source file:se.trixon.filebydate.ui.MainApp.java

private void initAccelerators() {
    final ObservableMap<KeyCombination, Runnable> accelerators = mStage.getScene().getAccelerators();

    accelerators.put(new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
        mStage.fireEvent(new WindowEvent(mStage, WindowEvent.WINDOW_CLOSE_REQUEST));
    });// w w w.j  av  a  2s.c  o  m

    accelerators.put(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
        profileEdit(null);
    });

    if (!IS_MAC) {
        accelerators.put(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
            displayOptions();
        });
    }
}

From source file:io.bitsquare.app.BitsquareApp.java

@Override
public void start(Stage stage) throws IOException {
    BitsquareApp.primaryStage = stage;/*  w  ww.j av  a2  s .  c o m*/

    String logPath = Paths.get(env.getProperty(AppOptionKeys.APP_DATA_DIR_KEY), "bitsquare").toString();
    Log.setup(logPath);
    log.info("Log files under: " + logPath);
    Version.printVersion();
    Utilities.printSysInfo();
    Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));

    UserThread.setExecutor(Platform::runLater);
    UserThread.setTimerClass(UITimer.class);

    shutDownHandler = this::stop;

    // setup UncaughtExceptionHandler
    Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
        // Might come from another thread 
        if (throwable.getCause() != null && throwable.getCause().getCause() != null
                && throwable.getCause().getCause() instanceof BlockStoreException) {
            log.error(throwable.getMessage());
        } else if (throwable instanceof ClassCastException
                && "sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData"
                        .equals(throwable.getMessage())) {
            log.warn(throwable.getMessage());
        } else {
            log.error("Uncaught Exception from thread " + Thread.currentThread().getName());
            log.error("throwableMessage= " + throwable.getMessage());
            log.error("throwableClass= " + throwable.getClass());
            log.error("Stack trace:\n" + ExceptionUtils.getStackTrace(throwable));
            throwable.printStackTrace();
            UserThread.execute(() -> showErrorPopup(throwable, false));
        }
    };
    Thread.setDefaultUncaughtExceptionHandler(handler);
    Thread.currentThread().setUncaughtExceptionHandler(handler);

    try {
        Utilities.checkCryptoPolicySetup();
    } catch (NoSuchAlgorithmException | LimitedKeyStrengthException e) {
        e.printStackTrace();
        UserThread.execute(() -> showErrorPopup(e, true));
    }

    Security.addProvider(new BouncyCastleProvider());

    try {
        // Guice
        bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
        injector = Guice.createInjector(bitsquareAppModule);
        injector.getInstance(InjectorViewFactory.class).setInjector(injector);

        Version.setBtcNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal());

        if (Utilities.isLinux())
            System.setProperty("prism.lcdtext", "false");

        Storage.setDatabaseCorruptionHandler((String fileName) -> {
            corruptedDatabaseFiles.add(fileName);
            if (mainView != null)
                mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
        });

        // load the main view and create the main scene
        CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
        mainView = (MainView) viewLoader.load(MainView.class);
        mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);

        /* Storage.setDatabaseCorruptionHandler((String fileName) -> {
        corruptedDatabaseFiles.add(fileName);
        if (mainView != null)
            mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
         });*/

        scene = new Scene(mainView.getRoot(), 1200, 700); //740

        Font.loadFont(getClass().getResource("/fonts/Verdana.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaBold.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaItalic.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaBoldItalic.ttf").toExternalForm(), 13);
        scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css",
                "/io/bitsquare/gui/CandleStickChart.css");

        // configure the system tray
        SystemTray.create(primaryStage, shutDownHandler);

        primaryStage.setOnCloseRequest(event -> {
            event.consume();
            stop();
        });
        scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> {
            if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                    || new KeyCodeCombination(KeyCode.W, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                stop();
            } else if (new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                    || new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                stop();
            } else if (new KeyCodeCombination(KeyCode.E, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                    || new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                showEmptyWalletPopup();
            } else if (new KeyCodeCombination(KeyCode.M, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showSendAlertMessagePopup();
            } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showFilterPopup();
            } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showFPSWindow();
            } else if (new KeyCodeCombination(KeyCode.J, KeyCombination.ALT_DOWN).match(keyEvent)) {
                WalletService walletService = injector.getInstance(WalletService.class);
                if (walletService.getWallet() != null)
                    new ShowWalletDataWindow(walletService).information("Wallet raw data").show();
                else
                    new Popup<>().warning("The wallet is not initialized yet").show();
            } else if (new KeyCodeCombination(KeyCode.G, KeyCombination.ALT_DOWN).match(keyEvent)) {
                TradeWalletService tradeWalletService = injector.getInstance(TradeWalletService.class);
                WalletService walletService = injector.getInstance(WalletService.class);
                if (walletService.getWallet() != null)
                    new SpendFromDepositTxWindow(tradeWalletService).information("Emergency wallet tool")
                            .show();
                else
                    new Popup<>().warning("The wallet is not initialized yet").show();
            } else if (DevFlags.DEV_MODE
                    && new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) {
                showDebugWindow();
            }
        });

        // configure the primary stage
        primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY));
        primaryStage.setScene(scene);
        primaryStage.setMinWidth(1000); // 1190
        primaryStage.setMinHeight(620);

        // on windows the title icon is also used as task bar icon in a larger size
        // on Linux no title icon is supported but also a large task bar icon is derived from that title icon
        String iconPath;
        if (Utilities.isOSX())
            iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png";
        else if (Utilities.isWindows())
            iconPath = "/images/task_bar_icon_windows.png";
        else
            iconPath = "/images/task_bar_icon_linux.png";

        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));

        // make the UI visible
        primaryStage.show();

        if (!Utilities.isCorrectOSArchitecture()) {
            String osArchitecture = Utilities.getOSArchitecture();
            // We don't force a shutdown as the osArchitecture might in strange cases return a wrong value.
            // Needs at least more testing on different machines...
            new Popup<>()
                    .warning("You probably have the wrong Bitsquare version for this computer.\n"
                            + "Your computer's architecture is: " + osArchitecture + ".\n"
                            + "The Bitsquare binary you installed is: " + Utilities.getJVMArchitecture() + ".\n"
                            + "Please shut down and re-install the correct version (" + osArchitecture + ").")
                    .show();
        }

        UserThread.runPeriodically(() -> Profiler.printSystemLoad(log), LOG_MEMORY_PERIOD_MIN,
                TimeUnit.MINUTES);

    } catch (Throwable throwable)

    {
        showErrorPopup(throwable, false);
    }

}

From source file:se.trixon.filebydate.ui.MainApp.java

private void initActions() {
    //add//from   www.  ja v a 2 s  . c  o  m
    mAddAction = new Action(Dict.ADD.toString(), (ActionEvent event) -> {
        profileEdit(null);
    });
    mAddAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.PLUS).size(ICON_SIZE_TOOLBAR).color(mIconColor));

    //cancel
    mCancelAction = new Action(Dict.CANCEL.toString(), (ActionEvent event) -> {
        mOperationThread.interrupt();
    });
    mCancelAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.BAN).size(ICON_SIZE_TOOLBAR).color(mIconColor));

    //home
    mHomeAction = new Action(Dict.LIST.toString(), (ActionEvent event) -> {
        mLogAction.setDisabled(false);
        setRunningState(RunState.STARTABLE);
        mRoot.setCenter(mListView);
    });
    mHomeAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.LIST).size(ICON_SIZE_TOOLBAR).color(mIconColor));

    //log
    mLogAction = new Action(Dict.OUTPUT.toString(), (ActionEvent event) -> {
        setRunningState(RunState.CLOSEABLE);
        mRoot.setCenter(mProgressPanel);
    });
    mLogAction.setGraphic(
            mFontAwesome.create(FontAwesome.Glyph.ALIGN_LEFT).size(ICON_SIZE_TOOLBAR).color(mIconColor));
    mLogAction.setDisabled(true);

    //options
    mOptionsAction = new Action(Dict.OPTIONS.toString(), (ActionEvent event) -> {
        displayOptions();
    });
    mOptionsAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.COG).size(ICON_SIZE_TOOLBAR).color(mIconColor));
    if (!IS_MAC) {
        mOptionsAction.setAccelerator(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN));
    }

    //help
    mHelpAction = new Action(Dict.HELP.toString(), (ActionEvent event) -> {
        SystemHelper.desktopBrowse("https://trixon.se/projects/filebydate/documentation/");
    });
    mHelpAction.setAccelerator(KeyCombination.keyCombination("F1"));

    //about
    PomInfo pomInfo = new PomInfo(FileByDate.class, "se.trixon", "filebydate");
    AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(FileByDate.class, "about"),
            SystemHelper.getResourceAsImageView(MainApp.class, "calendar-icon-1024px.png"));
    aboutModel.setAppVersion(pomInfo.getVersion());
    mAboutAction = AboutPane.getAction(mStage, aboutModel);

    //about date format
    String title = String.format(Dict.ABOUT_S.toString(), Dict.DATE_PATTERN.toString().toLowerCase());
    mAboutDateFormatAction = new Action(title, (ActionEvent event) -> {
        SystemHelper.desktopBrowse("https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html");
    });

    mRunAction = new Action(Dict.RUN.toString(), (ActionEvent event) -> {
        profileRun(mLastRunProfile);
    });
    mRunAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.PLAY).size(ICON_SIZE_TOOLBAR).color(mIconColor));
}

From source file:se.trixon.mapollage.ui.MainApp.java

private void initActions() {
    //add//from  w w  w .j  a va 2  s .c om
    mAddAction = new Action(Dict.ADD.toString(), (ActionEvent event) -> {
        profileEdit(null);
    });
    mAddAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.PLUS).size(ICON_SIZE_TOOLBAR).color(mIconColor));

    //cancel
    mCancelAction = new Action(Dict.CANCEL.toString(), (ActionEvent event) -> {
        mOperationThread.interrupt();
    });
    mCancelAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.BAN).size(ICON_SIZE_TOOLBAR).color(mIconColor));

    //home
    mHomeAction = new Action(Dict.LIST.toString(), (ActionEvent event) -> {
        mLogAction.setDisabled(false);
        setRunningState(RunState.STARTABLE);
        mRoot.setCenter(mListView);
    });
    mHomeAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.LIST).size(ICON_SIZE_TOOLBAR).color(mIconColor));

    //log
    mLogAction = new Action(Dict.OUTPUT.toString(), (ActionEvent event) -> {
        setRunningState(RunState.CLOSEABLE);
        mRoot.setCenter(mProgressPanel);
    });
    mLogAction.setGraphic(
            mFontAwesome.create(FontAwesome.Glyph.ALIGN_LEFT).size(ICON_SIZE_TOOLBAR).color(mIconColor));
    mLogAction.setDisabled(true);

    //options
    mOptionsAction = new Action(Dict.OPTIONS.toString(), (ActionEvent event) -> {
        displayOptions();
    });
    mOptionsAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.COG).size(ICON_SIZE_TOOLBAR).color(mIconColor));
    if (!IS_MAC) {
        mOptionsAction.setAccelerator(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN));
    }

    //help
    mHelpAction = new Action(Dict.HELP.toString(), (ActionEvent event) -> {
        SystemHelper.desktopBrowse("https://trixon.se/projects/mapollage/documentation/");
    });
    mHelpAction.setAccelerator(KeyCombination.keyCombination("F1"));

    //about
    PomInfo pomInfo = new PomInfo(Mapollage.class, "se.trixon", "mapollage");
    AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(Mapollage.class, "about"),
            SystemHelper.getResourceAsImageView(MainApp.class, "icon-1024px.png"));
    aboutModel.setAppVersion(pomInfo.getVersion());
    mAboutAction = AboutPane.getAction(mStage, aboutModel);

    //about date format
    String title = String.format(Dict.ABOUT_S.toString(), Dict.DATE_PATTERN.toString().toLowerCase());
    mAboutDateFormatAction = new Action(title, (ActionEvent event) -> {
        SystemHelper.desktopBrowse("https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html");
    });

    mRunAction = new Action(Dict.RUN.toString(), (ActionEvent event) -> {
        profileRun(mLastRunProfile);
    });
    mRunAction
            .setGraphic(mFontAwesome.create(FontAwesome.Glyph.PLAY).size(ICON_SIZE_TOOLBAR).color(mIconColor));
}

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  va2 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:qupath.lib.gui.tma.TMASummaryViewer.java

private void initialize() {

    model = new TMATableModel();

    groupByIDProperty.addListener((v, o, n) -> refreshTableData());

    MenuBar menuBar = new MenuBar();
    Menu menuFile = new Menu("File");
    MenuItem miOpen = new MenuItem("Open...");
    miOpen.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN));
    miOpen.setOnAction(e -> {/*w ww  .  java  2 s  .co  m*/
        File file = QuPathGUI.getDialogHelper(stage).promptForFile(null, null, "TMA data files",
                new String[] { "qptma" });
        if (file == null)
            return;
        setInputFile(file);
    });

    MenuItem miSave = new MenuItem("Save As...");
    miSave.setAccelerator(
            new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
    miSave.setOnAction(
            e -> SummaryMeasurementTableCommand.saveTableModel(model, null, Collections.emptyList()));

    MenuItem miImportFromImage = new MenuItem("Import from current image...");
    miImportFromImage.setAccelerator(
            new KeyCodeCombination(KeyCode.I, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
    miImportFromImage.setOnAction(e -> setTMAEntriesFromOpenImage());

    MenuItem miImportFromProject = new MenuItem("Import from current project... (experimental)");
    miImportFromProject.setAccelerator(
            new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
    miImportFromProject.setOnAction(e -> setTMAEntriesFromOpenProject());

    MenuItem miImportClipboard = new MenuItem("Import from clipboard...");
    miImportClipboard.setOnAction(e -> {
        String text = Clipboard.getSystemClipboard().getString();
        if (text == null) {
            DisplayHelpers.showErrorMessage("Import scores", "Clipboard is empty!");
            return;
        }
        int n = importScores(text);
        if (n > 0) {
            setTMAEntries(new ArrayList<>(entriesBase));
        }
        DisplayHelpers.showMessageDialog("Import scores", "Number of scores imported: " + n);
    });

    Menu menuEdit = new Menu("Edit");
    MenuItem miCopy = new MenuItem("Copy table to clipboard");
    miCopy.setOnAction(e -> {
        SummaryMeasurementTableCommand.copyTableContentsToClipboard(model, Collections.emptyList());
    });

    combinedPredicate.addListener((v, o, n) -> {
        // We want any other changes triggered by this to have happened, 
        // so that the data has already been updated
        Platform.runLater(() -> handleTableContentChange());
    });

    // Reset the scores for missing cores - this ensures they will be NaN and not influence subsequent results
    MenuItem miResetMissingScores = new MenuItem("Reset scores for missing cores");
    miResetMissingScores.setOnAction(e -> {
        int changes = 0;
        for (TMAEntry entry : entriesBase) {
            if (!entry.isMissing())
                continue;
            boolean changed = false;
            for (String m : entry.getMeasurementNames().toArray(new String[0])) {
                if (!TMASummaryEntry.isSurvivalColumn(m) && !Double.isNaN(entry.getMeasurementAsDouble(m))) {
                    entry.putMeasurement(m, null);
                    changed = true;
                }
            }
            if (changed)
                changes++;
        }
        if (changes == 0) {
            logger.info("No changes made when resetting scores for missing cores!");
            return;
        }
        logger.info("{} change(s) made when resetting scores for missing cores!", changes);
        table.refresh();
        updateSurvivalCurves();
        if (scatterPane != null)
            scatterPane.updateChart();
        if (histogramDisplay != null)
            histogramDisplay.refreshHistogram();
    });
    menuEdit.getItems().add(miResetMissingScores);

    QuPathGUI.addMenuItems(menuFile, miOpen, miSave, null, miImportClipboard, null, miImportFromImage,
            miImportFromProject);
    menuBar.getMenus().add(menuFile);
    menuEdit.getItems().add(miCopy);
    menuBar.getMenus().add(menuEdit);

    menuFile.setOnShowing(e -> {
        boolean imageDataAvailable = QuPathGUI.getInstance() != null
                && QuPathGUI.getInstance().getImageData() != null
                && QuPathGUI.getInstance().getImageData().getHierarchy().getTMAGrid() != null;
        miImportFromImage.setDisable(!imageDataAvailable);
        boolean projectAvailable = QuPathGUI.getInstance() != null
                && QuPathGUI.getInstance().getProject() != null
                && !QuPathGUI.getInstance().getProject().getImageList().isEmpty();
        miImportFromProject.setDisable(!projectAvailable);
    });

    // Double-clicking previously used for comments... but conflicts with tree table expansion
    //      table.setOnMouseClicked(e -> {
    //         if (!e.isPopupTrigger() && e.getClickCount() > 1)
    //            promptForComment();
    //      });

    table.setPlaceholder(new Text("Drag TMA data folder onto window, or choose File -> Open"));
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    BorderPane pane = new BorderPane();
    pane.setTop(menuBar);
    menuBar.setUseSystemMenuBar(true);

    // Create options
    ToolBar toolbar = new ToolBar();
    Label labelMeasurementMethod = new Label("Combination method");
    labelMeasurementMethod.setLabelFor(comboMeasurementMethod);
    labelMeasurementMethod
            .setTooltip(new Tooltip("Method whereby measurements for multiple cores with the same "
                    + TMACoreObject.KEY_UNIQUE_ID + " will be combined"));

    CheckBox cbHidePane = new CheckBox("Hide pane");
    cbHidePane.setSelected(hidePaneProperty.get());
    cbHidePane.selectedProperty().bindBidirectional(hidePaneProperty);

    CheckBox cbGroupByID = new CheckBox("Group by ID");
    entriesBase.addListener((Change<? extends TMAEntry> event) -> {
        if (!event.getList().stream().anyMatch(e -> e.getMetadataValue(TMACoreObject.KEY_UNIQUE_ID) != null)) {
            cbGroupByID.setSelected(false);
            cbGroupByID.setDisable(true);
        } else {
            cbGroupByID.setDisable(false);
        }
    });
    cbGroupByID.setSelected(groupByIDProperty.get());
    cbGroupByID.selectedProperty().bindBidirectional(groupByIDProperty);

    CheckBox cbUseSelected = new CheckBox("Use selection only");
    cbUseSelected.selectedProperty().bindBidirectional(useSelectedProperty);

    CheckBox cbSkipMissing = new CheckBox("Hide missing cores");
    cbSkipMissing.selectedProperty().bindBidirectional(skipMissingCoresProperty);
    skipMissingCoresProperty.addListener((v, o, n) -> {
        table.refresh();
        updateSurvivalCurves();
        if (histogramDisplay != null)
            histogramDisplay.refreshHistogram();
        updateSurvivalCurves();
        if (scatterPane != null)
            scatterPane.updateChart();
    });

    toolbar.getItems().addAll(labelMeasurementMethod, comboMeasurementMethod,
            new Separator(Orientation.VERTICAL), cbHidePane, new Separator(Orientation.VERTICAL), cbGroupByID,
            new Separator(Orientation.VERTICAL), cbUseSelected, new Separator(Orientation.VERTICAL),
            cbSkipMissing);
    comboMeasurementMethod.getItems().addAll(MeasurementCombinationMethod.values());
    comboMeasurementMethod.getSelectionModel().select(MeasurementCombinationMethod.MEDIAN);
    selectedMeasurementCombinationProperty.addListener((v, o, n) -> table.refresh());

    ContextMenu popup = new ContextMenu();
    MenuItem miSetMissing = new MenuItem("Set missing");
    miSetMissing.setOnAction(e -> setSelectedMissingStatus(true));

    MenuItem miSetAvailable = new MenuItem("Set available");
    miSetAvailable.setOnAction(e -> setSelectedMissingStatus(false));

    MenuItem miExpand = new MenuItem("Expand all");
    miExpand.setOnAction(e -> {
        if (table.getRoot() == null)
            return;
        for (TreeItem<?> item : table.getRoot().getChildren()) {
            item.setExpanded(true);
        }
    });
    MenuItem miCollapse = new MenuItem("Collapse all");
    miCollapse.setOnAction(e -> {
        if (table.getRoot() == null)
            return;
        for (TreeItem<?> item : table.getRoot().getChildren()) {
            item.setExpanded(false);
        }
    });
    popup.getItems().addAll(miSetMissing, miSetAvailable, new SeparatorMenuItem(), miExpand, miCollapse);
    table.setContextMenu(popup);

    table.setRowFactory(e -> {
        TreeTableRow<TMAEntry> row = new TreeTableRow<>();

        //         // Make rows invisible if they don't pass the predicate
        //         row.visibleProperty().bind(Bindings.createBooleanBinding(() -> {
        //               TMAEntry entry = row.getItem();
        //               if (entry == null || (entry.isMissing() && skipMissingCoresProperty.get()))
        //                     return false;
        //               return entries.getPredicate() == null || entries.getPredicate().test(entry);
        //               },
        //               skipMissingCoresProperty,
        //               entries.predicateProperty()));

        // Style rows according to what they contain
        row.styleProperty().bind(Bindings.createStringBinding(() -> {
            if (row.isSelected())
                return "";
            TMAEntry entry = row.getItem();
            if (entry == null || entry instanceof TMASummaryEntry)
                return "";
            else if (entry.isMissing())
                return "-fx-background-color:rgb(225,225,232)";
            else
                return "-fx-background-color:rgb(240,240,245)";
        }, row.itemProperty(), row.selectedProperty()));
        //         row.itemProperty().addListener((v, o, n) -> {
        //            if (n == null || n instanceof TMASummaryEntry || row.isSelected())
        //               row.setStyle("");
        //            else if (n.isMissing())
        //               row.setStyle("-fx-background-color:rgb(225,225,232)");            
        //            else
        //               row.setStyle("-fx-background-color:rgb(240,240,245)");            
        //         });
        return row;
    });

    BorderPane paneTable = new BorderPane();
    paneTable.setTop(toolbar);
    paneTable.setCenter(table);

    MasterDetailPane mdTablePane = new MasterDetailPane(Side.RIGHT, paneTable, createSidePane(), true);

    mdTablePane.showDetailNodeProperty().bind(Bindings.createBooleanBinding(
            () -> !hidePaneProperty.get() && !entriesBase.isEmpty(), hidePaneProperty, entriesBase));
    mdTablePane.setDividerPosition(2.0 / 3.0);

    pane.setCenter(mdTablePane);

    model.getEntries().addListener(new ListChangeListener<TMAEntry>() {
        @Override
        public void onChanged(ListChangeListener.Change<? extends TMAEntry> c) {
            if (histogramDisplay != null)
                histogramDisplay.refreshHistogram();
            updateSurvivalCurves();
            if (scatterPane != null)
                scatterPane.updateChart();
        }
    });

    Label labelPredicate = new Label();
    labelPredicate.setPadding(new Insets(5, 5, 5, 5));
    labelPredicate.setAlignment(Pos.CENTER);
    //      labelPredicate.setStyle("-fx-background-color: rgba(20, 120, 20, 0.15);");
    labelPredicate.setStyle("-fx-background-color: rgba(120, 20, 20, 0.15);");

    labelPredicate.textProperty().addListener((v, o, n) -> {
        if (n.trim().length() > 0)
            pane.setBottom(labelPredicate);
        else
            pane.setBottom(null);
    });
    labelPredicate.setMaxWidth(Double.MAX_VALUE);
    labelPredicate.setMaxHeight(labelPredicate.getPrefHeight());
    labelPredicate.setTextAlignment(TextAlignment.CENTER);
    predicateMeasurements.addListener((v, o, n) -> {
        if (n == null)
            labelPredicate.setText("");
        else if (n instanceof TablePredicate) {
            TablePredicate tp = (TablePredicate) n;
            if (tp.getOriginalCommand().trim().isEmpty())
                labelPredicate.setText("");
            else
                labelPredicate.setText("Predicate: " + tp.getOriginalCommand());
        } else
            labelPredicate.setText("Predicate: " + n.toString());
    });
    //      predicate.set(new TablePredicate("\"Tumor\" > 100"));

    scene = new Scene(pane);

    scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
        KeyCode code = e.getCode();
        if ((code == KeyCode.SPACE || code == KeyCode.ENTER) && entrySelected != null) {
            promptForComment();
            return;
        }
    });

}

From source file:se.trixon.filebydate.ui.MainApp.java

private void initMac() {
    MenuToolkit menuToolkit = MenuToolkit.toolkit();
    Menu applicationMenu = menuToolkit.createDefaultApplicationMenu(APP_TITLE);
    menuToolkit.setApplicationMenu(applicationMenu);

    applicationMenu.getItems().remove(0);
    MenuItem aboutMenuItem = new MenuItem(String.format(Dict.ABOUT_S.toString(), APP_TITLE));
    aboutMenuItem.setOnAction(mAboutAction);

    MenuItem settingsMenuItem = new MenuItem(Dict.PREFERENCES.toString());
    settingsMenuItem.setOnAction(mOptionsAction);
    settingsMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN));

    applicationMenu.getItems().add(0, aboutMenuItem);
    applicationMenu.getItems().add(2, settingsMenuItem);

    int cnt = applicationMenu.getItems().size();
    applicationMenu.getItems().get(cnt - 1).setText(String.format("%s %s", Dict.QUIT.toString(), APP_TITLE));
}