KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* EnumerationValue.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 javax.swing.*;
14
15 import org.enhydra.jawe.xml.*;
16 import org.enhydra.jawe.xml.panels.*;
17
18 /**
19 * Represents a WfMC DTD element that has the similar name.
20 *
21 * @see XML
22 */

23 public class EnumerationValue extends XMLComplexElement {
24    private XMLAttribute attrName=new XMLAttribute("Name"); // required
25

26    /**
27    * Creates a new instance of the class.
28    */

29    public EnumerationValue () {
30       super();
31
32       fillStructure();
33    }
34
35    /**
36    * Defines the super-class method. Read the explanation for
37    * this method within XMLComplexElement class.
38    */

39    protected void fillStructure () {
40       attrName.setRequired(true);
41       complexStructure.add(attrName);
42       attributes.add(attrName);
43    }
44
45    /**
46    * Overrides the super class method to return the value
47    * of it's "Name" attribute value.
48    *
49    * @return The value of this class "Name" attribute.
50    */

51    public Object JavaDoc toValue () {
52       return attrName.toValue();
53    }
54
55    /**
56    * Overrides super-class method to retreive the value
57    * of this class "Name" attribute.
58    * This is used when displaying instance of this class
59    * within dialog.
60    *
61    * @return The "Name" attribute value of this class.
62    */

63    public String JavaDoc toString () {
64       return attrName.toString();
65    }
66
67    /**
68     * This method checks if the value of the name attribute is valid.
69     */

70    public boolean isValidEnter (XMLPanel p) {
71       XMLGroupPanel gp=(XMLGroupPanel)p;
72       try {
73          XMLTextPanel tp=(XMLTextPanel)gp.getPanel(0);
74          String JavaDoc nameToCheck=tp.getText();
75          if (!XMLCollection.isIdValid(nameToCheck)) {
76             String JavaDoc message=XMLUtil.getLanguageDependentString("ErrorValueIsNotValid");
77             String JavaDoc dialogTitle=XMLUtil.getLanguageDependentString("Title");
78             XMLPanel.errorMessage(p.getDialog(),dialogTitle,attrName.toLabel()+": ",message);
79             ((JTextField)tp.getComponent(2)).requestFocus();
80             return false;
81          }
82       } catch (Exception JavaDoc ex){}
83
84       return true;
85    }
86
87 }
88
Popular Tags