KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > api > property > PartsSelectorPropertyEditor


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.wsdl.ui.api.property;
21
22 import java.awt.Component JavaDoc;
23 import java.beans.FeatureDescriptor JavaDoc;
24 import java.beans.PropertyChangeEvent JavaDoc;
25 import java.beans.PropertyChangeListener JavaDoc;
26 import java.beans.PropertyEditorSupport JavaDoc;
27
28 import org.openide.explorer.propertysheet.ExPropertyEditor;
29 import org.openide.explorer.propertysheet.PropertyEnv;
30
31 /**
32  *
33  * @author radval
34  *
35  */

36 public class PartsSelectorPropertyEditor extends PropertyEditorSupport JavaDoc implements ExPropertyEditor, PropertyChangeListener JavaDoc {
37
38     /** property name used by propertyChangeEvent */
39     protected static final String JavaDoc PROP_NAME = "parts";// NOI18N
40

41     /** Environment passed to the ExPropertyEditor*/
42     private PropertyEnv env;
43     
44     private String JavaDoc[] parts;
45     private String JavaDoc[] selectedPartNames;
46     
47     public PartsSelectorPropertyEditor(String JavaDoc[] parts, String JavaDoc spaceSeperatedPartNames) {
48         this.parts = parts;
49         selectedPartNames = spaceSeperatedPartNames.split(" ");
50     }
51     
52     /**
53      * This method is called by the IDE to pass
54      * the environment to the property editor.
55      * @param env Environment passed by the ide.
56      */

57     public void attachEnv(PropertyEnv ev) {
58         this.env = ev;
59         FeatureDescriptor JavaDoc desc = env.getFeatureDescriptor();
60         // make this is not editable
61
desc.setValue("canEditAsText", Boolean.FALSE); // NOI18N
62
}
63     
64     
65     
66     
67     /* (non-Javadoc)
68      * @see java.beans.PropertyEditorSupport#getAsText()
69      */

70     @Override JavaDoc
71     public String JavaDoc getAsText() {
72         if (getValue() == null) return "";
73         return super.getAsText();
74     }
75
76     /** @return tags */
77     @Override JavaDoc
78     public String JavaDoc[] getTags() {
79         return null;
80     }
81     
82     /** @return true */
83     @Override JavaDoc
84     public boolean supportsCustomEditor () {
85         return true;
86     }
87     
88     /** @return editor component */
89     @Override JavaDoc
90     public Component JavaDoc getCustomEditor () {
91         PartsSelectorPanel editor = new PartsSelectorPanel(parts, selectedPartNames, env);
92         editor.addPropertyChangeListener(PROP_NAME, this);
93         return editor;
94     }
95     /** handles property change
96      *
97      * @param evt propertyChangeEvent
98      */

99     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
100         setValue(evt.getNewValue());
101     }
102 }
103
104
Popular Tags