Search in sources :

Example 81 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project ACS by ACS-Community.

the class ErrorTreeCellRenderer method getNodesTree.

/**
	 * This method initializes jTree1	
	 * 	
	 * @return javax.swing.JTree	
	 */
private JTree getNodesTree() {
    if (nodesTree == null) {
        nodesTree = new JTree(new DefaultMutableTreeNode("ROOT"));
        nodesTree.setRootVisible(false);
        nodesTree.setCellRenderer(new ErrorTreeCellRenderer());
        nodesTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {

            public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
                complexNodeSelected = (DefaultMutableTreeNode) nodesTree.getLastSelectedPathComponent();
                if (complexNodeSelected != null)
                    complexSelected = (ComplexObject) complexNodeSelected.getUserObject();
                refreshNodeAttributesTable();
                refreshMembersTable();
            }
        });
    }
    ToolTipManager.sharedInstance().registerComponent(nodesTree);
    return nodesTree;
}
Also used : JTree(javax.swing.JTree) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 82 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project ACS by ACS-Community.

the class LogLvlTreeModel method removeComponent.

/**
	 * Remove all the occurrencies of the component with the given
	 * handle from the tree
	 * 
	 * @param handle The handle of the component to remove
	 */
private void removeComponent(int handle) {
    // Look for a node with the given handle
    DefaultMutableTreeNode compNode = findNode(containersNode, null, handle);
    if (compNode == null) {
        // The node is not in the tree: nothing to do
        return;
    }
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) compNode.getParent();
    int idx = parent.getIndex(compNode);
    parent.remove(compNode);
    Object[] children = new Object[] { compNode };
    int[] indexes = new int[] { idx };
    fireTreeNodesRemoved(parent, parent.getPath(), indexes, children);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 83 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project intellij-community by JetBrains.

the class DynamicToolWindowWrapper method deleteRow.

void deleteRow() {
    boolean isShowDialog = true;
    final int rowsCount = myTreeTable.getSelectedRows().length;
    int i = 0;
    final TreePath[] paths = myTreeTable.getTree().getSelectionPaths();
    if (paths == null)
        return;
    for (TreePath selectionPath : paths) {
        if (rowsCount > 1)
            isShowDialog = false;
        if (i == 0)
            isShowDialog = true;
        i++;
        //class
        final TreePath parent = selectionPath.getParentPath();
        if (parent.getParentPath() == null) {
            //selectionPath is class
            final Object classRow = selectionPath.getLastPathComponent();
            if (!(classRow instanceof DefaultMutableTreeNode))
                return;
            if (!removeClass(((DefaultMutableTreeNode) classRow), isShowDialog, rowsCount))
                return;
        } else {
            //selectionPath is dynamic item
            final Object classRow = parent.getLastPathComponent();
            final Object dynamicRow = selectionPath.getLastPathComponent();
            if (!(classRow instanceof DefaultMutableTreeNode))
                return;
            if (!(dynamicRow instanceof DefaultMutableTreeNode))
                return;
            final DefaultMutableTreeNode dynamicItemNode = (DefaultMutableTreeNode) dynamicRow;
            final DefaultMutableTreeNode classNode = (DefaultMutableTreeNode) classRow;
            final boolean removeClass = classNode.getChildCount() == 1;
            if (!removeDynamicElement(dynamicItemNode, isShowDialog, rowsCount))
                return;
            if (removeClass) {
                removeNamedElement((DNamedElement) classNode.getUserObject());
            }
        }
    }
    DynamicManager.getInstance(myProject).fireChange();
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 84 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project intellij-community by JetBrains.

the class DynamicToolWindowWrapper method buildTree.

private DefaultMutableTreeNode buildTree(DefaultMutableTreeNode rootNode) {
    final Collection<DClassElement> containingClasses = DynamicManager.getInstance(myProject).getAllContainingClasses();
    DefaultMutableTreeNode containingClassNode;
    for (DClassElement containingClassElement : containingClasses) {
        containingClassNode = new DefaultMutableTreeNode(containingClassElement);
        final Collection<DPropertyElement> properties = DynamicManager.getInstance(myProject).findDynamicPropertiesOfClass(containingClassElement.getName());
        //      if (properties.length == 0) continue;
        DefaultMutableTreeNode propertyTreeNode;
        for (DPropertyElement property : properties) {
            propertyTreeNode = new DefaultMutableTreeNode(property);
            containingClassNode.add(propertyTreeNode);
        }
        DefaultMutableTreeNode methodTreeNode;
        final Set<DMethodElement> methods = containingClassElement.getMethods();
        for (DMethodElement methodElement : methods) {
            final String[] psiTypes = QuickfixUtil.getArgumentsTypes(methodElement.getPairs());
            final DMethodElement method = DynamicManager.getInstance(myProject).findConcreteDynamicMethod(containingClassElement.getName(), methodElement.getName(), psiTypes);
            methodTreeNode = new DefaultMutableTreeNode(method);
            containingClassNode.add(methodTreeNode);
        }
        rootNode.add(containingClassNode);
    }
    return rootNode;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 85 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project intellij-community by JetBrains.

the class DynamicToolWindowWrapper method rebuildTreePanel.

public void rebuildTreePanel() {
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    buildTree(rootNode);
    rebuildTreeView(rootNode, false);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Aggregations

DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)692 TreePath (javax.swing.tree.TreePath)185 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)98 ArrayList (java.util.ArrayList)51 Nullable (org.jetbrains.annotations.Nullable)50 TreeNode (javax.swing.tree.TreeNode)42 Test (org.junit.Test)39 JTree (javax.swing.JTree)38 NotNull (org.jetbrains.annotations.NotNull)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 JScrollPane (javax.swing.JScrollPane)25 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)23 TreeSelectionListener (javax.swing.event.TreeSelectionListener)23 Module (com.intellij.openapi.module.Module)20 File (java.io.File)20 Tree (com.intellij.ui.treeStructure.Tree)19 Enumeration (java.util.Enumeration)19 MouseEvent (java.awt.event.MouseEvent)18 IOException (java.io.IOException)17 MProduct (org.compiere.model.MProduct)17