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/data/Node.java | 52 ++++++++++++++++------------------ 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'source/com/c2kernel/gui/data/Node.java') diff --git a/source/com/c2kernel/gui/data/Node.java b/source/com/c2kernel/gui/data/Node.java index 79eb3ad..6556b3a 100644 --- a/source/com/c2kernel/gui/data/Node.java +++ b/source/com/c2kernel/gui/data/Node.java @@ -42,11 +42,11 @@ public abstract class Node implements Runnable { public Node() { } - + protected void createTreeNode() { this.treeNode = new DefaultMutableTreeNode(this); } - + public Node(Path path, EntityTabManager desktop) { this.binding = path; this.desktop = desktop; @@ -58,7 +58,7 @@ public abstract class Node implements Runnable { else this.name = Gateway.getProperty("Name"); } - + public EntityTabManager getDesktop() { return desktop; } @@ -72,7 +72,7 @@ public abstract class Node implements Runnable { return new NodeItem(path, desktop); } catch (ObjectNotFoundException ex) { return new NodeContext(path, desktop); - } + } } @@ -107,15 +107,15 @@ public abstract class Node implements Runnable { else { synchronized (childNodes) { Node newNode; - for (Iterator nodes = childNodes.values().iterator(); nodes.hasNext();) { - newNode = (Node)nodes.next(); + for (Iterator nodes = childNodes.values().iterator(); nodes.hasNext();) { + newNode = nodes.next(); Logger.msg("subscribeNode target.add("+newNode.name+")"); target.add(newNode); } } } } - + public void loadMore() { Thread loading = new Thread(this); loading.start(); @@ -128,62 +128,58 @@ public abstract class Node implements Runnable { public void add(Node newNode) { synchronized(childNodes) { childNodes.put(newNode.getPath(), newNode); - for (Iterator e = subscribers.iterator(); e.hasNext();) { - NodeSubscriber thisSub = (NodeSubscriber)e.next(); - + for (NodeSubscriber thisSub : subscribers) { thisSub.add(newNode); } } } - + public void remove(Path oldPath) { synchronized(childNodes) { childNodes.remove(oldPath); - for (Iterator e = subscribers.iterator(); e.hasNext();) { - NodeSubscriber thisSub = (NodeSubscriber)e.next(); + for (NodeSubscriber thisSub : subscribers) { thisSub.remove(oldPath); } } } - + public void removeAllChildren() { synchronized(childNodes) { - Path thisPath; while (childNodes.keySet().iterator().hasNext()) { - remove((Path)childNodes.keySet().iterator().next()); + remove(childNodes.keySet().iterator().next()); } } } public Node getChildNode(Path itsPath) { - for (Iterator i = childNodes.keySet().iterator(); i.hasNext();) { - Object next = i.next(); - if ( next.equals(itsPath) ) return (Node)childNodes.get(next); + for (Iterator i = childNodes.keySet().iterator(); i.hasNext();) { + Object next = i.next(); + if ( next.equals(itsPath) ) return childNodes.get(next); } return null; } // end of current batch public void end(boolean more) { - for (Iterator e = subscribers.iterator(); e.hasNext();) { - NodeSubscriber thisSub = (NodeSubscriber)e.next(); + for (NodeSubscriber thisSub : subscribers) { thisSub.end(more); } } - public void run() { + @Override + public void run() { Thread.currentThread().setName("Node Loader: "+name); loadChildren(); } public abstract void loadChildren(); - + public void refresh() { removeAllChildren(); loadChildren(); } - + // Getters and Setters public int getSysKey() { return sysKey; } @@ -198,8 +194,9 @@ public abstract class Node implements Runnable { public Path getPath() { return binding; } public DynamicTreeBuilder getTreeBuilder() { return loader; } - - public String toString() { + + @Override + public String toString() { if (this.name.length() > 0) { return this.name; } @@ -214,7 +211,7 @@ public abstract class Node implements Runnable { public String getIconName() { return iconName; } - + public void setIcon(String icon) { iconName = icon; this.icon = Resource.getImageResource("typeicons/"+icon+"_16.png"); @@ -224,6 +221,7 @@ public abstract class Node implements Runnable { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(Language.translate("Refresh")); menuItem.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (isExpandable) refresh(); } -- cgit v1.2.3