KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > nodes > properties > ProcessContentsEditor


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 package org.netbeans.modules.xml.schema.abe.nodes.properties;
21
22 import org.netbeans.modules.xml.schema.model.Any.ProcessContents;
23 import java.beans.PropertyEditorSupport JavaDoc;
24 import org.openide.util.NbBundle;
25
26 /**
27  *
28  * @author Ajit Bhate
29  * "Lax", "Skip", "Strict", Empty
30  *
31  */

32 public class ProcessContentsEditor extends PropertyEditorSupport JavaDoc{
33
34     /**
35      * Creates a new instance of ProcessContentsEditor
36      */

37     public ProcessContentsEditor() {
38     }
39     
40     public String JavaDoc[] getTags() {
41         return new String JavaDoc[] {NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_EmptyProcessContents"),
42             NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Lax"),
43             NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Skip"),
44             NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Strict")};
45     }
46     
47     public void setAsText(String JavaDoc text) throws IllegalArgumentException JavaDoc {
48         if (text.equals(NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_EmptyProcessContents"))){
49             setValue(null);
50         } else if (text.equals(NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Lax"))){
51             setValue(ProcessContents.LAX);
52         } else if (text.equals(NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Skip"))){
53             setValue(ProcessContents.SKIP);
54         } else if (text.equals(NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Strict"))){
55             setValue(ProcessContents.STRICT);
56         }
57     }
58     
59     public String JavaDoc getAsText() {
60         Object JavaDoc val = getValue();
61         if (val instanceof ProcessContents){
62             if (ProcessContents.LAX.equals(val)) {
63                 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Lax");
64             } else if (ProcessContents.SKIP.equals(val)) {
65                 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Skip");
66             } else if (ProcessContents.STRICT.equals(val)) {
67                 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Strict");
68             }
69         }
70         // TODO how to display invalid values?
71
return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_EmptyProcessContents");
72     }
73     
74 }
75
Popular Tags