diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/gui/data | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (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')
| -rw-r--r-- | source/com/c2kernel/gui/data/Node.java | 52 | ||||
| -rw-r--r-- | source/com/c2kernel/gui/data/NodeAgent.java | 12 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/data/NodeCollection.java | 18 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/data/NodeContext.java | 16 | ||||
| -rw-r--r-- | source/com/c2kernel/gui/data/NodeEntity.java | 10 | ||||
| -rw-r--r-- | source/com/c2kernel/gui/data/NodeItem.java | 28 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/data/NodeSubscriber.java | 2 |
7 files changed, 74 insertions, 64 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();
}
diff --git a/source/com/c2kernel/gui/data/NodeAgent.java b/source/com/c2kernel/gui/data/NodeAgent.java index 138b576..9f6cdad 100644 --- a/source/com/c2kernel/gui/data/NodeAgent.java +++ b/source/com/c2kernel/gui/data/NodeAgent.java @@ -18,14 +18,16 @@ public class NodeAgent extends NodeEntity { super(path, desktop);
}
- public void loadChildren() {
+ @Override
+ public void loadChildren() {
}
-
- public ArrayList<String> getTabs() {
+
+ @Override
+ public ArrayList<String> getTabs() {
ArrayList<String> requiredTabs = super.getTabs();
requiredTabs.add("AgentProperties");
requiredTabs.add("JobList");
- return requiredTabs;
- }
+ return requiredTabs;
+ }
}
diff --git a/source/com/c2kernel/gui/data/NodeCollection.java b/source/com/c2kernel/gui/data/NodeCollection.java index 3b02098..f55f8cd 100755..100644 --- a/source/com/c2kernel/gui/data/NodeCollection.java +++ b/source/com/c2kernel/gui/data/NodeCollection.java @@ -16,7 +16,7 @@ import com.c2kernel.utils.Logger; public class NodeCollection extends Node {
ItemProxy parent;
- Parent2ChildCollection thisCollection;
+ Parent2ChildCollection<?> thisCollection;
String path;
public NodeCollection(ItemProxy parent, String name, EntityTabManager desktop) {
@@ -28,19 +28,20 @@ public class NodeCollection extends Node { this.makeExpandable();
}
- public void loadChildren() {
+ @Override
+ public void loadChildren() {
Logger.msg(8, "NodeCollection::loadChildren()");
try {
- thisCollection = (Parent2ChildCollection)parent.getObject("Collection/"+name);
+ thisCollection = (Parent2ChildCollection<?>)parent.getObject("Collection/"+name);
} catch (ObjectNotFoundException ex) {
end(false);
- return;
+ return;
}
-
+
this.type = thisCollection.getClass().getName();
int lastDot = this.type.lastIndexOf('.');
if (lastDot > -1) this.type = this.type.substring(lastDot+1);
- ArrayList collectionMembers = thisCollection.getMembers().list;
+ ArrayList<?> collectionMembers = thisCollection.getMembers().list;
for (int i=0; i<collectionMembers.size(); i++)
{
CollectionMember aMember = (CollectionMember)collectionMembers.get(i);
@@ -59,8 +60,9 @@ public class NodeCollection extends Node { end(false);
}
-
- public DefaultMutableTreeNode getTreeNode() {
+
+ @Override
+ public DefaultMutableTreeNode getTreeNode() {
return treeNode;
}
}
diff --git a/source/com/c2kernel/gui/data/NodeContext.java b/source/com/c2kernel/gui/data/NodeContext.java index 6e2bc75..9240af4 100755..100644 --- a/source/com/c2kernel/gui/data/NodeContext.java +++ b/source/com/c2kernel/gui/data/NodeContext.java @@ -11,7 +11,7 @@ import com.c2kernel.utils.Logger; public class NodeContext extends Node implements DomainPathSubscriber {
- Enumeration children;
+ Enumeration<?> children;
public NodeContext(Path path, EntityTabManager desktop) {
super(path, desktop);
@@ -22,7 +22,8 @@ public class NodeContext extends Node implements DomainPathSubscriber { }
- public void loadChildren() {
+ @Override
+ public void loadChildren() {
if (children == null) {
Gateway.getProxyManager().subscribeTree(this, (DomainPath)binding);
children = binding.getChildren();
@@ -38,16 +39,19 @@ public class NodeContext extends Node implements DomainPathSubscriber { }
end(children.hasMoreElements());
}
-
- public void pathAdded(DomainPath path) {
+
+ @Override
+ public void pathAdded(DomainPath path) {
add(newNode(path));
}
- public void refresh() {
+ @Override
+ public void refresh() {
children = null;
super.refresh();
}
- public void pathRemoved(DomainPath path) {
+ @Override
+ public void pathRemoved(DomainPath path) {
remove(path);
}
diff --git a/source/com/c2kernel/gui/data/NodeEntity.java b/source/com/c2kernel/gui/data/NodeEntity.java index 8c05afd..cce4f68 100644 --- a/source/com/c2kernel/gui/data/NodeEntity.java +++ b/source/com/c2kernel/gui/data/NodeEntity.java @@ -56,11 +56,13 @@ public abstract class NodeEntity extends Node { /**
*
*/
- public JPopupMenu getPopupMenu() {
+ @Override
+ public JPopupMenu getPopupMenu() {
JPopupMenu popup = super.getPopupMenu();
JMenuItem openItem = new JMenuItem(Language.translate("Open"));
openItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
openItem();
}
});
@@ -68,11 +70,11 @@ public abstract class NodeEntity extends Node { popup.add(openItem);
return popup;
}
-
+
public void openItem() {
desktop.add(this);
}
-
+
public ArrayList<String> getTabs() {
ArrayList<String> requiredTabs = new ArrayList<String>();
return requiredTabs;
diff --git a/source/com/c2kernel/gui/data/NodeItem.java b/source/com/c2kernel/gui/data/NodeItem.java index 84cba97..30f7ce3 100644 --- a/source/com/c2kernel/gui/data/NodeItem.java +++ b/source/com/c2kernel/gui/data/NodeItem.java @@ -3,7 +3,6 @@ package com.c2kernel.gui.data; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.StringTokenizer;
import javax.swing.JMenuItem;
@@ -31,10 +30,11 @@ public class NodeItem extends NodeEntity { makeExpandable();
} catch (Exception e) {
Logger.error(e);
- }
+ }
}
- public void loadChildren() {
+ @Override
+ public void loadChildren() {
try {
String collections = myEntity.queryData("Collection/all");
StringTokenizer tok = new StringTokenizer(collections, ",");
@@ -47,16 +47,16 @@ public class NodeItem extends NodeEntity { Logger.error(e);
}
}
-
+
+ @Override
public JPopupMenu getPopupMenu() {
JPopupMenu popup = super.getPopupMenu();
popup.addSeparator();
try {
- ArrayList jobList = ((ItemProxy)myEntity).getJobList(MainFrame.userAgent);
+ ArrayList<Job> jobList = ((ItemProxy)myEntity).getJobList(MainFrame.userAgent);
ArrayList<String> already = new ArrayList<String>();
if (jobList.size() > 0) {
- for (Iterator e = jobList.iterator(); e.hasNext();) {
- Job thisJob = (Job)e.next();
+ for (Job thisJob : jobList) {
String stepName = thisJob.getStepName();
if (already.contains(stepName))
continue;
@@ -64,12 +64,13 @@ public class NodeItem extends NodeEntity { JMenuItem menuItem = new JMenuItem(stepName);
menuItem.setActionCommand(stepName);
menuItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
execute(e.getActionCommand());
}
});
popup.add(menuItem);
-
+
}
}
else {
@@ -85,13 +86,14 @@ public class NodeItem extends NodeEntity { return popup;
}
-
+
public void execute(String stepName) {
EntityDetails thisDetail = desktop.add(this);
thisDetail.runCommand("Execution", stepName);
}
- public ArrayList<String> getTabs() {
+ @Override
+ public ArrayList<String> getTabs() {
ArrayList<String> requiredTabs = super.getTabs();
requiredTabs.add("Properties");
@@ -99,12 +101,12 @@ public class NodeItem extends NodeEntity { String collNames = myEntity.queryData(ClusterStorage.COLLECTION+"/all");
if (collNames.length() > 0)
requiredTabs.add("Collection");
- } catch (Exception e) { }
+ } catch (Exception e) { }
requiredTabs.add("Execution");
requiredTabs.add("History");
requiredTabs.add("Viewpoint");
requiredTabs.add("Workflow");
return requiredTabs;
-
+
}
}
diff --git a/source/com/c2kernel/gui/data/NodeSubscriber.java b/source/com/c2kernel/gui/data/NodeSubscriber.java index ae2ab44..70af660 100755..100644 --- a/source/com/c2kernel/gui/data/NodeSubscriber.java +++ b/source/com/c2kernel/gui/data/NodeSubscriber.java @@ -8,6 +8,6 @@ public interface NodeSubscriber { public void add(Node newNode);
public void remove(Path path);
-
+
public void end(boolean more);
}
|
