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"));
}
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);
}
}
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);
}
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);
}
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;
}
Aggregations