KickJava   Java API By Example, From Geeks To Geeks.

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


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
25 import org.netbeans.modules.xml.wsdl.model.Types;
26 import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
27 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.newtype.DocumentationNewType;
28 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.newtype.ImportSchemaNewType;
29 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.newtype.NewTypesFactory;
30 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.newtype.SchemaNewType;
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33 import org.openide.util.Utilities;
34 import org.openide.util.datatransfer.NewType;
35
36
37
38 /**
39  *
40  * @author Ritesh Adval
41  *
42  *
43  */

44 public class TypesNode extends WSDLElementNode {
45
46     private static final Image JavaDoc ICON = Utilities.loadImage
47          ("org/netbeans/modules/xml/wsdl/ui/view/resources/schema_folder_badge_var3.png");
48     
49     protected Types mWSDLConstruct;
50     
51     public TypesNode(Types wsdlConstruct) {
52         super(new GenericWSDLComponentChildren(wsdlConstruct), wsdlConstruct, new TypesNewTypesFactory());
53         mWSDLConstruct = wsdlConstruct;
54         
55         this.setDisplayName(NbBundle.getMessage(TypesNode.class, "TYPES_NODE_NAME"));
56     }
57     
58     @Override JavaDoc
59     public Image JavaDoc getIcon(int type) {
60         Image JavaDoc folderIcon = FolderNode.FolderIcon.getClosedIcon();
61         if (ICON != null) {
62             return Utilities.mergeImages(folderIcon, ICON, 8, 8);
63         }
64         
65         return folderIcon;
66     }
67     
68     @Override JavaDoc
69     public Image JavaDoc getOpenedIcon(int type) {
70         Image JavaDoc folderIcon = FolderNode.FolderIcon.getOpenedIcon();
71         if (ICON != null) {
72             return Utilities.mergeImages(folderIcon, ICON, 8, 8);
73         }
74         
75         return folderIcon;
76     }
77
78     public Object JavaDoc getWSDLConstruct() {
79         return mWSDLConstruct;
80     }
81     
82     @Override JavaDoc
83     public HelpCtx getHelpCtx() {
84         return new HelpCtx(TypesNode.class);
85     }
86     
87     public static final class TypesNewTypesFactory implements NewTypesFactory{
88
89         public NewType[] getNewTypes(WSDLComponent def) {
90             Types types = (Types) def;
91             ArrayList JavaDoc<NewType> list = new ArrayList JavaDoc<NewType>();
92             if (def.getDocumentation() == null) {
93                 list.add(new DocumentationNewType(def));
94             }
95             
96             list.add(new SchemaNewType(types));
97             list.add(new ImportSchemaNewType(types));
98             
99             return list.toArray(new NewType[list.size()]);
100         }
101     }
102
103     @Override JavaDoc
104     public String JavaDoc getTypeDisplayName() {
105         return NbBundle.getMessage(TypesNode.class, "LBL_TypesNode_TypeDisplayName");
106     }
107     
108 }
109
Popular Tags