KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* FinishMode.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 FinishMode 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    /**
39    * Creates a new instance of the class.
40    */

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

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

71    public boolean isEmpty() {
72       return (refMode.getChoosen() instanceof Empty);
73    }
74
75    /**
76    * Prepares the panel with a combo box to choose the one of
77    * allowed finish modes.
78    *
79    * @return XMLPanel to be shown.
80    */

81    public XMLPanel getPanel () {
82       return refMode.getPanel();
83    }
84
85    /**
86    * Overrides the super class method to return the value
87    * of the choosen mode.
88    *
89    * @return The value of choosen finish mode.
90    */

91    public Object JavaDoc toValue () {
92       return refMode.toValue();
93    }
94
95    /**
96    * Overrides super-class method to retreive the choosen
97    * mode.
98    * This is used when displaying instance of this class
99    * within combo box.
100    *
101    * @return The type of finishing mode.
102    */

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

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