diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-06-26 12:41:11 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-06-26 12:41:11 +0200 |
| commit | 99eed1e3c7e7292aea91131baeb36f81e23e3e82 (patch) | |
| tree | eb1afe9e57736bb1e9113ece476b9d8f0dcc7917 /src/main/java/com/c2kernel/gui/tree/NodeEntity.java | |
Initial refactor from kernel
Diffstat (limited to 'src/main/java/com/c2kernel/gui/tree/NodeEntity.java')
| -rw-r--r-- | src/main/java/com/c2kernel/gui/tree/NodeEntity.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/main/java/com/c2kernel/gui/tree/NodeEntity.java b/src/main/java/com/c2kernel/gui/tree/NodeEntity.java new file mode 100644 index 0000000..bc16a6c --- /dev/null +++ b/src/main/java/com/c2kernel/gui/tree/NodeEntity.java @@ -0,0 +1,82 @@ +package com.c2kernel.gui.tree;
+
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import com.c2kernel.entity.proxy.EntityProxy;
+import com.c2kernel.gui.EntityTabManager;
+import com.c2kernel.lookup.Path;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.Language;
+import com.c2kernel.utils.Logger;
+
+/**
+ * Structure for Item presence on the tree and ItemDetails boxes. Created by NodeFactory.
+ * @author $Author: abranson $
+ * @version $Version$
+ */
+public abstract class NodeEntity extends Node {
+
+ protected EntityProxy myEntity = null;
+
+ public NodeEntity(Path path, EntityTabManager desktop) {
+ super(path, desktop);
+ Logger.msg(2,"NodeEntity.<init> - Creating item for '"+path.toString()+"'.");
+
+ try {
+ // if an item - resolve the item and get its properties
+ myEntity = 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 = myEntity.getName();
+ if (alias != null) this.name = alias;
+
+ this.type = myEntity.getProperty("Type");
+ String iconString = this.type;
+ if (type.equals("ActivityDesc")) iconString = myEntity.getProperty("Complexity")+iconString;
+ iconString = iconString.toLowerCase();
+ this.setIcon(iconString);
+ createTreeNode();
+ } catch (Exception e) {
+ Logger.msg(2, "NodeEntity.<init> - "+sysKey+" failed to resolve:");
+ Logger.error(e);
+ }
+ }
+
+ public EntityProxy getEntity() {
+ return myEntity;
+ }
+ /**
+ *
+ */
+ @Override
+ public JPopupMenu 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);
+ return popup;
+ }
+
+ public void openItem() {
+ desktop.add(this);
+ }
+
+ public ArrayList<String> getTabs() {
+ ArrayList<String> requiredTabs = new ArrayList<String>();
+ return requiredTabs;
+ }
+}
|
