1 4 package org.oddjob.designer.components; 5 6 import java.awt.Component ; 7 8 import org.oddjob.Structural; 9 import org.oddjob.designer.arooa.ElementWrapper; 10 import org.oddjob.designer.elements.SimpleDE; 11 import org.oddjob.designer.factory.DesignFactory; 12 import org.oddjob.designer.factory.SimpleHierarchy; 13 import org.oddjob.designer.model.ComponentAction; 14 import org.oddjob.designer.model.DesignComponent; 15 import org.oddjob.designer.model.ElementField; 16 import org.oddjob.designer.model.FieldGroup; 17 import org.oddjob.designer.model.FormDefinition; 18 import org.oddjob.designer.model.StandardForm; 19 import org.oddjob.designer.model.StructuralDesignComponent; 20 import org.oddjob.designer.model.TransferComponentAction; 21 import org.oddjob.structural.ChildHelper; 22 import org.oddjob.structural.StructuralListener; 23 24 28 public final class RootDC 29 implements Structural, StructuralDesignComponent { 30 31 private SimpleDE idField = new SimpleDE(); 32 33 private Component mainForm; 34 35 private transient ChildHelper childHelper = new ChildHelper(this); 36 37 40 public SimpleDE getId() { 41 return idField; 42 } 43 46 public void setId(SimpleDE id) { 47 this.idField = id; 48 } 49 50 55 public void addStructuralListener(StructuralListener listener) { 56 childHelper.addStructuralListener(listener); 57 } 58 59 64 public void removeStructuralListener(StructuralListener listener) { 65 childHelper.removeStructuralListener(listener); 66 } 67 68 public void deleteChild(DesignComponent child) { 69 childHelper.removeChild(child); 70 } 71 72 75 public void replaceChild(DesignComponent child, DesignComponent replacement) { 76 childHelper.replaceChild(child, replacement); 77 } 78 79 public String name() { 80 return "Oddjob"; 81 } 82 83 public void name(String name) { 84 throw new UnsupportedOperationException ("Root can't have name set!"); 85 } 86 87 public String tag() { 88 return "oddjob"; 89 } 90 91 public void tag(String tag) { 92 throw new UnsupportedOperationException ("Root can't have tag set!"); 93 } 94 95 public FormDefinition form() { 96 return new StandardForm(tag()) 97 .addGroup( 98 new FieldGroup("General") 99 .add(new ElementField("Id", idField))); 100 } 101 102 public ElementWrapper[] elements() { 103 Object [] children = childHelper.getChildren(); 104 ElementWrapper[] results = new ElementWrapper[children.length]; 105 for (int i = 0; i < children.length; ++i) { 106 DesignComponent dc = (DesignComponent) children[i]; 107 ElementWrapper wrapper = new ElementWrapper( 108 dc.tag(), dc); 109 results[i] = wrapper; 110 } 111 return results; 112 } 113 114 public SimpleHierarchy availableActions() { 115 return new SimpleHierarchy(ComponentAction.class) 116 .addHierarchy(DesignFactory.childActions(this, "").setName("Set Job")); 117 } 118 119 122 public ComponentAction[] transferActions(String xml) { 123 return new ComponentAction[] { 124 new TransferComponentAction(this, xml, "Set Job", "") 125 }; 126 } 127 128 public void addComponent(Object child) { 129 childHelper.removeAllChildren(); 130 childHelper.addChild(child); 131 } 132 133 } 134 | Popular Tags |