summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/gui/tree/NodeItem.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-05-07 17:33:57 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-05-07 17:33:57 +0200
commit21230edbafdd30fcf0c43d1dc64ccbf4ca5e06a8 (patch)
treeb2908dbea534ca8d96a81ab922501769d4b70c4d /src/main/java/com/c2kernel/gui/tree/NodeItem.java
parent75bf1278296d33a7d9b6c01660a2f21e2d40d995 (diff)
Agent now extends Item, so they can have workflows. All traces of the
old 'Entity' superclasses should be removed, including proxies and paths. Very large change, breaks API compatibility with CRISTAL 2.x.
Diffstat (limited to 'src/main/java/com/c2kernel/gui/tree/NodeItem.java')
-rw-r--r--src/main/java/com/c2kernel/gui/tree/NodeItem.java93
1 files changed, 72 insertions, 21 deletions
diff --git a/src/main/java/com/c2kernel/gui/tree/NodeItem.java b/src/main/java/com/c2kernel/gui/tree/NodeItem.java
index 18d35be..9cdfc5a 100644
--- a/src/main/java/com/c2kernel/gui/tree/NodeItem.java
+++ b/src/main/java/com/c2kernel/gui/tree/NodeItem.java
@@ -15,13 +15,16 @@ import javax.swing.JPopupMenu;
import com.c2kernel.collection.Aggregation;
import com.c2kernel.collection.Collection;
import com.c2kernel.collection.CollectionMember;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.agent.Job;
import com.c2kernel.entity.proxy.ItemProxy;
-import com.c2kernel.gui.EntityDetails;
-import com.c2kernel.gui.EntityTabManager;
+import com.c2kernel.gui.ItemDetails;
+import com.c2kernel.gui.ItemTabManager;
import com.c2kernel.gui.MainFrame;
import com.c2kernel.lookup.Path;
import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.Language;
import com.c2kernel.utils.Logger;
/**
@@ -29,8 +32,57 @@ import com.c2kernel.utils.Logger;
* @author $Author: abranson $
* @version $Version$
*/
-public class NodeItem extends NodeEntity implements Transferable {
+public class NodeItem extends Node implements Transferable {
+ protected ItemProxy myItem = null;
+
+ public NodeItem(Path path, ItemTabManager desktop) {
+
+ super(path, desktop);
+ Logger.msg(2,"NodeEntity.<init> - Creating item for '"+path.toString()+"'.");
+
+ // if an item - resolve the item and get its properties
+ try {
+ myItem = Gateway.getProxyManager().getProxy(path);
+ this.sysKey = path.getSysKey();
+ Logger.msg(2,"NodeEntity.<init> - System key is "+this.sysKey);
+
+ // Name should be the alias if present
+ String alias = myItem.getName();
+ if (alias != null) this.name = alias;
+
+ try {
+ this.type = myItem.getProperty("Type");
+ } catch (ObjectNotFoundException e) {
+ this.type = "";
+ }
+ String iconString = this.type;
+ if (type.equals("ActivityDesc"))
+ try {
+ iconString = myItem.getProperty("Complexity")+iconString;
+ } catch (ObjectNotFoundException e) {
+ iconString = "error";
+ }
+ iconString = iconString.toLowerCase();
+ this.setIcon(iconString);
+ } catch (ObjectNotFoundException e1) {
+ this.sysKey = -1;
+ this.type="Error";
+ this.name="Entity not found";
+ this.setIcon("error");
+ }
+ createTreeNode();
+ makeExpandable();
+ }
+
+ public ItemProxy getItem() {
+ return myItem;
+ }
+
+ public void openItem() {
+ desktop.add(this);
+ }
+
public Collection<? extends CollectionMember> getParentCollection() {
return parentCollection;
}
@@ -49,16 +101,6 @@ public class NodeItem extends NodeEntity implements Transferable {
DataFlavor.getTextPlainUnicodeFlavor() };
- public NodeItem(Path path, EntityTabManager desktop) {
- super(path, desktop);
- try {
- makeExpandable();
- } catch (Exception e) {
- Logger.error(e);
- }
-
- }
-
public void setCollection(Collection<? extends CollectionMember> parentCollection, Integer slotNo, ItemProxy parentItem) {
this.parentCollection = parentCollection;
this.slotNo = slotNo;
@@ -68,10 +110,10 @@ public class NodeItem extends NodeEntity implements Transferable {
@Override
public void loadChildren() {
try {
- String collections = myEntity.queryData("Collection/all");
+ String collections = myItem.queryData("Collection/all");
StringTokenizer tok = new StringTokenizer(collections, ",");
while (tok.hasMoreTokens()) {
- NodeCollection newCollection = new NodeCollection((ItemProxy)myEntity, tok.nextToken(), desktop);
+ NodeCollection newCollection = new NodeCollection(myItem, tok.nextToken(), desktop);
add(newCollection);
}
end(false);
@@ -82,7 +124,17 @@ public class NodeItem extends NodeEntity implements Transferable {
@Override
public JPopupMenu getPopupMenu() {
- JPopupMenu popup = super.getPopupMenu();
+
+ JPopupMenu popup = super.getPopupMenu();
+ JMenuItem openItem = new JMenuItem(Language.translate("Open"));
+ openItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ openItem();
+ }
+ });
+ popup.addSeparator();
+ popup.add(openItem);
popup.addSeparator();
if (parentCollection != null && MainFrame.isAdmin) {
JMenuItem collMenuItem = new JMenuItem("Remove from collection");
@@ -104,7 +156,7 @@ public class NodeItem extends NodeEntity implements Transferable {
popup.addSeparator();
}
try {
- ArrayList<Job> jobList = ((ItemProxy)myEntity).getJobList(MainFrame.userAgent);
+ ArrayList<Job> jobList = myItem.getJobList(MainFrame.userAgent);
ArrayList<String> already = new ArrayList<String>();
if (jobList.size() > 0) {
for (Job thisJob : jobList) {
@@ -139,17 +191,16 @@ public class NodeItem extends NodeEntity implements Transferable {
}
public void execute(String stepName) {
- EntityDetails thisDetail = desktop.add(this);
+ ItemDetails thisDetail = desktop.add(this);
thisDetail.runCommand("Execution", stepName);
}
- @Override
public ArrayList<String> getTabs() {
- ArrayList<String> requiredTabs = super.getTabs();
+ ArrayList<String> requiredTabs = new ArrayList<String>();
requiredTabs.add("Properties");
try {
- String collNames = myEntity.queryData(ClusterStorage.COLLECTION+"/all");
+ String collNames = myItem.queryData(ClusterStorage.COLLECTION+"/all");
if (collNames.length() > 0)
requiredTabs.add("Collection");
} catch (Exception e) { }