Search in sources :

Example 6 with ListTreeTableModelOnColumns

use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.

the class AddMultipleFilesOptionsDialog method createTree.

private void createTree() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    for (AddedFileInfo myRoot : myRoots) {
        root.add(myRoot);
    }
    myModel = new ListTreeTableModelOnColumns(root, COLUMNS);
    myTreeTable = new TreeTableView(myModel);
    int comboHeight = new JComboBox().getPreferredSize().height;
    int checkBoxHeight = new JCheckBox().getPreferredSize().height;
    myTreeTable.setMinRowHeight(Math.max(comboHeight, checkBoxHeight) + 2);
    myTreeTable.setRootVisible(false);
    final JTableHeader tableHeader = myTreeTable.getTableHeader();
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    final TreeTableTree tree = myTreeTable.getTree();
    myTreeTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            final int keyCode = e.getKeyCode();
            if (keyCode == KeyEvent.VK_SPACE) {
                final int selectedColumn = myTreeTable.getSelectedColumn();
                if (selectedColumn == 0) {
                    return;
                }
                final int[] selectedRows = myTreeTable.getSelectedRows();
                if (selectedRows.length == 0) {
                    return;
                }
                final boolean included = !((AddedFileInfo) myTreeTable.getValueAt(selectedRows[0], 1)).included();
                for (int selectedRow : selectedRows) {
                    final AddedFileInfo addedFileInfo = (AddedFileInfo) myTreeTable.getValueAt(selectedRow, 1);
                    addedFileInfo.setIncluded(included);
                    myModel.nodeChanged(addedFileInfo);
                }
            }
        }
    });
    tree.setCellRenderer(new AddedFileCellRenderer());
    TreeUtil.installActions(tree);
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) KeyAdapter(java.awt.event.KeyAdapter) JTableHeader(javax.swing.table.JTableHeader) TreeTableView(com.intellij.ui.dualView.TreeTableView) KeyEvent(java.awt.event.KeyEvent) TreeTableTree(com.intellij.ui.treeStructure.treetable.TreeTableTree) AddedFileInfo(com.intellij.cvsSupport2.cvsoperations.cvsAdd.AddedFileInfo)

Example 7 with ListTreeTableModelOnColumns

use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.

the class CompareWithSelectedRevisionAction method showTreePopup.

private static void showTreePopup(final List<TreeItem<VcsFileRevision>> roots, final VirtualFile file, final Project project, final DiffProvider diffProvider) {
    final TreeTableView treeTable = new TreeTableView(new ListTreeTableModelOnColumns(new TreeNodeAdapter(null, null, roots), new ColumnInfo[] { BRANCH_COLUMN, REVISION_COLUMN, DATE_COLUMN, AUTHOR_COLUMN }));
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            int index = treeTable.getSelectionModel().getMinSelectionIndex();
            if (index == -1) {
                return;
            }
            VcsFileRevision revision = getRevisionAt(treeTable, index);
            if (revision != null) {
                DiffActionExecutor.showDiff(diffProvider, revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH);
            }
        }
    };
    treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new PopupChooserBuilder(treeTable).setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")).setItemChoosenCallback(runnable).setSouthComponent(createCommentsPanel(treeTable)).setResizable(true).setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup").createPopup().showCenteredInCurrentWindow(project);
    final int lastRow = treeTable.getRowCount() - 1;
    if (lastRow < 0)
        return;
    treeTable.getSelectionModel().addSelectionInterval(lastRow, lastRow);
    treeTable.scrollRectToVisible(treeTable.getCellRect(lastRow, 0, true));
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) ColumnInfo(com.intellij.util.ui.ColumnInfo) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder) TreeTableView(com.intellij.ui.dualView.TreeTableView)

Example 8 with ListTreeTableModelOnColumns

use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.

the class DynamicManagerImpl method removeItemFromTree.

private void removeItemFromTree(DItemElement itemElement, DClassElement classElement) {
    DynamicToolWindowWrapper wrapper = DynamicToolWindowWrapper.getInstance(myProject);
    ListTreeTableModelOnColumns model = wrapper.getTreeTableModel();
    Object classNode = TreeUtil.findNodeWithObject(classElement, model, model.getRoot());
    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) TreeUtil.findNodeWithObject(itemElement, model, classNode);
    if (node == null)
        return;
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
    doRemove(wrapper, node, parent);
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 9 with ListTreeTableModelOnColumns

use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.

the class DynamicManagerImpl method addItemInTree.

