Search in sources :

Example 11 with DefaultTreeModel

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

the class TreeHandlerBean method disconnect.

/**
	 * @author Miha Kadunc
	 * @author rbertoncelj
	 */
public void disconnect() {
    notifier.reportDebug("TreeHandlerBean::disconnect", "Requesting engine to disconnect the introspectable..:");
    if (clicked instanceof BACIRemoteNode) {
        BACIRemoteNode myNode = (BACIRemoteNode) clicked;
        RemoteNodeCouple rnc;
        String curl;
        if (myNode.getUserObject() instanceof String) {
            curl = (String) myNode.getUserObject();
        } else {
            curl = (String) ((OETreeNode) myNode.getParent()).getUserObject() + ":" + myNode.toString();
        }
        rnc = (RemoteNodeCouple) devices.get(curl);
        if (rnc == null) {
            clicked = null;
            notifier.reportError("TreeHandlerBean::disconnect - Unexpected null pointer (rnc).");
            return;
        }
        /*
				 * Clean treeByType
				 */
        if (rnc.deviceByType.isConnected()) {
            OETreeNode clk = (OETreeNode) rnc.deviceByType;
            clk.setChildrenDefined(true);
            rnc.deviceByType.disconnect();
            TreePath clkPath = new TreePath(clk.getPath());
            if (clkPath.isDescendant(tree.getSelectionPath()) || (clkPath.equals(tree.getSelectionPath()))) {
                this.selectedNode = clk;
                tree.setSelectionPath(clkPath);
                handler.setObject(null);
            }
            tree.collapsePath(clkPath);
            clk.removeAllChildren();
            ((DefaultTreeModel) tree.getModel()).reload(clk);
            clk.setChildrenDefined(false);
        }
        /*
				 * Clean treeByName
				 */
        OETreeNode clk = (OETreeNode) rnc.deviceByName;
        clk.setChildrenDefined(true);
        rnc.deviceByName.disconnect();
        TreePath clkPath = new TreePath(clk.getPath());
        if (clkPath.isDescendant(treeByName.getSelectionPath()) || (clkPath.equals(treeByName.getSelectionPath()))) {
            this.selectedNode = clk;
            treeByName.setSelectionPath(clkPath);
            handler.setObject(null);
        }
        treeByName.collapsePath(clkPath);
        purgeChildren(clk);
        clk.removeAllChildren();
        ((DefaultTreeModel) treeByName.getModel()).reload(clk);
        clk.setChildrenDefined(false);
    } else {
        notifier.reportError("TreeHandlerBean::disconnect - clicked not instanceof BACIRemoteNode.");
        if (clicked instanceof OETreeNode) {
            if (clicked.isConnected()) {
                OETreeNode clk = (OETreeNode) clicked;
                clk.setChildrenDefined(true);
                clicked.disconnect();
                TreePath clkPath = new TreePath(clk.getPath());
                if (clkPath.isDescendant(tree.getSelectionPath()) || (clkPath.equals(tree.getSelectionPath()))) {
                    this.selectedNode = clk;
                    tree.setSelectionPath(clkPath);
                    handler.setObject(null);
                }
                tree.collapsePath(clkPath);
                purgeChildren(clk);
                clk.removeAllChildren();
                ((DefaultTreeModel) tree.getModel()).reload(clk);
                clk.setChildrenDefined(false);
            }
        }
    }
    clicked = null;
}
Also used : TreePath(javax.swing.tree.TreePath) BACIRemoteNode(si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode) RemoteNodeCouple(si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 12 with DefaultTreeModel

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

the class TreeHandlerBean method removeNode.

/**
	 * removeNode method comment.
	 */
public void removeNode(javax.swing.tree.TreeNode node) {
    if (node.getParent() == null) {
        return;
    }
    InvocationCouple ic = getInvocationCouple((Invocation) node);
    if (ic == null) {
        notifier.reportError("TreeHandlerBean::removeNode - Unexpected null pointer (ic).");
        return;
    }
    /*
		 * Selecet parent if the note that is to be deleted is currently selected
		 */
    if (tree.getSelectionPath() != null) {
        if (tree.getSelectionPath().getLastPathComponent() == node)
            tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) node.getParent()).getPath()));
    } else if (treeByName.getSelectionPath() == null) {
        if (treeByName.getSelectionPath().getLastPathComponent() == ic.invocationByName)
            treeByName.setSelectionPath(new TreePath(((DefaultMutableTreeNode) ic.invocationByName.getParent()).getPath()));
    }
    /*
		 * remove node from treeByType
		 */
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    model.removeNodeFromParent((MutableTreeNode) ic.invocationByType);
    /*
		 * remove node from treeByName
		 */
    model = (DefaultTreeModel) treeByName.getModel();
    model.removeNodeFromParent((MutableTreeNode) ic.invocationByName);
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) InvocationCouple(si.ijs.acs.objectexplorer.engine.BACI.InvocationCouple) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 13 with DefaultTreeModel

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

the class ErrorTreeCellRenderer method refreshDocsTree.

public void refreshDocsTree() {
    TreeMap<String, EbeDocument> docs = manager.getDocuments();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) docsTree.getModel().getRoot();
    root.removeAllChildren();
    for (EbeDocument doc : docs.values()) {
        root.add(new DefaultMutableTreeNode(doc));
    }
    ((DefaultTreeModel) docsTree.getModel()).reload();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 14 with DefaultTreeModel

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

the class ErrorTreeCellRenderer method refreshNodesTree.

private void refreshNodesTree() {
    DefaultTreeModel model = (DefaultTreeModel) nodesTree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    root.removeAllChildren();
    if (docSelected == null) {
        model.reload();
        return;
    }
    TreeMap<String, ComplexObject> nodes = docSelected.getNodes();
    for (ComplexObject node : nodes.values()) {
        root.add(new DefaultMutableTreeNode(node));
    }
    model.reload();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ComplexObject(cl.utfsm.acs.types.ComplexObject) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 15 with DefaultTreeModel

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

the class SvnMergeSourceDetails method addRecursively.

private void addRecursively(final SvnFileRevision revision, final MyNode node, final List<TreePath> nodesToExpand) {
    final MyNode current = new MyNode(new MyNamedConfigurable(revision, myFile, myProject, myListsMap));
    node.add(current);
    final TreeNode[] path = ((DefaultTreeModel) myTree.getModel()).getPathToRoot(node);
    nodesToExpand.add(new TreePath(path));
    final List<SvnFileRevision> mergeSources = revision.getMergeSources();
    for (SvnFileRevision source : mergeSources) {
        addRecursively(source, current, nodesToExpand);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Aggregations

DefaultTreeModel (javax.swing.tree.DefaultTreeModel)362 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)204 TreePath (javax.swing.tree.TreePath)99 JTree (javax.swing.JTree)30 JScrollPane (javax.swing.JScrollPane)25 Test (org.junit.Test)24 Tree (com.intellij.ui.treeStructure.Tree)23 TreeNode (javax.swing.tree.TreeNode)22 ArrayList (java.util.ArrayList)21 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)20 TreeSelectionListener (javax.swing.event.TreeSelectionListener)18 MockTreeModelListener (com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener)16 MouseEvent (java.awt.event.MouseEvent)16 List (java.util.List)16 JPanel (javax.swing.JPanel)16 BorderLayout (java.awt.BorderLayout)14 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)14 IOException (java.io.IOException)12 Dimension (java.awt.Dimension)11 ActionEvent (java.awt.event.ActionEvent)11