Source Code Cross Referenced for SoapUI.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » soapui 1.7.5 » com.eviware.soapui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
0003:         *
0004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
0005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
0006:         *  the Free Software Foundation.
0007:         *
0008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
0009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
0010:         *  See the GNU Lesser General Public License for more details at gnu.org.
0011:         */
0012:
0013:        package com.eviware.soapui;
0014:
0015:        import java.awt.BorderLayout;
0016:        import java.awt.Color;
0017:        import java.awt.Component;
0018:        import java.awt.Dimension;
0019:        import java.awt.Insets;
0020:        import java.awt.Toolkit;
0021:        import java.awt.event.ActionEvent;
0022:        import java.awt.event.KeyEvent;
0023:        import java.awt.event.MouseAdapter;
0024:        import java.awt.event.MouseEvent;
0025:        import java.awt.event.WindowAdapter;
0026:        import java.awt.event.WindowEvent;
0027:        import java.io.File;
0028:        import java.io.IOException;
0029:        import java.net.URI;
0030:        import java.net.URISyntaxException;
0031:        import java.net.URL;
0032:        import java.util.ArrayList;
0033:        import java.util.Collection;
0034:        import java.util.Collections;
0035:        import java.util.List;
0036:        import java.util.Properties;
0037:
0038:        import javax.swing.AbstractAction;
0039:        import javax.swing.Action;
0040:        import javax.swing.BorderFactory;
0041:        import javax.swing.ImageIcon;
0042:        import javax.swing.JComponent;
0043:        import javax.swing.JFrame;
0044:        import javax.swing.JLabel;
0045:        import javax.swing.JMenu;
0046:        import javax.swing.JMenuBar;
0047:        import javax.swing.JOptionPane;
0048:        import javax.swing.JPanel;
0049:        import javax.swing.JScrollPane;
0050:        import javax.swing.JSplitPane;
0051:        import javax.swing.JTabbedPane;
0052:        import javax.swing.JWindow;
0053:        import javax.swing.SwingUtilities;
0054:        import javax.swing.ToolTipManager;
0055:        import javax.swing.UIManager;
0056:        import javax.swing.plaf.ColorUIResource;
0057:        import javax.xml.namespace.QName;
0058:        import javax.xml.parsers.FactoryConfigurationError;
0059:
0060:        import org.apache.log4j.Level;
0061:        import org.apache.log4j.Logger;
0062:        import org.apache.log4j.xml.DOMConfigurator;
0063:
0064:        import com.eviware.soapui.actions.SoapUIPreferencesAction;
0065:        import com.eviware.soapui.config.SoapuiSettingsDocumentConfig;
0066:        import com.eviware.soapui.impl.settings.XmlBeansSettingsImpl;
0067:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.axis1.Axis1XWSDL2JavaAction;
0068:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.axis2.Axis2WSDL2CodeAction;
0069:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.dotnet.DotNetWsdlAction;
0070:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.gsoap.GSoapAction;
0071:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.jaxb.JaxbXjcAction;
0072:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.jbossws.JBossWSConsumeAction;
0073:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.jbossws.WSToolsWsdl2JavaAction;
0074:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.oracle.OracleWsaGenProxyAction;
0075:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.SwingToolHost;
0076:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.tcpmon.TcpMonAction;
0077:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.wscompile.WSCompileAction;
0078:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.wsimport.WSImportAction;
0079:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.xfire.XFireAction;
0080:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.xmlbeans.XmlBeans2Action;
0081:        import com.eviware.soapui.impl.wsdl.actions.support.OpenUrlAction;
0082:        import com.eviware.soapui.impl.wsdl.actions.support.ShowOnlineHelpAction;
0083:        import com.eviware.soapui.impl.wsdl.support.HelpUrls;
0084:        import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
0085:        import com.eviware.soapui.model.ModelItem;
0086:        import com.eviware.soapui.model.PanelBuilder;
0087:        import com.eviware.soapui.model.settings.Settings;
0088:        import com.eviware.soapui.model.settings.SettingsListener;
0089:        import com.eviware.soapui.model.tree.SoapUITreeNode;
0090:        import com.eviware.soapui.model.util.PanelBuilderRegistry;
0091:        import com.eviware.soapui.model.workspace.Workspace;
0092:        import com.eviware.soapui.model.workspace.WorkspaceFactory;
0093:        import com.eviware.soapui.monitor.MockEngine;
0094:        import com.eviware.soapui.monitor.TestMonitor;
0095:        import com.eviware.soapui.settings.HttpSettings;
0096:        import com.eviware.soapui.settings.UISettings;
0097:        import com.eviware.soapui.settings.WsdlSettings;
0098:        import com.eviware.soapui.support.ClasspathHacker;
0099:        import com.eviware.soapui.support.SoapUIException;
0100:        import com.eviware.soapui.support.UISupport;
0101:        import com.eviware.soapui.support.action.SoapUIActionRegistry;
0102:        import com.eviware.soapui.support.action.swing.ActionList;
0103:        import com.eviware.soapui.support.action.swing.ActionListBuilder;
0104:        import com.eviware.soapui.support.action.swing.ActionSupport;
0105:        import com.eviware.soapui.support.action.swing.SwingActionDelegate;
0106:        import com.eviware.soapui.support.log.Log4JMonitor;
0107:        import com.eviware.soapui.support.log.LogDisablingTestMonitorListener;
0108:        import com.eviware.soapui.support.types.StringList;
0109:        import com.eviware.soapui.ui.JDesktopPanelsList;
0110:        import com.eviware.soapui.ui.Navigator;
0111:        import com.eviware.soapui.ui.NavigatorListener;
0112:        import com.eviware.soapui.ui.desktop.DesktopPanel;
0113:        import com.eviware.soapui.ui.desktop.DesktopRegistry;
0114:        import com.eviware.soapui.ui.desktop.SoapUIDesktop;
0115:        import com.eviware.soapui.ui.desktop.standalone.StandaloneDesktop;
0116:        import com.eviware.soapui.ui.desktop.standalone.StandaloneDesktopFactory;
0117:        import com.eviware.soapui.ui.support.DesktopListenerAdapter;
0118:        import com.eviware.x.form.XFormFactory;
0119:        import com.eviware.x.impl.swing.SwingFileDialogs;
0120:        import com.eviware.x.impl.swing.SwingFormFactory;
0121:        import com.jgoodies.looks.HeaderStyle;
0122:        import com.jgoodies.looks.Options;
0123:        import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;
0124:        import com.jgoodies.looks.plastic.theme.SkyBluer;
0125:
0126:        /**
0127:         * Main SoapUI entry point.
0128:         * 
0129:         * @author Ole.Matzura
0130:         * 
0131:         * For version 0.6
0132:         * @todo improve error assertion reporting +
0133:         * @todo find/search/replace +
0134:         * @todo undo +
0135:         * @todo recreate request and keep values +
0136:         * @todo dont create optional elements +
0137:         * @todo option to create requests when importing +
0138:         * @todo show soapaction +
0139:         * @todo save response +
0140:         * @todo color-coding +
0141:         * @todo rapportera fel vid null-svar +
0142:         * @todo fixa bugg vid update interface +
0143:         * @todo xmlbeans2 +
0144:         * @todo httpclient rc3 +
0145:         * @todo refactor request panels +
0146:         * @todo refactor project/interface/testsuite listeners +
0147:         * @todo create properties table +
0148:         * 
0149:         * For version 0.7
0150:         * @todo workspace in home folder +
0151:         * @todo allow renaming of operation names in tree +
0152:         * @todo add functionality for copying values from test response to following
0153:         *       test request +
0154:         * @todo fix relative xsd imports when loading from file system +
0155:         * @todo fix cancelling of request when closing request window -> introduce
0156:         *       DesktopPanel interface +
0157:         * @todo refactor panel creation / listener handling/release +
0158:         * @todo fix update of testcase window when adding test steps +
0159:         * @todo add delete-line action in xml-editor (Ctrl-D) +
0160:         * @todo add submit action to xml request editor (Ctrl Enter) +
0161:         * @todo add mousewheel support to xml editor +
0162:         * @todo add mousewheel + C support to xml editor (move cursor) +
0163:         * @todo fix revalidation problems +
0164:         * @todo add validation to xmleditors +
0165:         * @todo check localisation of schema errors +
0166:         * @todo add possibility to reload schema (neccessary?) +
0167:         * @todo fix cloning of assertions when cloning test steps +
0168:         * @todo ask for creation of optional elements when (re)creating new request +
0169:         * @todo add action to add existing namespaces to xpath in xpathassertion +
0170:         * 
0171:         * For version 0.8
0172:         * @todo fix default values when creating requests +
0173:         * @todo bug-fixes - creation of namespace declarations creates multiple with
0174:         *       same name + - check defintion update + - deletion of endpoint always
0175:         *       deletes first + - deleted assertions result in error during save/exit? + -
0176:         *       disable submit when missing endpoint + - clone request null-pointer + -
0177:         *       fix value transfer element <> attribute + - fix cancelling of test
0178:         *       requests +
0179:         * @todo create assertion events / listeners +
0180:         * @todo ask to add testcase if missing +
0181:         * @todo add alt-enter to response area +
0182:         * @todo allow url config of SchemaCompliance assertion +
0183:         * @todo add accelerators for common actions +
0184:         * @todo fix positions of dialogs +
0185:         * @todo add possibility to specify testsuite/testcase in maven-plugin +
0186:         * @todo refactoring: replaced SoapUIAction with standard swing Action +
0187:         * @todo refactoring: checked all JOptionPanes for correct title, etc. +
0188:         * @todo add filename-filters to filechoosers +
0189:         * @todo add shortcut for cancel request to editor +
0190:         * 
0191:         * For version 0.9
0192:         * @todo initial class/code comments +
0193:         * @todo bug-fixes - fix cancelling of test runs + - fix removal of request
0194:         *       test-steps when associated operations / interfaces are removed + -
0195:         *       update of request-step status in testcase panel + - focus on find-field
0196:         *       in find/replace dialog + - fix filters to not remove directories.. + -
0197:         *       change wsdl file filter to *.wsdl + - disable declare in transfer panel
0198:         *       when no transfer is selected + - declare in transfer panel declares
0199:         *       target from target response (should be request) + - ask to cancel when
0200:         *       closing running testcase + - fix pretty-printing of large xml-documents + -
0201:         *       fix find and replace + - fix node insert error on multiple clone
0202:         *       teststep + - fix log-messages from canceled requests + - disable
0203:         *       replace-related options in find/replace if editor is not editable +
0204:         * @todo add possibility to move teststeps within testcase +
0205:         * @todo improve/disable disabling of request-editor +
0206:         * @todo add addAssertion button to testrequest panel +
0207:         * @todo add copy/pase actions to editor popup +
0208:         * @todo model-items tests
0209:         * @todo improve wsdl/xsd viewer +
0210:         * @todo improve line-number reporting in validations +
0211:         * @todo added shift-tab to move focus between request/response editors +
0212:         * @todo refactorings - SoapUIException + - UIFacade for JOptionPane +
0213:         *       (partially)
0214:         * 
0215:         * For version 1.0b
0216:         * @todo initial user documentation / samples +
0217:         * @todo bug-fixes +
0218:         * @todo more tests / testing!
0219:         * @todo beta release +
0220:         * 
0221:         * For version 1.0
0222:         * @todo official release
0223:         * 
0224:         * For version 1.5
0225:         * @todo finish LoadTest panels - fix UI + - color legend + - reset action + -
0226:         *       interactive thread-count change + - error-log + - see responses + -
0227:         *       assertions + - command-line/maven-plugin + - export results +
0228:         * @todo loadtest fixes - resizing/scaling of graphs + - autoreset on restart +
0229:         * @todo fix disabling of relevant actions during test-runs + - Add to testcase,
0230:         *       delete testcase, etc +
0231:         * @todo allow TransferValues between any requests/responses +
0232:         * @todo fix "global values" in testcases + - properties +
0233:         * @todo improve endpoint editing + - add "edit.." to combobox +
0234:         * @todo remove xpath/xquery tester.. +
0235:         * @todo improve testcase properties dialog +
0236:         * @todo fix icons for all tree nodes +
0237:         * @todo fix updating of desktop panel titles +
0238:         * @todo global settings; + - proxy + - close connections + - user-agent header + -
0239:         *       preemptive authentication + - editor font + - socket timeout + - ?
0240:         * @todo add loop-functionality for testcases +
0241:         * @todo support one-way operations +
0242:         * @todo fix wsdlcontext initialization in loadtests +
0243:         * @todo create testrun summary in commandline
0244:         * @todo create loadtest summary in commandline
0245:         * @todo add maven.soapui.test.host commandline property +
0246:         * @todo add test-suite runner panel +
0247:         * @todo option to abort testcase on error +
0248:         * @todo ensure unique test-step names +
0249:         * @todo grooy-teststep +
0250:         * @todo onewayop tree icon +
0251:         * @todo fix desktoppanels list +
0252:         * 
0253:         * For version 1.6
0254:         * @todo finish SOAP 1.2 request generation +
0255:         * @todo finish gsoap integration +
0256:         * @todo bugfixes!
0257:         * @todo swa-attachments support +
0258:         * 
0259:         * Improvements
0260:         * @todo make modifications of response content "alive"
0261:         * @todo animated tree icons for testcase/loadtest runs
0262:         * @todo add run-testcase action in teststep/testcase editors
0263:         * @todo implement testsuite/testcase generation
0264:         * @todo refactor XmlObject configurables
0265:         * @todo workspace management
0266:         * @todo add reload-project!?
0267:         * @todo option to reload schemas on run testcase
0268:         * @todo option to select visible steps in loadtest statistics
0269:         * @todo generate testcase/testsuite actions
0270:         * @todo form-based input
0271:         */
0272:
0273:        public class SoapUI {
0274:            public static final String CURRENT_SOAPUI_WORKSPACE = SoapUI.class
0275:                    .getName()
0276:                    + "@workspace";
0277:            public final static Logger log = Logger.getLogger(SoapUI.class);
0278:            public final static String SOAPUI_VERSION = "1.7.5";
0279:            public static final String DEFAULT_WORKSPACE_FILE = "default-soapui-workspace.xml";
0280:            private final static String DEFAULT_SETTINGS_FILE = "soapui-settings.xml";
0281:            public static final String SOAPUI_SPLASH_GIF = "soapui-splash.gif";
0282:
0283:            // ------------------------------ FIELDS ------------------------------
0284:
0285:            private static SoapUI instance;
0286:            private static SoapuiSettingsDocumentConfig settingsDocument;
0287:            private static List<Object> logCache = new ArrayList<Object>();
0288:            private static Settings settings;
0289:
0290:            private static JFrame frame;
0291:
0292:            private Navigator navigator;
0293:            private SoapUIDesktop desktop;
0294:            private static TestMonitor testMonitor;
0295:            static Workspace workspace;
0296:            private JDesktopPanelsList desktopPanelsList;
0297:            private Log4JMonitor logMonitor;
0298:
0299:            private JMenu desktopMenu;
0300:            private JMenu helpMenu;
0301:            private JMenu fileMenu;
0302:            private JMenuBar menuBar;
0303:
0304:            public static boolean checkedGroovyLogMonitor;
0305:
0306:            private JPanel overviewPanel;
0307:            private JMenu toolsMenu;
0308:            private boolean saveOnExit = true;
0309:            private static MockEngine mockEngine;
0310:            private static boolean loadedExtLibs;
0311:            private static boolean isStandalone;
0312:            private JSplitPane contentSplit;
0313:            private InternalDesktopListener internalDesktopListener = new InternalDesktopListener();
0314:            private static SoapUIActionRegistry actionRegistry;
0315:            private static Logger errorLog = Logger
0316:                    .getLogger("soapui.errorlog");
0317:            private static boolean logIsInitialized;
0318:
0319:            // --------------------------- CONSTRUCTORS ---------------------------
0320:
0321:            public SoapUI() {
0322:                instance = this ;
0323:                testMonitor = new TestMonitor();
0324:                actionRegistry = new SoapUIActionRegistry(SoapUI.class
0325:                        .getResourceAsStream("/soapui-actions.xml"));
0326:            }
0327:
0328:            private void buildUI() {
0329:                frame.addWindowListener(new MainFrameWindowListener());
0330:                UISupport.setMainFrame(frame);
0331:
0332:                navigator = new Navigator(workspace);
0333:                navigator.addNavigatorListener(new InternalNavigatorListener());
0334:
0335:                desktopPanelsList = new JDesktopPanelsList(desktop);
0336:
0337:                JSplitPane splitPane = UISupport.createHorizontalSplit(
0338:                        buildMainPanel(), buildContentPanel());
0339:
0340:                frame.setJMenuBar(buildMainMenu());
0341:                frame.getContentPane().add(splitPane, BorderLayout.CENTER);
0342:                frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
0343:                frame.setSize(1000, 750);
0344:
0345:                splitPane.setDividerLocation(250);
0346:
0347:                navigator.selectModelItem(workspace);
0348:
0349:                desktop.addDesktopListener(internalDesktopListener);
0350:
0351:                ToolTipManager.sharedInstance().setInitialDelay(200);
0352:            }
0353:
0354:            private JMenuBar buildMainMenu() {
0355:                menuBar = new JMenuBar();
0356:                menuBar.putClientProperty(Options.HEADER_STYLE_KEY,
0357:                        HeaderStyle.BOTH);
0358:
0359:                menuBar.add(buildFileMenu());
0360:                menuBar.add(buildToolsMenu());
0361:                menuBar.add(buildDesktopMenu());
0362:                menuBar.add(buildHelpMenu());
0363:
0364:                return menuBar;
0365:            }
0366:
0367:            public static Workspace getWorkspace() {
0368:                return workspace;
0369:            }
0370:
0371:            private JMenu buildDesktopMenu() {
0372:                desktopMenu = new JMenu("Desktop");
0373:                desktopMenu.setMnemonic(KeyEvent.VK_D);
0374:
0375:                ActionSupport.addActions(desktop.getActions(), desktopMenu);
0376:
0377:                return desktopMenu;
0378:            }
0379:
0380:            private JMenu buildHelpMenu() {
0381:                helpMenu = new JMenu("Help");
0382:                helpMenu.setMnemonic(KeyEvent.VK_H);
0383:
0384:                helpMenu.add(new ShowOnlineHelpAction("User Guide",
0385:                        HelpUrls.USERGUIDE_HELP_URL));
0386:                helpMenu.add(new ShowOnlineHelpAction("Getting Started",
0387:                        HelpUrls.GETTINGSTARTED_HELP_URL));
0388:                helpMenu.addSeparator();
0389:
0390:                helpMenu.add(new ShowSystemPropertiesAction());
0391:
0392:                helpMenu.addSeparator();
0393:                helpMenu.add(new OpenUrlAction("soapui.org",
0394:                        "http://www.soapui.org"));
0395:                helpMenu.add(new AboutAction());
0396:                return helpMenu;
0397:            }
0398:
0399:            @SuppressWarnings("unchecked")
0400:            private JMenu buildToolsMenu() {
0401:                toolsMenu = new JMenu("Tools");
0402:                toolsMenu.setMnemonic(KeyEvent.VK_T);
0403:
0404:                toolsMenu
0405:                        .add(SwingActionDelegate
0406:                                .createDelegate(WSToolsWsdl2JavaAction.SOAPUI_ACTION_ID));
0407:                toolsMenu.add(SwingActionDelegate
0408:                        .createDelegate(JBossWSConsumeAction.SOAPUI_ACTION_ID));
0409:                toolsMenu.addSeparator();
0410:                toolsMenu.add(SwingActionDelegate
0411:                        .createDelegate(WSCompileAction.SOAPUI_ACTION_ID));
0412:                toolsMenu.add(SwingActionDelegate
0413:                        .createDelegate(WSImportAction.SOAPUI_ACTION_ID));
0414:                toolsMenu.addSeparator();
0415:                toolsMenu
0416:                        .add(SwingActionDelegate
0417:                                .createDelegate(Axis1XWSDL2JavaAction.SOAPUI_ACTION_ID));
0418:                toolsMenu.add(SwingActionDelegate
0419:                        .createDelegate(Axis2WSDL2CodeAction.SOAPUI_ACTION_ID));
0420:                toolsMenu.add(SwingActionDelegate
0421:                        .createDelegate(XFireAction.SOAPUI_ACTION_ID));
0422:                toolsMenu
0423:                        .add(SwingActionDelegate
0424:                                .createDelegate(OracleWsaGenProxyAction.SOAPUI_ACTION_ID));
0425:                toolsMenu.addSeparator();
0426:                toolsMenu.add(SwingActionDelegate
0427:                        .createDelegate(XmlBeans2Action.SOAPUI_ACTION_ID));
0428:                toolsMenu.add(SwingActionDelegate
0429:                        .createDelegate(JaxbXjcAction.SOAPUI_ACTION_ID));
0430:                toolsMenu.addSeparator();
0431:                toolsMenu.add(SwingActionDelegate
0432:                        .createDelegate(DotNetWsdlAction.SOAPUI_ACTION_ID));
0433:                toolsMenu.add(SwingActionDelegate
0434:                        .createDelegate(GSoapAction.SOAPUI_ACTION_ID));
0435:                toolsMenu.addSeparator();
0436:                toolsMenu.add(SwingActionDelegate
0437:                        .createDelegate(TcpMonAction.SOAPUI_ACTION_ID));
0438:                // toolsMenu.addSeparator();
0439:                // toolsMenu.add( new XQueryXPathTesterAction());
0440:
0441:                return toolsMenu;
0442:            }
0443:
0444:            private JMenu buildFileMenu() {
0445:                fileMenu = new JMenu("File");
0446:                fileMenu.setMnemonic(KeyEvent.VK_F);
0447:
0448:                ActionList actions = ActionListBuilder.buildActions(workspace);
0449:                actions.removeAction(actions.getActionCount() - 1);
0450:
0451:                ActionSupport.addActions(actions, fileMenu);
0452:
0453:                fileMenu.add(SoapUIPreferencesAction.getInstance());
0454:                fileMenu.add(new SavePreferencesAction());
0455:                fileMenu.add(new ImportPreferencesAction());
0456:
0457:                fileMenu.addSeparator();
0458:                fileMenu.add(new ExitAction());
0459:                fileMenu.add(new ExitWithoutSavingAction());
0460:                fileMenu.addSeparator();
0461:                fileMenu.add(new ShowOnlineHelpAction(
0462:                        HelpUrls.OVERVIEW_HELP_URL));
0463:
0464:                return fileMenu;
0465:            }
0466:
0467:            public JFrame getFrame() {
0468:                return frame;
0469:            }
0470:
0471:            private JComponent buildMainPanel() {
0472:                JSplitPane splitPane = UISupport.createVerticalSplit();
0473:
0474:                splitPane
0475:                        .setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
0476:
0477:                splitPane.setTopComponent(navigator);
0478:                splitPane.setBottomComponent(buildOverviewPanel());
0479:                splitPane.setDividerLocation(500);
0480:                splitPane.setResizeWeight(0.6);
0481:                return splitPane;
0482:            }
0483:
0484:            private Component buildOverviewPanel() {
0485:                JTabbedPane detailTabs = new JTabbedPane(JTabbedPane.BOTTOM);
0486:
0487:                overviewPanel = new JPanel(new BorderLayout());
0488:                detailTabs.addTab("Details", overviewPanel);
0489:                detailTabs
0490:                        .addTab("Windows", new JScrollPane(desktopPanelsList));
0491:
0492:                return UISupport.createTabPanel(detailTabs, true);
0493:            }
0494:
0495:            private void setOverviewPanel(Component panel) {
0496:                if (overviewPanel.getComponentCount() == 0 && panel == null)
0497:                    return;
0498:
0499:                overviewPanel.removeAll();
0500:                if (panel != null)
0501:                    overviewPanel.add(panel, BorderLayout.CENTER);
0502:                overviewPanel.revalidate();
0503:                overviewPanel.repaint();
0504:            }
0505:
0506:            private Component buildContentPanel() {
0507:                contentSplit = UISupport.createVerticalSplit();
0508:                contentSplit.setBorder(BorderFactory.createEmptyBorder(2, 2, 2,
0509:                        2));
0510:
0511:                contentSplit.setTopComponent(desktop.getDesktopComponent());
0512:                contentSplit.setBottomComponent(buildLogPanel(true,
0513:                        "soapUI log"));
0514:                contentSplit.setDividerLocation(550);
0515:                contentSplit.setResizeWeight(1);
0516:                return contentSplit;
0517:            }
0518:
0519:            public Component buildLogPanel(boolean hasDefault,
0520:                    String defaultName) {
0521:                logMonitor = new Log4JMonitor();
0522:                logMonitor.addLogArea(defaultName, "com.eviware.soapui",
0523:                        hasDefault).setLevel(Level.DEBUG);
0524:                logMonitor.addLogArea("http log", "httpclient.wire", false)
0525:                        .setLevel(Level.DEBUG);
0526:                logMonitor.addLogArea("jetty log", "jetty", false).setLevel(
0527:                        Level.INFO);
0528:                logMonitor.addLogArea("error log", "soapui.errorlog", false)
0529:                        .setLevel(Level.DEBUG);
0530:
0531:                for (Object message : logCache) {
0532:                    logMonitor.logEvent(message);
0533:                }
0534:
0535:                return UISupport.createTabPanel(logMonitor, true);
0536:            }
0537:
0538:            // -------------------------- OTHER METHODS --------------------------
0539:
0540:            public static synchronized void log(final Object msg) {
0541:                if (instance == null || instance.logMonitor == null) {
0542:                    logCache.add(msg);
0543:                    return;
0544:                }
0545:
0546:                if (SwingUtilities.isEventDispatchThread()) {
0547:                    instance.logMonitor.logEvent(msg);
0548:                } else {
0549:                    SwingUtilities.invokeLater(new Runnable() {
0550:                        public void run() {
0551:                            instance.logMonitor.logEvent(msg);
0552:                        }
0553:                    });
0554:                }
0555:            }
0556:
0557:            // -------------------------- INNER CLASSES --------------------------
0558:
0559:            private final class InternalDesktopListener extends
0560:                    DesktopListenerAdapter {
0561:                public void desktopPanelSelected(DesktopPanel desktopPanel) {
0562:                    ModelItem modelItem = desktopPanel.getModelItem();
0563:                    if (modelItem != null)
0564:                        navigator.selectModelItem(modelItem);
0565:                }
0566:            }
0567:
0568:            private final class MainFrameWindowListener extends WindowAdapter {
0569:                public void windowClosing(WindowEvent e) {
0570:                    if (saveOnExit) {
0571:                        String question = "Exit SoapUI?";
0572:
0573:                        if (getTestMonitor().hasRunningTests())
0574:                            question += "\n(Projects with running tests will not be saved)";
0575:
0576:                        if (!UISupport.confirm(question, "Question"))
0577:                            return;
0578:
0579:                        try {
0580:                            saveSettings();
0581:                            workspace.onClose();
0582:                        } catch (IOException e1) {
0583:                            SoapUI.logError(e1);
0584:                        }
0585:                    } else {
0586:                        if (!UISupport.confirm("Exit SoapUI without saving?",
0587:                                "Question")) {
0588:                            saveOnExit = true;
0589:                            return;
0590:                        }
0591:                    }
0592:
0593:                    frame.dispose();
0594:                }
0595:
0596:                public void windowClosed(WindowEvent e) {
0597:                    System.out.println("exiting..");
0598:                    System.exit(0);
0599:                }
0600:            }
0601:
0602:            /**
0603:             * Adapted theme for soapUI Look and Feel
0604:             * 
0605:             * @author ole.matzura
0606:             */
0607:
0608:            public static class SoapUITheme extends SkyBluer {
0609:                public static final Color BACKGROUND_COLOR = new Color(240,
0610:                        240, 240);
0611:
0612:                public ColorUIResource getControl() {
0613:                    return new ColorUIResource(BACKGROUND_COLOR);
0614:                }
0615:
0616:                public ColorUIResource getMenuBackground() {
0617:                    return getControl();
0618:                }
0619:
0620:                public ColorUIResource getMenuItemBackground() {
0621:                    return new ColorUIResource(new Color(248, 248, 248));
0622:                }
0623:            }
0624:
0625:            // --------------------------- main() method ---------------------------
0626:
0627:            public static void main(String[] args) throws Exception {
0628:                String title = "soapUI " + SOAPUI_VERSION;
0629:                String splashImage = "soapui-splash.gif";
0630:
0631:                startSoapUI(args, title, findSplash(splashImage));
0632:            }
0633:
0634:            public static URL findSplash(String filename) {
0635:                File file = new File(filename);
0636:                URL url = null;
0637:
0638:                try {
0639:                    if (!file.exists())
0640:                        url = SoapUI.class.getResource("/" + filename);
0641:                    else
0642:                        url = file.toURL();
0643:                } catch (Exception e1) {
0644:                }
0645:
0646:                try {
0647:                    if (url == null)
0648:                        url = new URL("http://www.soapui.org/images/"
0649:                                + filename);
0650:                } catch (Exception e2) {
0651:                    SoapUI.logError(e2);
0652:                }
0653:
0654:                return url;
0655:            }
0656:
0657:            public static SoapUI startSoapUI(String[] args, String title,
0658:                    URL splashImage) throws FactoryConfigurationError,
0659:                    SoapUIException {
0660:                isStandalone = true;
0661:
0662:                // force loading of SoapVersion 
0663:                SoapVersion.Soap11.equals(SoapVersion.Soap12);
0664:
0665:                initSoapUILog();
0666:
0667:                frame = new JFrame(title);
0668:                new SoapUISplash(splashImage);
0669:
0670:                initSoapUILookAndFeel();
0671:                prepareSwingUI();
0672:                loadExtLibs();
0673:
0674:                DesktopRegistry.getInstance().addDesktop("Default",
0675:                        new StandaloneDesktopFactory());
0676:
0677:                // Run with the currently installed license.
0678:                SoapUI soapUI = new SoapUI();
0679:
0680:                Workspace workspace = null;
0681:
0682:                if (args.length > 0) {
0683:                    workspace = WorkspaceFactory.getInstance().openWorkspace(
0684:                            args);
0685:                    getSettings().setString(CURRENT_SOAPUI_WORKSPACE, args[0]);
0686:                } else {
0687:                    String wsfile = getSettings().getString(
0688:                            CURRENT_SOAPUI_WORKSPACE,
0689:                            System.getProperty("user.home")
0690:                                    + File.separatorChar
0691:                                    + DEFAULT_WORKSPACE_FILE);
0692:                    workspace = WorkspaceFactory.getInstance().openWorkspace(
0693:                            new String[] { wsfile });
0694:                }
0695:
0696:                soapUI.show(workspace);
0697:                return soapUI;
0698:            }
0699:
0700:            public static boolean isStandalone() {
0701:                return isStandalone;
0702:            }
0703:
0704:            public static void loadExtLibs() {
0705:                if (loadedExtLibs)
0706:                    return;
0707:
0708:                try {
0709:                    File dir = new File("ext");
0710:
0711:                    if (dir.exists() && dir.isDirectory()) {
0712:                        File[] files = dir.listFiles();
0713:                        for (File file : files) {
0714:                            if (file.getName().toLowerCase().endsWith(".jar")) {
0715:                                ClasspathHacker.addFile(file);
0716:                            }
0717:                        }
0718:                    } else {
0719:                        log.info("Missing folder [" + dir.getAbsolutePath()
0720:                                + "] for external libraries");
0721:                    }
0722:
0723:                    loadedExtLibs = true;
0724:                } catch (IOException e) {
0725:                    SoapUI.logError(e);
0726:                }
0727:            }
0728:
0729:            public static void prepareSwingUI() {
0730:                UISupport.setToolHost(new SwingToolHost());
0731:                XFormFactory.Factory.instance = new SwingFormFactory();
0732:            }
0733:
0734:            public static void initSoapUILookAndFeel() {
0735:                try {
0736:                    if (getSettings().getBoolean(UISettings.NATIVE_LAF)) {
0737:                        javax.swing.UIManager.setLookAndFeel(UIManager
0738:                                .getSystemLookAndFeelClassName());
0739:                    } else {
0740:                        SoapUITheme theme = new SoapUITheme();
0741:
0742:                        PlasticXPLookAndFeel.setCurrentTheme(theme);
0743:                        PlasticXPLookAndFeel.setTabStyle("Metal");
0744:
0745:                        UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
0746:                        UIManager.put("TabbedPane.tabAreaInsets", new Insets(3,
0747:                                2, 0, 0));
0748:                        UIManager.put("TabbedPane.unselectedBackground",
0749:                                new Color(220, 220, 220));
0750:                        UIManager.put("TabbedPane.selected", new Color(240,
0751:                                240, 240));
0752:
0753:                        PlasticXPLookAndFeel.setPlasticTheme(theme);
0754:                    }
0755:                } catch (Throwable e) {
0756:                    System.err
0757:                            .println("Error initializing PlasticXPLookAndFeel; "
0758:                                    + e.getMessage());
0759:                }
0760:            }
0761:
0762:            public static JMenuBar getMenuBar() {
0763:                return instance == null ? null : instance.menuBar;
0764:            }
0765:
0766:            public static void initSoapUILog() throws FactoryConfigurationError {
0767:                if (!logIsInitialized) {
0768:                    File log4jconfig = new File("soapui-log4j.xml");
0769:                    if (log4jconfig.exists()) {
0770:                        System.out.println("Configuring log4j from ["
0771:                                + log4jconfig + "]");
0772:                        DOMConfigurator.configureAndWatch(log4jconfig
0773:                                .getAbsolutePath(), 5000);
0774:                    } else {
0775:                        URL log4jUrl = SoapUI.class
0776:                                .getResource("/soapui-log4j.xml");
0777:                        System.out.println("Configuring log4j from ["
0778:                                + log4jUrl + "]");
0779:                        DOMConfigurator.configure(log4jUrl);
0780:                    }
0781:
0782:                    logIsInitialized = true;
0783:                }
0784:            }
0785:
0786:            private void show(Workspace workspace) {
0787:                SoapUI.workspace = workspace;
0788:
0789:                String desktopType = getSettings().getString(
0790:                        UISettings.DESKTOP_TYPE, "Default");
0791:                desktop = DesktopRegistry.getInstance().createDesktop(
0792:                        desktopType, workspace);
0793:
0794:                if (desktop == null)
0795:                    desktop = new StandaloneDesktop(workspace);
0796:
0797:                getSettings().addSettingsListener(new SettingsListener() {
0798:
0799:                    public void settingChanged(String name, String newValue,
0800:                            String oldValue) {
0801:                        if (name.equals(UISettings.DESKTOP_TYPE)) {
0802:                            changeDesktop(DesktopRegistry.getInstance()
0803:                                    .createDesktop(newValue, SoapUI.workspace));
0804:                        }
0805:                    }
0806:                });
0807:
0808:                buildUI();
0809:                testMonitor
0810:                        .addTestMonitorListener(new LogDisablingTestMonitorListener());
0811:                testMonitor.init(workspace);
0812:                frame.setVisible(true);
0813:            }
0814:
0815:            private void changeDesktop(SoapUIDesktop newDesktop) {
0816:                desktopPanelsList.setDesktop(newDesktop);
0817:                desktop.removeDesktopListener(internalDesktopListener);
0818:
0819:                desktop.transferTo(newDesktop);
0820:                desktop.release();
0821:
0822:                desktop = newDesktop;
0823:                contentSplit.setTopComponent(desktop.getDesktopComponent());
0824:
0825:                desktop.addDesktopListener(internalDesktopListener);
0826:
0827:                desktopMenu.removeAll();
0828:                ActionSupport.addActions(desktop.getActions(), desktopMenu);
0829:            }
0830:
0831:            public static void logError(Throwable e) {
0832:                String msg = e.getMessage();
0833:                if (msg == null)
0834:                    msg = e.toString();
0835:
0836:                log.error("An error occured [" + msg
0837:                        + "], see error log for details");
0838:                errorLog.error(e.toString(), e);
0839:            }
0840:
0841:            public static synchronized Logger ensureGroovyLog() {
0842:                if (!checkedGroovyLogMonitor) {
0843:                    Log4JMonitor logMonitor = getLogMonitor();
0844:                    if (logMonitor != null
0845:                            && !logMonitor.hasLogArea("groovy.log"))
0846:                        logMonitor
0847:                                .addLogArea("groovy log", "groovy.log", false);
0848:
0849:                    checkedGroovyLogMonitor = true;
0850:                }
0851:
0852:                return Logger.getLogger("groovy.log");
0853:            }
0854:
0855:            public class InternalNavigatorListener implements  NavigatorListener {
0856:                public void nodeSelected(SoapUITreeNode treeNode) {
0857:                    if (treeNode == null) {
0858:                        setOverviewPanel(null);
0859:                    } else {
0860:                        PanelBuilder<ModelItem> panelBuilder = PanelBuilderRegistry
0861:                                .getPanelBuilder(treeNode.getModelItem());
0862:                        if (panelBuilder != null
0863:                                && panelBuilder.hasOverviewPanel()) {
0864:                            setOverviewPanel(panelBuilder
0865:                                    .buildOverviewPanel(treeNode.getModelItem()));
0866:                        } else {
0867:                            setOverviewPanel(null);
0868:                        }
0869:                    }
0870:                }
0871:            }
0872:
0873:            private class ExitAction extends AbstractAction {
0874:                public ExitAction() {
0875:                    super ("Exit");
0876:                    putValue(Action.SHORT_DESCRIPTION,
0877:                            "Saves all projects and exits SoapUI");
0878:                    putValue(Action.ACCELERATOR_KEY, UISupport
0879:                            .getKeyStroke("menu Q"));
0880:                }
0881:
0882:                public void actionPerformed(ActionEvent e) {
0883:                    saveOnExit = true;
0884:                    WindowEvent windowEvent = new WindowEvent(frame,
0885:                            WindowEvent.WINDOW_CLOSING);
0886:                    frame.dispatchEvent(windowEvent);
0887:                }
0888:            }
0889:
0890:            private class ShowSystemPropertiesAction extends AbstractAction {
0891:                public ShowSystemPropertiesAction() {
0892:                    super ("System Properties");
0893:                    putValue(Action.SHORT_DESCRIPTION,
0894:                            "Shows the current systems properties");
0895:                }
0896:
0897:                public void actionPerformed(ActionEvent e) {
0898:                    StringBuffer buffer = new StringBuffer();
0899:                    Properties properties = System.getProperties();
0900:
0901:                    List<String> keys = new ArrayList<String>();
0902:                    for (Object key : properties.keySet())
0903:                        keys.add(key.toString());
0904:
0905:                    Collections.sort(keys);
0906:
0907:                    String lastKey = null;
0908:
0909:                    for (String key : keys) {
0910:                        if (lastKey != null) {
0911:                            if (!key.startsWith(lastKey))
0912:                                buffer.append("\r\n");
0913:                        }
0914:
0915:                        int ix = key.indexOf('.');
0916:                        lastKey = ix == -1 ? key : key.substring(0, ix);
0917:
0918:                        buffer.append(key).append('=').append(
0919:                                properties.get(key)).append("\r\n");
0920:                    }
0921:
0922:                    UISupport.showExtendedInfo("System Properties",
0923:                            "Current system properties",
0924:                            "<html><body><pre><font size=-1>"
0925:                                    + buffer.toString()
0926:                                    + "</font></pre></body></html>",
0927:                            new Dimension(600, 400));
0928:                }
0929:            }
0930:
0931:            private class AboutAction extends AbstractAction {
0932:                public AboutAction() {
0933:                    super ("About soapUI");
0934:                    putValue(Action.SHORT_DESCRIPTION,
0935:                            "Shows information on soapUI");
0936:                }
0937:
0938:                public void actionPerformed(ActionEvent e) {
0939:                    URI splashURI = null;
0940:                    try {
0941:                        splashURI = SoapUI.findSplash(SoapUI.SOAPUI_SPLASH_GIF)
0942:                                .toURI();
0943:                    } catch (URISyntaxException e1) {
0944:                        SoapUI.logError(e1);
0945:                    }
0946:
0947:                    Properties props = new Properties();
0948:                    try {
0949:                        props.load(SoapUI.class
0950:                                .getResourceAsStream("/buildinfo.txt"));
0951:                    } catch (Exception e1) {
0952:                        SoapUI.logError(e1);
0953:                    }
0954:
0955:                    UISupport
0956:                            .showExtendedInfo(
0957:                                    "About soapUI",
0958:                                    null,
0959:                                    "<html><body><p align=center><img src=\""
0960:                                            + splashURI
0961:                                            + "\"><br>soapUI "
0962:                                            + SOAPUI_VERSION
0963:                                            + ", copyright (C) 2004-2007 eviware.com<br>"
0964:                                            + "<a href=\"http://www.soapui.org\">http://www.soapui.org</a> | "
0965:                                            + "<a href=\"http://www.eviware.com\">http://www.eviware.com</a><br>"
0966:                                            + "Build "
0967:                                            + props.getProperty("build.number")
0968:                                            + ", Build Date "
0969:                                            + props.getProperty("build.date")
0970:                                            + "</p></body></html>",
0971:
0972:                                    new Dimension(470, 350));
0973:                }
0974:            }
0975:
0976:            private class ExitWithoutSavingAction extends AbstractAction {
0977:                public ExitWithoutSavingAction() {
0978:                    super ("Exit without saving");
0979:                    putValue(Action.SHORT_DESCRIPTION,
0980:                            "Saves all projects and exits SoapUI");
0981:                    putValue(Action.ACCELERATOR_KEY, UISupport
0982:                            .getKeyStroke("ctrl alt Q"));
0983:                }
0984:
0985:                public void actionPerformed(ActionEvent e) {
0986:                    saveOnExit = false;
0987:                    WindowEvent windowEvent = new WindowEvent(frame,
0988:                            WindowEvent.WINDOW_CLOSING);
0989:                    frame.dispatchEvent(windowEvent);
0990:                }
0991:            }
0992:
0993:            private class SavePreferencesAction extends AbstractAction {
0994:                public SavePreferencesAction() {
0995:                    super ("Save Preferences");
0996:                    putValue(Action.SHORT_DESCRIPTION,
0997:                            "Saves all global preferences");
0998:                }
0999:
1000:                public void actionPerformed(ActionEvent e) {
1001:                    try {
1002:                        saveSettings();
1003:                    } catch (IOException e1) {
1004:                        UISupport.showErrorMessage(e1);
1005:                    }
1006:                }
1007:            }
1008:
1009:            private class ImportPreferencesAction extends AbstractAction {
1010:                public ImportPreferencesAction() {
1011:                    super ("Import Preferences");
1012:                    putValue(Action.SHORT_DESCRIPTION,
1013:                            "Imports soapUI Settings from another settings-file");
1014:                }
1015:
1016:                public void actionPerformed(ActionEvent e) {
1017:                    try {
1018:                        // prompt for import
1019:                        File file = UISupport.getFileDialogs().open(null,
1020:                                "Import Preferences", ".xml",
1021:                                "soapUI Settings XML (*.xml)", null);
1022:                        if (file != null) {
1023:                            SoapuiSettingsDocumentConfig doc = SoapuiSettingsDocumentConfig.Factory
1024:                                    .parse(file);
1025:                            settingsDocument.set(doc);
1026:                        }
1027:                    } catch (Exception e1) {
1028:                        UISupport.showErrorMessage(e1);
1029:                    }
1030:                }
1031:            }
1032:
1033:            public static TestMonitor getTestMonitor() {
1034:                return testMonitor;
1035:            }
1036:
1037:            public static void setTestMonitor(TestMonitor monitor) {
1038:                testMonitor = monitor;
1039:            }
1040:
1041:            public static Log4JMonitor getLogMonitor() {
1042:                return instance == null ? null : instance.logMonitor;
1043:            }
1044:
1045:            public static void setLogMonitor(Log4JMonitor monitor) {
1046:                if (instance != null)
1047:                    instance.logMonitor = monitor;
1048:            }
1049:
1050:            public static Settings getSettings() {
1051:                if (settings == null) {
1052:                    if (settingsDocument == null)
1053:                        initSettings(DEFAULT_SETTINGS_FILE);
1054:
1055:                    if (settingsDocument.getSoapuiSettings() == null) {
1056:                        settingsDocument.addNewSoapuiSettings();
1057:                        settings = new XmlBeansSettingsImpl(null, null,
1058:                                settingsDocument.getSoapuiSettings());
1059:
1060:                        settings.setBoolean(WsdlSettings.CACHE_WSDLS, true);
1061:                        settings.setBoolean(
1062:                                WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES,
1063:                                true);
1064:
1065:                        settings.setBoolean(
1066:                                HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN,
1067:                                true);
1068:                        settings.setBoolean(
1069:                                HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN,
1070:                                true);
1071:                    } else {
1072:                        settings = new XmlBeansSettingsImpl(null, null,
1073:                                settingsDocument.getSoapuiSettings());
1074:                    }
1075:
1076:                    if (!settings.isSet(WsdlSettings.EXCLUDED_TYPES)) {
1077:                        StringList list = new StringList();
1078:                        list.add("schema@http://www.w3.org/2001/XMLSchema");
1079:                        settings.setString(WsdlSettings.EXCLUDED_TYPES, list
1080:                                .toXml());
1081:                    }
1082:
1083:                    if (!settings.isSet(WsdlSettings.NAME_WITH_BINDING)) {
1084:                        settings.setBoolean(WsdlSettings.NAME_WITH_BINDING,
1085:                                true);
1086:                    }
1087:
1088:                    if (!settings.isSet(HttpSettings.MAX_CONNECTIONS_PER_HOST)) {
1089:                        settings.setLong(HttpSettings.MAX_CONNECTIONS_PER_HOST,
1090:                                500);
1091:                    }
1092:
1093:                    if (!settings.isSet(HttpSettings.MAX_TOTAL_CONNECTIONS)) {
1094:                        settings.setLong(HttpSettings.MAX_TOTAL_CONNECTIONS,
1095:                                2000);
1096:                    }
1097:                }
1098:
1099:                return settings;
1100:            }
1101:
1102:            public static void saveSettings() throws IOException {
1103:                File file = new File(DEFAULT_SETTINGS_FILE);
1104:                settingsDocument.save(file);
1105:                log.info("Saved global preferences to ["
1106:                        + file.getAbsolutePath() + "]");
1107:            }
1108:
1109:            /**
1110:             * Initializes the soapui settings from the specified file. Must be called on
1111:             * startup before any model items are created.
1112:             * 
1113:             * @param fileName
1114:             */
1115:
1116:            public static void initSettings(String fileName) {
1117:                try {
1118:                    File settingsFile = new File(fileName);
1119:                    if (!settingsFile.exists()) {
1120:                        if (isStandalone) {
1121:                            settingsFile = importSettingsOnStartup(settingsFile);
1122:                        }
1123:
1124:                        if (settingsDocument == null) {
1125:                            log.info("Creating new settings at ["
1126:                                    + settingsFile.getAbsolutePath() + "]");
1127:                            settingsDocument = SoapuiSettingsDocumentConfig.Factory
1128:                                    .newInstance();
1129:                        }
1130:                    } else {
1131:                        settingsDocument = SoapuiSettingsDocumentConfig.Factory
1132:                                .parse(settingsFile);
1133:                        log.info("initialized soapui-settings from ["
1134:                                + settingsFile.getAbsolutePath() + "]");
1135:                    }
1136:                } catch (Exception e) {
1137:                    log.warn("Failed to load settings from [" + e.getMessage()
1138:                            + "], creating new");
1139:                    settingsDocument = SoapuiSettingsDocumentConfig.Factory
1140:                            .newInstance();
1141:                }
1142:            }
1143:
1144:            private static File importSettingsOnStartup(File settingsFile)
1145:                    throws Exception {
1146:                javax.swing.UIManager.setLookAndFeel(UIManager
1147:                        .getSystemLookAndFeelClassName());
1148:                if (JOptionPane
1149:                        .showConfirmDialog(
1150:                                null,
1151:                                "Missing soapUI Settings, import from existing installation?",
1152:                                "Import Preferences", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
1153:                    while (true) {
1154:                        settingsFile = SwingFileDialogs.openFile(null,
1155:                                "Import Preferences", ".xml",
1156:                                "soapUI settings XML", settingsFile
1157:                                        .getAbsolutePath());
1158:                        if (settingsFile != null) {
1159:                            try {
1160:                                settingsDocument = SoapuiSettingsDocumentConfig.Factory
1161:                                        .parse(settingsFile);
1162:                                log.info("imported soapui-settings from ["
1163:                                        + settingsFile.getAbsolutePath() + "]");
1164:                                break;
1165:                            } catch (Exception e) {
1166:                                if (JOptionPane.showConfirmDialog(null,
1167:                                        "Error loading settings from ["
1168:                                                + settingsFile
1169:                                                        .getAbsolutePath()
1170:                                                + "]\r\nspecify another?",
1171:                                        "Error Importing",
1172:                                        JOptionPane.OK_CANCEL_OPTION,
1173:                                        JOptionPane.ERROR_MESSAGE) == JOptionPane.CANCEL_OPTION) {
1174:                                    break;
1175:                                }
1176:                            }
1177:                        }
1178:                    }
1179:                }
1180:
1181:                return settingsFile;
1182:            }
1183:
1184:            // instance is null in Eclipse. /Lars
1185:            // eclipse-version(s) should provide SoapUIDesktop implementation
1186:            public static SoapUIDesktop getDesktop() {
1187:                return instance != null ? instance.desktop : null;
1188:            }
1189:
1190:            public static void setDesktop(SoapUIDesktop desktop) {
1191:                if (instance != null)
1192:                    instance.desktop = desktop;
1193:            }
1194:
1195:            public static Navigator getNavigator() {
1196:                return instance != null ? instance.navigator : null;
1197:            }
1198:
1199:            public static SoapUIActionRegistry getActionRegistry() {
1200:                return actionRegistry;
1201:            }
1202:
1203:            public static void setNavigator(Navigator navigator) {
1204:                if (instance != null)
1205:                    instance.navigator = navigator;
1206:            }
1207:
1208:            static class SoapUISplash extends JWindow {
1209:                public SoapUISplash(URL splashImage) {
1210:                    super (frame);
1211:                    JLabel l = new JLabel(new ImageIcon(splashImage));
1212:                    getContentPane().add(l, BorderLayout.CENTER);
1213:                    pack();
1214:                    Dimension screenSize = Toolkit.getDefaultToolkit()
1215:                            .getScreenSize();
1216:                    Dimension labelSize = l.getPreferredSize();
1217:                    setLocation(screenSize.width / 2 - (labelSize.width / 2),
1218:                            screenSize.height / 2 - (labelSize.height / 2));
1219:                    addMouseListener(new MouseAdapter() {
1220:                        public void mousePressed(MouseEvent e) {
1221:                            if (frame.isVisible()) {
1222:                                setVisible(false);
1223:                                dispose();
1224:                            }
1225:                        }
1226:                    });
1227:                    final int pause = 1000;
1228:                    final Runnable closerRunner = new Runnable() {
1229:                        public void run() {
1230:                            setVisible(false);
1231:                            dispose();
1232:                        }
1233:                    };
1234:
1235:                    Runnable waitRunner = new Runnable() {
1236:                        public void run() {
1237:                            try {
1238:                                do {
1239:                                    Thread.sleep(pause);
1240:                                } while (!frame.isVisible());
1241:
1242:                                SwingUtilities.invokeAndWait(closerRunner);
1243:                            } catch (Exception e) {
1244:                                SoapUI.logError(e);
1245:                                // can catch InvocationTargetException
1246:                                // can catch InterruptedException
1247:                            }
1248:                        }
1249:                    };
1250:                    setVisible(true);
1251:                    Thread splashThread = new Thread(waitRunner, "SplashThread");
1252:                    splashThread.start();
1253:                }
1254:            }
1255:
1256:            public static MockEngine getMockEngine() {
1257:                if (mockEngine == null)
1258:                    mockEngine = new MockEngine();
1259:
1260:                return mockEngine;
1261:            }
1262:
1263:            public static String getSchemaDirectory() {
1264:                return SoapUI.getSettings().getString(
1265:                        WsdlSettings.SCHEMA_DIRECTORY, null);
1266:            }
1267:
1268:            public static Collection<? extends QName> getExcludedTypes() {
1269:                List<QName> result = new ArrayList<QName>();
1270:
1271:                String excluded = SoapUI.getSettings().getString(
1272:                        WsdlSettings.EXCLUDED_TYPES, null);
1273:                if (excluded != null && excluded.trim().length() > 0) {
1274:                    try {
1275:                        StringList names = StringList.fromXml(excluded);
1276:                        for (String name : names) {
1277:                            int ix = name.indexOf('@');
1278:                            result.add(new QName(name.substring(ix + 1), name
1279:                                    .substring(0, ix)));
1280:                        }
1281:                    } catch (Exception e) {
1282:                        SoapUI.logError(e);
1283:                    }
1284:                }
1285:
1286:                return result;
1287:            }
1288:
1289:            public static void setStandalone(boolean b) {
1290:                SoapUI.isStandalone = b;
1291:            }
1292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.