From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: More code cleanup: Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class --- source/com/c2kernel/gui/DynamicTreeBuilder.java | 41 +++++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) mode change 100755 => 100644 source/com/c2kernel/gui/DynamicTreeBuilder.java (limited to 'source/com/c2kernel/gui/DynamicTreeBuilder.java') diff --git a/source/com/c2kernel/gui/DynamicTreeBuilder.java b/source/com/c2kernel/gui/DynamicTreeBuilder.java old mode 100755 new mode 100644 index 29a62dc..a72c156 --- a/source/com/c2kernel/gui/DynamicTreeBuilder.java +++ b/source/com/c2kernel/gui/DynamicTreeBuilder.java @@ -7,6 +7,7 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import com.c2kernel.gui.data.Node; +import com.c2kernel.gui.data.NodeItem; import com.c2kernel.gui.data.NodeSubscriber; import com.c2kernel.lookup.Path; import com.c2kernel.utils.Language; @@ -33,7 +34,7 @@ public class DynamicTreeBuilder implements NodeSubscriber { private DefaultMutableTreeNode loading; private static ImageIcon loadIcon = Resource.getImageResource("loading.gif"); private static ImageIcon pauseIcon = Resource.getImageResource("reload.gif"); - + /** * The newly created DynamicTreeBuilder records its parent node - the one for which it will build child nodes for. * @param nodeClicked The Parent Tree Node that will be populated. @@ -67,7 +68,8 @@ public class DynamicTreeBuilder implements NodeSubscriber { /** * Used by the JTree to find the text representation of the node. */ - public String toString() { + @Override + public String toString() { switch (state) { case IDLE: return Language.translate("Initializing Tree Node Loader"); @@ -80,9 +82,9 @@ public class DynamicTreeBuilder implements NodeSubscriber { default: return ""; } - + } - + public ImageIcon getIcon() { if (state == LOADING) return loadIcon; @@ -94,19 +96,21 @@ public class DynamicTreeBuilder implements NodeSubscriber { return loading; } - public void add(Node newNode) { + @Override + public void add(Node newNode) { Logger.msg(2, "DynamicTreeBuilder.add() - Received item for tree. Name: "+newNode); - + // have we inserted the node yet? SwingUtilities.invokeLater(new TreeAddThread(newNode)); } - + class TreeAddThread implements Runnable { Node newNode; TreeAddThread(Node newNode) { this.newNode = newNode; } - public void run() { + @Override + public void run() { boolean inserted = false; DefaultMutableTreeNode newTreeNode = newNode.getTreeNode(); // loop though all children unless we have done the insertion @@ -133,21 +137,23 @@ public class DynamicTreeBuilder implements NodeSubscriber { if (!inserted) treeModel.insertNodeInto(newTreeNode, parent, parent.getChildCount()); } - + } - + class TreeRemoveThread implements Runnable { DefaultMutableTreeNode oldNode; TreeRemoveThread(DefaultMutableTreeNode oldNode) { this.oldNode = oldNode; } - - public void run() { + + @Override + public void run() { treeModel.removeNodeFromParent(oldNode); } } - - public void end(boolean more) { + + @Override + public void end(boolean more) { if (more) { state = PARTIAL; } @@ -158,9 +164,10 @@ public class DynamicTreeBuilder implements NodeSubscriber { SwingUtilities.invokeLater(new TreeRemoveThread(loading)); } } - } - - public void remove(Path path) { + } + + @Override + public void remove(Path path) { synchronized (treeModel) { for (int i=0; i