KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > elements > StartMode


1 /* StartMode.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.xml.elements;
12
13 import org.enhydra.jawe.xml.*;
14 import org.enhydra.jawe.xml.panels.*;
15 import org.w3c.dom.*;
16
17 /**
18 * Represents a WfMC DTD element that has the similar name.
19 *
20 * @see XML
21 */

22 public class StartMode extends XMLComplexElement {
23
24    private boolean fromXMLExecuted=false;
25
26    private XMLComplexChoice refMode=new XMLComplexChoice(name,
27       new XMLElement[] {
28          new Empty(),
29          new Automatic(),
30          new Manual()
31       },1) {
32          public XMLPanel getPanel () {
33             return new XMLComboPanel(this);
34          }
35       };
36
37    /**
38    * Creates a new instance of the class.
39    */

40    public StartMode () {
41       super();
42
43       fillStructure ();
44    }
45
46    /**
47    * Defines the super-class method. Read the explanation for
48    * this method within XMLComplexElement class.
49    */

50    protected void fillStructure () {
51       //refMode.setRequired(true);
52
complexStructure.add(refMode);
53    }
54
55    public void fromXML(Node node) {
56       fromXMLExecuted=true;
57       refMode.setValue(refMode.getChoices()[0]);
58       super.fromXML(node);
59    }
60
61    protected void afterImporting () {
62       if (!fromXMLExecuted) {
63          refMode.setValue(refMode.getChoices()[0]);
64       }
65    }
66
67    /**
68    * The start mode is empty if user didn't select Automatic or Manual.
69    */

70    public boolean isEmpty() {
71       return (refMode.getChoosen() instanceof Empty);
72    }
73
74    /**
75    * Overrides the super class method to return the value
76    * of the choosen mode.
77    *
78    * @return The value of choosen start mode.
79    */

80    public Object JavaDoc toValue () {
81       return refMode.toValue();
82    }
83
84    /**
85    * Overrides super-class method to retreive the choosen
86    * mode.
87    * This is used when displaying instance of this class
88    * within combo box.
89    *
90    * @return The type of starting mode.
91    */

92    public String JavaDoc toString () {
93       return refMode.toString();
94    }
95
96    /**
97    * Prepares the panel with a combo box to choose the one of
98    * allowed start modes.
99    *
100    * @return XMLPanel to be shown.
101    */

102    public XMLPanel getPanel () {
103       return refMode.getPanel();
104    }
105
106    /**
107    * Used to create exact copy of instance of this class.
108    * The newly created instance will have all the properties
109    * same as the copied one.
110    *
111    * @return The newly created instance of this class.
112    */

113    public Object JavaDoc clone () {
114       StartMode sm=(StartMode)super.clone();
115
116       sm.refMode=(XMLComplexChoice)this.refMode.clone();
117       sm.fillStructure();
118
119       return sm;
120    }
121
122 }
123
Popular Tags