KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > tax > beans > editor > NullStringCustomEditor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.tax.beans.editor;
20
21 import javax.swing.JPanel JavaDoc;
22
23 import org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor;
24
25 /**
26  *
27  * @author Libor Kramolis
28  * @version
29  */

30 public class NullStringCustomEditor extends JPanel JavaDoc implements EnhancedCustomPropertyEditor {
31
32     /** Serial Version UID */
33     private static final long serialVersionUID =-7120244860529998751L;
34
35     //
36
// init
37
//
38

39     /** Creates new customizer NullStringCustomEditor */
40     public NullStringCustomEditor (NullStringEditor editor) {
41         initComponents ();
42
43         textArea.setText (editor.getAsText());
44         textArea.setEditable (editor.isEditable());
45         
46         initAccessibility();
47     }
48
49
50     //
51
// EnhancedCustomPropertyEditor
52
//
53

54     /**
55      * @return Returns the property value that is result of the CustomPropertyEditor.
56      * @exception InvalidStateException when the custom property editor does not represent valid property value
57      * (and thus it should not be set)
58      */

59     public Object JavaDoc getPropertyValue () throws IllegalStateException JavaDoc {
60     String JavaDoc text = textArea.getText();
61
62     if ( NullStringEditor.DEFAULT_NULL.equals (text) ) {
63         return null;
64     } else if ( text.length() == 0 ) {
65         return null;
66     } else {
67         return text;
68     }
69     }
70
71     //
72
// form
73
//
74

75     /** This method is called from within the constructor to
76      * initialize the form.
77      * WARNING: Do NOT modify this code. The content of this method is
78      * always regenerated by the FormEditor.
79      */

80     private void initComponents() {//GEN-BEGIN:initComponents
81
textAreaScroll = new javax.swing.JScrollPane JavaDoc();
82         textArea = new javax.swing.JTextArea JavaDoc();
83
84         setLayout(new java.awt.BorderLayout JavaDoc());
85
86         setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(6, 6, 6, 6)));
87         setPreferredSize(new java.awt.Dimension JavaDoc(350, 230));
88         textAreaScroll.setViewportView(textArea);
89
90         add(textAreaScroll, java.awt.BorderLayout.CENTER);
91
92     }//GEN-END:initComponents
93

94
95     // Variables declaration - do not modify//GEN-BEGIN:variables
96
private javax.swing.JTextArea JavaDoc textArea;
97     private javax.swing.JScrollPane JavaDoc textAreaScroll;
98     // End of variables declaration//GEN-END:variables
99

100    /** Initialize accesibility
101      */

102     public void initAccessibility(){
103         
104        this.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_NullStringCustomEditor"));
105        textArea.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_textArea"));
106     }
107 }
108
Popular Tags