KickJava   Java API By Example, From Geeks To Geeks.

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


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

46 public class WSDLColumnsCategory extends AbstractCategory {
47     /** Associated WSDL model. */
48     private WSDLModel wsdlModel;
49     /** Our visual component. */
50     private WSDLColumnsView component;
51     /** Our lookup. */
52     private Lookup lookup;
53
54     /**
55      * Creates a new instance of WSDLColumnsCategory.
56      *
57      * @param model model to display.
58      * @param lookup associated Lookup instance.
59      */

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

111     private void initComponents() {
112         if (component == null) {
113             component = new WSDLColumnsView(wsdlModel, getLookup());
114         }
115     }
116
117     public void showComponent(Component comp) {
118         if (comp instanceof WSDLComponent) {
119             component.showComponent((WSDLComponent) comp);
120         } else if (comp instanceof SchemaComponent) {
121             component.showComponent((SchemaComponent) comp);
122         }
123     }
124 }
125
Popular Tags