1 4 package org.oddjob.designer.model; 5 6 import org.oddjob.designer.arooa.DesignIH; 7 8 12 public class SingleTypeSelection implements DesignDefinition { 13 14 private final String heading; 15 private final DesignElementType designElement; 16 17 public SingleTypeSelection(String heading, DesignElementType de) { 18 this.heading = heading; 19 this.designElement = de; 20 21 } 22 23 public String getTitle() { 24 return heading; 25 } 26 27 public String [] getOptions() { 28 return designElement.supportedTypes(); 29 } 30 31 public String getSelected() { 32 if (designElement.childCount() == 0) { 33 return null; 34 } 35 return designElement.children(0).type(); 36 } 37 38 public void setSelected(String type) { 39 String oldType = ""; 40 if (designElement.childCount() > 0) { 41 oldType = designElement.children(0).type(); 42 } 43 if (!"".equals(oldType) && !oldType.equals(type)) { 44 designElement.removeChild(0); 45 } 46 if (!"".equals(type) && !oldType.equals(type)) { 47 DesignElementType newChild = designElement.createType(type); 48 designElement.addChild(newChild); 49 } 50 } 51 52 public DesignElementType getChildDesignElement() { 53 if (designElement.childCount() > 0) { 54 return designElement.children()[0]; 55 } 56 return null; 57 } 58 59 62 public void accept(DesignProcessor processor) { 63 processor.onSingleTypeSelection(this); 64 } 65 66 69 public boolean isPopulated() { 70 DesignIH dih = DesignIH.getHelper(designElement.getClass()); 71 return dih.hasDetailData(designElement); 72 } 73 } 74 | Popular Tags |