KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > jaxws > actions > AddOperationAction


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.websvc.core.jaxws.actions;
20
21 import org.netbeans.modules.websvc.api.jaxws.project.WSUtils;
22 import org.netbeans.modules.websvc.api.jaxws.project.config.Service;
23 import org.netbeans.modules.websvc.core.AddOperationCookie;
24 import org.netbeans.modules.websvc.core.WebServiceActionProvider;
25 import org.netbeans.modules.websvc.core.WebServiceActionProvider;
26 import org.openide.filesystems.FileObject;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29 import org.openide.nodes.Node;
30 import org.openide.util.actions.NodeAction;
31
32 public class AddOperationAction extends NodeAction {
33     
34     public String JavaDoc getName() {
35         return NbBundle.getMessage(AddOperationAction.class, "LBL_OperationAction");
36     }
37     
38     public HelpCtx getHelpCtx() {
39         return HelpCtx.DEFAULT_HELP;
40     }
41         
42     protected boolean asynchronous() {
43         return false;
44     }
45     
46     protected boolean enable(Node[] activatedNodes) {
47         return activatedNodes.length == 1 &&
48                 // Retouche
49
//( activatedNodes[0].getLookup().lookup(ClassMember.class) != null || JMIUtils.getClassMemberFromNode(activatedNodes[0])!=null ) &&
50
//JMIUtils.getJavaClassFromNode(activatedNodes[0]) != null &&
51
!isFromWSDL(activatedNodes[0]);
52     }
53
54     private boolean isFromWSDL(Node node) {
55         Service service = (Service)node.getLookup().lookup(Service.class);
56         if (service!=null) return (service.getWsdlUrl()!=null);
57         return false;
58     }
59     
60     protected void performAction(Node[] activatedNodes) {
61
62         if (activatedNodes.length != 1) {
63             return;
64         }
65         
66         FileObject implClassFo = activatedNodes[0].getLookup().lookup(FileObject.class);
67         if (implClassFo!=null) {
68             AddOperationCookie addOperationCookie = WebServiceActionProvider.getAddOperationAction(implClassFo);
69             if (addOperationCookie!=null) addOperationCookie.addOperation(implClassFo);
70         }
71 // Retouche
72
// JavaMetamodel.getManager().waitScanFinished();
73
//
74
// JaxWsClassesCookie cookie = JaxWsCookieFactory.getJaxWsClassesCookie((Service)activatedNodes[0].getLookup().lookup(Service.class),JMIUtils.getJavaClassFromNode(activatedNodes[0]));
75
// if (cookie == null) return;
76
// JavaClass javaClass = JMIUtils.getJavaClassFromNode(activatedNodes[0]);
77
// Method m = WSUtils.addWsOperation(javaClass, NbBundle.getMessage(AddOperationAction.class, "TXT_DefaultOperationName"));
78
// if (m!=null) JMIUtils.openInEditor(m);
79
}
80 }
81
82
Popular Tags