KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > basic > editors > FormPropertyEditor


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * FormPropertyEditor.java
22  *
23  */

24
25 package org.netbeans.modules.xml.schema.ui.basic.editors;
26
27 import java.beans.PropertyEditorSupport JavaDoc;
28 import org.netbeans.modules.xml.schema.model.Form;
29 import org.openide.util.NbBundle;
30
31 /**
32  *
33  * @author Ajit Bhate
34  * "qualified", "unqualified", Empty (Default for Schema)
35  *
36  */

37 public class FormPropertyEditor extends PropertyEditorSupport JavaDoc{
38
39     /**
40      * Creates a new instance of FormPropertyEditor
41      */

42     public FormPropertyEditor() {
43     }
44
45     public String JavaDoc[] getTags() {
46         return new String JavaDoc[] {NbBundle.getMessage(FormPropertyEditor.class,getEmptyLabel()),
47             NbBundle.getMessage(FormPropertyEditor.class,"LBL_Qualified"),
48             NbBundle.getMessage(FormPropertyEditor.class,"LBL_Unqualified")};
49     }
50     
51     public void setAsText(String JavaDoc text) throws IllegalArgumentException JavaDoc {
52         if (text.equals(NbBundle.getMessage(FormPropertyEditor.class,getEmptyLabel()))){
53             setValue(null);
54         } else if (text.equals(NbBundle.getMessage(FormPropertyEditor.class,"LBL_Qualified"))){
55             setValue(Form.QUALIFIED);
56         } else if (text.equals(NbBundle.getMessage(FormPropertyEditor.class,"LBL_Unqualified"))){
57             setValue(Form.UNQUALIFIED);
58         }
59     }
60     
61     public String JavaDoc getAsText() {
62         Object JavaDoc val = getValue();
63         if (val instanceof Form){
64             if (Form.QUALIFIED.equals(val)) {
65                 return NbBundle.getMessage(FormPropertyEditor.class,"LBL_Qualified");
66             } else if (Form.UNQUALIFIED.equals(val)) {
67                 return NbBundle.getMessage(FormPropertyEditor.class,"LBL_Unqualified");
68             }
69         }
70         // TODO how to display invalid values?
71
return NbBundle.getMessage(FormPropertyEditor.class,getEmptyLabel());
72     }
73     
74     protected String JavaDoc getEmptyLabel() {
75         return "LBL_Empty";
76     }
77     
78     public static class SchemaFormPropertyEditor extends FormPropertyEditor{
79         /**
80          * Creates a new instance of SchemaFormPropertyEditor
81          */

82         public SchemaFormPropertyEditor() {
83         }
84     
85         protected String JavaDoc getEmptyLabel() {
86             return "LBL_EmptyForSchema";
87         }
88
89     }
90 }
91
Popular Tags