KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > view > MultiTypeTableDummy


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

4 package org.oddjob.designer.view;
5
6 import org.oddjob.designer.elements.simple.SimpleTextAttribute;
7 import org.oddjob.designer.model.DesignDefinition;
8 import org.oddjob.designer.model.DesignElementType;
9 import org.oddjob.designer.model.MultiTypeTable;
10
11 public class MultiTypeTableDummy extends DummyView {
12
13     private MultiTypeTable multiTypeTable;
14     
15     public MultiTypeTableDummy(MultiTypeTable multiTypeTable) {
16         this.multiTypeTable = multiTypeTable;
17         DesignElementType de = (DesignElementType) multiTypeTable.getDesignElement();
18         DesignElementType[] children = de.children();
19         for (int i = 0; i < children.length; ++i) {
20             DesignDefinition designDefinition = children[i].detail();
21             inline(designDefinition);
22         }
23     }
24     
25     public DummyView create(String JavaDoc type) {
26         if (multiTypeTable.isNamed()) {
27             throw new RuntimeException JavaDoc("Table is named! supply a name.");
28         }
29         DesignElementType det = multiTypeTable.getDesignElement();
30         DesignElementType child = det.createType(type);
31         det.addChild(child);
32         return inline(child.detail());
33     }
34     
35     public DummyView create(String JavaDoc name, String JavaDoc type) {
36         if (multiTypeTable.isNamed()) {
37             throw new RuntimeException JavaDoc("Table isn't named! don't supply a name.");
38         }
39         DesignElementType det = multiTypeTable.getDesignElement();
40         DesignElementType child = det.createType(type);
41         SimpleTextAttribute elementName = new SimpleTextAttribute();
42         elementName.attribute(name);
43         child.setName(elementName);
44         det.addChild(child);
45         return inline(child.detail());
46     }
47 }
48
Popular Tags