KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > design > view > 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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.design.view.actions;
21
22 import java.awt.Dialog JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import java.io.File JavaDoc;
26 import java.io.IOException JavaDoc;
27 import java.io.IOException JavaDoc;
28 import javax.swing.AbstractAction JavaDoc;
29 import org.netbeans.modules.websvc.api.jaxws.project.config.Service;
30 import org.netbeans.modules.websvc.core.AddWsOperationHelper;
31 import org.netbeans.modules.websvc.core._RetoucheUtil;
32 import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport;
33 import org.openide.DialogDescriptor;
34 import org.openide.DialogDisplayer;
35 import org.openide.ErrorManager;
36 import org.openide.filesystems.FileObject;
37 import org.openide.filesystems.FileUtil;
38 import org.openide.util.NbBundle;
39
40 /**
41  *
42  * @author Ajit Bhate
43  */

44 public class AddOperationAction extends AbstractAction JavaDoc {
45     
46     private FileObject implementationClass;
47     private Service service;
48     /**
49      * Creates a new instance of AddOperationAction
50      * @param implementationClass fileobject of service implementation class
51      */

52     public AddOperationAction(Service service, FileObject implementationClass) {
53         super(getName());
54         this.service=service;
55         this.implementationClass = implementationClass;
56     }
57     
58     private static String JavaDoc getName() {
59         return NbBundle.getMessage(AddOperationAction.class, "LBL_AddOperation");
60     }
61
62     public void actionPerformed(ActionEvent JavaDoc arg0) {
63         
64         String JavaDoc localWsdlUrl = service.getLocalWsdlFile();
65         AddOperationFromSchemaPanel panel = null;
66         if (localWsdlUrl!=null) { //WS from e
67
JAXWSSupport support = JAXWSSupport.getJAXWSSupport(implementationClass);
68             if (support!=null) {
69                 FileObject localWsdlFolder = support.getLocalWsdlFolderForService(service.getName(),false);
70                 if (localWsdlFolder!=null) {
71                     File JavaDoc wsdlFolder = FileUtil.toFile(localWsdlFolder);
72                     File JavaDoc wsdlFile = new File JavaDoc(wsdlFolder.getAbsolutePath()+File.separator+localWsdlUrl);
73                     if (wsdlFile!=null && wsdlFile.exists()) {
74                         panel = new AddOperationFromSchemaPanel(wsdlFile);
75                     }
76                 }
77             }
78         }
79         if (panel!=null) {
80             DialogDescriptor desc = new DialogDescriptor(panel,
81                     NbBundle.getMessage(AddOperationAction.class, "TTL_AddWsOperation"));
82             desc.setButtonListener(new ActionListener JavaDoc() {
83                 public void actionPerformed(ActionEvent JavaDoc evt) {
84                     if (evt.getSource() == DialogDescriptor.OK_OPTION) {
85                         //TODO implement the action
86
}
87                 }
88             });
89
90             Dialog JavaDoc dialog = DialogDisplayer.getDefault().createDialog(desc);
91             dialog.setVisible(true);
92         } else { // WS from Java
93
AddWsOperationHelper strategy = new AddWsOperationHelper(getName());
94             try {
95                 String JavaDoc className = _RetoucheUtil.getMainClassName(implementationClass);
96                 if (className != null) {
97                     strategy.addMethod(implementationClass, className);
98                 }
99             } catch (IOException JavaDoc ex) {
100                 ErrorManager.getDefault().notify(ex);
101             }
102         }
103     }
104
105 }
106
Popular Tags