KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > netbeans > module > WSDLTreeCategory


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.netbeans.module;
21
22 import java.awt.Image JavaDoc;
23
24 import javax.swing.Icon JavaDoc;
25 import javax.swing.ImageIcon JavaDoc;
26
27 import org.netbeans.modules.xml.schema.model.SchemaComponent;
28 import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
29 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
30 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.WSDLSettings.ViewMode;
31 import org.netbeans.modules.xml.wsdl.ui.search.AttributeNameSearchProvider;
32 import org.netbeans.modules.xml.wsdl.ui.search.AttributeValueSearchProvider;
33 import org.netbeans.modules.xml.wsdl.ui.search.ComponentNameSearchProvider;
34 import org.netbeans.modules.xml.wsdl.ui.search.ComponentTypeSearchProvider;
35 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.TreeEditorView;
36 import org.netbeans.modules.xml.xam.Component;
37 import org.netbeans.modules.xml.xam.ui.category.AbstractCategory;
38 import org.openide.util.Lookup;
39 import org.openide.util.NbBundle;
40 import org.openide.util.Utilities;
41 import org.openide.util.lookup.Lookups;
42 import org.openide.util.lookup.ProxyLookup;
43
44 /**
45  * Displays the tree form of the WSDL editor.
46  *
47  * @author Nathan Fiedler
48  */

49 public class WSDLTreeCategory extends AbstractCategory {
50     /** Associated WSDL model. */
51     private WSDLModel wsdlModel;
52     /** Our visual component. */
53     private TreeEditorView component;
54     /** Our lookup. */
55     private Lookup lookup;
56
57     /**
58      * Creates a new instance of WSDLTreeCategory.
59      *
60      * @param model schema model to display.
61      * @param lookup associated Lookup instance.
62      */

63     public WSDLTreeCategory(WSDLModel model, Lookup lookup) {
64         wsdlModel = model;
65         Object JavaDoc[] searchers = new Object JavaDoc[] {
66             new ComponentNameSearchProvider(model, this),
67             new ComponentTypeSearchProvider(model, this),
68             new AttributeNameSearchProvider(model, this),
69             new AttributeValueSearchProvider(model, this),
70         };
71         this.lookup = new ProxyLookup(new Lookup[] {
72             lookup,
73             Lookups.fixed(searchers)
74         });
75     }
76
77     public void componentHidden() {
78     }
79
80     public void componentShown() {
81         initComponents();
82         WSDLSettings.getDefault().setViewMode(ViewMode.TREE);
83     }
84
85     public java.awt.Component JavaDoc getComponent() {
86         initComponents();
87         return component;
88     }
89
90     public String JavaDoc getDescription() {
91         return NbBundle.getMessage(WSDLTreeCategory.class,
92                 "HINT_WsdlCategory_Tree");
93     }
94
95     public Icon JavaDoc getIcon() {
96         String JavaDoc url = NbBundle.getMessage(WSDLTreeCategory.class,
97                 "IMG_WsdlCategory_Tree");
98         Image JavaDoc img = Utilities.loadImage(url);
99         return new ImageIcon JavaDoc(img);
100     }
101
102     public Lookup getLookup() {
103         return lookup;
104     }
105
106     public String JavaDoc getTitle() {
107         return NbBundle.getMessage(WSDLTreeCategory.class,
108                 "LBL_WsdlCategory_Tree");
109     }
110
111     /**
112      * Construct our visual components, if they have not been already.
113      */

114     private void initComponents() {
115         if (component == null) {
116             component = new TreeEditorView(wsdlModel);
117         }
118     }
119
120     public void showComponent(Component comp) {
121         if (comp instanceof WSDLComponent) {
122             component.showComponent((WSDLComponent) comp);
123         } else if (comp instanceof SchemaComponent) {
124             component.showComponent((SchemaComponent) comp);
125         }
126     }
127 }
128
Popular Tags