KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > components > StructuralDC


1 /*
2  * (c) Rob Gordon 2005.
3  */

4 package org.oddjob.designer.components;
5
6 import org.oddjob.Structural;
7 import org.oddjob.designer.arooa.ElementWrapper;
8 import org.oddjob.designer.model.DesignComponent;
9 import org.oddjob.designer.model.StructuralDesignComponent;
10 import org.oddjob.structural.ChildHelper;
11 import org.oddjob.structural.StructuralListener;
12
13 /**
14  * For DesignComponents to extend which have children.
15  */

16 abstract public class StructuralDC extends BaseDC
17 implements Structural, StructuralDesignComponent {
18
19     protected transient ChildHelper childHelper
20         = new ChildHelper(this);
21         
22     /* (non-Javadoc)
23      * @see org.oddjob.Structural#addStructuralListener(org.oddjob.structural.StructuralListener)
24      */

25     public void addStructuralListener(StructuralListener listener) {
26         childHelper.addStructuralListener(listener);
27     }
28
29     /* (non-Javadoc)
30      * @see org.oddjob.Structural#removeStructuralListener(org.oddjob.structural.StructuralListener)
31      */

32     public void removeStructuralListener(StructuralListener listener) {
33         childHelper.removeStructuralListener(listener);
34     }
35     
36     public void deleteChild(DesignComponent child) {
37         childHelper.removeChild(child);
38     }
39     
40     public void replaceChild(DesignComponent child, DesignComponent replacement) {
41         childHelper.replaceChild(child, replacement);
42     }
43
44     protected ElementWrapper[] childElements() {
45         Object JavaDoc[] children = childHelper.getChildren();
46         ElementWrapper[] results = new ElementWrapper[children.length];
47         for (int i = 0; i < children.length; ++i) {
48             DesignComponent dc = (DesignComponent) children[i];
49             ElementWrapper wrapper = new ElementWrapper(
50                     dc.tag(), dc);
51             results[i] = wrapper;
52         }
53         return results;
54     }
55 }
56
Popular Tags