summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/data/Node.java
diff options
context:
space:
mode:
authorabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
committerabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
commit0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch)
tree5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/gui/data/Node.java
parent036cbdba66f804743c4c838ed598d6972c4b3e17 (diff)
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
Diffstat (limited to 'source/com/c2kernel/gui/data/Node.java')
-rw-r--r--source/com/c2kernel/gui/data/Node.java52
1 files changed, 25 insertions, 27 deletions
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<Node> 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<Path> 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();
}