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