Exemplo n.º 1
0
  public void onDisconnectDb(ActionEvent ev) {
    TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem();
    if (selectedItem == null) {
      return;
    }

    selectedItem.getValue().getMongoConnection().close();
    removeFromRoot(selectedItem);
  }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 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();
       }
     }
   }
 }
Exemplo n.º 4
0
  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()))));
  }
Exemplo n.º 5
0
  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();
            });
  }
Exemplo n.º 6
0
  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));
            });
  }
Exemplo n.º 7
0
 public Path getSelectedTabPath() {
   TreeItem<Item> selectedItem = controller.getTreeView().getSelectionModel().getSelectedItem();
   Item value = selectedItem.getValue();
   Path path = value.getPath();
   return path;
 }