KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > treeeditor > XSDImportNode


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.view.treeeditor;
21
22 import java.awt.Image JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.netbeans.modules.xml.schema.model.Schema;
28 import org.netbeans.modules.xml.wsdl.model.Import;
29 import org.openide.nodes.Node;
30 import org.openide.util.NbBundle;
31 import org.openide.util.Utilities;
32
33
34
35 /**
36  * @author radval
37  *
38  * To change the template for this generated type comment go to
39  * Window - Preferences - Java - Code Generation - Code and Comments
40  */

41 public class XSDImportNode extends ImportNode {
42
43     Image JavaDoc ICON = Utilities.loadImage
44             ("org/netbeans/modules/xml/wsdl/ui/view/resources/import-include-redefine.png");
45
46     public XSDImportNode(Import wsdlConstruct) {
47         super(new XSDImportNodeChildren(wsdlConstruct),
48                 wsdlConstruct);
49     }
50
51
52     @Override JavaDoc
53     public Image JavaDoc getIcon(int type) {
54         return ICON;
55     }
56
57     @Override JavaDoc
58     public Image JavaDoc getOpenedIcon(int type) {
59         return ICON;
60     }
61
62     @Override JavaDoc
63     public String JavaDoc getTypeDisplayName() {
64         return NbBundle.getMessage(XSDImportNode.class, "LBL_XSDImportNode_TypeDisplayName");
65     }
66
67     @Override JavaDoc
68     protected void updateDisplayName() {
69         Import imp = (Import) getWSDLComponent();
70         setDisplayName(imp.getLocation());
71     }
72
73     public static class XSDImportNodeChildren extends GenericWSDLComponentChildren {
74
75         private Import mWsdlConstruct;
76
77         public XSDImportNodeChildren(Import wsdlConstruct) {
78             super(wsdlConstruct);
79             this.mWsdlConstruct = wsdlConstruct;
80         }
81
82         @Override JavaDoc
83         protected Node[] createNodes(Object JavaDoc key) {
84             if (key instanceof Schema) {
85                 Schema schema = (Schema) key;
86                 NodesFactory factory = NodesFactory.getInstance();
87                 Node node = factory.create(schema);
88                 node.setDisplayName(this.mWsdlConstruct.getNamespace());
89                 return new Node[] { node };
90             }
91             return super.createNodes(key);
92         }
93
94         @Override JavaDoc
95         @SuppressWarnings JavaDoc("unchecked")
96         protected Collection JavaDoc getKeys() {
97             ArrayList JavaDoc keys = new ArrayList JavaDoc();
98             List JavaDoc list = mWsdlConstruct.getModel().findSchemas(mWsdlConstruct.getNamespace());
99             if (list != null && list.size() > 0) {
100                 Schema schema = (Schema) list.get(0);
101                 if (schema != null) {
102                     keys.add(schema);
103                 }
104             }
105             keys.addAll(super.getKeys());
106             return keys;
107         }
108
109     }
110 }
111
Popular Tags