1 19 20 package org.netbeans.modules.websvc.design.view.actions; 21 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import java.io.File ; 26 import java.io.IOException ; 27 import java.io.IOException ; 28 import javax.swing.AbstractAction ; 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 44 public class AddOperationAction extends AbstractAction { 45 46 private FileObject implementationClass; 47 private Service service; 48 52 public AddOperationAction(Service service, FileObject implementationClass) { 53 super(getName()); 54 this.service=service; 55 this.implementationClass = implementationClass; 56 } 57 58 private static String getName() { 59 return NbBundle.getMessage(AddOperationAction.class, "LBL_AddOperation"); 60 } 61 62 public void actionPerformed(ActionEvent arg0) { 63 64 String localWsdlUrl = service.getLocalWsdlFile(); 65 AddOperationFromSchemaPanel panel = null; 66 if (localWsdlUrl!=null) { JAXWSSupport support = JAXWSSupport.getJAXWSSupport(implementationClass); 68 if (support!=null) { 69 FileObject localWsdlFolder = support.getLocalWsdlFolderForService(service.getName(),false); 70 if (localWsdlFolder!=null) { 71 File wsdlFolder = FileUtil.toFile(localWsdlFolder); 72 File wsdlFile = new File (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 () { 83 public void actionPerformed(ActionEvent evt) { 84 if (evt.getSource() == DialogDescriptor.OK_OPTION) { 85 } 87 } 88 }); 89 90 Dialog dialog = DialogDisplayer.getDefault().createDialog(desc); 91 dialog.setVisible(true); 92 } else { AddWsOperationHelper strategy = new AddWsOperationHelper(getName()); 94 try { 95 String className = _RetoucheUtil.getMainClassName(implementationClass); 96 if (className != null) { 97 strategy.addMethod(implementationClass, className); 98 } 99 } catch (IOException ex) { 100 ErrorManager.getDefault().notify(ex); 101 } 102 } 103 } 104 105 } 106 | Popular Tags |