diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-07-30 16:54:59 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-07-30 16:54:59 +0200 |
| commit | 8c272e0261686302e86849ad86ae8fa393d9e95e (patch) | |
| tree | a6da6535ac8a5654491e63bd0920119b03b5b26c /src | |
| parent | 5209536cdc57f462cc2f031a17d881fe103218b4 (diff) | |
Constructor crashed when the item had no Type property
Fixes #54
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/com/c2kernel/gui/tree/NodeEntity.java | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/main/java/com/c2kernel/gui/tree/NodeEntity.java b/src/main/java/com/c2kernel/gui/tree/NodeEntity.java index bc16a6c..aa425d6 100644 --- a/src/main/java/com/c2kernel/gui/tree/NodeEntity.java +++ b/src/main/java/com/c2kernel/gui/tree/NodeEntity.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.proxy.EntityProxy;
import com.c2kernel.gui.EntityTabManager;
import com.c2kernel.lookup.Path;
@@ -28,26 +29,37 @@ public abstract class NodeEntity extends Node { super(path, desktop);
Logger.msg(2,"NodeEntity.<init> - Creating item for '"+path.toString()+"'.");
- try {
- // if an item - resolve the item and get its properties
+ // if an item - resolve the item and get its properties
+ try {
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);
- }
+ 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;
+
+ try {
+ this.type = myEntity.getProperty("Type");
+ } catch (ObjectNotFoundException e) {
+ this.type = "";
+ }
+ String iconString = this.type;
+ if (type.equals("ActivityDesc"))
+ try {
+ iconString = myEntity.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();
}
public EntityProxy getEntity() {
|
