KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* RedefinableHeader.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 import javax.swing.*;
17 import javax.swing.tree.*;
18
19 /**
20 * Represents a WfMC DTD element that has the similar name.
21 *
22 * @see XML
23 */

24 public class RedefinableHeader extends XMLComplexElement {
25    private transient XMLElement myOwner=null;
26
27    private Author refAuthor=new Author(); // min=0
28
private Version refVersion=new Version(); // min=0
29
private Codepage refCodepage=new Codepage(); // min=0
30
private Countrykey refCountrykey=new Countrykey(); // min=0
31
private Responsibles refResponsibles; // min=0
32

33    /** Enables canceling of changes to the responsible collection. */
34    private Responsibles clonedResps;
35
36    private boolean fromXMLExecuted=false;
37
38    private XMLAttribute attrPublicationStatus=new XMLAttribute("PublicationStatus",
39       new String JavaDoc[] {
40          "",
41          "UNDER_REVISION",
42          "RELEASED",
43          "UNDER_TEST"
44       },3);
45
46    /**
47    * Creates a new instance of the class.
48    *
49    */

50    public RedefinableHeader (XMLComplexElement packageOrWProcess) {
51       super();
52
53       refResponsibles=new Responsibles(packageOrWProcess);
54       fillStructure ();
55    }
56
57    /**
58    * Defines the super-class method. Read the explanation for
59    * this method within XMLComplexElement class.
60    */

61    protected void fillStructure () {
62       complexStructure.add(attrPublicationStatus);
63       attributes.add(attrPublicationStatus);
64       complexStructure.add(refAuthor);
65       complexStructure.add(refVersion);
66       complexStructure.add(refCodepage);
67       complexStructure.add(refCountrykey);
68       complexStructure.add(refResponsibles);
69    }
70
71    /**
72    * Overrides super-class method to realize this class specific
73    * writting to XML file.
74    *
75    * @return The string for a WfMC DTD RedefinableHeader element tag.
76    */

77    public void toXML (Node parent) throws DOMException {
78       super.toXML(parent);
79    }
80
81    public void fromXML (Node node) {
82       fromXMLExecuted=true;
83       attrPublicationStatus.setValue("");
84       super.fromXML(node);
85    }
86
87    protected void afterImporting () {
88       // adjusting responsibles of package
89
refResponsibles.afterImporting();
90       if (!fromXMLExecuted) {
91          attrPublicationStatus.setValue("");
92       }
93    }
94
95   /**
96    * Uses a trick to set the cloned instance of responsibles to
97    * be edited, so that canceling of changes to the responsible
98    * collection can be handled - the real instance of responsibles
99    * is set to the cloned instance within the isValidData method.
100    */

101    public XMLPanel getPanel () {
102       complexStructure.remove(refResponsibles);
103       clonedResps=(Responsibles)refResponsibles.clone();
104       complexStructure.add(5,clonedResps);
105       XMLPanel p=super.getPanel();
106       complexStructure.remove(clonedResps);
107       complexStructure.add(5,refResponsibles);
108       return p;
109    }
110
111    /**
112     * This method is called only if user doesn't press Cancel button
113     * within the dialog for editing RedefinableHeader properties, so
114     * the changes to the real collection of Responsibles are applied here.
115     * @param groupPanel The panel for editing parameters.
116     * @return always returns <tt>true</tt>.
117     */

118    public boolean isValidEnter( XMLPanel groupPanel ) {
119       // replace responsibles with the one entered
120
if ( clonedResps != null ) {
121          complexStructure.remove( refResponsibles );
122          refResponsibles = clonedResps;
123          complexStructure.add( 5, refResponsibles );
124       }
125
126       return true;
127    }
128
129 }
130
Popular Tags