Ejemplo n.º 1
0
  public String getSelectedNodeStringifiedValue() {
    NoSqlTreeNode lastSelectedResultNode =
        (NoSqlTreeNode) resultTableView.getTree().getLastSelectedPathComponent();
    if (lastSelectedResultNode == null) {
      lastSelectedResultNode = (NoSqlTreeNode) resultTableView.getTree().getModel().getRoot();
    }
    NodeDescriptor userObject = lastSelectedResultNode.getDescriptor();
    if (userObject instanceof MongoResultDescriptor) {
      return stringifyResult(lastSelectedResultNode);
    }

    return userObject.toString();
  }
Ejemplo n.º 2
0
  public void updateResultTableTree(MongoResult mongoResult) {
    resultTableView =
        new JsonTreeTableView(
            JsonTreeModel.buildJsonTree(mongoResult), JsonTreeTableView.COLUMNS_FOR_READING);
    resultTableView.setName("resultTreeTable");

    resultTableView.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent mouseEvent) {
            if (mouseEvent.getClickCount() == 2 && MongoResultPanel.this.isSelectedNodeId()) {
              MongoResultPanel.this.editSelectedMongoDocument();
            }
          }
        });

    buildPopupMenu();

    resultTreePanel.invalidate();
    resultTreePanel.removeAll();
    resultTreePanel.add(new JBScrollPane(resultTableView));
    resultTreePanel.validate();
  }
Ejemplo n.º 3
0
  private DBObject getSelectedMongoDocument() {
    TreeTableTree tree = resultTableView.getTree();
    NoSqlTreeNode treeNode = (NoSqlTreeNode) tree.getLastSelectedPathComponent();
    if (treeNode == null) {
      return null;
    }

    NodeDescriptor descriptor = treeNode.getDescriptor();
    if (descriptor instanceof MongoKeyValueDescriptor) {
      MongoKeyValueDescriptor keyValueDescriptor = (MongoKeyValueDescriptor) descriptor;
      if (StringUtils.equals(keyValueDescriptor.getKey(), "_id")) {
        return mongoDocumentOperations.getMongoDocument(keyValueDescriptor.getValue());
      }
    }

    return null;
  }
Ejemplo n.º 4
0
  public boolean isSelectedNodeId() {
    if (resultTableView == null) {
      return false;
    }
    TreeTableTree tree = resultTableView.getTree();
    NoSqlTreeNode treeNode = (NoSqlTreeNode) tree.getLastSelectedPathComponent();
    if (treeNode == null) {
      return false;
    }

    NodeDescriptor descriptor = treeNode.getDescriptor();
    if (descriptor instanceof MongoKeyValueDescriptor) {
      MongoKeyValueDescriptor keyValueDescriptor = (MongoKeyValueDescriptor) descriptor;
      return StringUtils.equals(keyValueDescriptor.getKey(), "_id");
    }

    return false;
  }
Ejemplo n.º 5
0
 void collapseAll() {
   TreeTableTree tree = resultTableView.getTree();
   TreeUtil.collapseAll(tree, 1);
 }
Ejemplo n.º 6
0
 void expandAll() {
   TreeUtil.expandAll(resultTableView.getTree());
 }