KickJava   Java API By Example, From Geeks To Geeks.

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


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  * DesignPatternEditor.java
22  *
23  */

24
25 package org.netbeans.modules.xml.schema.abe.nodes.properties;
26
27 import java.beans.PropertyEditorSupport JavaDoc;
28 import org.netbeans.modules.xml.axi.SchemaGenerator;
29 import org.netbeans.modules.xml.schema.abe.wizard.SchemaTransformPatternSelectionUI;
30 import org.netbeans.modules.xml.schema.model.Form;
31 import org.openide.util.NbBundle;
32
33 /**
34  *
35  * @author Ayub Khan
36  * "russianDoll", "salamiSlice", "venitianBlind", "gardenofEden", Empty (Default for Schema)
37  *
38  */

39 public class DesignPatternEditor extends PropertyEditorSupport JavaDoc{
40
41     /**
42      * Creates a new instance of FormPropertyEditor
43      */

44     public DesignPatternEditor() {
45     }
46
47     public String JavaDoc[] getTags() {
48         return new String JavaDoc[] {getAsText(),
49             NbBundle.getMessage(DesignPatternEditor.class,getEmptyLabel())};
50     }
51     
52     public void setAsText(String JavaDoc text) throws IllegalArgumentException JavaDoc {
53         if (text.equals(NbBundle.getMessage(DesignPatternEditor.class,getEmptyLabel()))){
54             setValue(null);
55         } else if (text.equals(NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_russianDoll"))){
56             setValue(SchemaGenerator.Pattern.RUSSIAN_DOLL);
57         } else if (text.equals(NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_salamiSlice"))){
58             setValue(SchemaGenerator.Pattern.SALAMI_SLICE);
59         } else if (text.equals(NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_venetianBlind"))){
60             setValue(SchemaGenerator.Pattern.VENITIAN_BLIND);
61         } else if (text.equals(NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_gardenOfEden"))){
62             setValue(SchemaGenerator.Pattern.GARDEN_OF_EDEN);
63         }
64     }
65     
66     public String JavaDoc getAsText() {
67         Object JavaDoc val = getValue();
68         if (val instanceof SchemaGenerator.Pattern){
69             if (SchemaGenerator.Pattern.RUSSIAN_DOLL.equals(val)) {
70                 return NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_russianDoll");
71             } else if (SchemaGenerator.Pattern.SALAMI_SLICE.equals(val)) {
72                 return NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_salamiSlice");
73             } else if (SchemaGenerator.Pattern.VENITIAN_BLIND.equals(val)) {
74                 return NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_venetianBlind");
75             } else if (SchemaGenerator.Pattern.GARDEN_OF_EDEN.equals(val)) {
76                 return NbBundle.getMessage(SchemaTransformPatternSelectionUI.class,"LBL_SchemaTransform_gardenOfEden");
77             }
78         }
79         // TODO how to display invalid values?
80
return NbBundle.getMessage(DesignPatternEditor.class,getEmptyLabel());
81     }
82     
83     protected String JavaDoc getEmptyLabel() {
84         return "LBL_SchemaTransform_Select_DesignPattern";
85     }
86 }
87
Popular Tags