Example usage for javafx.scene.input KeyCode DELETE

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

Introduction

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

Prototype

KeyCode DELETE

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

Click Source Link

Document

Constant for the Delete key.

Usage

From source file:investiagenofx2.view.InvestiaGenOFXController.java

/**
 * Initializes the controller class.//from ww w.  j a v  a2  s .  c  o  m
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    txt_investiaURL.setText(PropertiesInit.getInvestiaURL());
    dtp_lastDate.setValue(LocalDate.parse(PropertiesInit.getLastGenUsedDate()));
    String[] clientNums = PropertiesInit.getClientNumList().split(",");
    for (String clientNum : clientNums) {
        if (!clientNum.trim().isEmpty()) {
            cbo_clientNum.getItems().add(clientNum.trim());
        }
    }
    Arrays.fill(linkAccountToLocalAccountIndex, -1);
    resetControls();

    cbo_clientNum.getEditor().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
        if (event.getCode() == KeyCode.DELETE) {
            cbo_clientNum.getItems().remove(cbo_clientNum.getValue());
            event.consume();
        }
    });

    dtp_lastDate.setConverter(new StringConverter<LocalDate>() {
        final String pattern = "yyyy-MM-dd";
        final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(pattern);

        {
            dtp_lastDate.setPromptText(pattern.toLowerCase());
        }

        @Override
        public String toString(LocalDate date) {
            if (date != null) {
                return dateFormatter.format(date);
            } else {
                return "";
            }
        }

        @Override
        public LocalDate fromString(String string) {
            if (string != null && !string.isEmpty()) {
                return LocalDate.parse(string, dateFormatter);
            } else {
                return null;
            }
        }
    });

    //This deals with the bug located here where the datepicker value is not updated on focus lost
    //https://bugs.openjdk.java.net/browse/JDK-8092295?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
    dtp_lastDate.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (!newValue) {
                dtp_lastDate
                        .setValue(dtp_lastDate.getConverter().fromString(dtp_lastDate.getEditor().getText()));
            }
        }
    });
}

From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java

public ClassTree(JEVisDataSource ds) {
    super();/*from w  w w. j av  a  2  s  . c  om*/
    try {
        _ds = ds;

        _itemCache = new HashMap<>();
        _graphicCache = new HashMap<>();
        _itemChildren = new HashMap<>();

        JEVisClass root = new JEVisRootClass(ds);
        TreeItem<JEVisClass> rootItem = buildItem(root);

        setShowRoot(true);
        rootItem.setExpanded(true);

        getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        _editor.setTreeView(this);

        setCellFactory(new Callback<TreeView<JEVisClass>, TreeCell<JEVisClass>>() {

            //                @Override
            //                public TreeCell<JEVisClass> call(TreeView<JEVisClass> p) {
            //                    return new ClassCell();
            //                }
            @Override
            public TreeCell<JEVisClass> call(TreeView<JEVisClass> param) {
                return new TreeCell<JEVisClass>() {
                    //                        private ImageView imageView = new ImageView();

                    @Override
                    protected void updateItem(JEVisClass item, boolean empty) {
                        super.updateItem(item, empty);

                        if (!empty) {
                            ClassGraphic gc = getClassGraphic(item);

                            setContextMenu(gc.getContexMenu());
                            //                                setText(item);
                            setGraphic(gc.getGraphic());
                        } else {
                            setText(null);
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<JEVisClass>>() {

            @Override
            public void changed(ObservableValue<? extends TreeItem<JEVisClass>> ov, TreeItem<JEVisClass> t,
                    TreeItem<JEVisClass> t1) {
                try {
                    if (t1 != null) {
                        _editor.setJEVisClass(t1.getValue());
                    }
                } catch (Exception ex) {
                    System.out.println("Error while changing editor: " + ex);
                }

            }
        });

        addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {

            @Override
            public void handle(KeyEvent t) {
                if (t.getCode() == KeyCode.F2) {
                    System.out.println("F2 rename event");
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            fireEventRename();
                        }
                    });

                } else if (t.getCode() == KeyCode.DELETE) {

                    fireDelete(getSelectionModel().getSelectedItem().getValue());
                }
            }

        });

        setId("objecttree");

        getStylesheets().add("/styles/Styles.css");
        setPrefWidth(500);

        setRoot(rootItem);
        setEditable(true);

    } catch (Exception ex) {
        //            Logger.getLogger(ObjectTree.class.getName()).log(Level.SEVERE, null, ex);
        ex.printStackTrace();
    }

}

