Example usage for javafx.scene.input KeyCombination KeyCombination

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

Introduction

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

Prototype

protected KeyCombination(final Modifier... modifiers) 

Source Link

Document

Constructs a KeyCombination with the specified list of modifiers.

Usage

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);// w  ww.  j  av  a 2s  .c o  m
    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.bekwam.resignator.ResignatorAppMainViewController.java

@FXML
public void initialize() {

    try {//from  w w  w .j  av a2  s  . c om

        miHelp.setAccelerator(KeyCombination.keyCombination("F1"));

        cbType.getItems().add(SigningArgumentsType.JAR);
        cbType.getItems().add(SigningArgumentsType.FOLDER);

        cbType.getSelectionModel().select(SigningArgumentsType.JAR);

        cbType.setConverter(new StringConverter<SigningArgumentsType>() {

            @Override
            public String toString(SigningArgumentsType type) {
                return StringUtils.capitalize(StringUtils.lowerCase(String.valueOf(type)));
            }

            @Override
            public SigningArgumentsType fromString(String type) {
                return Enum.valueOf(SigningArgumentsType.class, StringUtils.upperCase(type));
            }

        });

        activeConfiguration.activeProfileProperty().bindBidirectional(activeProfile.profileNameProperty());
        tfSourceFile.textProperty().bindBidirectional(activeProfile.sourceFileFileNameProperty());
        tfTargetFile.textProperty().bindBidirectional(activeProfile.targetFileFileNameProperty());
        ckReplace.selectedProperty().bindBidirectional(activeProfile.replaceSignaturesProperty());
        cbType.valueProperty().bindBidirectional(activeProfile.argsTypeProperty());

        miSave.disableProperty().bind(needsSave.not());

        tfSourceFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener));
        tfTargetFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener));
        ckReplace.selectedProperty().addListener(new WeakInvalidationListener(needsSaveListener));
        cbType.valueProperty().addListener(new WeakInvalidationListener(needsSaveListener));

        lblSource.setText(SOURCE_LABEL_JAR);
        lblTarget.setText(TARGET_LABEL_JAR);
        cbType.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> {
            if (new_v == SigningArgumentsType.FOLDER) {
                if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_FOLDER)) {
                    lblSource.setText(SOURCE_LABEL_FOLDER);
                }
                if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_FOLDER)) {
                    lblTarget.setText(TARGET_LABEL_FOLDER);
                }
            } else {
                if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_JAR)) {
                    lblSource.setText(SOURCE_LABEL_JAR);
                }
                if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_JAR)) {
                    lblTarget.setText(TARGET_LABEL_JAR);
                }
            }
        });

        lvProfiles.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> {

            if (new_v == null) { // coming from clearSelection or sort
                return;
            }

            if (needsSave.getValue()) {

                Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Discard unsaved profile?");
                alert.setHeaderText("Unsaved profile");
                Optional<ButtonType> response = alert.showAndWait();
                if (!response.isPresent() || response.get() != ButtonType.OK) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("[SELECT] discard canceled");
                    }
                    return;
                }
            }

            if (logger.isDebugEnabled()) {
                logger.debug("[SELECT] nv={}", new_v);
            }
            doLoadProfile(new_v);
        });

        lvProfiles.setCellFactory(TextFieldListCell.forListView());

        Task<Void> t = new Task<Void>() {

            @Override
            protected Void call() throws Exception {

                updateMessage("Loading configuration");
                configurationDS.loadConfiguration();

                if (!configurationDS.isSecured()) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("[CALL] config not secured; getting password");
                    }
                    NewPasswordController npc = newPasswordControllerProvider.get();

                    if (logger.isDebugEnabled()) {
                        logger.debug("[INIT TASK] npc id={}", npc.hashCode());
                    }

                    Platform.runLater(() -> {
                        try {
                            npc.showAndWait();
                        } catch (Exception exc) {
                            logger.error("error showing npc", exc);
                        }
                    });

                    synchronized (npc) {
                        try {
                            npc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password
                        } catch (InterruptedException exc) {
                            logger.error("new password operation interrupted", exc);
                        }
                    }

                    if (logger.isDebugEnabled()) {
                        logger.debug("[INIT TASK] npc={}", npc.getHashedPassword());
                    }

                    if (StringUtils.isNotEmpty(npc.getHashedPassword())) {

                        activeConfiguration.setHashedPassword(npc.getHashedPassword());
                        activeConfiguration.setUnhashedPassword(npc.getUnhashedPassword());
                        activeConfiguration.setLastUpdatedDateTime(LocalDateTime.now());
                        configurationDS.saveConfiguration();

                        configurationDS.loadConfiguration();
                        configurationDS.decrypt(activeConfiguration.getUnhashedPassword());

                    } else {

                        Platform.runLater(() -> {
                            Alert noPassword = new Alert(Alert.AlertType.INFORMATION,
                                    "You'll need to provide a password to save your keystore credentials.");
                            noPassword.showAndWait();
                        });

                        return null;
                    }
                } else {

                    PasswordController pc = passwordControllerProvider.get();

                    Platform.runLater(() -> {
                        try {
                            pc.showAndWait();
                        } catch (Exception exc) {
                            logger.error("error showing pc", exc);
                        }
                    });

                    synchronized (pc) {
                        try {
                            pc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password
                        } catch (InterruptedException exc) {
                            logger.error("password operation interrupted", exc);
                        }
                    }

                    Platform.runLater(() -> {

                        if (pc.getStage().isShowing()) { // ended in timeout timeout
                            pc.getStage().hide();
                        }

                        if (pc.wasCancelled() || pc.wasReset() || !pc.doesPasswordMatch()) {

                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] was cancelled or the number of retries was exceeded");
                            }

                            String msg = "";
                            if (pc.wasCancelled()) {
                                msg = "You must provide a password to the datastore. Exitting...";
                            } else if (pc.wasReset()) {
                                msg = "Data file removed. Exitting...";
                            } else {
                                msg = "Exceeded maximum number of retries. Exitting...";
                            }

                            Alert alert = new Alert(Alert.AlertType.WARNING, msg);
                            alert.setOnCloseRequest((evt) -> {
                                Platform.exit();
                                System.exit(1);
                            });
                            alert.showAndWait();

                        } else {

                            //
                            // save password for later decryption ops
                            //

                            activeConfiguration.setUnhashedPassword(pc.getPassword());
                            configurationDS.decrypt(activeConfiguration.getUnhashedPassword());

                            //
                            // init profileBrowser
                            //
                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] loading profiles from source");
                            }

                            long startTimeMillis = System.currentTimeMillis();

                            final List<String> profileNames = configurationDS.getProfiles().stream()
                                    .map(Profile::getProfileName).sorted((o1, o2) -> o1.compareToIgnoreCase(o2))
                                    .collect(Collectors.toList());

                            final List<String> recentProfiles = configurationDS.getRecentProfileNames();

                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] loading profiles into UI");
                            }

                            lvProfiles.setItems(FXCollections.observableArrayList(profileNames));

                            if (CollectionUtils.isNotEmpty(recentProfiles)) {
                                mRecentProfiles.getItems().clear();
                                mRecentProfiles.getItems().addAll(
                                        FXCollections.observableArrayList(recentProfiles.stream().map((s) -> {
                                            MenuItem mi = new MenuItem(s);
                                            mi.setOnAction(recentProfileLoadHandler);
                                            return mi;
                                        }).collect(Collectors.toList())));
                            }

                            //
                            // #31 preload the last active profile
                            //
                            if (StringUtils.isNotEmpty(activeConfiguration.getActiveProfile())) {

                                if (logger.isDebugEnabled()) {
                                    logger.debug("[INIT TASK] preloading last active profile={}",
                                            activeConfiguration.getActiveProfile());
                                }
                                doLoadProfile(activeConfiguration.getActiveProfile());
                            }

                            long endTimeMillis = System.currentTimeMillis();

                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] loading profiles took {} ms",
                                        (endTimeMillis - startTimeMillis));
                            }
                        }
                    });
                }

                return null;
            }

            @Override
            protected void succeeded() {
                super.succeeded();
                updateMessage("");
                lblStatus.textProperty().unbind();
            }

            @Override
            protected void cancelled() {
                super.cancelled();
                logger.error("task cancelled", getException());
                updateMessage("");
                lblStatus.textProperty().unbind();
            }

            @Override
            protected void failed() {
                super.failed();
                logger.error("task failed", getException());
                updateMessage("");
                lblStatus.textProperty().unbind();
            }
        };

        lblStatus.textProperty().bind(t.messageProperty());

        new Thread(t).start();

    } catch (Exception exc) {

        logger.error("can't load configuration", exc);

        String msg = "Verify that the user has access to the directory '" + configFile + "' under "
                + System.getProperty("user.home") + ".";

        Alert alert = new Alert(Alert.AlertType.ERROR, msg);
        alert.setHeaderText("Can't load config file");
        alert.showAndWait();

        Platform.exit();
    }
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param primaryStage/* w  w  w . jav a2s.  co m*/
 * @param racine
 * @param taille
 * @throws Exception
 */
