1 4 package org.oddjob.designer.components; 5 6 import java.awt.Component ; 7 8 import org.oddjob.designer.elements.ScheduleDE; 9 import org.oddjob.designer.factory.DesignFactory; 10 import org.oddjob.designer.factory.SimpleHierarchy; 11 import org.oddjob.designer.model.ComponentAction; 12 import org.oddjob.designer.model.ComponentElement; 13 import org.oddjob.designer.model.DesignComponent; 14 import org.oddjob.designer.model.ElementField; 15 import org.oddjob.designer.model.FieldGroup; 16 import org.oddjob.designer.model.FormDefinition; 17 import org.oddjob.designer.model.StandardForm; 18 import org.oddjob.designer.model.TransferComponentAction; 19 20 23 public class RepeatDC extends StructuralDC { 24 25 private Component mainForm; 26 27 private ScheduleDE schedule = new ScheduleDE(); 28 private ScheduleDE retry = new ScheduleDE(); 29 30 private DesignComponent child; 31 private DesignComponent exception; 32 33 public FormDefinition form() { 34 return new StandardForm(tag()) 35 .addGroup(basePanel()) 36 .addGroup( 37 new FieldGroup("Schedule Details") 38 .add(new ElementField("Schedule", schedule)) 39 .add(new ElementField("Retry", retry))); 40 } 41 42 public SimpleHierarchy availableActions() { 43 return new SimpleHierarchy(ComponentAction.class) 44 .addHierarchy(DesignFactory.childActions(this, "child").setName("Set Child")) 45 .addHierarchy(DesignFactory.childActions(this, "exception").setName("Set Exception")); 46 } 47 48 51 public ComponentAction[] transferActions(String xml) { 52 return new ComponentAction[] { 53 new TransferComponentAction(this, xml, "Set Child", "child"), 54 new TransferComponentAction(this, xml, "Set Exception", "exception") 55 }; 56 } 57 58 public void deleteChild(DesignComponent child) { 59 if (child == this.child) { 60 this.child = null; 61 } 62 if (child == exception) { 63 exception = null; 64 } 65 super.deleteChild(child); 66 } 67 68 public void addComponentChild(DesignComponent child) { 69 childHelper.removeAllChildren(); 70 this.child = child; 71 childHelper.addChild(child); 72 if (exception != null) { 73 childHelper.addChild(exception); 74 } 75 } 76 77 public Object elementChild() { 78 return ComponentElement.createNested(child); 79 } 80 81 public void addComponentException(DesignComponent exception) { 82 if (this.exception != null) { 83 childHelper.removeChild(this.exception); 84 } 85 this.exception = exception; 86 childHelper.addChild(exception); 87 } 88 89 public Object elementException() { 90 return ComponentElement.createNested(exception); 91 } 92 93 public void setSchedule(ScheduleDE schedule) { 94 this.schedule = schedule; 95 } 96 97 public ScheduleDE getSchedule() { 98 return schedule; 99 } 100 101 public void setRetry(ScheduleDE schedule) { 102 this.retry = schedule; 103 } 104 105 public ScheduleDE getRetry() { 106 return retry; 107 } 108 109 } 110 | Popular Tags |