KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.netbeans.core.api.multiview.MultiViewHandler;
22 import org.netbeans.core.api.multiview.MultiViewPerspective;
23 import org.netbeans.core.api.multiview.MultiViews;
24 import org.netbeans.core.spi.multiview.MultiViewDescription;
25 import org.netbeans.core.spi.multiview.MultiViewFactory;
26 import org.openide.windows.CloneableTopComponent;
27 import org.openide.windows.TopComponent;
28
29 /**
30  *
31  * @author Jeri Lockhart
32  */

33 public class WSDLMultiViewFactory {
34     /**
35      * Creates a new instance of WSDLMultiViewFactory
36      */

37     public WSDLMultiViewFactory() {
38     }
39     
40     public static CloneableTopComponent createMultiView(WSDLDataObject wsdlDataObject) {
41         MultiViewDescription views[] = new MultiViewDescription[3];
42         
43         views[0] = getWSDLSourceMultiviewDesc(wsdlDataObject);
44         views[1] = getWSDLTreeViewMultiViewDesc(wsdlDataObject);
45         views[2] = getWSDLDesignMultiviewDesc(wsdlDataObject);
46         
47         CloneableTopComponent multiview =
48                 MultiViewFactory.createCloneableMultiView(
49                 views,
50                 views[0],
51                 new WSDLEditorSupport.CloseHandler(wsdlDataObject));
52         
53         //IZ 84440 - show file name with extension
54
String JavaDoc name = wsdlDataObject.getNodeDelegate().getDisplayName();
55         multiview.setDisplayName(name);
56         multiview.setName(name);
57         
58         
59         return multiview;
60     }
61     
62     
63     private static MultiViewDescription getWSDLTreeViewMultiViewDesc(WSDLDataObject wsdlDataObject) {
64         return new WSDLTreeViewMultiViewDesc(wsdlDataObject);
65     }
66     
67     private static MultiViewDescription getWSDLSourceMultiviewDesc(WSDLDataObject wsdlDataObject) {
68         return new WSDLSourceMultiviewDesc(wsdlDataObject);
69     }
70     
71     private static MultiViewDescription getWSDLDesignMultiviewDesc(WSDLDataObject wsdlDataObject) {
72         return new WSDLDesignMultiViewDesc(wsdlDataObject);
73     }
74     
75     /**
76      * Shows the desired multiview element. Must be called after the editor
77      * has been opened (i.e. WSDLEditorSupport.open()) so the TopComponent
78      * will be the active one in the registry.
79      *
80      * @param id identifier of the multiview element.
81      */

82     public static void requestMultiviewActive(String JavaDoc id) {
83         TopComponent activeTC = TopComponent.getRegistry().getActivated();
84         MultiViewHandler handler = MultiViews.findMultiViewHandler(activeTC);
85         if (handler != null) {
86             MultiViewPerspective[] perspectives = handler.getPerspectives();
87             for (MultiViewPerspective perspective : perspectives) {
88                 if (perspective.preferredID().equals(id)) {
89                     handler.requestActive(perspective);
90                 }
91             }
92         }
93     }
94 }
95
Popular Tags