From 8c272e0261686302e86849ad86ae8fa393d9e95e Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 30 Jul 2012 16:54:59 +0200 Subject: Constructor crashed when the item had no Type property Fixes #54 --- .../java/com/c2kernel/gui/tree/NodeEntity.java | 50 ++++++++++++++-------- 1 file 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. - 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. - 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. - "+sysKey+" failed to resolve:"); - Logger.error(e); - } + this.sysKey = path.getSysKey(); + Logger.msg(2,"NodeEntity. - 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() { -- cgit v1.2.3