@Override public void initialize(URL url, ResourceBundle r) { modFuncContextMenu = new ModFuncContextMenu(dbgController); modulesTree .getSelectionModel() .selectedItemProperty() .addListener( (o, old, newItem) -> { modFuncContextMenu.selectedTreeItemProperty().set(newItem); if (newItem != null) modFuncContextMenu.selectedItemProperty().set(newItem.getValue()); }); sortedTreeModules.setComparator(treeItemModFuncComparator()); SplitPane.setResizableWithParent(modulesBox, Boolean.FALSE); ErlyBerly.nodeAPI().connectedProperty().addListener(this::onConnected); modulesTree.setCellFactory(new ModFuncTreeCellFactory(dbgController)); /*modulesTree.setOnKeyPressed(this::onKeyPressInModuleTree);*/ modulesTree.setContextMenu(modFuncContextMenu); addModulesFloatySearchControl(); dbgController.initialize(url, r); dbgSplitPane.getItems().add(new DbgTraceView(dbgController)); }
@Override public void initialize(URL arg0, ResourceBundle arg1) { storedPreferences = Preferences.userRoot().node(PrefsConstants.PREFS_NODE); // DynamiPrefs.Basic.prefs().read(preferences); TreeItem<PrefsItem> root = new TreeItem<PrefsItem>(new PrefsItem(null, "General", "")); for (DynamiPrefs p : prefsPages) { final Prefs prefsNode = p.prefs(); prefsNode.read(storedPreferences); final Prefs.Panel panel = p.prefs().getClass().getAnnotation(Prefs.Panel.class); TreeItem<PrefsItem> child = new TreeItem<PrefsItem>(new PrefsItem(prefsNode, panel.name(), panel.description())); root.getChildren().add(child); } root.setExpanded(true); tree.setRoot(root); tree.getSelectionModel() .selectedItemProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue.getValue().prefs != null) { main.detailNodeProperty().set(new PrefsPage(newValue.getValue().prefs).getNode()); } }); }
@Override public void initialize(URL location, ResourceBundle resources) { // dummy entries TreeItem<String> rootItem = new TreeItem<String>("Dummy"); rootItem.setExpanded(true); for (int i = 1; i < 6; i++) { TreeItem<String> item = new TreeItem<String>("Sub Dummy " + i); rootItem.getChildren().add(item); } treeView = new TreeView<>(rootItem); treeView .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener<TreeItem>() { @Override public void changed( ObservableValue<? extends TreeItem> observable, TreeItem oldValue, TreeItem newValue) { Logger.getLogger(SystemtreePresenter.class.getName()) .log(Level.INFO, "Tree selection changed: {0}", newValue); someLogic.doSomething(); } }); rootPane.getChildren().add(treeView); }
public void onDisconnectDb(ActionEvent ev) { TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem(); if (selectedItem == null) { return; } selectedItem.getValue().getMongoConnection().close(); removeFromRoot(selectedItem); }
/** * TreeViewで板を選択する。 * * <p>仮実装で二階層まで対応 * * @param board */ public void setSelection(Board board) { TreeItem<Board> root = boardTreeView.getRoot(); for (TreeItem<Board> boardItem1 : root.getChildren()) { for (TreeItem<Board> boardItem2 : boardItem1.getChildren()) { if (boardItem2.getValue() != null && boardItem2.getValue().getId() != null && boardItem2.getValue().getId().equals(board.getId())) { boardTreeView.getSelectionModel().select(boardItem2); } } } }
private void onCreateNewCollection(ActionEvent ev) { TextInputDialog dialog = new TextInputDialog(); dialog.setContentText("Enter Name:"); dialog.setHeaderText("Create new collection"); dialog .showAndWait() .ifPresent( r -> { DbTreeValue value = treeView.getSelectionModel().getSelectedItem().getValue(); value.getMongoDatabase().createCollection(dialog.getResult()); reloadSelectedTreeItem(); }); }
private void onDropIndex(ActionEvent ev) { DbTreeValue value = treeView.getSelectionModel().getSelectedItem().getValue(); String indexName = value.getDisplayValue(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setHeaderText("Drop index " + indexName); alert.setContentText("Are you sure?"); alert .showAndWait() .filter(r -> r == ButtonType.OK) .ifPresent( r -> { value.getMongoDatabase().dropIndex(value.getCollectionName(), indexName); reloadSelectedTreeItem(); }); }
@SuppressWarnings("unchecked") @FXML private void handleButtonAction(ActionEvent event) { // createTree(); // create root TreeItem<String> root = new TreeItem<>("Output Structure"); // root.setExpanded(true); // create child TreeItem<String> item1 = new TreeItem<>("Data collect"); TreeItem<String> item1c1 = new TreeItem<>("Data Base"); TreeItem<String> item1c2 = new TreeItem<>("Field Trip"); TreeItem<String> item1c3 = new TreeItem<>("Darwin01"); item1.getChildren().addAll(item1c1, item1c2, item1c3); // item1.setExpanded(false); TreeItem<String> item2 = new TreeItem<>("Scanline"); TreeItem<String> item2C1 = new TreeItem<>("Power Law"); TreeItem<String> item2C2 = new TreeItem<>("New data"); item2.getChildren().addAll(item2C1, item2C2); TreeItem<String> item3 = new TreeItem<>("Modeling"); TreeItem<String> item3C1 = new TreeItem<>("2D"); TreeItem<String> item3C2 = new TreeItem<>("3D"); item3.getChildren().addAll(item3C1, item3C2); // itemChild2.setExpanded(false); // root is the parent of itemChild root.getChildren().addAll(item1, item2, item3); treeview_outs .getSelectionModel() .selectedItemProperty() .addListener( (v, oldvalue, newvalue) -> { if (newvalue != null) { System.out.println(newvalue.toString()); } }); treeview_outs.setRoot(root); grid_output_project.setDisable(true); check_output_newproject.setDisable(false); }
private void onDropDB(ActionEvent ev) { DbTreeValue value = treeView.getSelectionModel().getSelectedItem().getValue(); String dbName = value.getDisplayValue(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setHeaderText("Drop database " + dbName); alert.setContentText("Are you sure?"); alert .showAndWait() .filter(r -> r == ButtonType.OK) .ifPresent( r -> { value.getMongoDatabase().drop(); reloadSelectedTreeItem(); popupService.showInfo(String.format("Database '%s' dropped", dbName)); }); }
private void onRemoveAllDocuments(ActionEvent ev) { DbTreeValue value = treeView.getSelectionModel().getSelectedItem().getValue(); String collectionName = value.getDisplayValue(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setHeaderText("Remove all documents form " + collectionName); alert.setContentText("Are you sure?"); alert .showAndWait() .filter(r -> r == ButtonType.OK) .ifPresent( r -> { value.getMongoDatabase().removeAllDocuments(collectionName); popupService.showInfo( String.format("All documents from collection '%s' removed", collectionName)); }); }
private void onReanameCollection(ActionEvent actionEvent) { TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem(); if (selectedItem == null) { return; } DbTreeValue value = selectedItem.getValue(); TextInputDialog dialog = new TextInputDialog(value.getDisplayValue()); dialog.setContentText("New collection name:"); dialog.setHeaderText("Rename collection"); dialog .showAndWait() .ifPresent( targetCollection -> { MongoCollection<Document> collection = value.getMongoDatabase().getMongoDb().getCollection(value.getDisplayValue()); collection.renameCollection( new MongoNamespace(value.getMongoDatabase().getName(), targetCollection)); ((DynamicTreeItem) selectedItem.getParent()).reload(); }); }
public void onCreateNewDb(ActionEvent ev) { TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem(); if (selectedItem == null || selectedItem.getValue().getValueType() != TreeValueType.CONNECTION) { return; } TextInputDialog dialog = new TextInputDialog(); dialog.setContentText("Enter Name:"); dialog.setHeaderText("Create new db"); dialog .showAndWait() .ifPresent( r -> selectedItem .getChildren() .add( createDbItem( selectedItem .getValue() .getMongoConnection() .createMongoDB(dialog.getResult())))); }
private void onCopyCollection(ActionEvent actionEvent) { TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem(); if (selectedItem == null) { return; } DbTreeValue value = selectedItem.getValue(); String sourceCollectionName = value.getDisplayValue(); TextInputDialog dialog = new TextInputDialog(sourceCollectionName + "_copy"); dialog.setContentText("New collection name:"); dialog.setHeaderText("Copy collection"); dialog .showAndWait() .ifPresent( targetCollection -> { new CopyCollectionHelper( value.getMongoDatabase(), sourceCollectionName, targetCollection) .copy(); ((DynamicTreeItem) selectedItem.getParent()).reload(); popupService.showInfo( String.format( "Collection %s copied to %s", sourceCollectionName, targetCollection)); }); }
@Override public void initialize(URL arg0, ResourceBundle arg1) { log.debug("Controller.initialize"); service = new BbsService(); service.setController(this); service.init(); service.updateBoardList(); boardTreeView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); boardTreeView .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (boardTreeView.getSelectionModel().getSelectedItem() == null) { return; } Board board = (Board) boardTreeView.getSelectionModel().getSelectedItem().getValue(); if (board.getUrl() == null) { return; } log.debug("選択 " + board); service.openBoard(board); } }); messageThreadListView.setCellFactory( new Callback<ListView<MessageThread>, ListCell<MessageThread>>() { @Override public ListCell<MessageThread> call(ListView<MessageThread> param) { return new MessageThreadCell(); } }); messageThreadListView .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { MessageThread messageThread = (MessageThread) messageThreadListView.getSelectionModel().getSelectedItem(); if (messageThread != null) { messageThreadTitleLabel.setText(messageThread.getTitle()); service.openMessageThread(messageThread); } } }); webEngine = messageView.getEngine(); setupToolbar(boardListToolbar); setupToolbar(messageListToolbar); setupToolbar(threadListToolbar); if (IrisWindow.isMac()) { menuBar.setUseSystemMenuBar(true); } else { menuBar.setUseSystemMenuBar(false); closeButton.setVisible(false); minimizedButton.setVisible(false); maximizedButton.setVisible(false); } service.openLastSelectedItem(); }
/** *************************Selection Tasks************************** */ @FXML private void file_select(MouseEvent mouse) throws SQLException { TreeItem<StrucTree> item = structure_tree.getSelectionModel().getSelectedItem(); if (mouse.getClickCount() == 1 && item != null) { selected = item; if (item.getValue().isProject()) { info.setText( " [Project: " + item.getValue().toString() + "] [ID: " + item.getValue().getID() + "]"); } else if (item.getValue().isDirectory()) { info.setText( " [Directory: " + item.getValue().toString() + "] [ID: " + item.getValue().getID() + "] [Parent ID: " + item.getValue().getPID() + "]"); } else if (item.getValue().isFile()) { String query = "SELECT * FROM PFiles WHERE pfid like '" + item.getValue().getID() + "'"; Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(query); if (rs.next()) { if (rs.getInt("creatorID") == 0) { info.setText( " [File: " + item.getValue().toString() + "] [ID: " + item.getValue().getID() + "] [Created Time: " + rs.getTimestamp("timeCreated") + "]"); } else { query = "SELECT userName from Users WHERE userID like '" + rs.getInt("creatorID") + "'"; Statement st1 = conn.createStatement(); ResultSet rs1 = st1.executeQuery(query); if (rs1.next()) { info.setText( " [File: " + item.getValue().toString() + "] [ID: " + item.getValue().getID() + "] [Creator: " + rs1.getString("userName") + "] [Created Time: " + rs.getTimestamp("timeCreated") + "]"); } } } } else { info.setText(" *sQuire Project Menu*"); } if (Objects.equals(currProjectName, "")) { curr_position.setText(item.getValue().toString()); } else { curr_position.setText(getCurrPosition(item)); } } if (mouse.getClickCount() == 2 && item != null) { selected = item; curr_position.setText(item.getValue().toString()); if (currPID == 0 && !Objects.equals(item.getValue().toString(), "sQuire Project")) { currProjectName = item.getValue().toString(); currPID = item.getValue().getID(); setTree(null, 0); } else { curr_position.setText(getCurrPosition(item)); } if (item.getValue().isFile()) { selectedFile = item; readFile(selectedFile); } } }
@Override public void start(Stage primaryStage) { final String duckLabelText = "Selected Tree Item From Duck Tree: \n"; final String royalLabelText = "Selected Tree Item From Royal Tree: \n"; // Use HBOX and VBOX layout panes to space out the controls // in a single row HBox treeBox = new HBox(); VBox labelBox = new VBox(30); HBox controlBox = new HBox(10); // Create labels to highlight the selected items from the TreeViews final Label duckLabel = new Label(duckLabelText); final Label royalLabel = new Label(royalLabelText); // Create and empty TreeView TreeView<String> duckTree = new TreeView<String>(); // Create a TreeItem that will act as the root item of the TreeView TreeItem<String> duckRoot = new TreeItem<String>("Della Duck - Donald Duck"); // Add TreeItems to the root duckRoot .getChildren() .addAll( new TreeItem<String>("Huey Duck"), new TreeItem<String>("Dewey Duck"), new TreeItem<String>("Louie Duck")); // Use the setRoot method to set the root TreeItem duckTree.setRoot(duckRoot); // Set a ChangeListener to handle events that occur with a Treeitem // is selected duckTree .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener<TreeItem<String>>() { public void changed( ObservableValue<? extends TreeItem<String>> observableValue, TreeItem<String> oldItem, TreeItem<String> newItem) { duckLabel.setText(duckLabelText + newItem.getValue()); } }); // Create TreeItems for the Hierarchy of the TreeView TreeItem<String> royalRoot = new TreeItem<String>("Queen Elizabeth - Prince Philip"); TreeItem<String> Charlie = new TreeItem<String>("Prince Charles - Princess Diana"); TreeItem<String> Annie = new TreeItem<String>("Princess Anne - Mark Phillips"); TreeItem<String> Andy = new TreeItem<String>("Prince Andrew - Sarah Ferguson"); TreeItem<String> Eddie = new TreeItem<String>("Prince Edward - Sophie"); // Populate the TreeItem to be used as the root with the other TreeItems royalRoot.getChildren().addAll(Charlie, Annie, Andy, Eddie); // Create a TreeView using the root TreeItem TreeView<String> royalTree = new TreeView<String>(royalRoot); // Populate the other TreeItems with more TreeItems // to build the family tree Charlie.getChildren() .addAll(new TreeItem<String>("Prince William"), new TreeItem<String>("Prince Henry")); Annie.getChildren() .addAll(new TreeItem<String>("Peter Phillips"), new TreeItem<String>("Zara Phillips")); Andy.getChildren() .addAll( new TreeItem<String>("Princess Beatrice"), new TreeItem<String>("Princess Eugenie")); Eddie.getChildren() .addAll(new TreeItem<String>("Lady Louise"), new TreeItem<String>("Viscount Severn")); // Set a ChangeListener to handle events that occur with a Treeitem // is selected royalTree .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener<TreeItem<String>>() { public void changed( ObservableValue<? extends TreeItem<String>> observableValue, TreeItem<String> oldItem, TreeItem<String> newItem) { royalLabel.setText(royalLabelText + newItem.getValue()); } }); // Add the TreeViews to the HBox treeBox.getChildren().add(duckTree); treeBox.getChildren().add(royalTree); // Add the labels to the VBox labelBox.getChildren().add(duckLabel); labelBox.getChildren().add(royalLabel); // Add the HBox and VBox to another HBox to // position the layout panes controlBox.getChildren().add(treeBox); controlBox.getChildren().add(labelBox); // Add the main HBOX layout pane to the scene Scene scene = new Scene(controlBox, 800, 250); // Show the form primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
public void reloadSelectedTreeItem() { TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem(); findParentOfType(selectedItem, DynamicTreeItem.class).ifPresent(ti -> ti.reload()); }