1 4 package org.oddjob.designer.model; 5 6 import java.util.Observable ; 7 import java.util.Observer ; 8 9 import org.oddjob.arooa.reflect.IntrospectionHelper; 10 import org.oddjob.designer.arooa.DesignIH; 11 import org.oddjob.designer.elements.simple.SimpleTextAttribute; 12 13 14 15 22 abstract public class DesignElementType extends DesignAdult 23 implements DesignElement { 24 25 protected Observer detailObserver = new Observer () { 26 public void update(Observable o, Object arg) { 27 setChanged(); 28 notifyObservers(DEObservable.detailChanged(o)); 29 }; 30 }; 31 32 37 private SimpleTextAttribute name; 38 39 44 private String type; 45 46 49 public DesignElementType() { 50 setName(new SimpleTextAttribute()); 51 } 52 53 59 public void type(String type) { 60 this.type = type; 61 } 62 63 68 public String type() { 69 return type; 70 } 71 72 77 public void setName(SimpleTextAttribute name) { 78 name.addObserver(detailObserver); 79 this.name = name; 80 } 81 82 87 public SimpleTextAttribute getName() { 88 return name; 89 } 90 91 public boolean hasDetail() { 92 try { 93 getClass().getDeclaredMethod("detail", new Class [0]); 94 return true; 95 } catch (NoSuchMethodException e) { 96 return false; 97 } 98 } 99 100 106 public DesignDefinition detail() { 107 throw new IllegalStateException ("Check hasDetail first!"); 108 } 109 110 114 public void clear() { 115 name.clear(); 116 clearChildren(); 117 } 118 } 119 | Popular Tags |