01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.actions;
14:
15: import java.io.File;
16:
17: import com.eviware.soapui.SoapUI;
18: import com.eviware.soapui.impl.WorkspaceImpl;
19: import com.eviware.soapui.impl.wsdl.WsdlProject;
20: import com.eviware.soapui.support.UISupport;
21: import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
22:
23: /**
24: * Actions for importing an existing soapui-project file into the current workspace
25: *
26: * @author Ole.Matzura
27: */
28:
29: public class ImportWsdlProjectAction extends
30: AbstractSoapUIAction<WorkspaceImpl> {
31: public static final String SOAPUI_ACTION_ID = "ImportWsdlProjectAction";
32:
33: public ImportWsdlProjectAction() {
34: super ("Import Project",
35: "Adds an existing project into this workspace");
36: }
37:
38: public void perform(WorkspaceImpl workspace, Object param) {
39: File file = UISupport.getFileDialogs().openXML(this ,
40: "Select soapui project file");
41: if (file == null)
42: return;
43:
44: String fileName = file.getAbsolutePath();
45: if (fileName == null)
46: return;
47:
48: ClassLoader contextClassLoader = Thread.currentThread()
49: .getContextClassLoader();
50: Thread.currentThread().setContextClassLoader(
51: SoapUI.class.getClassLoader());
52:
53: try {
54: WsdlProject project = (WsdlProject) workspace
55: .importProject(fileName);
56: if (project != null)
57: UISupport.select(project);
58: } catch (Exception ex) {
59: UISupport.showErrorMessage(ex);
60: } finally {
61: Thread.currentThread().setContextClassLoader(
62: contextClassLoader);
63: }
64: }
65: }
|