Example usage for javafx.scene.input KeyCode F5

List of usage examples for javafx.scene.input KeyCode F5

Introduction

In this page you can find the example usage for javafx.scene.input KeyCode F5.

Prototype

KeyCode F5

To view the source code for javafx.scene.input KeyCode F5.

Click Source Link

Document

Constant for the F5 function key.

Usage

From source file:com.heliosdecompiler.helios.gui.controller.MenuBarController.java

@FXML
private void initialize() {
    stage.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
        if (event.isShortcutDown() && event.getCode() == KeyCode.O) {
            onOpen();//  w ww.ja v a  2  s  .c  om
        }
    });
    stage.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
        if (event.isShortcutDown() && event.getCode() == KeyCode.N) {
            onReset();
        }
    });
    stage.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
        if (event.getCode() == KeyCode.F5) {
            getParentController().getFileTreeController().reload();
        }
    });

    try {
        GuiceFXMLLoader.Result result = loader.load(getClass().getResource("/views/pathEditor.fxml"));
        pathEditorController = result.getController();
    } catch (IOException ex) {
        messageHandler.handleException(Message.ERROR_UNKNOWN_ERROR.format(), ex);
    }
    try {
        GuiceFXMLLoader.Result result = loader.load(getClass().getResource("/views/transformerSettings.fxml"));
        transformerSettingsController = result.getController();
    } catch (IOException ex) {
        messageHandler.handleException(Message.ERROR_UNKNOWN_ERROR.format(), ex);
    }

    // for mac (and maybe linux once java supports it)
    // todo refactor into UIController
    root.setUseSystemMenuBar(true);
}

From source file:org.craftercms.social.migration.controllers.MainController.java

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    configTable();//  w  w  w  .ja v  a  2 s .co  m
    mnuQuit.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            stopTasks();
            Platform.exit();
        }
    });
    ctxClearLog.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            logTable.getItems().clear();
        }
    });
    ctxClearProfileSelection.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstProfileScripts.getSelectionModel().clearSelection();
        }
    });
    ctxClearSocialSelection.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstSocialScripts.getSelectionModel().clearSelection();
        }
    });

    lstProfileScripts.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    lstSocialScripts.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    lstProfileScripts.setCellFactory(new Callback<ListView, ListCell>() {
        @Override
        public ListCell call(final ListView listView) {
            return new FileListCell();
        }
    });
    lstSocialScripts.setCellFactory(new Callback<ListView, ListCell>() {
        @Override
        public ListCell call(final ListView listView) {
            return new FileListCell();
        }
    });
    ctxReloadProfileScrp.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstProfileScripts.getItems().clear();
            try {
                extractBuildInScripts("profile", lstProfileScripts);
            } catch (MigrationException e) {
                log.error("Unable to extract BuildIn scripts");
            }
            loadScripts(MigrationTool.systemProperties.getString("crafter.migration.profile.scripts"),
                    lstProfileScripts);
        }
    });
    ctxReloadSocialScrp.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstSocialScripts.getItems().clear();
            try {
                extractBuildInScripts("profile", lstSocialScripts);
            } catch (MigrationException e) {
                log.error("Unable to extract BuildIn scripts");
            }
            loadScripts(MigrationTool.systemProperties.getString("crafter.migration.social.scripts"),
                    lstSocialScripts);
        }
    });
    final MigrationSelectionAction selectionEventHandler = new MigrationSelectionAction();
    rbtMigrateProfile.setOnAction(selectionEventHandler);
    rbtMigrateSocial.setOnAction(selectionEventHandler);
    loadScripts();
    loadDefaultValues();
    saveLog.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
    saveLog.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent event) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Save Migration Log");
            fileChooser.setInitialFileName("Crafter-Migration-"
                    + new SimpleDateFormat("yyyy-MM-dd@HH_mm").format(new Date()) + ".html");
            final File savedFile = fileChooser.showSaveDialog(scene.getWindow());
            if (savedFile == null) {
                return;
            }
            try {
                getHtml(new FileWriter(savedFile));
                log.info("Saved Html log file");
            } catch (IOException | TransformerException ex) {
                log.error("Unable to save file", ex);
            }
        }
    });
    mnuStart.setAccelerator(new KeyCodeCombination(KeyCode.F5));
    mnuStart.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent event) {

            if (currentTask == null || !currentTask.isRunning()) {
                ObservableList scriptsToRun;
                if (rbtMigrateProfile.isSelected()) {
                    scriptsToRun = lstProfileScripts.getSelectionModel().getSelectedItems();
                } else {
                    scriptsToRun = lstSocialScripts.getSelectionModel().getSelectedItems();
                }
                currentTask = new MigrationPipeService(logTable, pgbTaskProgress, srcHost.getText(),
                        srcPort.getText(), srcDb.getText(), dstHost.getText(), dstPort.getText(),
                        dstDb.getText(), scriptsToRun);
            }
            if (!currentTask.isRunning()) {
                final Thread t = new Thread(currentTask, "Migration Task");
                t.start();
            }
        }
    });
}