public void onDisconnectDb(ActionEvent ev) { TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem(); if (selectedItem == null) { return; } selectedItem.getValue().getMongoConnection().close(); removeFromRoot(selectedItem); }
private void buildCollectionDetail(MongoDatabase db, TreeItem<DbTreeValue> ti) { DbTreeValue indexCategory = new DbTreeValue(db, "Indexes", TreeValueType.CATEGORY); indexCategory.setCollectionName(ti.getValue().getDisplayValue()); ti.getChildren() .add( new DynamicTreeItem( indexCategory, new FontAwesomeIconView(FontAwesomeIcon.FOLDER), executor, popupService, this::buildIndexes)); }
public void treeViewClicked(MouseEvent ev) { if (ev.getClickCount() == 2) { // don't process click on triangle EventTarget target = ev.getTarget(); if (target instanceof Node && !"arrow".equals(((Node) target).getStyleClass())) { TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem(); if (selectedItem != null && selectedItem.getValue().getValueType() == TreeValueType.COLLECTION) { mainFrameController.openTab(); ev.consume(); } } } }
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 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(); }); }
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)); }); }
public Path getSelectedTabPath() { TreeItem<Item> selectedItem = controller.getTreeView().getSelectionModel().getSelectedItem(); Item value = selectedItem.getValue(); Path path = value.getPath(); return path; }