From source file:com.exalttech.trex.ui.views.PacketTableView.java

/**
 * Build component UI/*from  w  ww  .  j  a  v a2 s .  c o m*/
 */
private void buildUI(boolean addExportToYamlBtn) {
    setTopAnchor(this, 0d);
    setLeftAnchor(this, 0d);
    setBottomAnchor(this, 0d);
    setRightAnchor(this, 0d);
    // build btn bar
    HBox buttonContainer = new HBox();
    buttonContainer.setSpacing(5);
    addPacketBtn = new StreamTableButton(StreamTableAction.ADD);
    initializeStreamButtons(addPacketBtn, false);
    buttonContainer.getChildren().add(addPacketBtn);

    // add build stream btn
    buildPacketBtn = new StreamTableButton(StreamTableAction.BUILD);
    buildPacketBtn.setId("buildStreamBtn");
    initializeStreamButtons(buildPacketBtn, false);
    buttonContainer.getChildren().add(buildPacketBtn);

    editPacketBtn = new StreamTableButton(StreamTableAction.EDIT);
    editPacketBtn.setId("editStreanBtn");
    initializeStreamButtons(editPacketBtn, true);
    buttonContainer.getChildren().add(editPacketBtn);

    deleteButtonBtn = new StreamTableButton(StreamTableAction.DELETE);
    initializeStreamButtons(deleteButtonBtn, true);
    buttonContainer.getChildren().add(deleteButtonBtn);

    importPcapButton = new StreamTableButton(StreamTableAction.IMPORT_PCAP);
    initializeStreamButtons(importPcapButton, false);
    buttonContainer.getChildren().add(importPcapButton);

    exportPcapButton = new StreamTableButton(StreamTableAction.EXPORT_TO_PCAP);
    initializeStreamButtons(exportPcapButton, true);
    buttonContainer.getChildren().add(exportPcapButton);

    if (addExportToYamlBtn) {
        exportToYaml = new StreamTableButton(StreamTableAction.EXPORT_TO_YAML);
        initializeStreamButtons(exportToYaml, false);
        buttonContainer.getChildren().add(exportToYaml);
    }
    getChildren().add(buttonContainer);
    setTopAnchor(buttonContainer, 5d);

    rightClickMenu = new ContextMenu();
    addMenuItem(StreamTableAction.EDIT);
    addMenuItem(StreamTableAction.DELETE);
    addMenuItem(StreamTableAction.EXPORT_TO_PCAP);
    addMenuItem(StreamTableAction.EXPORT_TO_YAML);

    // add table view
    streamPacketTableView = new TableView<>();
    streamPacketTableView.setId("streamTableView");
    streamPacketTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    streamPacketTableView.setFixedCellSize(32);
    streamPacketTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    streamPacketTableView.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            handleTableRowClick(event);
        }
    });

    streamPacketTableView.getSelectionModel().selectedItemProperty()
            .addListener((ObservableValue<? extends TableProfileStream> observable, TableProfileStream oldValue,
                    TableProfileStream newValue) -> {
                boolean notSelected = !(newValue != null);

                exportPcapButton.setDisable(notSelected);
                editPacketBtn.setDisable(notSelected);
                deleteButtonBtn.setDisable(notSelected);
            });

    streamPacketTableView.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> {
        if (copyCombination.match(event)) {
            selectedProfile = tabledata.getProfiles()
                    .get(streamPacketTableView.getSelectionModel().getSelectedIndex());
        } else if (pasteCombination.match(event)) {
            handleDuplicateStream();
        } else if (event.getCode() == KeyCode.DELETE) {
            handleDeletePacket();
        }
    });
    streamPacketTableView.setEditable(true);
    initializeTableColumn();
    // disable table reordering
    streamPacketTableView.widthProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> source, Number oldWidth, Number newWidth) {
            TableHeaderRow header = (TableHeaderRow) streamPacketTableView.lookup("TableHeaderRow");
            header.reorderingProperty().addListener(new ChangeListener<Boolean>() {
                @Override
                public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
                        Boolean newValue) {
                    header.setReordering(false);
                }
            });
        }
    });

    getChildren().add(streamPacketTableView);
    setTopAnchor(streamPacketTableView, 35d);
    setBottomAnchor(streamPacketTableView, 5d);
    setLeftAnchor(streamPacketTableView, 0d);
    setRightAnchor(streamPacketTableView, 0d);
}

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) {//w w  w.ja  va2  s  . c  o  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:view.EditorView.java

@FXML
// This method is called by the FXMLLoader when initialization is complete
void initialize() {
    assert insertRoom != null : "fx:id=\"insertRoom\" was not injected: check your FXML file 'EditorMain.fxml'.";
    assert drawing != null : "fx:id=\"drawing\" was not injected: check your FXML file 'EditorMain.fxml'.";
    assert insertPath != null : "fx:id=\"insertPath\" was not injected: check your FXML file 'EditorMain.fxml'.";

    currentEditorInstance = this;

    // modify the default exception handler to show the ReportingDialog on every uncaught exception
    final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread
            .getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
        if (currentUncaughtExceptionHandler != null) {
            // execute current handler as we only want to append it
            currentUncaughtExceptionHandler.uncaughtException(thread, exception);
        }//from   w  w w . ja va2 s .  c  o  m
        Platform.runLater(() -> {
            new ExceptionAlert(exception).showAndWait();
            new ReportingDialog(stage.getScene()).show(AppConfig.gitHubUserName, AppConfig.gitHubRepoName,
                    exception);
        });
    });

    currentGame.addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            newValue.modifiedProperty().addListener((observable1, oldValue1, newValue1) -> {
                this.menuItemSave.setDisable(!newValue1);
                setWindowTitle(newValue);
            });
        }
        setWindowTitle(newValue);
    });

    initGame();

    scrollPane.hvalueProperty().addListener((observable, oldValue, newValue) -> unselectingDisabled = true);
    scrollPane.vvalueProperty().addListener((observable, oldValue, newValue) -> unselectingDisabled = true);

    // add button icons
    insertRoom.setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("add-room.png"))));
    moveButton.setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("move-arrows.png"))));
    insertPath.setGraphic(
            new ImageView(new Image(EditorView.class.getResourceAsStream("connecting-points.png"))));
    autoLayoutButton
            .setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("autoLayout.png"))));
    refreshViewButton
            .setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("refreshView.png"))));

    // add tooltips
    insertRoom.setTooltip(new Tooltip("Insert a new room"));
    moveButton.setTooltip(new Tooltip("Move rooms"));
    insertPath.setTooltip(new Tooltip("Connect rooms to create walk paths"));
    autoLayoutButton.setTooltip(new Tooltip("Automatically rearrange the rooms in the view below"));
    refreshViewButton.setTooltip(new Tooltip("Refresh the current view"));

    // forward events to all selected items
    // drawing.setOnMouseClicked(forwardEventsToSelectableNodesHandler);
    // drawing.setOnMousePressed(forwardEventsToSelectableNodesHandler);
    // drawing.setOnMouseReleased(forwardEventsToSelectableNodesHandler);
    // drawing.setOnDragDetected(forwardEventsToSelectableNodesHandler);
    // drawing.setOnMouseDragged(forwardEventsToSelectableNodesHandler);
    scrollPane.setOnKeyPressed(event -> {
        if (event.getCode().equals(KeyCode.DELETE)) {
            for (Node child : new ArrayList<>(drawing.getChildren())) {
                if (child instanceof Disposable) {
                    if (((Disposable) child).isSelected() && event.getTarget() != child) {
                        FOKLogger.fine(EditorView.class.getName(),
                                "Sending disposal command to child, Child is:  " + child.toString()
                                        + "\ntarget is: " + event.getTarget().toString());
                        try {
                            ((Disposable) child).dispose();
                        } catch (IllegalStateException e) {
                            FOKLogger.log(EditorView.class.getName(), Level.INFO,
                                    "User tried to remove the current room (not allowed)", e);
                            new Alert(Alert.AlertType.ERROR, "Could not perform delete operation: \n\n"
                                    + ExceptionUtils.getRootCauseMessage(e)).show();
                        }
                    }
                }
            }
        } else if (event.getCode().equals(KeyCode.A) && event.isControlDown()) {
            // select everything
            for (Node child : new ArrayList<>(drawing.getChildren())) {
                if (child instanceof Selectable) {
                    ((Selectable) child).setSelected(true);
                }
            }
        }
    });
}