Search in sources :

Example 71 with DefaultMutableTreeNode

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

the class LogLvlTreeModel method buildServicesNode.

/**
	 * Build the list of services
	 */
private void buildServicesNode() {
    servicesNode.add(new DefaultMutableTreeNode("CDB"));
    servicesNode.add(new DefaultMutableTreeNode("AcsAlarmService"));
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 72 with DefaultMutableTreeNode

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

the class Gui method toTreeNode.

private void toTreeNode(Gen.AnchorNode src, DefaultMutableTreeNode trg) {
    for (Gen.AnchorNode subSrc : src.children) {
        DefaultMutableTreeNode subTrg = new DefaultMutableTreeNode(subSrc);
        trg.add(subTrg);
        toTreeNode(subSrc, subTrg);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 73 with DefaultMutableTreeNode

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

the class Gui method show.

void show(Gen.AnchorNode n) {
    DefaultMutableTreeNode r = new DefaultMutableTreeNode(n);
    toTreeNode(n, r);
    JTree t = new JTree(r);
    final JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            synchronized (Gui.this) {
                Gui.this.notify();
            }
            f.dispose();
        }
    });
    f.getContentPane().add(new JScrollPane(t));
    f.pack();
    f.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTree(javax.swing.JTree) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 74 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode 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 75 with DefaultMutableTreeNode

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

the class AlarmTreeModel method addChild.

/**
	 * Add an alarm as a child of the passed node
	 * 
	 * @param al The alarm to add
	 * @param parent The parent node;
	 * 				if it is <code>null</code> the child is added to the root node
	 * @return The newly added node
	 */
public DefaultMutableTreeNode addChild(Alarm al, DefaultMutableTreeNode parent) {
    if (al == null) {
        throw new IllegalArgumentException("The alarm can't be null");
    }
    if (parent == null) {
        parent = (DefaultMutableTreeNode) root;
    }
    final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(new NodeContent(al));
    final DefaultMutableTreeNode parentNode = parent;
    try {
        // Inside the EDT for safety
        EDTExecutor.instance().executeSync(new Runnable() {

            public void run() {
                insertNodeInto(newNode, parentNode, 0);
                nodeStructureChanged(parentNode);
            }
        });
    } catch (Exception e) {
        // What to do in this case?
        e.printStackTrace();
    }
    return newNode;
}
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