1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.actions.iface;
14
15 import com.eviware.soapui.impl.support.definition.export.WsdlDefinitionExporter;
16 import com.eviware.soapui.impl.wsdl.WsdlInterface;
17 import com.eviware.soapui.support.UISupport;
18 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
19
20 import java.io.File;
21
22 /***
23 * Exports the definition (wsdls and xsds) of a WsdlInterface to the file system
24 *
25 * @author Ole.Matzura
26 */
27
28 @SuppressWarnings("unchecked")
29 public class ExportDefinitionAction extends AbstractSoapUIAction<WsdlInterface>
30 {
31 public static final String SOAPUI_ACTION_ID = "ExportDefinitionAction";
32
33 public ExportDefinitionAction()
34 {
35 super("Export Definition", "Exports the entire WSDL and included/imported files to a local directory");
36 }
37
38 public void perform(WsdlInterface iface, Object param)
39 {
40 try
41 {
42 if (exportDefinition(null, iface) != null)
43 UISupport.showInfoMessage("Definition exported succesfully");
44 }
45 catch (Exception e1)
46 {
47 UISupport.showErrorMessage(e1);
48 }
49 }
50
51 public String exportDefinition(String location, WsdlInterface iface) throws Exception
52 {
53 File folderName = location == null ? UISupport.getFileDialogs().openDirectory(this, "Select output directory", null)
54 : new File(location);
55
56 if (folderName == null)
57 return null;
58
59 WsdlDefinitionExporter exporter = new WsdlDefinitionExporter(iface);
60 return exporter.export(folderName.getAbsolutePath());
61 }
62 }