com.intellij.ui.treeStructure.treetable.TreeTableTree Java Examples

The following examples show how to use com.intellij.ui.treeStructure.treetable.TreeTableTree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoResultPanel.java    From nosql4idea with Apache License 2.0 7 votes vote down vote up
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;
}
 
Example #2
Source File: JsonTreeTableView.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
public JsonTreeTableView(TreeNode rootNode, ColumnInfo[] columnInfos) {
    super(new ListTreeTableModelOnColumns(rootNode, columnInfos));
    this.columns = columnInfos;

    final TreeTableTree tree = getTree();

    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    UIUtil.setLineStyleAngled(tree);
    setTreeCellRenderer(new KeyCellRenderer());

    TreeUtil.expand(tree, 2);

    new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() {
        @Override
        public String convert(final TreePath path) {
            final NoSqlTreeNode node = (NoSqlTreeNode) path.getLastPathComponent();
            NodeDescriptor descriptor = node.getDescriptor();
            return descriptor.getFormattedKey();
        }
    });
}
 
Example #3
Source File: MongoResultPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: AbstractRefactoringPanel.java    From IntelliJDeodorant with MIT License 5 votes vote down vote up
/**
 * Highlights refactoring-specific code fragment.
 */
private void highlightCode(InputEvent e) {
    TreeTableTree treeTableTree = treeTable.getTree();
    TreePath selectedPath = treeTableTree.getSelectionModel().getSelectionPath();
    if (selectedPath != null) {
        Object o = selectedPath.getLastPathComponent();
        if (refactoringType.instanceOfCandidateRefactoring(o)) {
            AbstractCandidateRefactoring refactoring = (AbstractCandidateRefactoring) o;
            refactoring.highlightCode();
        } else {
            expandOrCollapsePath(e, treeTableTree, selectedPath);
        }
    }
}
 
Example #5
Source File: AbstractRefactoringPanel.java    From IntelliJDeodorant with MIT License 5 votes vote down vote up
/**
 * Collapse if the selected path is extended, otherwise expand.
 */
public static void expandOrCollapsePath(InputEvent e, TreeTableTree treeTableTree, TreePath selectedPath) {
    if (e instanceof KeyEvent) {
        if (treeTableTree.isExpanded(selectedPath)) {
            treeTableTree.collapsePath(selectedPath);
        } else {
            treeTableTree.expandPath(selectedPath);
        }
    }
}
 
Example #6
Source File: ExtractMethodPanel.java    From IntelliJDeodorant with MIT License 5 votes vote down vote up
/**
 * Opens the definition of appropriate method for the selected suggestion by double-clicking or Enter key pressing.
 */
private void openMethodDefinition(InputEvent e) {
    TreeTableTree treeTableTree = treeTable.getTree();
    TreePath selectedPath = treeTableTree.getSelectionModel().getSelectionPath();
    if (selectedPath != null) {
        Object o = selectedPath.getLastPathComponent();
        if (o instanceof ASTSlice) {
            openDefinition(((ASTSlice) o).getSourceMethodDeclaration(), scope, (ASTSlice) o);
        } else if (o instanceof ExtractMethodCandidateGroup) {
            expandOrCollapsePath(e, treeTableTree, selectedPath);
        }
    }
}
 
Example #7
Source File: FlutterLogTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void update() {
  columns.update();

  reload(getRoot());
  treeTable.updateUI();

  final TreeTableTree tree = treeTable.getTree();

  // Restore/preserve selection state.
  tree.setSelectionRows(treeTable.getSelectedRows());

  // Select and reveal a selection path (e.g., on error) if specified.
  if (pathToSelectAndReveal != null) {
    // TODO(pq): if there are timing issues, consider a delayed uiExec
    // TODO(pq): consider scrolling bounding rectangle to top of scrollpane
    tree.setSelectionPath(pathToSelectAndReveal);
    tree.scrollPathToVisible(pathToSelectAndReveal);
    pathToSelectAndReveal = null;
  }

  if (updateCallback != null) {
    updateCallback.updated();
  }

  if (autoScrollToEnd) {
    uiExec(this::scrollToEnd, 100);
  }
}
 
Example #8
Source File: FlutterLogTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void update() {
  columns.update();

  reload(getRoot());
  treeTable.updateUI();

  final TreeTableTree tree = treeTable.getTree();

  // Restore/preserve selection state.
  tree.setSelectionRows(treeTable.getSelectedRows());

  // Select and reveal a selection path (e.g., on error) if specified.
  if (pathToSelectAndReveal != null) {
    // TODO(pq): if there are timing issues, consider a delayed uiExec
    // TODO(pq): consider scrolling bounding rectangle to top of scrollpane
    tree.setSelectionPath(pathToSelectAndReveal);
    tree.scrollPathToVisible(pathToSelectAndReveal);
    pathToSelectAndReveal = null;
  }

  if (updateCallback != null) {
    updateCallback.updated();
  }

  if (autoScrollToEnd) {
    uiExec(this::scrollToEnd, 100);
  }
}
 
Example #9
Source File: AbstractTreeUpdater.java    From consulo with Apache License 2.0 5 votes vote down vote up
public AbstractTreeUpdater(@Nonnull AbstractTreeBuilder treeBuilder) {
  myTreeBuilder = treeBuilder;
  final JTree tree = myTreeBuilder.getTree();
  final JComponent component = tree instanceof TreeTableTree ? ((TreeTableTree)tree).getTreeTable() : tree;
  myUpdateQueue = new MergingUpdateQueue("UpdateQueue", 100, component.isShowing(), component);
  myUpdateQueue.setRestartTimerOnAdd(false);

  final UiNotifyConnector uiNotifyConnector = new UiNotifyConnector(component, myUpdateQueue);
  Disposer.register(this, myUpdateQueue);
  Disposer.register(this, uiNotifyConnector);
}
 
Example #10
Source File: FlutterLogTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void setTree(JTree tree) {
  super.setTree(tree);
  treeTable = ((TreeTableTree)tree).getTreeTable();
  columns.init(treeTable);
}
 
Example #11
Source File: FlutterLogTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void setTree(JTree tree) {
  super.setTree(tree);
  treeTable = ((TreeTableTree)tree).getTreeTable();
  columns.init(treeTable);
}
 
Example #12
Source File: MongoResultPanel.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
void collapseAll() {
    TreeTableTree tree = resultTableView.getTree();
    TreeUtil.collapseAll(tree, 1);
}
 
Example #13
Source File: RedisPanel.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
void collapseAll() {
    TreeTableTree tree = resultTableView.getTree();
    TreeUtil.collapseAll(tree, 1);
}
 
Example #14
Source File: CouchbasePanel.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
void collapseAll() {
    TreeTableTree tree = resultTableView.getTree();
    TreeUtil.collapseAll(tree, 1);
}
 
Example #15
Source File: InspectionsConfigTreeTable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setTree(final JTree tree) {
  myTreeTable = ((TreeTableTree)tree).getTreeTable();
}
 
Example #16
Source File: ValueCellRenderer.java    From nosql4idea with Apache License 2.0 3 votes vote down vote up
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {

    TreeTableTree tree = ((TreeTable) table).getTree();
    TreePath pathForRow = tree.getPathForRow(row);

    final NoSqlTreeNode node = (NoSqlTreeNode) pathForRow.getLastPathComponent();

    node.getDescriptor().renderValue(this, tree.isExpanded(pathForRow));
}