private void creeMenu(VBox racine, int taille) throws Exception {
    //Pane myPane = (Pane) FXMLLoader.load(getClass().getResource("menuPrincipal.fxml"));
    VBox myPane = new VBox();
    myPane.setPrefHeight(80);
    myPane.setPrefWidth(3000);
    MenuBar menuPrincipal = new MenuBar();
    menuPrincipal.setMinHeight(25);
    menuPrincipal.setPrefHeight(29);
    menuPrincipal.setPrefWidth(3000);
    /* 
     Menu projets
     */
    Menu menuProjet = new Menu(rb.getString("projets"));
    menuPrincipal.getMenus().add(menuProjet);
    nouveauProjet = new MenuItem(rb.getString("nouveauProjet"));
    nouveauProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+N"));
    menuProjet.getItems().add(nouveauProjet);
    chargeProjet = new MenuItem(rb.getString("ouvrirProjet"));
    chargeProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+O"));
    menuProjet.getItems().add(chargeProjet);
    sauveProjet = new MenuItem(rb.getString("sauverProjet"));
    sauveProjet.setDisable(true);
    sauveProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+S"));
    menuProjet.getItems().add(sauveProjet);
    sauveSousProjet = new MenuItem(rb.getString("sauverProjetSous"));
    sauveSousProjet.setDisable(true);
    sauveSousProjet.setAccelerator(KeyCombination.keyCombination("Shift+Ctrl+S"));
    menuProjet.getItems().add(sauveSousProjet);
    derniersProjets = new Menu(rb.getString("derniersProjets"));
    //        derniersProjets.setDisable(true);
    menuProjet.getItems().add(derniersProjets);
    fichHistoFichiers = new File(repertConfig.getAbsolutePath() + File.separator + "derniersprojets.cfg");
    nombreHistoFichiers = 0;
    if (fichHistoFichiers.exists()) {
        FileReader fr;
        fr = new FileReader(fichHistoFichiers);
        try (BufferedReader br = new BufferedReader(fr)) {
            while ((texteHisto = br.readLine()) != null) {
                MenuItem menuDerniersFichiers = new MenuItem(texteHisto);
                derniersProjets.getItems().add(menuDerniersFichiers);
                histoFichiers[nombreHistoFichiers] = texteHisto;
                nombreHistoFichiers++;
                menuDerniersFichiers.setOnAction((ActionEvent e) -> {
                    MenuItem mnu = (MenuItem) e.getSource();
                    try {
                        try {
                            projetChargeNom(mnu.getText());
                        } catch (InterruptedException ex) {
                            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
                    }
                });

            }
        }
    }

    SeparatorMenuItem sep1 = new SeparatorMenuItem();
    menuProjet.getItems().add(sep1);
    fermerProjet = new MenuItem(rb.getString("quitterApplication"));
    fermerProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+Q"));
    menuProjet.getItems().add(fermerProjet);
    /*
     Menu affichage
     */
    Menu menuAffichage = new Menu(rb.getString("affichage"));
    menuPrincipal.getMenus().add(menuAffichage);
    affichageVisite = new MenuItem(rb.getString("main.creationVisite"));
    affichageVisite.setAccelerator(KeyCombination.keyCombination("Ctrl+1"));
    menuAffichage.getItems().add(affichageVisite);
    affichageInterface = new MenuItem(rb.getString("main.creationInterface"));
    affichageInterface.setAccelerator(KeyCombination.keyCombination("Ctrl+2"));
    menuAffichage.getItems().add(affichageInterface);
    affichagePlan = new MenuItem(rb.getString("main.tabPlan"));
    affichagePlan.setAccelerator(KeyCombination.keyCombination("Ctrl+3"));
    affichagePlan.setDisable(true);
    menuAffichage.getItems().add(affichagePlan);
    SeparatorMenuItem sep3 = new SeparatorMenuItem();
    menuAffichage.getItems().add(sep3);
    configTransformation = new MenuItem(rb.getString("affichageConfiguration"));
    menuAffichage.getItems().add(configTransformation);

    /*
     Menu panoramiques
     */
    menuPanoramique = new Menu(rb.getString("panoramiques"));
    menuPanoramique.setDisable(true);
    menuPrincipal.getMenus().add(menuPanoramique);
    ajouterPano = new MenuItem(rb.getString("ajouterPanoramiques"));
    ajouterPano.setAccelerator(KeyCombination.keyCombination("Ctrl+A"));
    menuPanoramique.getItems().add(ajouterPano);
    ajouterPlan = new MenuItem(rb.getString("ajouterPlan"));
    ajouterPlan.setAccelerator(KeyCombination.keyCombination("Ctrl+P"));
    menuPanoramique.getItems().add(ajouterPlan);
    ajouterPlan.setDisable(true);
    SeparatorMenuItem sep2 = new SeparatorMenuItem();
    menuPanoramique.getItems().add(sep2);
    visiteGenere = new MenuItem(rb.getString("genererVisite"));
    visiteGenere.setDisable(true);
    visiteGenere.setAccelerator(KeyCombination.keyCombination("Ctrl+V"));
    menuPanoramique.getItems().add(visiteGenere);
    /*
     Menu Modles 
     */
    menuModeles = new Menu(rb.getString("menuModele"));
    menuPrincipal.getMenus().add(menuModeles);

    chargerModele = new MenuItem(rb.getString("modeleCharger"));
    menuModeles.getItems().add(chargerModele);

    sauverModele = new MenuItem(rb.getString("modeleSauver"));
    menuModeles.getItems().add(sauverModele);

    /*
     Menu transformations 
     */
    menuTransformation = new Menu(rb.getString("outils"));
    menuPrincipal.getMenus().add(menuTransformation);
    equi2CubeTransformation = new MenuItem(rb.getString("outilsEqui2Cube"));
    menuTransformation.getItems().add(equi2CubeTransformation);
    cube2EquiTransformation = new MenuItem(rb.getString("outilsCube2Equi"));
    menuTransformation.getItems().add(cube2EquiTransformation);

    /*
     Menu Aide
     */
    Menu menuAide = new Menu(rb.getString("aide"));
    menuPrincipal.getMenus().add(menuAide);
    aide = new MenuItem(rb.getString("aideAide"));
    aide.setAccelerator(KeyCombination.keyCombination("Ctrl+H"));
    menuAide.getItems().add(aide);
    SeparatorMenuItem sep4 = new SeparatorMenuItem();
    menuAide.getItems().add(sep4);
    aPropos = new MenuItem(rb.getString("aideAPropos"));
    menuAide.getItems().add(aPropos);
    /*
     barre de boutons 
     */
    HBox barreBouton = new HBox();
    barreBouton.getStyleClass().add("menuBarreOutils1");

    barreBouton.setPrefHeight(50);
    barreBouton.setMinHeight(50);
    barreBouton.setPrefWidth(3000);
    /*
     Bouton nouveau Projet
     */
    ScrollPane spBtnNouvprojet = new ScrollPane();
    spBtnNouvprojet.getStyleClass().add("menuBarreOutils");
    spBtnNouvprojet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnNouvprojet.setPrefHeight(35);
    spBtnNouvprojet.setMaxHeight(35);
    spBtnNouvprojet.setPadding(new Insets(2));
    spBtnNouvprojet.setPrefWidth(35);

    HBox.setMargin(spBtnNouvprojet, new Insets(5, 15, 0, 15));
    imgNouveauProjet = new ImageView(
            new Image("file:" + repertAppli + File.separator + "images/nouveauProjet.png"));
    spBtnNouvprojet.setContent(imgNouveauProjet);
    Tooltip t0 = new Tooltip(rb.getString("nouveauProjet"));
    t0.setStyle(tooltipStyle);
    spBtnNouvprojet.setTooltip(t0);
    barreBouton.getChildren().add(spBtnNouvprojet);
    /*
     Bouton ouvrir Projet
     */
    ScrollPane spBtnOuvrirProjet = new ScrollPane();
    spBtnOuvrirProjet.getStyleClass().add("menuBarreOutils");
    spBtnOuvrirProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnOuvrirProjet.setPrefHeight(35);
    spBtnOuvrirProjet.setMaxHeight(35);
    spBtnOuvrirProjet.setPadding(new Insets(2));
    spBtnOuvrirProjet.setPrefWidth(35);

    HBox.setMargin(spBtnOuvrirProjet, new Insets(5, 15, 0, 0));
    imgChargeProjet = new ImageView(
            new Image("file:" + repertAppli + File.separator + "images/ouvrirProjet.png"));
    spBtnOuvrirProjet.setContent(imgChargeProjet);
    Tooltip t1 = new Tooltip(rb.getString("ouvrirProjet"));
    t1.setStyle(tooltipStyle);
    spBtnOuvrirProjet.setTooltip(t1);
    barreBouton.getChildren().add(spBtnOuvrirProjet);

    /*
     Bouton sauve Projet
     */
    ScrollPane spBtnSauveProjet = new ScrollPane();
    spBtnSauveProjet.getStyleClass().add("menuBarreOutils");
    spBtnSauveProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnSauveProjet.setPrefHeight(35);
    spBtnSauveProjet.setMaxHeight(35);
    spBtnSauveProjet.setPadding(new Insets(2));
    spBtnSauveProjet.setPrefWidth(35);

    HBox.setMargin(spBtnSauveProjet, new Insets(5, 15, 0, 0));
    imgSauveProjet = new ImageView(
            new Image("file:" + repertAppli + File.separator + "images/sauveProjet.png"));
    spBtnSauveProjet.setContent(imgSauveProjet);
    Tooltip t2 = new Tooltip(rb.getString("sauverProjet"));
    t2.setStyle(tooltipStyle);
    spBtnSauveProjet.setTooltip(t2);
    barreBouton.getChildren().add(spBtnSauveProjet);
    Separator sepImages = new Separator(Orientation.VERTICAL);
    sepImages.prefHeight(200);
    barreBouton.getChildren().add(sepImages);
    imgSauveProjet.setDisable(true);
    imgSauveProjet.setOpacity(0.3);
    /*
     Bouton Ajoute Panoramique
     */
    ScrollPane spBtnAjoutePano = new ScrollPane();
    spBtnAjoutePano.getStyleClass().add("menuBarreOutils");
    spBtnAjoutePano.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnAjoutePano.setPrefHeight(35);
    spBtnAjoutePano.setMaxHeight(35);
    spBtnAjoutePano.setPadding(new Insets(2));
    spBtnAjoutePano.setPrefWidth(35);

    HBox.setMargin(spBtnAjoutePano, new Insets(5, 15, 0, 15));
    imgAjouterPano = new ImageView(
            new Image("file:" + repertAppli + File.separator + "images/ajoutePanoramique.png"));
    spBtnAjoutePano.setContent(imgAjouterPano);
    Tooltip t3 = new Tooltip(rb.getString("ajouterPanoramiques"));
    t3.setStyle(tooltipStyle);
    spBtnAjoutePano.setTooltip(t3);
    barreBouton.getChildren().add(spBtnAjoutePano);
    imgAjouterPano.setDisable(true);
    imgAjouterPano.setOpacity(0.3);

    /*
     Bouton Ajoute Panoramique
     */
    ScrollPane spBtnAjoutePlan = new ScrollPane();
    spBtnAjoutePlan.getStyleClass().add("menuBarreOutils");
    spBtnAjoutePlan.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnAjoutePlan.setPrefHeight(35);
    spBtnAjoutePlan.setMaxHeight(35);
    spBtnAjoutePlan.setPadding(new Insets(2));
    spBtnAjoutePlan.setPrefWidth(35);

    HBox.setMargin(spBtnAjoutePlan, new Insets(5, 15, 0, 15));
    imgAjouterPlan = new ImageView(new Image("file:" + repertAppli + File.separator + "images/ajoutePlan.png"));
    spBtnAjoutePlan.setContent(imgAjouterPlan);
    Tooltip t31 = new Tooltip(rb.getString("ajouterPlan"));
    t31.setStyle(tooltipStyle);
    spBtnAjoutePlan.setTooltip(t31);
    barreBouton.getChildren().add(spBtnAjoutePlan);
    imgAjouterPlan.setDisable(true);
    imgAjouterPlan.setOpacity(0.3);

    /*
     Bouton Gnre
     */
    ScrollPane spBtnGenereVisite = new ScrollPane();
    spBtnGenereVisite.getStyleClass().add("menuBarreOutils");
    spBtnGenereVisite.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnGenereVisite.setPrefHeight(35);
    spBtnGenereVisite.setMaxHeight(35);
    spBtnGenereVisite.setPadding(new Insets(2));
    spBtnGenereVisite.setPrefWidth(70);

    HBox.setMargin(spBtnGenereVisite, new Insets(5, 15, 0, 0));
    imgVisiteGenere = new ImageView(
            new Image("file:" + repertAppli + File.separator + "images/genereVisite.png"));
    spBtnGenereVisite.setContent(imgVisiteGenere);
    Tooltip t4 = new Tooltip(rb.getString("genererVisite"));
    t4.setStyle(tooltipStyle);
    spBtnGenereVisite.setTooltip(t4);
    barreBouton.getChildren().add(spBtnGenereVisite);
    imgVisiteGenere.setDisable(true);
    imgVisiteGenere.setOpacity(0.3);
    Separator sepImages1 = new Separator(Orientation.VERTICAL);
    sepImages1.prefHeight(200);
    barreBouton.getChildren().add(sepImages1);
    /*
     Bouton equi -> faces de  Cube
     */
    ScrollPane spBtnEqui2Cube = new ScrollPane();
    spBtnEqui2Cube.getStyleClass().add("menuBarreOutils");
    spBtnEqui2Cube.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnEqui2Cube.setPrefHeight(35);
    spBtnEqui2Cube.setMaxHeight(35);
    spBtnEqui2Cube.setPadding(new Insets(2));
    spBtnEqui2Cube.setPrefWidth(109);

    HBox.setMargin(spBtnEqui2Cube, new Insets(5, 15, 0, 250));
    imgEqui2Cube = new ImageView(new Image("file:" + repertAppli + File.separator + "images/equi2cube.png"));
    spBtnEqui2Cube.setContent(imgEqui2Cube);
    Tooltip t6 = new Tooltip(rb.getString("outilsEqui2Cube"));
    t6.setStyle(tooltipStyle);
    spBtnEqui2Cube.setTooltip(t6);
    barreBouton.getChildren().add(spBtnEqui2Cube);

    /*
     Bouton faces de cube -> equi
     */
    ScrollPane spBtnCube2Equi = new ScrollPane();
    spBtnCube2Equi.getStyleClass().add("menuBarreOutils");
    spBtnCube2Equi.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnCube2Equi.setPrefHeight(35);
    spBtnCube2Equi.setMaxHeight(35);
    spBtnCube2Equi.setPadding(new Insets(2));
    spBtnCube2Equi.setPrefWidth(109);

    HBox.setMargin(spBtnCube2Equi, new Insets(5, 25, 0, 0));
    imgCube2Equi = new ImageView(new Image("file:" + repertAppli + File.separator + "images/cube2equi.png"));
    spBtnCube2Equi.setContent(imgCube2Equi);
    Tooltip t5 = new Tooltip(rb.getString("outilsCube2Equi"));
    t5.setStyle(tooltipStyle);
    spBtnCube2Equi.setTooltip(t5);
    barreBouton.getChildren().add(spBtnCube2Equi);

    myPane.getChildren().addAll(menuPrincipal, barreBouton);
    racine.getChildren().add(myPane);
    nouveauProjet.setOnAction((ActionEvent e) -> {
        projetsNouveau();
    });
    chargeProjet.setOnAction((ActionEvent e) -> {
        try {
            try {
                projetCharge();
            } catch (InterruptedException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    sauveProjet.setOnAction((ActionEvent e) -> {
        try {
            projetSauve();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    sauveSousProjet.setOnAction((ActionEvent e) -> {
        try {
            projetSauveSous();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    visiteGenere.setOnAction((ActionEvent e) -> {
        try {
            genereVisite();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    fermerProjet.setOnAction((ActionEvent e) -> {
        try {
            projetsFermer();
        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    ajouterPano.setOnAction((ActionEvent e) -> {
        try {
            panoramiquesAjouter();
        } catch (InterruptedException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    ajouterPlan.setOnAction((ActionEvent e) -> {
        planAjouter();
    });
    aPropos.setOnAction((ActionEvent e) -> {
        aideapropos();
    });
    aide.setOnAction((ActionEvent e) -> {
        AideDialogController.affiche();
    });

    chargerModele.setOnAction((ActionEvent e) -> {
        try {
            modeleCharger();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    sauverModele.setOnAction((ActionEvent e) -> {
        try {
            modeleSauver();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    cube2EquiTransformation.setOnAction((ActionEvent e) -> {
        transformationCube2Equi();
    });

    equi2CubeTransformation.setOnAction((ActionEvent e) -> {
        transformationEqui2Cube();
    });
    affichageVisite.setOnAction((ActionEvent e) -> {
        tabPaneEnvironnement.getSelectionModel().select(0);
    });
    affichageInterface.setOnAction((ActionEvent e) -> {
        tabPaneEnvironnement.getSelectionModel().select(1);
    });
    affichagePlan.setOnAction((ActionEvent e) -> {
        if (!tabPlan.isDisabled()) {
            tabPaneEnvironnement.getSelectionModel().select(2);
        }
    });

    configTransformation.setOnAction((ActionEvent e) -> {
        try {
            ConfigDialogController cfg = new ConfigDialogController();
            cfg.afficheFenetre();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    spBtnNouvprojet.setOnMouseClicked((MouseEvent t) -> {
        projetsNouveau();
    });
    spBtnOuvrirProjet.setOnMouseClicked((MouseEvent t) -> {
        try {
            try {
                projetCharge();
            } catch (InterruptedException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnSauveProjet.setOnMouseClicked((MouseEvent t) -> {
        try {
            projetSauve();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnAjoutePano.setOnMouseClicked((MouseEvent t) -> {
        try {
            panoramiquesAjouter();
        } catch (InterruptedException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnAjoutePlan.setOnMouseClicked((MouseEvent t) -> {
        planAjouter();
    });
    spBtnGenereVisite.setOnMouseClicked((MouseEvent t) -> {
        try {
            genereVisite();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnEqui2Cube.setOnMouseClicked((MouseEvent t) -> {
        transformationEqui2Cube();
    });
    spBtnCube2Equi.setOnMouseClicked((MouseEvent t) -> {
        transformationCube2Equi();
    });

}

From source file:org.drombler.fx.core.action.impl.FXActionUtils.java

public static void configureAction(FXAction fxAction, ActionDescriptor actionDescriptor) {
    fxAction.setDisplayName(actionDescriptor.getDisplayName());
    if (actionDescriptor.getAccelerator() != null && !actionDescriptor.getAccelerator().equals("")) {
        fxAction.setAccelerator(KeyCombination.keyCombination(actionDescriptor.getAccelerator()));
    }//from  w ww  . ja  va  2 s .  c o  m
    if (!StringUtils.isBlank(actionDescriptor.getIcon())) {
        IconFactory iconFactory = new IconFactory(actionDescriptor.getIcon(),
                actionDescriptor.getResourceLoader(), false);
        fxAction.setGraphicFactory(iconFactory);
    }
}

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

private void initActions() {
    //add//from   w  ww .  ja  v a 2s .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/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/* www.j  av a2 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/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));
}