List of usage examples for javafx.scene.input KeyCode F2
KeyCode F2
To view the source code for javafx.scene.input KeyCode F2.
Click Source Link
From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java
public ClassTree(JEVisDataSource ds) { super();/*from w w w . j a v a2 s .c o m*/ 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(); } }