Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrealey2005-04-19 17:35:02 +0000
committercbrealey2005-04-19 17:35:02 +0000
commit971d821534b5c95766bd2839d77be1e4b518d73b (patch)
tree302d5be26445644d36e59abebd479e2e17c19ab3 /bundles/org.eclipse.wst.ws.explorer/src/org/eclipse
parent8d8e8d6abe52012d9c8a6174777f608a0890b48a (diff)
downloadwebtools.webservices-971d821534b5c95766bd2839d77be1e4b518d73b.tar.gz
webtools.webservices-971d821534b5c95766bd2839d77be1e4b518d73b.tar.xz
webtools.webservices-971d821534b5c95766bd2839d77be1e4b518d73b.zip
[88679] [91880] Refactor Web Services Explorer from component jst.ws to wst.ws / Delete obsolete org.eclipse.wst.ws plugins
Diffstat (limited to 'bundles/org.eclipse.wst.ws.explorer/src/org/eclipse')
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/CatalinaRunnable.java59
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOption.java51
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOptions.java50
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardRunnable.java52
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardTask.java65
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorer.java230
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerContext.java15
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerLauncherCommand.java87
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeDefault.java77
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeWSE.java76
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/plugin/ExplorerPlugin.java194
-rw-r--r--bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/popup/PopupTestWSDL.java122
12 files changed, 1078 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/CatalinaRunnable.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/CatalinaRunnable.java
new file mode 100644
index 000000000..19ba1f16f
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/CatalinaRunnable.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.ws.internal.explorer;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.help.internal.appserver.AppserverPlugin;
+import org.eclipse.help.internal.appserver.WebappManager;
+
+public class CatalinaRunnable {
+
+ private static CatalinaRunnable catalinaRunnable_;
+
+ private CatalinaRunnable() {
+ }
+
+ public static CatalinaRunnable getCatalinaRunnable() {
+ if (catalinaRunnable_ == null) {
+ catalinaRunnable_ = new CatalinaRunnable();
+ catalinaRunnable_.init();
+ }
+ return catalinaRunnable_;
+ }
+
+ public boolean isTomcatStarted() {
+ try {
+ return AppserverPlugin.getDefault().getAppServer().isRunning();
+ } catch (Throwable t) {
+ return false;
+ }
+ }
+
+ public int getTomcatPort() {
+ return WebappManager.getPort();
+ }
+
+ private void init() {
+ WSExplorer wsExplorer = WSExplorer.getInstance();
+ String ctxt = wsExplorer.getContextName();
+ String pluginID = wsExplorer.getParentPluginID();
+ String warLocation = wsExplorer.getWARLocation();
+ String webappLocation = wsExplorer.getWebAppLocation();
+ try {
+ if (warLocation != null)
+ WebappManager.start(ctxt, pluginID, new Path(warLocation));
+ else
+ WebappManager.start(ctxt, pluginID, new Path(webappLocation));
+ } catch (Throwable t) {
+ }
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOption.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOption.java
new file mode 100644
index 000000000..3666ede76
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOption.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.ws.internal.explorer;
+
+/**
+ * @author cbrealey@ca.ibm.com
+ *
+ * This simple class is used to hold a single Web Services
+ * Explorer launch option property and its value. Allowed
+ * launch option properties are defined by
+ * <code>{@link LaunchOptions}</code>.
+ */
+public class LaunchOption {
+ private String key_;
+
+ private String option_;
+
+ /*
+ * Constructs a new launch option with the given
+ * property name and value.
+ */
+ public LaunchOption(String key, String option) {
+ key_ = key;
+ option_ = option;
+ }
+
+ /**
+ * Returns the property name of this launch option.
+ * @return The property name.
+ */
+ public String getKey() {
+ return key_;
+ }
+
+ /**
+ * Returns the property value of this launch option.
+ * @return The property value.
+ */
+ public String getOption() {
+ return option_;
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOptions.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOptions.java
new file mode 100644
index 000000000..392f03b11
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchOptions.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.ws.internal.explorer;
+
+/**
+ * @author cbrealey@ca.ibm.com
+ *
+ * This class defines the property names understood by the Web Services Explorer
+ * and used to configure it's initial appearance and behaviour at the time it is
+ * launched.
+ * @see LaunchOption
+ */
+public class LaunchOptions {
+ // General purpose preload constants
+
+ public static final String STATE_LOCATION = "stateLocation";
+
+ public static final String DEFAULT_FAVORITES_LOCATION = "defaultFavoritesLocation";
+
+ // WSDL Page preload constants
+
+ public static final String WSDL_URL = "wsdl";
+
+ public static final String WEB_SERVICE_ENDPOINT = "webServiceEndpoint";
+
+ public static final String SERVICE_QNAME_STRING = "serviceQNameString";
+
+ public static final String BINDING_NAME_STRING = "bindingNameString";
+
+ // UDDI Page preload constants
+
+ public static final String INQUIRY_URL = "inquiry";
+
+ public static final String PUBLISH_URL = "publish";
+
+ public static final String SERVICE_NAME = "serviceName";
+
+ public static final String SERVICE_KEY = "serviceKey";
+
+ public static final String CATEGORIES_DIRECTORY = "categoriesDirectory";
+}
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardRunnable.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardRunnable.java
new file mode 100644
index 000000000..6375d5312
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardRunnable.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.ws.internal.explorer;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.command.internal.env.ui.widgets.DynamicWizard;
+
+public class LaunchWizardRunnable extends Thread implements Runnable {
+ private String id;
+
+ private String wsdlURL;
+
+ private boolean finish;
+
+ public LaunchWizardRunnable(String id, String wsdlURL) {
+ this.id = id;
+ this.wsdlURL = (wsdlURL != null) ? wsdlURL : "";
+ finish = false;
+ }
+
+ public boolean isFinish() {
+ return finish;
+ }
+
+ public void run() {
+ try {
+ DynamicWizard wizard = new DynamicWizard();
+ wizard.setInitialData(id);
+ IStructuredSelection sel = new StructuredSelection(wsdlURL);
+ wizard.init(null, sel);
+ WizardDialog wd = new WizardDialog(new Shell(Display.getDefault(),
+ SWT.APPLICATION_MODAL), wizard);
+ wd.open();
+ } catch (Exception e) {
+ } finally {
+ finish = true;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardTask.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardTask.java
new file mode 100644
index 000000000..f5329e2f4
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/LaunchWizardTask.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.ws.internal.explorer;
+
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+public class LaunchWizardTask {
+ // singleton
+ private static LaunchWizardTask task_;
+
+ // the shell for the wizard to be launched
+ private Shell shell_;
+
+ // the LaunchWizardRunnable that is currently running
+ private LaunchWizardRunnable runnable_;
+
+ private LaunchWizardTask(Shell shell) {
+ shell_ = shell;
+ runnable_ = null;
+ }
+
+ public static LaunchWizardTask getInstance() {
+ if (task_ == null)
+ task_ = new LaunchWizardTask(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell());
+ return task_;
+ }
+
+ public void asyncExec(Runnable runnable) throws SWTException {
+ shell_.getDisplay().asyncExec(runnable);
+ }
+
+ public boolean checkAndAsyncExec(LaunchWizardRunnable runnable) {
+ try {
+ if (!getIsExecuting()) {
+ asyncExec(runnable);
+ runnable_ = runnable;
+ return true;
+ } else
+ return false;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public boolean getIsExecuting() {
+ if (runnable_ != null) {
+ boolean isFinish = runnable_.isFinish();
+ if (isFinish)
+ runnable_ = null;
+ return !isFinish;
+ } else
+ return false;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorer.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorer.java
new file mode 100644
index 000000000..31675476f
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorer.java
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.ws.internal.explorer;
+
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin;
+
+public class WSExplorer {
+ private static WSExplorer instance;
+
+ private static int launchOptionsKey_ = 0;
+
+ public WSExplorer() {
+ }
+
+ public static WSExplorer getInstance() {
+ if (instance == null) {
+ instance = new WSExplorer();
+ }
+ return instance;
+ }
+
+ public String getContextName() {
+ return "wsexplorer";
+ }
+
+ public String getParentPluginID() {
+ return ExplorerPlugin.ID;
+ }
+
+ public String getWARLocation() {
+ return "wsexplorer.war";
+ }
+
+ public String getWebAppLocation() {
+ return "wsexplorer";
+ }
+
+ public String getWelcomeURL() {
+ return "wsexplorer.jsp";
+ }
+
+ public String getLaunchOptionRegistryURL() {
+ return "launch_options_registry.jsp";
+ }
+
+ public String getBaseURL() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("http://localhost:");
+ sb.append(CatalinaRunnable.getCatalinaRunnable().getTomcatPort());
+ sb.append("/");
+ sb.append(getContextName());
+ sb.append("/");
+ return sb.toString();
+ }
+
+ public String getMetadataDirectory() {
+ // <workspace>/.metadata/.plugins/org.eclipse.wst.ws.explorer/ (note
+ // the trailing separator).
+ return ExplorerPlugin.getInstance().getPluginStateLocation();
+ }
+
+ public IStatus launch(IWorkbench wb, IStructuredSelection sel,
+ LaunchOption[] options, boolean forceLaunchOutsideIDE) {
+ // launchOptionKey
+ int launchOptionKey = getLaunchOptionsKey();
+ // Web Services Explorer URL
+ StringBuffer sb = new StringBuffer();
+ sb.append(getBaseURL());
+ sb.append(getWelcomeURL());
+ sb.append("?");
+ if (options != null && options.length > 0) {
+ String encodedID = null;
+ try {
+ encodedID = URLEncoder.encode(ExplorerPlugin.ID,
+ ExplorerPlugin.CHARSET);
+ } catch (UnsupportedEncodingException e) {
+ return new Status(
+ IStatus.ERROR,
+ ExplorerPlugin.ID,
+ 0,
+ ExplorerPlugin
+ .getMessage("%MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8"),
+ e);
+ }
+ sb.append(encodedID);
+ sb.append("=");
+ sb.append(launchOptionKey);
+ }
+ // launch Web Services Explorer
+ try {
+ URL url = new URL(sb.toString());
+ if (forceLaunchOutsideIDE) {
+ if (System.getProperty("os.name").toLowerCase().indexOf("win") == -1)
+ Runtime.getRuntime()
+ .exec("mozilla " + url.toExternalForm());
+ else
+ Runtime.getRuntime().exec(
+ "cmd /C start iexplore " + url.toExternalForm());
+ } else {
+ // browserId
+ StringBuffer browserId = new StringBuffer();
+ browserId.append(ExplorerPlugin.ID);
+ browserId.append(getContextName());
+
+ IWorkbenchBrowserSupport browserSupport = ExplorerPlugin.getInstance().getWorkbench().getBrowserSupport();
+ IWebBrowser browser = browserSupport.createBrowser(browserId.toString());
+ browser.openURL(url);
+ }
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, ExplorerPlugin.ID, 0,
+ ExplorerPlugin.getMessage("%MSG_ERROR_LAUNCH_WSEXPLORER"),
+ e);
+ }
+ // register launch options
+ if (options != null && options.length > 0) {
+ try {
+ StringBuffer launchOptionsRegURL = new StringBuffer();
+ launchOptionsRegURL.append(getBaseURL());
+ launchOptionsRegURL.append(getLaunchOptionRegistryURL());
+ URL url = new URL(launchOptionsRegURL.toString());
+ URLConnection connection = url.openConnection();
+ connection.setDoOutput(true);
+ PrintWriter out = new PrintWriter(connection.getOutputStream());
+ StringBuffer params = new StringBuffer();
+ String encodedID = null;
+ try {
+ encodedID = URLEncoder.encode(ExplorerPlugin.ID,
+ ExplorerPlugin.CHARSET);
+ } catch (UnsupportedEncodingException e) {
+ return new Status(
+ IStatus.ERROR,
+ ExplorerPlugin.ID,
+ 0,
+ ExplorerPlugin
+ .getMessage("%MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8"),
+ e);
+ }
+ params.append(encodedID);
+ params.append("=");
+ params.append(launchOptionKey);
+ params.append("&");
+ for (int i = 0; i < options.length; i++) {
+ if (options[i] != null) {
+ params.append(options[i].getKey());
+ params.append("=");
+ String option = null;
+ try {
+ option = URLEncoder.encode(options[i].getOption(),
+ ExplorerPlugin.CHARSET);
+ } catch (UnsupportedEncodingException e) {
+ return new Status(
+ IStatus.ERROR,
+ ExplorerPlugin.ID,
+ 0,
+ ExplorerPlugin
+ .getMessage("%MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8"),
+ e);
+ }
+ params.append(option);
+ params.append("&");
+ }
+ }
+ out.print(params.toString());
+ out.close();
+ out = null;
+ InputStream is = connection.getInputStream();
+ is.close();
+ is = null;
+ } catch (Exception e) {
+ return new Status(IStatus.WARNING, ExplorerPlugin.ID, 0,
+ ExplorerPlugin
+ .getMessage("%MSG_ERROR_LOAD_LAUNCH_OPTIONS"),
+ e);
+ }
+ }
+ return new Status(IStatus.OK, ExplorerPlugin.ID, 0, "", null);
+ }
+
+ private static int getLaunchOptionsKey() {
+ return launchOptionsKey_++;
+ }
+
+ public IStatus launch(IWorkbench wb, IStructuredSelection sel,
+ String[] inquiryURL, String[] publishURL,
+ boolean forceLaunchOutsideIDE) {
+ int inquiryURLOptionLength = (inquiryURL != null) ? inquiryURL.length
+ : 0;
+ int publishURLOptionLength = (publishURL != null) ? publishURL.length
+ : 0;
+ LaunchOption[] options = new LaunchOption[inquiryURLOptionLength
+ + publishURLOptionLength];
+ int index = 0;
+ if (inquiryURL != null) {
+ for (int i = 0; i < inquiryURL.length; i++) {
+ options[index] = new LaunchOption(LaunchOptions.INQUIRY_URL,
+ inquiryURL[i]);
+ index++;
+ }
+ }
+ if (publishURL != null) {
+ for (int i = 0; i < publishURL.length; i++) {
+ options[index] = new LaunchOption(LaunchOptions.PUBLISH_URL,
+ publishURL[i]);
+ index++;
+ }
+ }
+ return launch(wb, sel, options, forceLaunchOutsideIDE);
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerContext.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerContext.java
new file mode 100644
index 000000000..9d8ee2c16
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerContext.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.ws.internal.explorer;
+
+public final class WSExplorerContext {
+ public static final String ID = "org.eclipse.wst.ws.explorer";
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerLauncherCommand.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerLauncherCommand.java
new file mode 100644
index 000000000..6069758b3
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/WSExplorerLauncherCommand.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.ws.internal.explorer;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.command.internal.env.common.EnvironmentUtils;
+import org.eclipse.wst.command.internal.provisional.env.core.SimpleCommand;
+import org.eclipse.wst.command.internal.provisional.env.core.common.Environment;
+import org.eclipse.wst.command.internal.provisional.env.core.common.Status;
+
+/**
+ * @author cbrealey@ca.ibm.com
+ *
+ * This <code>Command</code>, when executed, launches the
+ * Web Services Explorer.
+ */
+public class WSExplorerLauncherCommand extends SimpleCommand {
+ private boolean forceLaunchOutsideIDE;
+
+ private LaunchOption[] launchOptions;
+
+ public WSExplorerLauncherCommand() {
+ super("WSExplorerLauncherCommand", "WSExplorerLauncherCommand");
+ }
+
+ public void writeCategoryInfo(String inquiryURL, String categoriesDirectory) {
+ try {
+ Properties p = new Properties();
+ p.setProperty(LaunchOptions.CATEGORIES_DIRECTORY,
+ categoriesDirectory);
+ StringBuffer propertiesFileName = new StringBuffer();
+ propertiesFileName.append(WSExplorer.getInstance()
+ .getMetadataDirectory());
+ File metadataDirectoryFile = new File(propertiesFileName.toString());
+ if (!metadataDirectoryFile.exists()) {
+ metadataDirectoryFile.mkdirs();
+ }
+ propertiesFileName.append(URLEncoder.encode(inquiryURL,"UTF-8")).append(
+ ".properties");
+ FileOutputStream fout = new FileOutputStream(propertiesFileName
+ .toString());
+ p.store(fout, null);
+ fout.close();
+ } catch (IOException e) {
+ }
+ }
+
+ public IStatus execute() {
+ return WSExplorer.getInstance().launch(null, null, launchOptions,
+ forceLaunchOutsideIDE);
+ }
+
+ public Status execute(Environment env) {
+ return EnvironmentUtils.convertIStatusToStatus(execute());
+ }
+
+ /**
+ * @param forceLaunchOutsideIDE
+ * The forceLaunchOutsideIDE to set.
+ */
+ public void setForceLaunchOutsideIDE(boolean forceLaunchOutsideIDE) {
+ this.forceLaunchOutsideIDE = forceLaunchOutsideIDE;
+ }
+
+ /**
+ * @param launchOptions
+ * The launchOptions to set.
+ */
+ public void setLaunchOptions(LaunchOption[] launchOptions) {
+ this.launchOptions = launchOptions;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeDefault.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeDefault.java
new file mode 100644
index 000000000..f1816997c
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeDefault.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.ws.internal.explorer.favorites;
+
+import java.io.IOException;
+
+import org.apache.wsil.WSILDocument;
+import org.apache.wsil.WSILException;
+import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin;
+import org.eclipse.wst.ws.internal.parser.favorites.FavoritesRegistryTypeAbstract;
+import org.eclipse.wst.ws.internal.parser.favorites.IFavoritesUDDIRegistry;
+
+public class FavoritesRegistryTypeDefault extends FavoritesRegistryTypeAbstract {
+ private static WSILDocument wsilDoc_;
+
+ public static final String FAVORITES_DEFAULT = "properties/favorites_default.wsil";
+
+ private String defaultFavorites_ = null;
+
+ public FavoritesRegistryTypeDefault() {
+ super();
+ wsilDoc_ = null;
+ }
+
+ public FavoritesRegistryTypeDefault(String defaultFavorites) {
+ super();
+ wsilDoc_ = null;
+ defaultFavorites_ = defaultFavorites;
+ }
+
+ public String getReadLocation() {
+ StringBuffer readLocation = new StringBuffer();
+ if (defaultFavorites_ == null)
+ {
+ readLocation.append(ExplorerPlugin.getInstance().getPluginInstallLocation());
+ readLocation.append(FAVORITES_DEFAULT);
+ }
+ else
+ {
+ readLocation.append(defaultFavorites_);
+ }
+ return readLocation.toString();
+ }
+
+ public String getWriteLocation() {
+ return null;
+ }
+
+ protected WSILDocument getWSILDocument() {
+ if (wsilDoc_ == null) {
+ wsilDoc_ = loadWSILDocument(getReadLocation(), true);
+ IFavoritesUDDIRegistry[] registries = getFavoritesUDDIRegistries();
+ /* TODO: Public registry strings shouldn't be in properties - Ain't extensible.
+ for (int i = 0; i < registries.length; i++) {
+ registries[i].setName(WSPlugin.getResourceString(registries[i].getName()));
+ }
+ */
+ }
+ return wsilDoc_;
+ }
+
+ public WSILDocument getFavoritesDefault() {
+ return getWSILDocument();
+ }
+
+ public void save() throws WSILException, IOException {
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeWSE.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeWSE.java
new file mode 100644
index 000000000..253fc8c16
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/favorites/FavoritesRegistryTypeWSE.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.ws.internal.explorer.favorites;
+
+import org.apache.wsil.WSILDocument;
+import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin;
+import org.eclipse.wst.ws.internal.parser.favorites.FavoritesRegistryTypeAbstract;
+
+
+public class FavoritesRegistryTypeWSE extends FavoritesRegistryTypeAbstract
+{
+ private static WSILDocument wsilDoc_;
+ public static final String FAVORITES_WSEXPLORER = "favorites.wsil";
+ private String defaultFavorites_ = null;
+ private String stateLocation_ = null;
+
+ public FavoritesRegistryTypeWSE()
+ {
+ super();
+ wsilDoc_ = null;
+ }
+
+ public FavoritesRegistryTypeWSE(String defaultFavorites, String stateLocation) {
+ super();
+ wsilDoc_ = null;
+ defaultFavorites_ = defaultFavorites;
+ stateLocation_ = stateLocation;
+ }
+
+ public String getReadLocation()
+ {
+ StringBuffer readLocation = new StringBuffer();
+ readLocation.append(stateLocation_ == null ? ExplorerPlugin.getInstance().getPluginStateLocation() : stateLocation_);
+ readLocation.append(FAVORITES_WSEXPLORER);
+ return readLocation.toString();
+ }
+
+ public String getWriteLocation()
+ {
+ return getReadLocation();
+ }
+
+ protected WSILDocument getWSILDocument()
+ {
+ if (wsilDoc_ == null)
+ {
+ wsilDoc_ = loadWSILDocument(getReadLocation(), false);
+ if (wsilDoc_ == null)
+ {
+ restoreFavoritesDefault();
+ try
+ {
+ save();
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
+ return wsilDoc_;
+ }
+
+ public void restoreFavoritesDefault()
+ {
+ wsilDoc_ = (new FavoritesRegistryTypeDefault(defaultFavorites_)).getWSILDocument();
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/plugin/ExplorerPlugin.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/plugin/ExplorerPlugin.java
new file mode 100644
index 000000000..4eddd5916
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/plugin/ExplorerPlugin.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.ws.internal.explorer.plugin;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.Hashtable;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.ws.internal.explorer.LaunchWizardTask;
+import org.eclipse.wst.ws.internal.explorer.favorites.FavoritesRegistryTypeDefault;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * This is the plugin class for the Web Services Explorer.
+ */
+public class ExplorerPlugin extends AbstractUIPlugin
+{
+ /**
+ * The identifier of the descriptor of this plugin in plugin.xml.
+ */
+ public static final String ID = "org.eclipse.wst.ws.explorer";
+ public static final String CHARSET = "UTF-8";
+ /**
+ * The reference to the singleton instance of this plugin.
+ */
+ private static ExplorerPlugin instance_;
+
+ /**
+ * Constructs a runtime plugin object for this plugin. The "plugin" element
+ * in plugin.xml should include the attribute class =
+ * "org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin".
+ *
+ * @param descriptor
+ * The descriptor of this plugin.
+ */
+ public ExplorerPlugin()
+ {
+ super();
+ instance_ = this;
+ }
+
+ /**
+ * Returns the singleton instance of this plugin. Equivalent to calling
+ * (ExplorerPlugin)Platform.getPlugin("org.eclipse.wst.ws.explorer");
+ *
+ * @return The ExplorerPlugin singleton.
+ */
+ static public ExplorerPlugin getInstance()
+ {
+ return instance_;
+ }
+
+ /**
+ * Called once by the platform when this plugin is first loaded.
+ *
+ * @throws CoreException
+ * If this plugin fails to start.
+ */
+ public void start(BundleContext bundle) throws Exception
+ {
+ super.start(bundle);
+ // init the shell of LaunchWizardTask
+ LaunchWizardTask.getInstance();
+ }
+
+ /**
+ * Called once by the platform when this plugin is unloaded.
+ *
+ * @throws CoreException
+ * If this plugin fails to shutdown.
+ */
+ public void stop(BundleContext bundle) throws Exception
+ {
+ super.stop(bundle);
+ }
+
+ /**
+ * Returns the message string identified by the given key from the
+ * plugin.properties file for the appropriate locale.
+ *
+ * @param key
+ * The message key string prefixed by a "%" symbol. That is, the
+ * string passed in must be of the form "%KEY" where the
+ * plugin.properties file contains a line of the form: "KEY =
+ * value".
+ * @return The locale-specific message.
+ */
+ public static String getMessage(String key)
+ {
+ return Platform.getResourceString(instance_.getBundle(), key);
+ }
+
+ /**
+ * Returns the message string identified by the given key from the
+ * plugin.properties file for the appropriate locale. Substitution sequences
+ * in the message string are replaced by the given array of substitution
+ * objects (which are most frequently strings). See java.text.MessageFormat
+ * for further details on substitution.
+ *
+ * @param key
+ * The message key string prefixed by a "%" symbol. That is, the
+ * string passed in must be of the form "%KEY" where the
+ * plugin.properties file contains a line of the form: "KEY =
+ * value".
+ * @param args
+ * The substitution values for the message as required by the
+ * message in plugin.properties and by the rules of class
+ * java.text.MessageFormat.
+ * @return The locale-specific message.
+ */
+ public static String getMessage(String key, Object[] args)
+ {
+ return MessageFormat.format(getMessage(key), args);
+ }
+
+ /**
+ * Returns an image descriptor for the named resource as relative to the
+ * plugin install location.
+ *
+ * @return An image descriptor, possibly null.
+ */
+ public static ImageDescriptor getImageDescriptor(String name)
+ {
+ try
+ {
+ URL installURL = instance_.getBundle().getEntry("/");
+ URL imageURL = new URL(installURL, name);
+ return ImageDescriptor.createFromURL(imageURL);
+ }
+ catch (MalformedURLException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * See IPluginHelper.
+ */
+ public void setMsgLoggerConfig(Hashtable msgLoggerConfig)
+ {
+ }
+
+ /**
+ * See IPluginHelper.
+ */
+ public Hashtable getMsgLoggerConfig(Plugin plugin)
+ {
+ return new Hashtable();
+ }
+
+ /**
+ * See IPluginHelper.
+ */
+ public Hashtable getMsgLoggerConfig()
+ {
+ return getMsgLoggerConfig(this);
+ }
+
+ public String getPluginStateLocation()
+ {
+ return Platform.getPluginStateLocation(this).addTrailingSeparator().toOSString();
+ }
+
+ public String getDefaultFavoritesLocation()
+ {
+ return getPluginInstallLocation()+FavoritesRegistryTypeDefault.FAVORITES_DEFAULT;
+ }
+
+ public String getPluginInstallLocation()
+ {
+ try
+ {
+ return Platform.resolve(instance_.getBundle().getEntry("/")).getFile();
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/popup/PopupTestWSDL.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/popup/PopupTestWSDL.java
new file mode 100644
index 000000000..ef6803fdb
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/popup/PopupTestWSDL.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.ws.internal.explorer.popup;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.wst.ws.internal.explorer.LaunchOption;
+import org.eclipse.wst.ws.internal.explorer.LaunchOptions;
+import org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand;
+import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin;
+import org.eclipse.wst.ws.internal.monitor.GetMonitorCommand;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class PopupTestWSDL extends Action implements IActionDelegate
+{
+ public PopupTestWSDL()
+ {
+ super(ExplorerPlugin.getMessage("%POPUP_TEST_WSDL"));
+ }
+
+ private IStructuredSelection getWorkbenchSelection()
+ {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null)
+ {
+ ISelection selection = window.getSelectionService().getSelection();
+ if (selection instanceof IStructuredSelection)
+ return (IStructuredSelection)selection;
+ }
+ return null;
+ }
+
+ public void run()
+ {
+ String stateLocation = ExplorerPlugin.getInstance().getPluginStateLocation();
+ String defaultFavoritesLocation = ExplorerPlugin.getInstance().getDefaultFavoritesLocation();
+ WSExplorerLauncherCommand command = new WSExplorerLauncherCommand();
+ command.setForceLaunchOutsideIDE(false);
+ IStructuredSelection selection = getWorkbenchSelection();
+ Vector launchOptions = new Vector();
+ if (selection != null)
+ {
+ for (Iterator it = selection.iterator(); it.hasNext();)
+ {
+ String wsdlURL = null;
+ Object object = it.next();
+ if (object instanceof IResource)
+ {
+ File wsdlFile = ((IResource)object).getLocation().toFile();
+ try
+ {
+ wsdlURL = wsdlFile.toURL().toString();
+ }
+ catch (MalformedURLException murle)
+ {
+ wsdlURL = wsdlFile.toString();
+ }
+ }
+ /* TODO: Move this up to org.eclipse.jst.ws.ui.
+ if (object instanceof ServiceImpl)
+ {
+ ServiceImpl serviceImpl = (ServiceImpl)object;
+ wsdlURL = J2EEActionAdapterFactory.getWSDLURI(serviceImpl);
+ }
+ if (object instanceof ServiceRef)
+ {
+ ServiceRef serviceImpl = (ServiceRef)object;
+ wsdlURL = J2EEActionAdapterFactory.getWSDLURI(serviceImpl);
+ }
+ if (object instanceof WSDLResourceImpl)
+ {
+ WSDLResourceImpl WSDLRImpl = (WSDLResourceImpl)object;
+ wsdlURL = J2EEActionAdapterFactory.getWSDLURI(WSDLRImpl);
+ }
+ */
+ GetMonitorCommand getMonitorCmd = new GetMonitorCommand();
+ getMonitorCmd.setMonitorService(true);
+ getMonitorCmd.setCreate(false);
+ getMonitorCmd.setWebServicesParser(new WebServicesParser());
+ getMonitorCmd.setWsdlURI(wsdlURL);
+ getMonitorCmd.execute(null);
+ List endpoints = getMonitorCmd.getEndpoints();
+ for (Iterator endpointsIt = endpoints.iterator(); endpointsIt.hasNext();)
+ launchOptions.add(new LaunchOption(LaunchOptions.WEB_SERVICE_ENDPOINT, (String)endpointsIt.next()));
+ launchOptions.add(new LaunchOption(LaunchOptions.WSDL_URL, wsdlURL));
+ launchOptions.add(new LaunchOption(LaunchOptions.STATE_LOCATION,stateLocation));
+ launchOptions.add(new LaunchOption(LaunchOptions.DEFAULT_FAVORITES_LOCATION,defaultFavoritesLocation));
+ }
+ }
+ command.setLaunchOptions((LaunchOption[])launchOptions.toArray(new LaunchOption[0]));
+ command.execute();
+ }
+
+ public void run(IAction action)
+ {
+ run();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ }
+}

Back to the top