KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > actions > WSDLViewOpenAction


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.actions;
21
22 import java.io.IOException JavaDoc;
23 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.WSDLDataObject;
24 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.WSDLEditorSupport;
25 import org.netbeans.modules.xml.xam.ui.cookies.ViewComponentCookie;
26 import org.openide.cookies.OpenCookie;
27 import org.openide.nodes.Node;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle;
30 import org.openide.util.actions.NodeAction;
31
32 /**
33  * Opens the WSDLDataObject in the WSDL editor tree view.
34  *
35  * @author Jeri Lockhart
36  */

37 public class WSDLViewOpenAction extends NodeAction{
38     /** silence compiler warnings */
39     private static final long serialVersionUID = 1L;
40
41     protected void performAction(Node[] node) {
42         if (node == null || node[0] == null) {
43             return;
44         }
45         WSDLDataObject sdo = (WSDLDataObject) node[0].getLookup().lookup(
46                 WSDLDataObject.class);
47         if (sdo != null) {
48             WSDLEditorSupport wes = sdo.getWSDLEditorSupport();
49             ViewComponentCookie svc = (ViewComponentCookie) sdo.getCookie(
50                     ViewComponentCookie.class);
51             if (svc != null) {
52                 try {
53                     if (wes.getOpenedPanes() == null ||
54                             wes.getOpenedPanes().length == 0) {
55                         svc.view(ViewComponentCookie.View.STRUCTURE,
56                                 wes.getModel().getDefinitions());
57                     } else {
58                         wes.open();
59                     }
60                     return;
61                 } catch (IOException JavaDoc ioe) {
62                     //ErrorManager.getDefault().notify(ex);
63
}
64             }
65         }
66         // default to open cookie
67
OpenCookie oc = (OpenCookie) node[0].getCookie(OpenCookie.class);
68         if (oc != null) {
69             oc.open();
70         }
71     }
72
73     protected boolean enable(Node[] node) {
74         return true;
75     }
76
77     public String JavaDoc getName() {
78         return NbBundle.getMessage(WSDLViewOpenAction.class,
79                 "WSDLViewOpenAction_Name");
80     }
81
82     public HelpCtx getHelpCtx() {
83         return HelpCtx.DEFAULT_HELP;
84     }
85
86     protected boolean asynchronous() {
87         return false;
88     }
89 }
90
Popular Tags