private void addItemInTree(final DClassElement classElement, final DItemElement itemElement, final ToolWindow window) {
    final ListTreeTableModelOnColumns myTreeTableModel = DynamicToolWindowWrapper.getInstance(myProject).getTreeTableModel();
    window.activate(() -> {
        final Object rootObject = myTreeTableModel.getRoot();
        if (!(rootObject instanceof DefaultMutableTreeNode))
            return;
        final DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) rootObject;
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(itemElement);
        if (rootNode.getChildCount() > 0) {
            for (DefaultMutableTreeNode classNode = (DefaultMutableTreeNode) rootNode.getFirstChild(); classNode != null; classNode = (DefaultMutableTreeNode) rootNode.getChildAfter(classNode)) {
                final Object classRow = classNode.getUserObject();
                if (!(classRow instanceof DClassElement))
                    return;
                DClassElement otherClassName = (DClassElement) classRow;
                if (otherClassName.equals(classElement)) {
                    int index = getIndexToInsert(classNode, itemElement);
                    classNode.insert(node, index);
                    myTreeTableModel.nodesWereInserted(classNode, new int[] { index });
                    DynamicToolWindowWrapper.getInstance(myProject).setSelectedNode(node);
                    return;
                }
            }
        }
        // if there is no such class in tree
        int index = getIndexToInsert(rootNode, classElement);
        DefaultMutableTreeNode classNode = new DefaultMutableTreeNode(classElement);
        rootNode.insert(classNode, index);
        myTreeTableModel.nodesWereInserted(rootNode, new int[] { index });
        classNode.add(node);
        myTreeTableModel.nodesWereInserted(classNode, new int[] { 0 });
        DynamicToolWindowWrapper.getInstance(myProject).setSelectedNode(node);
    }, true);
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 10 with ListTreeTableModelOnColumns

use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.

the class GrDynamicImplicitMethod method navigate.

@Override
public void navigate(boolean requestFocus) {
    DynamicToolWindowWrapper.getInstance(getProject()).getToolWindow().activate(() -> {
        DynamicToolWindowWrapper toolWindowWrapper = DynamicToolWindowWrapper.getInstance(getProject());
        final TreeTable treeTable = toolWindowWrapper.getTreeTable();
        final ListTreeTableModelOnColumns model = toolWindowWrapper.getTreeTableModel();
        Object root = model.getRoot();
        if (root == null || !(root instanceof DefaultMutableTreeNode))
            return;
        DefaultMutableTreeNode treeRoot = ((DefaultMutableTreeNode) root);
        DefaultMutableTreeNode desiredNode;
        JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
        final PsiClassType fqClassName = facade.getElementFactory().createTypeByFQClassName(myContainingClassName, ProjectScope.getAllScope(getProject()));
        final PsiClass psiClass = fqClassName.resolve();
        if (psiClass == null)
            return;
        PsiClass trueClass = null;
        DMethodElement methodElement = null;
        final GrParameter[] parameters = getParameters();
        List<String> parameterTypes = new ArrayList<>();
        for (GrParameter parameter : parameters) {
            final String type = parameter.getType().getCanonicalText();
            parameterTypes.add(type);
        }
        for (PsiClass aSuper : PsiUtil.iterateSupers(psiClass, true)) {
            methodElement = DynamicManager.getInstance(getProject()).findConcreteDynamicMethod(aSuper.getQualifiedName(), getName(), ArrayUtil.toStringArray(parameterTypes));
            if (methodElement != null) {
                trueClass = aSuper;
                break;
            }
        }
        if (trueClass == null)
            return;
        final DefaultMutableTreeNode classNode = TreeUtil.findNodeWithObject(treeRoot, new DClassElement(getProject(), trueClass.getQualifiedName()));
        if (classNode == null)
            return;
        desiredNode = TreeUtil.findNodeWithObject(classNode, methodElement);
        if (desiredNode == null)
            return;
        final TreePath path = TreeUtil.getPathFromRoot(desiredNode);
        treeTable.getTree().expandPath(path);
        treeTable.getTree().setSelectionPath(path);
        treeTable.getTree().fireTreeExpanded(path);
        //        ToolWindowManager.getInstance(myProject).getFocusManager().requestFocus(treeTable, true);
        treeTable.revalidate();
        treeTable.repaint();
    }, true);
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) ArrayList(java.util.ArrayList) DMethodElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DMethodElement) GrParameter(org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter) DClassElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DClassElement) TreePath(javax.swing.tree.TreePath)

Aggregations

ListTreeTableModelOnColumns (com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns)12 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)9 TreeTableView (com.intellij.ui.dualView.TreeTableView)4 ColumnInfo (com.intellij.util.ui.ColumnInfo)4 TreePath (javax.swing.tree.TreePath)3 TreeColumnInfo (com.intellij.ui.treeStructure.treetable.TreeColumnInfo)2 TreeTable (com.intellij.ui.treeStructure.treetable.TreeTable)2 TreeTableTree (com.intellij.ui.treeStructure.treetable.TreeTableTree)2 AsyncProcessIcon (com.intellij.util.ui.AsyncProcessIcon)2 ArrayList (java.util.ArrayList)2 DClassElement (org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DClassElement)2 AddedFileInfo (com.intellij.cvsSupport2.cvsoperations.cvsAdd.AddedFileInfo)1 PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)1 RefactoringElementListener (com.intellij.refactoring.listeners.RefactoringElementListener)1 RefactoringElementListenerProvider (com.intellij.refactoring.listeners.RefactoringElementListenerProvider)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1