KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > treeeditor > extension > bpel > PropertyNameProperty


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 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor.extension.bpel;
20
21 import java.beans.PropertyEditor JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.List JavaDoc;
25
26 import javax.xml.namespace.QName JavaDoc;
27
28 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
29 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
30 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.BPELQName;
31 import org.netbeans.modules.xml.wsdl.ui.api.property.ComboBoxPropertyEditor;
32 import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter;
33 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.Utility;
34 import org.netbeans.modules.xml.xam.ui.XAMUtils;
35 import org.openide.nodes.PropertySupport;
36
37 public class PropertyNameProperty extends PropertySupport.Reflection {
38
39     private static QName JavaDoc propertyQName = BPELQName.PROPERTY.getQName();
40     
41     ExtensibilityElementPropertyAdapter adapter;
42     
43     public PropertyNameProperty(ExtensibilityElementPropertyAdapter instance, Class JavaDoc valueType, String JavaDoc getter, String JavaDoc setter) throws NoSuchMethodException JavaDoc {
44         super(instance, valueType, getter, setter);
45         adapter = instance;
46     }
47     
48     
49     @Override JavaDoc
50     public PropertyEditor JavaDoc getPropertyEditor() {
51         ArrayList JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
52         list.add("");
53         WSDLModel model = adapter.getExtensibilityElement().getModel();
54         addToPropertyList(list, model);
55         
56         //Get from imported wsdls too.
57
Collection JavaDoc<WSDLModel> importedModels = Utility.getImportedDocuments(model);
58         for (WSDLModel imp : importedModels ) {
59             addToPropertyList(list, imp);
60         }
61         
62         return new ComboBoxPropertyEditor(list.toArray(new String JavaDoc[list.size()]));
63     }
64     
65     private void addToPropertyList(List JavaDoc<String JavaDoc> propertyList, WSDLModel model) {
66         List JavaDoc<ExtensibilityElement> ees = model.getDefinitions().getExtensibilityElements();
67         String JavaDoc prefix = Utility.getNamespacePrefix(model.getDefinitions().getTargetNamespace(),
68                 adapter.getExtensibilityElement());
69         for (ExtensibilityElement ee : ees) {
70             if (propertyQName.equals(ee.getQName())) {
71                 propertyList.add(prefix + ":" + ee.getAttribute("name"));
72             }
73         }
74     }
75     
76     @Override JavaDoc
77     public boolean canWrite() {
78         return XAMUtils.isWritable(adapter.getExtensibilityElement().getModel());
79     }
80
81 }
82
Popular Tags