Author: Grid.Qian
Date: 2008-06-27 04:19:24 -0400 (Fri, 27 Jun 2008)
New Revision: 8979
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java
Removed:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.core/build.properties
trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java
trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF
Log:
JBIDE-2047: codes review and make some change for file format
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC
(rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC
(rev 8979)
@@ -4,7 +4,7 @@
Bundle-SymbolicName: org.jboss.tools.ws.core;singleton:=true
Bundle-Version: 1.0.0
Bundle-Localization: plugin
-Bundle-Activator: org.jboss.tools.ws.core.JbossWSCorePlugin
+Bundle-Activator: org.jboss.tools.ws.core.JBossWSCorePlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.wst.common.project.facet.core,
@@ -22,7 +22,7 @@
org.eclipse.jdt.launching,
org.eclipse.jst.j2ee,
org.eclipse.jst.ws.consumption.ui
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Bundle-Vendor: %PLUGIN_PROVIDER
Export-Package: org.jboss.tools.ws.core,
org.jboss.tools.ws.core.classpath,
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/build.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/build.properties 2008-06-27 06:07:21 UTC (rev
8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/build.properties 2008-06-27 08:19:24 UTC (rev
8979)
@@ -2,4 +2,5 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ plugin.properties
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml 2008-06-27 06:07:21 UTC (rev
8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml 2008-06-27 08:19:24 UTC (rev
8979)
@@ -20,7 +20,7 @@
facet="jbossws.core"
id="jbossws.core.install"
type="INSTALL">
- <delegate
class="org.jboss.tools.ws.core.facet.delegate.JbossWSInstallRuntimeDelegate"/>
+ <delegate
class="org.jboss.tools.ws.core.facet.delegate.JBossWSInstallRuntimeDelegate"/>
<config-factory
class="org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider">
</config-factory>
@@ -30,7 +30,7 @@
id="jbossws.core.uninstall"
type="UNINSTALL">
<delegate
-
class="org.jboss.tools.ws.core.facet.delegate.JbossWSUnInstallRuntimeDelegate">
+
class="org.jboss.tools.ws.core.facet.delegate.JBossWSUnInstallRuntimeDelegate">
</delegate>
</action>
@@ -49,7 +49,7 @@
<extension
point="org.eclipse.jdt.core.classpathContainerInitializer">
<classpathContainerInitializer
-
class="org.jboss.tools.ws.core.classpath.JbossWSRuntimeClassPathInitializer"
+
class="org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer"
id="JBossWS_Runtime">
</classpathContainerInitializer>
</extension>
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+
+package org.jboss.tools.ws.core;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class JBossWSCorePlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.ws.core";
+
+ // The shared instance
+ private static JBossWSCorePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public JBossWSCorePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static JBossWSCorePlugin getDefault() {
+ return plugin;
+ }
+
+}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-
-package org.jboss.tools.ws.core;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class JbossWSCorePlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.ws.core";
-
- // The shared instance
- private static JbossWSCorePlugin plugin;
-
- /**
- * The constructor
- */
- public JbossWSCorePlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static JbossWSCorePlugin getDefault() {
- return plugin;
- }
-
-}
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.classpath;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntime {
+
+ String name = null;
+
+ String homeDir = null;
+
+ String version = null;
+
+ boolean defaultRt = false;
+
+ List<String> libraries;
+
+ private boolean userConfigClasspath;
+
+ /**
+ * Default constructor
+ */
+ public JBossWSRuntime() {
+ libraries = new ArrayList<String>();
+ }
+
+ /**
+ * Get JBossWSRuntime name
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get path to home directory
+ *
+ * @return home directory path as string
+ */
+ public String getHomeDir() {
+ return homeDir;
+ }
+
+ /**
+ * Set JBossWSRuntime name
+ *
+ * @param name
+ * new JBossWSRuntime name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set home directory
+ *
+ * @param homeDir
+ * new JBossWSRuntime's home directory
+ */
+ public void setHomeDir(String homeDir) {
+ this.homeDir = homeDir;
+ }
+
+ /**
+ * Mark runtime as default
+ *
+ * @param b
+ * new value for default property
+ */
+ public void setDefault(boolean b) {
+ this.defaultRt = b;
+ }
+
+ /**
+ * Get default flag
+ *
+ * @return default property
+ */
+ public boolean isDefault() {
+ return defaultRt;
+ }
+
+ public List<String> getLibraries(){
+
+ return this.libraries;
+ }
+
+ public void setLibraries(List<String> libraries){
+ this.libraries = libraries;
+ }
+
+ public boolean isUserConfigClasspath(){
+ return this.userConfigClasspath;
+ }
+
+ public void setUserConfigClasspath(boolean userConfigClasspath){
+ this.userConfigClasspath = userConfigClasspath;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+}
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.classpath;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimeClassPathInitializer extends
+ ClasspathContainerInitializer {
+
+ public JBossWSRuntimeClassPathInitializer() {
+ }
+
+ private String segment;
+
+ @Override
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException {
+
+ if (containerPath.segment(0).equals(
+ JBossWSCoreMessages.JBossWS_Runtime_Lib)) {
+ JBossWSRuntimeClasspathContainer container = new JBossWSRuntimeClasspathContainer(
+ containerPath);
+ segment = containerPath.segment(1);
+ JavaCore.setClasspathContainer(containerPath,
+ new IJavaProject[] { project },
+ new IClasspathContainer[] { container }, null);
+ }
+ }
+
+ public IClasspathEntry[] getEntries(IPath path) {
+ return new JBossWSRuntimeClasspathContainer(path).getClasspathEntries();
+ }
+
+ public class JBossWSRuntimeClasspathContainer implements
+ IClasspathContainer {
+ private IPath path;
+ private IClasspathEntry[] entries = null;
+
+ public JBossWSRuntimeClasspathContainer(IPath path) {
+ this.path = path;
+ }
+
+ public String getDescription() {
+ return JBossWSCoreMessages.JBossWS_Runtime;
+ }
+
+ public int getKind() {
+ return IClasspathContainer.K_APPLICATION;
+ }
+
+ public IPath getPath() {
+ return path;
+ }
+
+ public IClasspathEntry[] getClasspathEntries() {
+ if (entries == null) {
+ ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance()
+ .findRuntimeByName(segment);
+ if (jbws != null) {
+
+ List<String> jars =
JBossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws);
+ for (String jar : jars) {
+ entryList.add(getEntry(new Path(jar)));
+ }
+ entries = entryList.toArray(new IClasspathEntry[entryList.size()]);
+ if (entries == null)
+ return new IClasspathEntry[0];
+ }
+ }
+ return entries;
+ }
+
+ protected IClasspathEntry getEntry(IPath path) {
+ return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
+ .getClasspathEntry();
+ }
+
+ public void removeEntry(String jarName) {
+ if (entries == null) {
+ return;
+ }
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
+ int i = 0;
+ for (IClasspathEntry entry : entries) {
+ if (!entry.toString().contains(jarName)) {
+ newEntries[i++] = entry;
+ }
+ }
+ entries = newEntries;
+ }
+
+ }
+
+ public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
+ for (IClasspathEntry entry : list) {
+ if (entry.getPath().lastSegment().equals(jarName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,141 @@
+package org.jboss.tools.ws.core.classpath;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+
+/**
+ *
+ * @author Grid Qian
+ *
+ */
+public class JBossWSRuntimeListConverter {
+
+ /*
+ * Constants definitions
+ */
+ private static final String REGEXP_ESCAPE = "\\";
+ private static final String COMMA = ",";
+ private static final String LIBRARY_SEPARATOR = ";";
+ private static final String EMPTY_STRING = "";
+ private static final String FIELD_SEPARATOR = "|";
+ private static final String DEFAULT = "default";
+ private static final String HOME_DIR = "homeDir";
+ private static final String VERSION = "version";
+ private static final String NAME = "name";
+ private static final String USER_CONFIG_CLASSPATH = "userConfig";
+ private static final String LIBRARY = "libraries";
+
+ /**
+ * Load String to JBossWSRuntime map from String
+ * @param input
+ * String representation of map
+ * @return
+ * Map<String, JBossWSRuntime> loaded from string
+ * TODO - switch to XML?
+ * TODO - write converter from old serialization format to XML?
+ * TODO - handle errors in string format
+ */
+ public Map<String, JBossWSRuntime> getMap(String input) {
+
+ Map<String, JBossWSRuntime> result = new HashMap<String,
JBossWSRuntime>();
+ if (input == null || EMPTY_STRING.equals(input.trim())) {
+ return result;
+ }
+ StringTokenizer runtimes = new StringTokenizer(input, COMMA);
+ while (runtimes.hasMoreTokens()) {
+ String runtime = runtimes.nextToken();
+ String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
+ JBossWSRuntime rt = new JBossWSRuntime();
+ final int step = 2;
+ for (int i = 0; i < map.length; i += step) {
+ String name = map[i];
+ String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
+ if (NAME.equals(name)) {
+ rt.setName(value);
+ } else if (HOME_DIR.equals(name)) {
+ rt.setHomeDir(value);
+ } else if (VERSION.equals(name)) {
+ rt.setVersion(value);
+ } else if (DEFAULT.equals(name)) {
+ rt.setDefault(Boolean.parseBoolean(value));
+ }else if(USER_CONFIG_CLASSPATH.equals(name)){
+ rt.setUserConfigClasspath(Boolean.parseBoolean(value));
+ }else if(LIBRARY.equals(name)){
+ if(value != null && !EMPTY_STRING.equals(value)){
+ rt.setLibraries(getLibrariesFromString(value));
+ }
+ }
+
+ }
+ result.put(rt.getName(), rt);
+ }
+
+ return result;
+ }
+
+ private List<String> getLibrariesFromString(String strLibraries){
+ List<String> libraries = new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(strLibraries, LIBRARY_SEPARATOR);
+ while(st.hasMoreTokens()){
+ String library = st.nextToken();
+ if(!libraries.contains(library)){
+ libraries.add(library);
+ }
+ }
+ return libraries;
+
+ }
+
+ private String convertListToString(List<String> libraries){
+ String strLib = "";
+ for(String library: libraries){
+ if("".equals(strLib)){
+ strLib = library;
+ }else{
+ strLib = strLib + LIBRARY_SEPARATOR + library;
+ }
+ }
+ return strLib;
+ }
+
+ /**
+ * Convert map String to JBossWSRUntime to string representation
+ * @param runtimeMap
+ * Map<String, JBossWSRuntime> - map of String to JBossWS Runtime to
convert
+ * in String
+ * @return
+ * String representation of String to JBossWS Runtime map
+ */
+ public String getString(Map<String, JBossWSRuntime> runtimeMap) {
+ StringBuffer buffer = new StringBuffer();
+ JBossWSRuntime[] runtimes = runtimeMap.values().toArray(
+ new JBossWSRuntime[runtimeMap.size()]);
+ for (int i = 0; i < runtimes.length; i++) {
+ buffer.append(NAME).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getName());
+ buffer.append(FIELD_SEPARATOR).append(VERSION).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getVersion());
+ buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getHomeDir());
+ buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isDefault());
+ buffer.append(FIELD_SEPARATOR).append(USER_CONFIG_CLASSPATH).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isUserConfigClasspath());
+ buffer.append(FIELD_SEPARATOR).append(LIBRARY).append(FIELD_SEPARATOR);
+ buffer.append(convertListToString(runtimes[i].getLibraries()));
+ if (i != runtimes.length - 1) {
+ buffer.append(COMMA);
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,359 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.classpath;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimeManager {
+
+ private static JBossWSRuntimeListConverter converter = new
JBossWSRuntimeListConverter();
+
+ private Map<String, JBossWSRuntime> runtimes = new HashMap<String,
JBossWSRuntime>();
+
+ /**
+ * Private constructor
+ */
+ private JBossWSRuntimeManager() {
+ load();
+ }
+
+ /**
+ * This class make Java Runtime responsible for solving synchronization
+ * problems during initialization if there is any
+ *
+ */
+ static class JBossWSRuntimeManagerHolder {
+ private static final JBossWSRuntimeManager INSTANCE = new JBossWSRuntimeManager();
+ }
+
+ /**
+ * Return JBossWSRuntimeManaher instance
+ *
+ * @return JBossWSRuntimeManager instance
+ */
+ public static JBossWSRuntimeManager getInstance() {
+ return JBossWSRuntimeManagerHolder.INSTANCE;
+ }
+
+ /**
+ * Return Array of configured JBossWSRuntimes
+ *
+ * @return JBossWSRuntime[]
+ */
+ public JBossWSRuntime[] getRuntimes() {
+ Collection<JBossWSRuntime> c = runtimes.values();
+ return c.toArray(new JBossWSRuntime[runtimes.size()]);
+ }
+
+ /**
+ * Add new JBossWSRuntime
+ *
+ * @param runtime
+ * JBossWSRuntime
+ */
+ public void addRuntime(JBossWSRuntime runtime) {
+ if (runtimes.size() == 0) {
+ runtime.setDefault(true);
+ }
+
+ JBossWSRuntime oldDefaultRuntime = getDefaultRuntime();
+ if (oldDefaultRuntime != null && runtime.isDefault()) {
+ oldDefaultRuntime.setDefault(false);
+ }
+ runtimes.put(runtime.getName(), runtime);
+ save();
+ }
+
+ /**
+ * Add new JBossWSRuntime with given parameters
+ *
+ * @param name
+ * String - runtime name
+ * @param path
+ * String - runtime home folder
+ * @param version
+ * String - string representation of version number
+ * @param defaultRt
+ * boolean - default flag
+ */
+ public void addRuntime(String name, String path, String version,
+ boolean defaultRt) {
+ JBossWSRuntime jbossWSRt = new JBossWSRuntime();
+ jbossWSRt.setHomeDir(path);
+ jbossWSRt.setName(name);
+ jbossWSRt.setVersion(version);
+ jbossWSRt.setDefault(defaultRt);
+ addRuntime(jbossWSRt);
+ }
+
+ /**
+ * Return JBossWSRuntime by given name
+ *
+ * @param name
+ * String - JBossWSRuntime name
+ * @return JBossWSRuntime - found JBossWSRuntime instance or null
+ */
+ public JBossWSRuntime findRuntimeByName(String name) {
+ for (JBossWSRuntime jbossWSRuntime : runtimes.values()) {
+ if (jbossWSRuntime.getName().equals(name)) {
+ return jbossWSRuntime;
+ }
+ }
+ return null;
+ }
+
+ public List<String> getAllRuntimeJars(JBossWSRuntime rt){
+ List<String> jarList = new ArrayList<String>();
+ if (rt != null) {
+ if (rt.isUserConfigClasspath()) {
+ jarList.addAll(rt.getLibraries());
+
+ } else {
+ IPath wsPath = new Path(rt.getHomeDir());
+ if (wsPath != null) {
+ IPath libPath = wsPath
+ .append(JBossWSCoreMessages.Dir_Lib);
+ List<File> libs = getJarsOfFolder(libPath.toFile());
+ libPath = wsPath
+ .append(JBossWSCoreMessages.Dir_Client);
+ List<File> clientJars = getJarsOfFolder(libPath.toFile());
+
+ jarList = mergeTwoList(libs, clientJars);
+ }
+ }
+
+ }
+ return jarList;
+ }
+
+
+
+ private List<File> getJarsOfFolder(File folder){
+ List<File> jars = new ArrayList<File>();
+ if(folder.isDirectory()){
+ for(File file: folder.listFiles()){
+ if(file.isFile() && (file.getName().endsWith(".jar") ||
file.getName().endsWith(".zip"))){
+ jars.add(file);
+ }else if (folder.isDirectory()){
+ jars.addAll(getJarsOfFolder(file));
+ }
+ }
+ }
+
+ return jars;
+ }
+
+ // if two folders have the same jar file, one of them will be ignored.
+ private List<String> mergeTwoList(List<File> jarList1, List<File>
jarList2){
+ List<String> rtList = new ArrayList<String>();
+ List<String> distinctFileNames = new ArrayList<String>();
+
+ for(File jarFile: jarList1){
+ distinctFileNames.add(jarFile.getName());
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ for(File jarFile: jarList2){
+ if(!distinctFileNames.contains(jarFile.getName())){
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ }
+
+ return rtList;
+
+ }
+
+ /**
+ * Remove given JBossWSRuntime from manager
+ *
+ * @param rt
+ * JBossWSRuntime
+ */
+ public void removeRuntime(JBossWSRuntime rt) {
+ runtimes.remove(rt.getName());
+ }
+
+ /**
+ * Save preference value and force save changes to disk
+ */
+ public void save() {
+ JBossWSCorePlugin.getDefault().getPreferenceStore().setValue(
+ JBossWSCoreMessages.WS_Location, converter.getString(runtimes));
+ IPreferenceStore store = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Marks this runtime as default. Marks other runtimes with the same version
+ * as not default.
+ *
+ * @param runtime
+ */
+ public void setDefaultRuntime(JBossWSRuntime runtime) {
+ JBossWSRuntime[] runtimes = getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ runtimes[i].setDefault(false);
+ }
+ runtime.setDefault(true);
+ }
+
+ /**
+ * Return first default JBossWSRuntime
+ *
+ * @return JBossWSRuntime
+ */
+ public JBossWSRuntime getDefaultRuntime() {
+ for (JBossWSRuntime rt : runtimes.values()) {
+ if (rt.isDefault()) {
+ return rt;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return list of available JBossWSRuntime names
+ *
+ * @return List<String>
+ */
+ public List<String> getRuntimeNames() {
+ JBossWSRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossWSRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * Return a list of all runtime names
+ *
+ * @return List of all runtime names
+ */
+ public List<String> getAllRuntimeNames() {
+ JBossWSRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossWSRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * TBD
+ *
+ * @param oldName
+ * old runtime name
+ * @param newName
+ * new runtime name
+ */
+ public void changeRuntimeName(String oldName, String newName) {
+ JBossWSRuntime o = findRuntimeByName(oldName);
+ if (o == null) {
+ return;
+ }
+ o.setName(newName);
+ onRuntimeNameChanged(oldName, newName);
+ }
+
+ private void onRuntimeNameChanged(String oldName, String newName) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet("jbossws.core");
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName =
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ String name = null;
+ try {
+ name = facetedProject.getProject().getPersistentProperty(
+ qRuntimeName);
+ if (name != null && name.equals(oldName)) {
+ facetedProject.getProject().setPersistentProperty(
+ qRuntimeName, newName);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public static boolean isRuntimeUsed(String name) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet("jbossws.core");
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName =
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ try {
+ if (name.equals(facetedProject.getProject()
+ .getPersistentProperty(qRuntimeName))) {
+ return true;
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ public void load() {
+ IPreferenceStore ps = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+
+ String runtimeListString = ps
+ .getString(JBossWSCoreMessages.WS_Location);
+
+ runtimes = converter.getMap(runtimeListString);
+ }
+
+}
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.classpath;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntime {
-
- String name = null;
-
- String homeDir = null;
-
- String version = null;
-
- boolean defaultRt = false;
-
- List<String> libraries;
-
- private boolean userConfigClasspath;
-
- /**
- * Default constructor
- */
- public JbossWSRuntime() {
- libraries = new ArrayList<String>();
- }
-
- /**
- * Get JbossWSRuntime name
- *
- * @return name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get path to home directory
- *
- * @return home directory path as string
- */
- public String getHomeDir() {
- return homeDir;
- }
-
- /**
- * Set JbossWSRuntime name
- *
- * @param name
- * new JbossWSRuntime name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Set home directory
- *
- * @param homeDir
- * new JbossWSRuntime's home directory
- */
- public void setHomeDir(String homeDir) {
- this.homeDir = homeDir;
- }
-
- /**
- * Mark runtime as default
- *
- * @param b
- * new value for default property
- */
- public void setDefault(boolean b) {
- this.defaultRt = b;
- }
-
- /**
- * Get default flag
- *
- * @return default property
- */
- public boolean isDefault() {
- return defaultRt;
- }
-
- public List<String> getLibraries(){
-
- return this.libraries;
- }
-
- public void setLibraries(List<String> libraries){
- this.libraries = libraries;
- }
-
- public boolean isUserConfigClasspath(){
- return this.userConfigClasspath;
- }
-
- public void setUserConfigClasspath(boolean userConfigClasspath){
- this.userConfigClasspath = userConfigClasspath;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.classpath;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.ClasspathContainerInitializer;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimeClassPathInitializer extends
- ClasspathContainerInitializer {
-
- public JbossWSRuntimeClassPathInitializer() {
- }
-
- private String segment;
-
- @Override
- public void initialize(IPath containerPath, IJavaProject project)
- throws CoreException {
-
- if (containerPath.segment(0).equals(
- JbossWSCoreMessages.JBossWS_Runtime_Lib)) {
- JbossWSRuntimeClasspathContainer container = new JbossWSRuntimeClasspathContainer(
- containerPath);
- segment = containerPath.segment(1);
- JavaCore.setClasspathContainer(containerPath,
- new IJavaProject[] { project },
- new IClasspathContainer[] { container }, null);
- }
- }
-
- public IClasspathEntry[] getEntries(IPath path) {
- return new JbossWSRuntimeClasspathContainer(path).getClasspathEntries();
- }
-
- public class JbossWSRuntimeClasspathContainer implements
- IClasspathContainer {
- private IPath path;
- private IClasspathEntry[] entries = null;
-
- public JbossWSRuntimeClasspathContainer(IPath path) {
- this.path = path;
- }
-
- public String getDescription() {
- return JbossWSCoreMessages.JBossWS_Runtime;
- }
-
- public int getKind() {
- return IClasspathContainer.K_APPLICATION;
- }
-
- public IPath getPath() {
- return path;
- }
-
- public IClasspathEntry[] getClasspathEntries() {
- if (entries == null) {
- ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
- .findRuntimeByName(segment);
- if (jbws != null) {
- if (jbws.isUserConfigClasspath()) {
- for (String jar : jbws.getLibraries()) {
- entryList.add(getEntry(new Path(jar)));
- }
- entries = entryList
- .toArray(new IClasspathEntry[entryList.size()]);
- } else {
- IPath wsPath = new Path(jbws.getHomeDir());
- if (wsPath != null) {
- IPath libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Lib);
- entryList.addAll(Arrays.asList(getEntries(libPath,
- entryList)));
- libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Client);
- entryList.addAll(Arrays.asList(getEntries(libPath,
- entryList)));
- entries = entryList
- .toArray(new IClasspathEntry[entryList
- .size()]);
- }
- }
- if (entries == null)
- return new IClasspathEntry[0];
- }
- }
- return entries;
- }
-
- protected IClasspathEntry getEntry(IPath path) {
- return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
- .getClasspathEntry();
- }
-
- protected IClasspathEntry[] getEntries(IPath folder,
- ArrayList<IClasspathEntry> entryList) {
- String[] files = folder.toFile().list();
- ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- for (int i = 0; i < files.length; i++) {
- if (files[i].endsWith(".jar")
- && filterJars(files[i], entryList)) {
- list.add(getEntry(folder.append(files[i])));
- } else if (folder.append(files[i]).toFile().isDirectory()) {
- list.addAll(Arrays.asList(getEntries(folder
- .append(files[i]), entryList)));
- }
- }
- return list.toArray(new IClasspathEntry[list.size()]);
- }
-
- public void removeEntry(String jarName) {
- if (entries == null) {
- return;
- }
- IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
- int i = 0;
- for (IClasspathEntry entry : entries) {
- if (!entry.toString().contains(jarName)) {
- newEntries[i++] = entry;
- }
- }
- entries = newEntries;
- }
-
- }
-
- public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
- for (IClasspathEntry entry : list) {
- if (entry.getPath().lastSegment().equals(jarName)) {
- return false;
- }
- }
- return true;
- }
-
-}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,141 +0,0 @@
-package org.jboss.tools.ws.core.classpath;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-
-/**
- *
- * @author Grid Qian
- *
- */
-public class JbossWSRuntimeListConverter {
-
- /*
- * Constants definitions
- */
- private static final String REGEXP_ESCAPE = "\\";
- private static final String COMMA = ",";
- private static final String LIBRARY_SEPARATOR = ";";
- private static final String EMPTY_STRING = "";
- private static final String FIELD_SEPARATOR = "|";
- private static final String DEFAULT = "default";
- private static final String HOME_DIR = "homeDir";
- private static final String VERSION = "version";
- private static final String NAME = "name";
- private static final String USER_CONFIG_CLASSPATH = "userConfig";
- private static final String LIBRARY = "libraries";
-
- /**
- * Load String to JbossWSRuntime map from String
- * @param input
- * String representation of map
- * @return
- * Map<String, JbossWSRuntime> loaded from string
- * TODO - switch to XML?
- * TODO - write converter from old serialization format to XML?
- * TODO - handle errors in string format
- */
- public Map<String, JbossWSRuntime> getMap(String input) {
-
- Map<String, JbossWSRuntime> result = new HashMap<String,
JbossWSRuntime>();
- if (input == null || EMPTY_STRING.equals(input.trim())) {
- return result;
- }
- StringTokenizer runtimes = new StringTokenizer(input, COMMA);
- while (runtimes.hasMoreTokens()) {
- String runtime = runtimes.nextToken();
- String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
- JbossWSRuntime rt = new JbossWSRuntime();
- final int step = 2;
- for (int i = 0; i < map.length; i += step) {
- String name = map[i];
- String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
- if (NAME.equals(name)) {
- rt.setName(value);
- } else if (HOME_DIR.equals(name)) {
- rt.setHomeDir(value);
- } else if (VERSION.equals(name)) {
- rt.setVersion(value);
- } else if (DEFAULT.equals(name)) {
- rt.setDefault(Boolean.parseBoolean(value));
- }else if(USER_CONFIG_CLASSPATH.equals(name)){
- rt.setUserConfigClasspath(Boolean.parseBoolean(value));
- }else if(LIBRARY.equals(name)){
- if(value != null && !EMPTY_STRING.equals(value)){
- rt.setLibraries(getLibrariesFromString(value));
- }
- }
-
- }
- result.put(rt.getName(), rt);
- }
-
- return result;
- }
-
- private List<String> getLibrariesFromString(String strLibraries){
- List<String> libraries = new ArrayList<String>();
- StringTokenizer st = new StringTokenizer(strLibraries, LIBRARY_SEPARATOR);
- while(st.hasMoreTokens()){
- String library = st.nextToken();
- if(!libraries.contains(library)){
- libraries.add(library);
- }
- }
- return libraries;
-
- }
-
- private String convertListToString(List<String> libraries){
- String strLib = "";
- for(String library: libraries){
- if("".equals(strLib)){
- strLib = library;
- }else{
- strLib = strLib + LIBRARY_SEPARATOR + library;
- }
- }
- return strLib;
- }
-
- /**
- * Convert map String to JbossWSRUntime to string representation
- * @param runtimeMap
- * Map<String, JbossWSRuntime> - map of String to JbossWS Runtime to
convert
- * in String
- * @return
- * String representation of String to JbossWS Runtime map
- */
- public String getString(Map<String, JbossWSRuntime> runtimeMap) {
- StringBuffer buffer = new StringBuffer();
- JbossWSRuntime[] runtimes = runtimeMap.values().toArray(
- new JbossWSRuntime[runtimeMap.size()]);
- for (int i = 0; i < runtimes.length; i++) {
- buffer.append(NAME).append(FIELD_SEPARATOR);
- buffer.append(runtimes[i].getName());
- buffer.append(FIELD_SEPARATOR).append(VERSION).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].getVersion());
- buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].getHomeDir());
- buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].isDefault());
- buffer.append(FIELD_SEPARATOR).append(USER_CONFIG_CLASSPATH).append(FIELD_SEPARATOR);
- buffer.append(runtimes[i].isUserConfigClasspath());
- buffer.append(FIELD_SEPARATOR).append(LIBRARY).append(FIELD_SEPARATOR);
- buffer.append(convertListToString(runtimes[i].getLibraries()));
- if (i != runtimes.length - 1) {
- buffer.append(COMMA);
- }
- }
- return buffer.toString();
- }
- }
-
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.classpath;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jface.preference.IPersistentPreferenceStore;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimeManager {
-
- private static JbossWSRuntimeListConverter converter = new
JbossWSRuntimeListConverter();
-
- private Map<String, JbossWSRuntime> runtimes = new HashMap<String,
JbossWSRuntime>();
-
- /**
- * Private constructor
- */
- private JbossWSRuntimeManager() {
- load();
- }
-
- /**
- * This class make Java Runtime responsible for solving synchronization
- * problems during initialization if there is any
- *
- */
- static class JbossWSRuntimeManagerHolder {
- private static final JbossWSRuntimeManager INSTANCE = new JbossWSRuntimeManager();
- }
-
- /**
- * Return JbossWSRuntimeManaher instance
- *
- * @return JbossWSRuntimeManager instance
- */
- public static JbossWSRuntimeManager getInstance() {
- return JbossWSRuntimeManagerHolder.INSTANCE;
- }
-
- /**
- * Return Array of configured JbossWSRuntimes
- *
- * @return JbossWSRuntime[]
- */
- public JbossWSRuntime[] getRuntimes() {
- Collection<JbossWSRuntime> c = runtimes.values();
- return c.toArray(new JbossWSRuntime[runtimes.size()]);
- }
-
- /**
- * Add new JbossWSRuntime
- *
- * @param runtime
- * JbossWSRuntime
- */
- public void addRuntime(JbossWSRuntime runtime) {
- if (runtimes.size() == 0) {
- runtime.setDefault(true);
- }
-
- JbossWSRuntime oldDefaultRuntime = getDefaultRuntime();
- if (oldDefaultRuntime != null && runtime.isDefault()) {
- oldDefaultRuntime.setDefault(false);
- }
- runtimes.put(runtime.getName(), runtime);
- save();
- }
-
- /**
- * Add new JbossWSRuntime with given parameters
- *
- * @param name
- * String - runtime name
- * @param path
- * String - runtime home folder
- * @param version
- * String - string representation of version number
- * @param defaultRt
- * boolean - default flag
- */
- public void addRuntime(String name, String path, String version,
- boolean defaultRt) {
- JbossWSRuntime jbossWSRt = new JbossWSRuntime();
- jbossWSRt.setHomeDir(path);
- jbossWSRt.setName(name);
- jbossWSRt.setVersion(version);
- jbossWSRt.setDefault(defaultRt);
- addRuntime(jbossWSRt);
- }
-
- /**
- * Return JbossWSRuntime by given name
- *
- * @param name
- * String - JbossWSRuntime name
- * @return JbossWSRuntime - found JbossWSRuntime instance or null
- */
- public JbossWSRuntime findRuntimeByName(String name) {
- for (JbossWSRuntime jbossWSRuntime : runtimes.values()) {
- if (jbossWSRuntime.getName().equals(name)) {
- return jbossWSRuntime;
- }
- }
- return null;
- }
-
- public List<String> getAllRuntimeJars(JbossWSRuntime rt){
- List<String> jarList = new ArrayList<String>();
- if (rt != null) {
- if (rt.isUserConfigClasspath()) {
- jarList.addAll(rt.getLibraries());
-
- } else {
- IPath wsPath = new Path(rt.getHomeDir());
- if (wsPath != null) {
- IPath libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Lib);
- List<File> libs = getJarsOfFolder(libPath.toFile());
- libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Client);
- List<File> clientJars = getJarsOfFolder(libPath.toFile());
-
- jarList = mergeTwoList(libs, clientJars);
- }
- }
-
- }
- return jarList;
- }
-
-
-
- private List<File> getJarsOfFolder(File folder){
- List<File> jars = new ArrayList<File>();
- if(folder.isDirectory()){
- for(File file: folder.listFiles()){
- if(file.isFile() && (file.getName().endsWith(".jar") ||
file.getName().endsWith(".zip"))){
- jars.add(file);
- }else if (folder.isDirectory()){
- jars.addAll(getJarsOfFolder(file));
- }
- }
- }
-
- return jars;
- }
-
- // if two folders have the same jar file, one of them will be ignored.
- private List<String> mergeTwoList(List<File> jarList1, List<File>
jarList2){
- List<String> rtList = new ArrayList<String>();
- List<String> distinctFileNames = new ArrayList<String>();
-
- for(File jarFile: jarList1){
- distinctFileNames.add(jarFile.getName());
- rtList.add(jarFile.getAbsolutePath());
- }
- for(File jarFile: jarList2){
- if(!distinctFileNames.contains(jarFile.getName())){
- rtList.add(jarFile.getAbsolutePath());
- }
- }
-
- return rtList;
-
- }
-
- /**
- * Remove given JbossWSRuntime from manager
- *
- * @param rt
- * JbossWSRuntime
- */
- public void removeRuntime(JbossWSRuntime rt) {
- runtimes.remove(rt.getName());
- }
-
- /**
- * Save preference value and force save changes to disk
- */
- public void save() {
- JbossWSCorePlugin.getDefault().getPreferenceStore().setValue(
- JbossWSCoreMessages.WS_Location, converter.getString(runtimes));
- IPreferenceStore store = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- if (store instanceof IPersistentPreferenceStore) {
- try {
- ((IPersistentPreferenceStore) store).save();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Marks this runtime as default. Marks other runtimes with the same version
- * as not default.
- *
- * @param runtime
- */
- public void setDefaultRuntime(JbossWSRuntime runtime) {
- JbossWSRuntime[] runtimes = getRuntimes();
- for (int i = 0; i < runtimes.length; i++) {
- runtimes[i].setDefault(false);
- }
- runtime.setDefault(true);
- }
-
- /**
- * Return first default JbossWSRuntime
- *
- * @return JbossWSRuntime
- */
- public JbossWSRuntime getDefaultRuntime() {
- for (JbossWSRuntime rt : runtimes.values()) {
- if (rt.isDefault()) {
- return rt;
- }
- }
- return null;
- }
-
- /**
- * Return list of available JbossWSRuntime names
- *
- * @return List<String>
- */
- public List<String> getRuntimeNames() {
- JbossWSRuntime[] rts = getRuntimes();
- List<String> result = new ArrayList<String>();
- for (JbossWSRuntime jbossWSRuntime : rts) {
- result.add(jbossWSRuntime.getName());
- }
- return result;
- }
-
- /**
- * Return a list of all runtime names
- *
- * @return List of all runtime names
- */
- public List<String> getAllRuntimeNames() {
- JbossWSRuntime[] rts = getRuntimes();
- List<String> result = new ArrayList<String>();
- for (JbossWSRuntime jbossWSRuntime : rts) {
- result.add(jbossWSRuntime.getName());
- }
- return result;
- }
-
- /**
- * TBD
- *
- * @param oldName
- * old runtime name
- * @param newName
- * new runtime name
- */
- public void changeRuntimeName(String oldName, String newName) {
- JbossWSRuntime o = findRuntimeByName(oldName);
- if (o == null) {
- return;
- }
- o.setName(newName);
- onRuntimeNameChanged(oldName, newName);
- }
-
- private void onRuntimeNameChanged(String oldName, String newName) {
- IProjectFacet facet = ProjectFacetsManager
- .getProjectFacet("jbossws.core");
- Set<IFacetedProject> facetedProjects = null;
- try {
- facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (IFacetedProject facetedProject : facetedProjects) {
- QualifiedName qRuntimeName =
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
- String name = null;
- try {
- name = facetedProject.getProject().getPersistentProperty(
- qRuntimeName);
- if (name != null && name.equals(oldName)) {
- facetedProject.getProject().setPersistentProperty(
- qRuntimeName, newName);
- }
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- }
-
- public static boolean isRuntimeUsed(String name) {
- IProjectFacet facet = ProjectFacetsManager
- .getProjectFacet("jbossws.core");
- Set<IFacetedProject> facetedProjects = null;
- try {
- facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (IFacetedProject facetedProject : facetedProjects) {
- QualifiedName qRuntimeName =
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
- try {
- if (name.equals(facetedProject.getProject()
- .getPersistentProperty(qRuntimeName))) {
- return true;
- }
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
- return false;
- }
-
- public void load() {
- IPreferenceStore ps = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
-
- String runtimeListString = ps
- .getString(JbossWSCoreMessages.WS_Location);
-
- runtimes = converter.getMap(runtimeListString);
- }
-
-}
\ No newline at end of file
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.command;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
+import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSClassPathCommand extends AbstractDataModelOperation {
+
+ IProject project;
+ private IDataModel model;
+
+ public JBossWSClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ this.model = model;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ boolean isServerSupplied = model
+ .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED);
+ if (isServerSupplied) {
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME,
+ IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED);
+ } else {
+ // store runtime name and runtime location to the project
+
+ String runtimeName = model
+ .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID);
+ String runtimeLocation = model
+ .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME);
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
+ runtimeName);
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
+ runtimeLocation);
+ boolean isDeployed = model
+ .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY);
+
+ status = addClassPath(project, runtimeName, isDeployed);
+ }
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossWSCoreMessages.Error_Add_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus addClassPath(IProject project, String segment,
+ boolean isDeployed) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ IClasspathEntry newClasspath;
+ IJavaProject javaProject = JavaCore.create(project);
+
+ if (isDeployed) {
+ IClasspathAttribute depAttrib = JavaCore
+ .newClasspathAttribute(
+ IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY,
+ ClasspathDependencyUtil.getDefaultRuntimePath(
+ true).toString());
+ newClasspath = JavaCore.newContainerEntry(new Path(
+ JBossWSCoreMessages.JBossWS_Runtime_Lib)
+ .append(segment), null,
+ new IClasspathAttribute[] { depAttrib }, true);
+ } else {
+ newClasspath = JavaCore.newContainerEntry(new Path(
+ JBossWSCoreMessages.JBossWS_Runtime_Lib)
+ .append(segment));
+ }
+
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (oldClasspathEntries[i].getPath().equals(
+ newClasspath.getPath())) {
+ isFolderInClassPathAlready = true;
+ break;
+ }
+ }
+
+ if (!isFolderInClassPathAlready) {
+
+ IClasspathEntry[] newClasspathEntries = new
IClasspathEntry[oldClasspathEntries.length + 1];
+ for (int i = 0; i < oldClasspathEntries.length; i++) {
+ newClasspathEntries[i] = oldClasspathEntries[i];
+ }
+ newClasspathEntries[oldClasspathEntries.length] = newClasspath;
+
+ javaProject.setRawClasspath(newClasspathEntries,
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
-import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-import org.jboss.tools.ws.core.utils.StatusUtils;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSClassPathCommand extends AbstractDataModelOperation {
-
- IProject project;
- private IDataModel model;
-
- public JbossWSClassPathCommand(IProject project, IDataModel model) {
- this.project = project;
- this.model = model;
- }
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- return executeOverride(monitor);
- }
-
- public IStatus executeOverride(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- boolean isServerSupplied = model
- .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED);
- if (isServerSupplied) {
- project
- .setPersistentProperty(
- IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME,
- IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED);
- } else {
- // store runtime name and runtime location to the project
-
- String runtimeName = model
- .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID);
- String runtimeLocation = model
- .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME);
- project
- .setPersistentProperty(
- IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
- runtimeName);
- project
- .setPersistentProperty(
- IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
- runtimeLocation);
- boolean isDeployed = model
- .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY);
-
- status = addClassPath(project, runtimeName, isDeployed);
- }
-
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(
- JbossWSCoreMessages.Error_Add_Facet_JBossWS, e);
- }
- return status;
- }
-
- public IStatus addClassPath(IProject project, String segment,
- boolean isDeployed) {
- IStatus status = Status.OK_STATUS;
- try {
-
- IClasspathEntry newClasspath;
- IJavaProject javaProject = JavaCore.create(project);
-
- if (isDeployed) {
- IClasspathAttribute depAttrib = JavaCore
- .newClasspathAttribute(
- IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY,
- ClasspathDependencyUtil.getDefaultRuntimePath(
- true).toString());
- newClasspath = JavaCore.newContainerEntry(new Path(
- JbossWSCoreMessages.JBossWS_Runtime_Lib)
- .append(segment), null,
- new IClasspathAttribute[] { depAttrib }, true);
- } else {
- newClasspath = JavaCore.newContainerEntry(new Path(
- JbossWSCoreMessages.JBossWS_Runtime_Lib)
- .append(segment));
- }
-
- IClasspathEntry[] oldClasspathEntries = javaProject
- .readRawClasspath();
-
- boolean isFolderInClassPathAlready = false;
- for (int i = 0; i < oldClasspathEntries.length
- && !isFolderInClassPathAlready; i++) {
- if (oldClasspathEntries[i].getPath().equals(
- newClasspath.getPath())) {
- isFolderInClassPathAlready = true;
- break;
- }
- }
-
- if (!isFolderInClassPathAlready) {
-
- IClasspathEntry[] newClasspathEntries = new
IClasspathEntry[oldClasspathEntries.length + 1];
- for (int i = 0; i < oldClasspathEntries.length; i++) {
- newClasspathEntries[i] = oldClasspathEntries[i];
- }
- newClasspathEntries[oldClasspathEntries.length] = newClasspath;
-
- javaProject.setRawClasspath(newClasspathEntries,
- new NullProgressMonitor());
- }
- } catch (JavaModelException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- return status;
- }
-
- return status;
- }
-
-}
\ No newline at end of file
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,102 @@
+package org.jboss.tools.ws.core.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+
+public class UninstallJBossWSClassPathCommand {
+ IProject project;
+
+ public UninstallJBossWSClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ boolean isServerSupplied = Boolean
+ .getBoolean(project
+ .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME));
+ if (isServerSupplied) {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
+ } else {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
+ String runtimeName = project
+ .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+
+ status = removeClassPath(project, runtimeName);
+ }
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossWSCoreMessages.Error_Remove_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus removeClassPath(IProject project, String segment) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ List<IClasspathEntry> classpathEntries = new
ArrayList<IClasspathEntry>();
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (!oldClasspathEntries[i].getPath().equals(
+ new Path(JBossWSCoreMessages.JBossWS_Runtime_Lib)
+ .append(segment))) {
+ classpathEntries.add(oldClasspathEntries[i]);
+ }
+ }
+ if (classpathEntries.size() < oldClasspathEntries.length) {
+ javaProject.setRawClasspath(classpathEntries
+ .toArray(new IClasspathEntry[classpathEntries.size()]),
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Remove_Facet_JBossWS,
+ new String[] { e.getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,102 +0,0 @@
-package org.jboss.tools.ws.core.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-import org.jboss.tools.ws.core.utils.StatusUtils;
-
-public class UninstallJbossWSClassPathCommand {
- IProject project;
-
- public UninstallJbossWSClassPathCommand(IProject project, IDataModel model) {
- this.project = project;
- }
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- return executeOverride(monitor);
- }
-
- public IStatus executeOverride(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- boolean isServerSupplied = Boolean
- .getBoolean(project
- .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME));
- if (isServerSupplied) {
-// project
-// .getPersistentProperties()
-// .remove(
-// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
- } else {
-// project
-// .getPersistentProperties()
-// .remove(
-// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
-// project
-// .getPersistentProperties()
-// .remove(
-// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
- String runtimeName = project
- .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
-
- status = removeClassPath(project, runtimeName);
- }
-
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(
- JbossWSCoreMessages.Error_Remove_Facet_JBossWS, e);
- }
- return status;
- }
-
- public IStatus removeClassPath(IProject project, String segment) {
- IStatus status = Status.OK_STATUS;
- try {
- IJavaProject javaProject = JavaCore.create(project);
- IClasspathEntry[] oldClasspathEntries = javaProject
- .readRawClasspath();
-
- boolean isFolderInClassPathAlready = false;
- List<IClasspathEntry> classpathEntries = new
ArrayList<IClasspathEntry>();
- for (int i = 0; i < oldClasspathEntries.length
- && !isFolderInClassPathAlready; i++) {
- if (!oldClasspathEntries[i].getPath().equals(
- new Path(JbossWSCoreMessages.JBossWS_Runtime_Lib)
- .append(segment))) {
- classpathEntries.add(oldClasspathEntries[i]);
- }
- }
- if (classpathEntries.size() < oldClasspathEntries.length) {
- javaProject.setRawClasspath(classpathEntries
- .toArray(new IClasspathEntry[classpathEntries.size()]),
- new NullProgressMonitor());
- }
- } catch (JavaModelException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Remove_Facet_JBossWS,
- new String[] { e.getLocalizedMessage() }), e);
- return status;
- }
-
- return status;
- }
-
-}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -13,7 +13,6 @@
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.jboss.tools.ws.core.utils.StatusUtils;
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.facet.delegate;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.ws.core.command.JBossWSClassPathCommand;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSInstallRuntimeDelegate implements IDelegate {
+
+ public void execute(IProject project, IProjectFacetVersion arg1,
+ Object arg2, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(JBossWSCoreMessages.Progress_Install_JBossWS_Runtime,
+ 2);
+
+ IDataModel model = (IDataModel) arg2;
+
+ JBossWSClassPathCommand command = new JBossWSClassPathCommand(project,
+ model);
+ IStatus status = command.executeOverride(monitor);
+ if(!status.equals(Status.OK_STATUS)){
+ throw new CoreException(status);
+ }
+ monitor.worked(1);
+ monitor.done();
+ }
+
+}
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.facet.delegate;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.ws.core.command.UninstallJBossWSClassPathCommand;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSUnInstallRuntimeDelegate implements IDelegate {
+
+ public void execute(IProject project, IProjectFacetVersion arg1,
+ Object arg2, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(
+ JBossWSCoreMessages.Progress_UnInstall_JBossWS_Runtime, 2);
+
+ IDataModel model = (IDataModel) arg2;
+
+ UninstallJBossWSClassPathCommand command = new UninstallJBossWSClassPathCommand(
+ project, model);
+ command.executeOverride(monitor);
+ monitor.worked(1);
+ monitor.done();
+ }
+
+}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.facet.delegate;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IDelegate;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.jboss.tools.ws.core.command.JbossWSClassPathCommand;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSInstallRuntimeDelegate implements IDelegate {
-
- public void execute(IProject project, IProjectFacetVersion arg1,
- Object arg2, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(JbossWSCoreMessages.Progress_Install_JBossWS_Runtime,
- 2);
-
- IDataModel model = (IDataModel) arg2;
-
- JbossWSClassPathCommand command = new JbossWSClassPathCommand(project,
- model);
- IStatus status = command.executeOverride(monitor);
- if(!status.equals(Status.OK_STATUS)){
- throw new CoreException(status);
- }
- monitor.worked(1);
- monitor.done();
- }
-
-}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.facet.delegate;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IDelegate;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.jboss.tools.ws.core.command.UninstallJbossWSClassPathCommand;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSUnInstallRuntimeDelegate implements IDelegate {
-
- public void execute(IProject project, IProjectFacetVersion arg1,
- Object arg2, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(
- JbossWSCoreMessages.Progress_UnInstall_JBossWS_Runtime, 2);
-
- IDataModel model = (IDataModel) arg2;
-
- UninstallJbossWSClassPathCommand command = new UninstallJbossWSClassPathCommand(
- project, model);
- command.executeOverride(monitor);
- monitor.worked(1);
- monitor.done();
- }
-
-}
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,15 @@
+Progress_Install_JBossWS_Runtime=JBoss Web Service Runtime
+Progress_UnInstall_JBossWS_Runtime=Uninstall JBoss Web Service Runtime
+Dir_Lib=lib
+Dir_Client=client
+Dir_Web_Inf=WEB-INF
+Dir_Web_Content=WebContent
+Error_Copy=Exception while copy JBossWS jars
+WS_Location=jbosswsruntimelocation
+JBossWS_Runtime_Lib=JBossWS_Runtime
+JBossWS_Runtime=JBoss WS Runtime
+JBossAS=JBOSS
+Error_WS_Location=The JBoss WS Runtime Location is NULL
+Error_WS_Classpath=A error comes up when create JBoss WS Classpath
+Error_Add_Facet_JBossWS=Exception while install JBossWS facet
+Error_Remove_Facet_JBossWS=Exception while uninstall JBossWS facet
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSCoreMessages {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.ws.core.messages.JBossWSCore"; //$NON-NLS-1$
+
+ private JBossWSCoreMessages() {
+ // Do not instantiate
+ }
+
+ public static String Progress_Install_JBossWS_Runtime;
+ public static String Progress_UnInstall_JBossWS_Runtime;
+ public static String Dir_Lib;
+ public static String Dir_Client;
+ public static String Dir_Web_Inf;
+ public static String Dir_Web_Content;
+ public static String Error_Copy;
+ public static String WS_Location;
+ public static String JBossWS_Runtime_Lib;
+ public static String JBossWS_Runtime;
+ public static String JBossAS;
+ public static String Error_WS_Location;
+ public static String Error_WS_Classpath;
+ public static String Error_Add_Facet_JBossWS;
+ public static String Error_Remove_Facet_JBossWS;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossWSCoreMessages.class);
+ }
+}
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,15 +0,0 @@
-Progress_Install_JBossWS_Runtime=JBoss Web Service Runtime
-Progress_UnInstall_JBossWS_Runtime=Uninstall JBoss Web Service Runtime
-Dir_Lib=lib
-Dir_Client=client
-Dir_Web_Inf=WEB-INF
-Dir_Web_Content=WebContent
-Error_Copy=Exception while copy JBossWS jars
-WS_Location=jbosswsruntimelocation
-JBossWS_Runtime_Lib=JBossWS_Runtime
-JBossWS_Runtime=JBoss WS Runtime
-JBossAS=JBOSS
-Error_WS_Location=The JBoss WS Runtime Location is NULL
-Error_WS_Classpath=A error comes up when create JBoss WS Classpath
-Error_Add_Facet_JBossWS=Exception while install JBossWS facet
-Error_Remove_Facet_JBossWS=Exception while uninstall JBossWS facet
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.messages;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSCoreMessages {
-
- private static final String BUNDLE_NAME =
"org.jboss.tools.ws.core.messages.JbossWSCore"; //$NON-NLS-1$
-
- private JbossWSCoreMessages() {
- // Do not instantiate
- }
-
- public static String Progress_Install_JBossWS_Runtime;
- public static String Progress_UnInstall_JBossWS_Runtime;
- public static String Dir_Lib;
- public static String Dir_Client;
- public static String Dir_Web_Inf;
- public static String Dir_Web_Content;
- public static String Error_Copy;
- public static String WS_Location;
- public static String JBossWS_Runtime_Lib;
- public static String JBossWS_Runtime;
- public static String JBossAS;
- public static String Error_WS_Location;
- public static String Error_WS_Classpath;
- public static String Error_Add_Facet_JBossWS;
- public static String Error_Remove_Facet_JBossWS;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JbossWSCoreMessages.class);
- }
-}
\ No newline at end of file
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSCoreUtils {
+
+ public static IPath pathToWebProjectContainer(String project) {
+ IPath projectRoot = getProjectRoot(project);
+ IPath currentDynamicWebProjectDir = J2EEUtils
+ .getWebContentPath(getProjectName(project));
+ IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils
+ .getWebContentPath(getProjectName(project))
+ .removeFirstSegments(1).makeAbsolute();
+ if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
+ return getWorkspace().append(currentDynamicWebProjectDir);
+ } else {
+ return projectRoot
+ .append(currentDynamicWebProjectDirWithoutProjectRoot);
+ }
+
+ }
+
+ public static IPath getProjectRoot(String project) {
+ String projectString = replaceEscapecharactors(project.toString());
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(
+ getProjectNameFromFramewokNameString(projectString))
+ .getLocation();
+ }
+
+ // Fix for the windows build not working
+ private static String replaceEscapecharactors(String vulnarableString) {
+ if (vulnarableString.indexOf("/") != -1) {
+ vulnarableString = vulnarableString.replace('/', File.separator
+ .charAt(0));
+ }
+ return vulnarableString;
+ }
+
+ private static String getProjectNameFromFramewokNameString(
+ String frameworkProjectString) {
+ if (frameworkProjectString.indexOf(getSplitCharactor()) == -1) {
+ return frameworkProjectString;
+ } else {
+ return frameworkProjectString.split(getSplitCharactors())[1];
+ }
+ }
+
+ private static String getSplitCharactor() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
+ return "\\";
+ } else {
+ return File.separator;
+ }
+ }
+
+ private static String getSplitCharactors() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
+ return "\\" + File.separator;
+ } else {
+ return File.separator;
+ }
+ }
+
+ public static IPath getWorkspace() {
+ return ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ }
+
+ public static IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ public static IProject getProjectName(String project) {
+ String projectString = replaceEscapecharactors(project.toString());
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(
+ getProjectNameFromFramewokNameString(projectString));
+ }
+
+ public static IStatus copy(IPath sourcePath, IPath targetPath) {
+
+ IStatus status = Status.OK_STATUS;
+ File sourceDir = sourcePath.toFile();
+ File[] children = sourceDir.listFiles();
+
+ FileInputStream finStream = null;
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].isFile()) {
+ try {
+ finStream = new FileInputStream(children[i]);
+ } catch (FileNotFoundException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ }
+ try {
+ makeFile(getWorkspaceRoot().getContainerForLocation(
+ targetPath), children[i].getName(), finStream);
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ }
+ } else {
+ try {
+ IFolder temp = makeFolder(getWorkspaceRoot()
+ .getContainerForLocation(targetPath), children[i]
+ .getName());
+ copy(sourcePath.append(children[i].getName()), temp
+ .getLocation());
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ }
+ }
+ }
+ return status;
+ }
+
+ private static IFolder makeFolder(IContainer parent, String folderName)
+ throws CoreException {
+ IResource child = parent.findMember(folderName);
+ if (child == null) {
+ IFolder folder = parent.getFolder(new Path(folderName));
+ try {
+ folder.create(true, true, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return folder;
+ } else {
+ if (child.getType() == IResource.FOLDER) {
+ return (IFolder) child;
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR,
+ "ResourceUtils", 0, NLS.bind("ERROR",//
EnvironmentMessages.MSG_ERROR_RESOURCE_NOT_FOLDER,
+ new Object[] { parent.getFullPath().append(
+ folderName).toString() }), null));
+ }
+ }
+
+ }
+
+ private static IFile makeFile(IContainer parent, String fileName,
+ InputStream inputStream) throws CoreException {
+ IResource child = parent.findMember(fileName);
+
+ if (child != null) {
+ if (child.getType() == IResource.FILE) {
+
+ // We have permission to overwrite so check if file is read-only
+ if (child.getResourceAttributes() != null
+ && child.getResourceAttributes().isReadOnly()) {
+ IFile[] files = new IFile[1];
+ files[0] = (IFile) child;
+ }
+
+ // Change the contents of the existing file.
+ IFile file = parent.getFile(new Path(fileName));
+ file.setContents(inputStream, true, true, null);
+
+ return file;
+
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR,
+ "ResourceUtils", 0, NLS.bind("ERROR",
+ new Object[] { parent.getFullPath().append(
+ fileName) }), null));
+ }
+ } else {
+ // Create a new file.
+ IFile file = parent.getFile(new Path(fileName));
+ file.create(inputStream, true, null);
+
+ return file;
+ }
+ }
+
+
+
+
+}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.ws.internal.common.J2EEUtils;
-import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSCoreUtils {
-
- public static IPath pathToWebProjectContainer(String project) {
- IPath projectRoot = getProjectRoot(project);
- IPath currentDynamicWebProjectDir = J2EEUtils
- .getWebContentPath(getProjectName(project));
- IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils
- .getWebContentPath(getProjectName(project))
- .removeFirstSegments(1).makeAbsolute();
- if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
- return getWorkspace().append(currentDynamicWebProjectDir);
- } else {
- return projectRoot
- .append(currentDynamicWebProjectDirWithoutProjectRoot);
- }
-
- }
-
- public static IPath getProjectRoot(String project) {
- String projectString = replaceEscapecharactors(project.toString());
- return ResourcesPlugin.getWorkspace().getRoot().getProject(
- getProjectNameFromFramewokNameString(projectString))
- .getLocation();
- }
-
- // Fix for the windows build not working
- private static String replaceEscapecharactors(String vulnarableString) {
- if (vulnarableString.indexOf("/") != -1) {
- vulnarableString = vulnarableString.replace('/', File.separator
- .charAt(0));
- }
- return vulnarableString;
- }
-
- private static String getProjectNameFromFramewokNameString(
- String frameworkProjectString) {
- if (frameworkProjectString.indexOf(getSplitCharactor()) == -1) {
- return frameworkProjectString;
- } else {
- return frameworkProjectString.split(getSplitCharactors())[1];
- }
- }
-
- private static String getSplitCharactor() {
- // Windows check (because from inside wtp in return I received a hard
- // coded path)
- if (File.separatorChar == '\\') {
- return "\\";
- } else {
- return File.separator;
- }
- }
-
- private static String getSplitCharactors() {
- // Windows check (because from inside wtp in return I received a hard
- // coded path)
- if (File.separatorChar == '\\') {
- return "\\" + File.separator;
- } else {
- return File.separator;
- }
- }
-
- public static IPath getWorkspace() {
- return ResourcesPlugin.getWorkspace().getRoot().getLocation();
- }
-
- public static IWorkspaceRoot getWorkspaceRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- public static IProject getProjectName(String project) {
- String projectString = replaceEscapecharactors(project.toString());
- return ResourcesPlugin.getWorkspace().getRoot().getProject(
- getProjectNameFromFramewokNameString(projectString));
- }
-
- public static IStatus copy(IPath sourcePath, IPath targetPath) {
-
- IStatus status = Status.OK_STATUS;
- File sourceDir = sourcePath.toFile();
- File[] children = sourceDir.listFiles();
-
- FileInputStream finStream = null;
- for (int i = 0; i < children.length; i++) {
- if (children[i].isFile()) {
- try {
- finStream = new FileInputStream(children[i]);
- } catch (FileNotFoundException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- }
- try {
- makeFile(getWorkspaceRoot().getContainerForLocation(
- targetPath), children[i].getName(), finStream);
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- }
- } else {
- try {
- IFolder temp = makeFolder(getWorkspaceRoot()
- .getContainerForLocation(targetPath), children[i]
- .getName());
- copy(sourcePath.append(children[i].getName()), temp
- .getLocation());
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- }
- }
- }
- return status;
- }
-
- private static IFolder makeFolder(IContainer parent, String folderName)
- throws CoreException {
- IResource child = parent.findMember(folderName);
- if (child == null) {
- IFolder folder = parent.getFolder(new Path(folderName));
- try {
- folder.create(true, true, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return folder;
- } else {
- if (child.getType() == IResource.FOLDER) {
- return (IFolder) child;
- } else {
- throw new CoreException(new Status(IStatus.ERROR,
- "ResourceUtils", 0, NLS.bind("ERROR",//
EnvironmentMessages.MSG_ERROR_RESOURCE_NOT_FOLDER,
- new Object[] { parent.getFullPath().append(
- folderName).toString() }), null));
- }
- }
-
- }
-
- private static IFile makeFile(IContainer parent, String fileName,
- InputStream inputStream) throws CoreException {
- IResource child = parent.findMember(fileName);
-
- if (child != null) {
- if (child.getType() == IResource.FILE) {
-
- // We have permission to overwrite so check if file is read-only
- if (child.getResourceAttributes() != null
- && child.getResourceAttributes().isReadOnly()) {
- IFile[] files = new IFile[1];
- files[0] = (IFile) child;
- }
-
- // Change the contents of the existing file.
- IFile file = parent.getFile(new Path(fileName));
- file.setContents(inputStream, true, true, null);
-
- return file;
-
- } else {
- throw new CoreException(new Status(IStatus.ERROR,
- "ResourceUtils", 0, NLS.bind("ERROR",
- new Object[] { parent.getFullPath().append(
- fileName) }), null));
- }
- } else {
- // Create a new file.
- IFile file = parent.getFile(new Path(fileName));
- file.create(inputStream, true, null);
-
- return file;
- }
- }
-
-
-
-
-}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2008-06-27
06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2008-06-27
08:19:24 UTC (rev 8979)
@@ -30,7 +30,7 @@
org.eclipse.wst.common.project.facet.core,
org.eclipse.wst.server.core,
org.jboss.tools.common
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.creation.core.commands,
org.jboss.tools.ws.creation.core.data,
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -45,7 +45,7 @@
.getWebProjectName());
try {
- String runtimeLocation = JBossWSCreationUtils.getJbossWSRuntimeLocation(project);
+ String runtimeLocation = JBossWSCreationUtils.getJBossWSRuntimeLocation(project);
String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
IPath path = new Path(commandLocation);
String command = "sh " + cmdFileName_linux;
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -30,7 +30,7 @@
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -55,13 +55,13 @@
try {
String location = JBossWSCreationUtils
- .getJbossWSRuntimeLocation(JBossWSCreationUtils
+ .getJBossWSRuntimeLocation(JBossWSCreationUtils
.getProjectByName(model.getWebProjectName()));
if (location.equals("")) {
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
- } else if (!new Path(location).append(JbossWSUIMessages.Bin)
- .append(JbossWSUIMessages.Command).toFile().exists()) {
+ } else if (!new Path(location).append(JBossWSUIMessages.Bin)
+ .append(JBossWSUIMessages.Command).toFile().exists()) {
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -15,13 +15,13 @@
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
public class InitialCommand extends AbstractDataModelOperation {
@@ -40,11 +40,11 @@
throws ExecutionException {
try {
- String location =
JBossWSCreationUtils.getJbossWSRuntimeLocation(JBossWSCreationUtils.getProjectByName(model.getWebProjectName()));
+ String location =
JBossWSCreationUtils.getJBossWSRuntimeLocation(JBossWSCreationUtils.getProjectByName(model.getWebProjectName()));
if (location.equals("")) {
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
- } else if(!new
Path(location).append(JbossWSUIMessages.Bin).append(JbossWSUIMessages.Command).toFile().exists()){
+ } else if(!new
Path(location).append(JBossWSUIMessages.Bin).append(JBossWSUIMessages.Command).toFile().exists()){
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -22,8 +22,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import
org.jboss.tools.ws.core.classpath.JbossWSRuntimeClassPathInitializer.JbossWSRuntimeClasspathContainer;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
+import
org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer.JBossWSRuntimeClasspathContainer;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
@@ -71,9 +70,9 @@
for(IClasspathEntry entry:entries){
IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(),
project);
- if(container instanceof JbossWSRuntimeClasspathContainer){
- ((JbossWSRuntimeClasspathContainer)container).removeEntry("jaxws-rt.jar");
- ((JbossWSRuntimeClasspathContainer)container).removeEntry("jaxws-tools.jar");
+ if(container instanceof JBossWSRuntimeClasspathContainer){
+ ((JBossWSRuntimeClasspathContainer)container).removeEntry("jaxws-rt.jar");
+ ((JBossWSRuntimeClasspathContainer)container).removeEntry("jaxws-tools.jar");
}
}
} catch (JavaModelException e) {
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -44,11 +44,11 @@
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
@@ -273,15 +273,15 @@
}
public static boolean validateJBossWSLocation() {
- String location = JbossWSCorePlugin.getDefault().getPreferenceStore()
- .getString(JbossWSCoreMessages.WS_Location);
+ String location = JBossWSCorePlugin.getDefault().getPreferenceStore()
+ .getString(JBossWSCoreMessages.WS_Location);
if (location == null || location.equals("")) {
return false;
}
return true;
}
- public static String getJbossWSRuntimeLocation(IProject project)
+ public static String getJBossWSRuntimeLocation(IProject project)
throws CoreException {
String isServerSupplied = project
@@ -293,7 +293,7 @@
&& !"".equals(jbwsRuntimeName)
&& !IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED
.equals(isServerSupplied)) {
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance()
.findRuntimeByName(jbwsRuntimeName);
if (jbws != null) {
return jbws.getHomeDir();
@@ -332,7 +332,7 @@
// if no target runtime has been specified, get runtime location from
// default jbossws runtime
if (prjFacetRuntime == null) {
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance()
.getDefaultRuntime();
if (jbws != null) {
return jbws.getHomeDir();
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF 2008-06-27
06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF 2008-06-27
08:19:24 UTC (rev 8979)
@@ -25,5 +25,5 @@
org.eclipse.wst.common.modulecore,
org.eclipse.wst.common.project.facet.ui,
org.jboss.tools.ws.ui
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.ui.wsrt
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -41,13 +41,13 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.ui.CreationUIPlugin;
-import org.jboss.tools.ws.ui.preferences.JbossRuntimeListFieldEditor;
+import org.jboss.tools.ws.ui.preferences.JBossRuntimeListFieldEditor;
/**
* @author Dennyxu
@@ -135,7 +135,7 @@
cmbRuntimes.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String runtimeName = cmbRuntimes.getText();
- JbossWSRuntime jr = (JbossWSRuntime) cmbRuntimes
+ JBossWSRuntime jr = (JBossWSRuntime) cmbRuntimes
.getData(runtimeName);
saveJBosswsRuntimeToModel(jr);
}
@@ -166,7 +166,7 @@
}
- protected void saveJBosswsRuntimeToModel(JbossWSRuntime jbws) {
+ protected void saveJBosswsRuntimeToModel(JBossWSRuntime jbws) {
String duplicateMsg = "";
try {
duplicateMsg = getDuplicateJars(jbws.getName());
@@ -214,7 +214,7 @@
IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
false);
String runtimeId = cmbRuntimes.getText();
- JbossWSRuntime jbws =
JbossWSRuntimeManager.getInstance().findRuntimeByName(runtimeId);
+ JBossWSRuntime jbws =
JBossWSRuntimeManager.getInstance().findRuntimeByName(runtimeId);
if (jbws != null) {
@@ -233,15 +233,15 @@
}
protected void initializeRuntimesCombo(Combo cmRuntime, String runtimeName) {
- JbossWSRuntime selectedJbws = null;
- JbossWSRuntime defaultJbws = null;
+ JBossWSRuntime selectedJbws = null;
+ JBossWSRuntime defaultJbws = null;
int selectIndex = 0;
int defaultIndex = 0;
cmRuntime.removeAll();
- JbossWSRuntime[] runtimes = JbossWSRuntimeManager.getInstance()
+ JBossWSRuntime[] runtimes = JBossWSRuntimeManager.getInstance()
.getRuntimes();
for (int i = 0; i < runtimes.length; i++) {
- JbossWSRuntime jr = runtimes[i];
+ JBossWSRuntime jr = runtimes[i];
cmRuntime.add(jr.getName());
cmRuntime.setData(jr.getName(), jr);
@@ -269,16 +269,16 @@
* create a new jbossws runtime and set user supplied runtime to the new one
*/
protected void newJBossWSRuntime() {
- List<JbossWSRuntime> exists = new
ArrayList<JbossWSRuntime>(Arrays.asList(JbossWSRuntimeManager.getInstance().getRuntimes()));
- List<JbossWSRuntime> added = new ArrayList<JbossWSRuntime>();
+ List<JBossWSRuntime> exists = new
ArrayList<JBossWSRuntime>(Arrays.asList(JBossWSRuntimeManager.getInstance().getRuntimes()));
+ List<JBossWSRuntime> added = new ArrayList<JBossWSRuntime>();
- JbossRuntimeListFieldEditor.JbossWSRuntimeNewWizard newRtwizard = new
JbossRuntimeListFieldEditor.JbossWSRuntimeNewWizard(
+ JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard newRtwizard = new
JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard(
exists, added) {
public boolean performFinish() {
- JbossWSRuntime rt = getRuntime();
+ JBossWSRuntime rt = getRuntime();
rt.setDefault(true);
- JbossWSRuntimeManager.getInstance().addRuntime(rt);
- JbossWSRuntimeManager.getInstance().save();
+ JBossWSRuntimeManager.getInstance().addRuntime(rt);
+ JBossWSRuntimeManager.getInstance().save();
return true;
}
@@ -333,11 +333,11 @@
List<String> allExistingJars = new ArrayList<String>();
List<String> runtimeJars = new ArrayList<String>();
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance().findRuntimeByName(jbwsName);
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance().findRuntimeByName(jbwsName);
if(jbws.isUserConfigClasspath()){
runtimeJars.addAll(jbws.getLibraries());
}else{
- runtimeJars.addAll(JbossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws));
+ runtimeJars.addAll(JBossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws));
}
String prjName =
model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -59,7 +59,7 @@
commands.add(new ValidateWSImplCommand(model));
commands.add(new WSProviderInvokeCommand(model));
commands.add(new MergeWebXMLCommand(model));
- //commands.add(new
JbossWSRuntimeCommand(ResourcesPlugin.getWorkspace().getRoot().getProject(project)));
+ //commands.add(new
JBossWSRuntimeCommand(ResourcesPlugin.getWorkspace().getRoot().getProject(project)));
}
return new SimpleCommandFactory(commands);
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC
(rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC
(rev 8979)
@@ -3,7 +3,7 @@
Bundle-Name: %PLUGIN_NAME
Bundle-SymbolicName: org.jboss.tools.ws.ui;singleton:=true
Bundle-Version: 1.0.0
-Bundle-Activator: org.jboss.tools.ws.ui.JbossWSUIPlugin
+Bundle-Activator: org.jboss.tools.ws.ui.JBossWSUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -11,7 +11,7 @@
org.jboss.tools.ws.core,
org.eclipse.ui.ide,
org.eclipse.wst.common.project.facet.core
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.ui,
org.jboss.tools.ws.ui.messages,
org.jboss.tools.ws.ui.preferences
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2008-06-27 08:19:24 UTC (rev 8979)
@@ -3,8 +3,8 @@
<page
name="%JBOSSWS_PREFERENCE_PAGE"
category="org.eclipse.wst.ws.internal.ui.preferences.name"
-
class="org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage"
-
id="org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage">
+
class="org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage"
+
id="org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage">
</page>
</extension>
</plugin>
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class JBossWSUIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.ws.ui";
+
+ // The shared instance
+ private static JBossWSUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public JBossWSUIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static JBossWSUIPlugin getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ path = "icons/" + path; //$NON-NLS-1$
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.ws.ui",
path); //$NON-NLS-1$
+ }
+}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class JbossWSUIPlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.ws.ui";
-
- // The shared instance
- private static JbossWSUIPlugin plugin;
-
- /**
- * The constructor
- */
- public JbossWSUIPlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static JbossWSUIPlugin getDefault() {
- return plugin;
- }
-
- public static ImageDescriptor getImageDescriptor(String path) {
- path = "icons/" + path; //$NON-NLS-1$
- return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.ws.ui",
path); //$NON-NLS-1$
- }
-}
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,37 @@
+Label_JBossWS_Runtime_Load_Error=Error occurred while loading JBossWS Command. Select the
correct JBoss Server or JBoss EAP folder.
+
+Command=wsconsume.sh
+Bin=bin
+Client=client
+Lib=lib
+Endorsed=endorsed
+
+Error_JBossWS_Basic_Editor_Composite=Parent control should be Composite
+Error_JBossWS_Basic_Editor_Support=Editor supports only grid layout
+Error_JBossWS_Basic_Editor_Different=Parent for label is different
+JBossWS_Runtime_List_Field_Editor_Name=Name
+JBossWS_Runtime_List_Field_Editor_Version=Version
+JBossWS_Runtime_List_Field_Editor_Path=Path
+JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be=inputElement must be
+JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List=an instance of
List<JBossWSRuntime>.
+JBossWS_Runtime_Delete_Confirm_Title=Confirm Runtime Delete
+JBossWS_Runtime_Delete_Used_Confirm=Runtime ''{0}'' is used by JBossWS
projects. Are you sure you want to delete it?
+JBossWS_Runtime_Delete_Not_Used_Confirm=Are you sure you want to delete runtime
''{0}''?
+JBossWS_Runtime_List_Field_Editor_Edit_Runtime=Edit JBossWS Runtime
+JBossWS_Runtime_List_Field_Editor_Modify_Runtime=Input new values
+JBossWS_Runtime_List_Field_Editor_New_Runtime=New JBossWS Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty=Path to
JBossWS home directory cannot be empty
+JBossWS_Runtime_List_Field_Editor_Already_Exists=' already exists
+JBossWS_Runtime_List_Field_Editor_Runtime=JBossWS Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct=Runtime name is not
correct
+Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty=Name cannot be empty
+JBossWS_Runtime_List_Field_Editor_Create_A_Runtime=Create a JBossWS Runtime
+JBossWS_Runtime_List_Field_Editor_Home_Folder=Home Folder:
+JBossWS_Composite_Editor_This_Method_Can_Be_Invoked=This metod can be invoked after
getEditorControls(parent) only
+JBossWS_Button_Field_Editor_Browse=Browse...
+Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet=Not implemented yet. Please setup
real acion for editor.
+JBossWS_SWT_Field_Editor_Factory_Browse=Browse...
+JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder=Select JBossWS Home Folder
+JBossWS_Runtime_List_Field_Editor_Name2=Name:
+JBossWS_Runtime_Check_Field_Default_Classpath=Configure JBoss Web Service Classpath
+JBossWS_Preference_Page_Runtimes=JBossWS Runtimes
\ No newline at end of file
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public final class JBossWSUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
+ "org.jboss.tools.ws.ui.messages.JBossWSUI"; //$NON-NLS-1$
+
+ private JBossWSUIMessages() {
+ // Do not instantiate
+ }
+
+ public static String Label_JBossWS_Runtime_Load_Error;
+
+ public static String Bin;
+ public static String Command;
+ public static String Client;
+ public static String Lib;
+ public static String Endorsed;
+
+ public static String Error_JBossWS_Basic_Editor_Composite;
+ public static String Error_JBossWS_Basic_Editor_Support;
+ public static String Error_JBossWS_Basic_Editor_Different;
+ public static String JBossWS_Runtime_List_Field_Editor_Name;
+ public static String JBossWS_Runtime_List_Field_Editor_Version;
+ public static String JBossWS_Runtime_List_Field_Editor_Path;
+ public static String JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be;
+ public static String JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List;
+ public static String JBossWS_Runtime_Delete_Confirm_Title;
+ public static String JBossWS_Runtime_Delete_Used_Confirm;
+ public static String JBossWS_Runtime_Delete_Not_Used_Confirm;
+ public static String JBossWS_Runtime_List_Field_Editor_Edit_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Modify_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_New_Runtime;
+ public static String
Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Already_Exists;
+ public static String JBossWS_Runtime_List_Field_Editor_Runtime;
+ public static String
Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Create_A_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Home_Folder;
+ public static String JBossWS_Composite_Editor_This_Method_Can_Be_Invoked;
+ public static String JBossWS_Button_Field_Editor_Browse;
+ public static String Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet;
+ public static String JBossWS_SWT_Field_Editor_Factory_Browse;
+ public static String JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder;
+ public static String JBossWS_Runtime_List_Field_Editor_Name2;
+ public static String JBossWS_Runtime_Check_Field_Default_Classpath;
+ public static String JBossWS_Preference_Page_Runtimes;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossWSUIMessages.class);
+ }
+}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,37 +0,0 @@
-Label_JBossWS_Runtime_Load_Error=Error occurred while loading JBossWS runtime. Select the
correct JBossWS runtime folder.
-
-Command=wsconsume.sh
-Bin=bin
-Client=client
-Lib=lib
-Endorsed=endorsed
-
-Error_JBossWS_Basic_Editor_Composite=Parent control should be Composite
-Error_JBossWS_Basic_Editor_Support=Editor supports only grid layout
-Error_JBossWS_Basic_Editor_Different=Parent for label is different
-JBossWS_Runtime_List_Field_Editor_Name=Name
-JBossWS_Runtime_List_Field_Editor_Version=Version
-JBossWS_Runtime_List_Field_Editor_Path=Path
-JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be=inputElement must be
-JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List=an instance of
List<JBossWSRuntime>.
-JBossWS_Runtime_Delete_Confirm_Title=Confirm Runtime Delete
-JBossWS_Runtime_Delete_Used_Confirm=Runtime ''{0}'' is used by JBossWS
projects. Are you sure you want to delete it?
-JBossWS_Runtime_Delete_Not_Used_Confirm=Are you sure you want to delete runtime
''{0}''?
-JBossWS_Runtime_List_Field_Editor_Edit_Runtime=Edit JBossWS Runtime
-JBossWS_Runtime_List_Field_Editor_Modify_Runtime=Input new values
-JBossWS_Runtime_List_Field_Editor_New_Runtime=New JBossWS Runtime
-Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty=Path to
JBossWS home directory cannot be empty
-JBossWS_Runtime_List_Field_Editor_Already_Exists=' already exists
-JBossWS_Runtime_List_Field_Editor_Runtime=JBossWS Runtime
-Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct=Runtime name is not
correct
-Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty=Name cannot be empty
-JBossWS_Runtime_List_Field_Editor_Create_A_Runtime=Create a JBossWS Runtime
-JBossWS_Runtime_List_Field_Editor_Home_Folder=Home Folder:
-JBossWS_Composite_Editor_This_Method_Can_Be_Invoked=This metod can be invoked after
getEditorControls(parent) only
-JBossWS_Button_Field_Editor_Browse=Browse...
-Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet=Not implemented yet. Please setup
real acion for editor.
-JBossWS_SWT_Field_Editor_Factory_Browse=Browse...
-JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder=Select JBossWS Home Folder
-JBossWS_Runtime_List_Field_Editor_Name2=Name:
-JBossWS_Runtime_Check_Field_Default_Classpath=Configure JBoss Web Service Classpath
-JBossWS_Preference_Page_Runtimes=JBossWS Runtimes
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.messages;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Grid Qian
- */
-public final class JbossWSUIMessages extends NLS {
-
- private static final String BUNDLE_NAME =
- "org.jboss.tools.ws.ui.messages.JbossWSUI"; //$NON-NLS-1$
-
- private JbossWSUIMessages() {
- // Do not instantiate
- }
-
- public static String Label_JBossWS_Runtime_Load_Error;
-
- public static String Bin;
- public static String Command;
- public static String Client;
- public static String Lib;
- public static String Endorsed;
-
- public static String Error_JBossWS_Basic_Editor_Composite;
- public static String Error_JBossWS_Basic_Editor_Support;
- public static String Error_JBossWS_Basic_Editor_Different;
- public static String JBossWS_Runtime_List_Field_Editor_Name;
- public static String JBossWS_Runtime_List_Field_Editor_Version;
- public static String JBossWS_Runtime_List_Field_Editor_Path;
- public static String JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be;
- public static String JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List;
- public static String JBossWS_Runtime_Delete_Confirm_Title;
- public static String JBossWS_Runtime_Delete_Used_Confirm;
- public static String JBossWS_Runtime_Delete_Not_Used_Confirm;
- public static String JBossWS_Runtime_List_Field_Editor_Edit_Runtime;
- public static String JBossWS_Runtime_List_Field_Editor_Modify_Runtime;
- public static String JBossWS_Runtime_List_Field_Editor_New_Runtime;
- public static String
Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty;
- public static String JBossWS_Runtime_List_Field_Editor_Already_Exists;
- public static String JBossWS_Runtime_List_Field_Editor_Runtime;
- public static String
Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct;
- public static String Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty;
- public static String JBossWS_Runtime_List_Field_Editor_Create_A_Runtime;
- public static String JBossWS_Runtime_List_Field_Editor_Home_Folder;
- public static String JBossWS_Composite_Editor_This_Method_Can_Be_Invoked;
- public static String JBossWS_Button_Field_Editor_Browse;
- public static String Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet;
- public static String JBossWS_SWT_Field_Editor_Factory_Browse;
- public static String JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder;
- public static String JBossWS_Runtime_List_Field_Editor_Name2;
- public static String JBossWS_Runtime_Check_Field_Default_Classpath;
- public static String JBossWS_Preference_Page_Runtimes;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JbossWSUIMessages.class);
- }
-}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -26,7 +26,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -66,8 +66,8 @@
* @param parent
*/
public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite,
JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite)parent).getLayout() instanceof
GridLayout,JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Assert.isTrue(parent instanceof Composite,
JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)parent).getLayout() instanceof
GridLayout,JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
Composite aComposite = (Composite) parent;
final Control[] controls = (Control[])getEditorControls(aComposite);
GridLayout gl = (GridLayout)((Composite)parent).getLayout();
@@ -110,7 +110,7 @@
labelControl.setText(this.labelText);
} else if(parent!=null) {
if(labelControl.getParent()!=parent)
- throw new
IllegalArgumentException(JbossWSUIMessages.Error_JBossWS_Basic_Editor_Different);
+ throw new
IllegalArgumentException(JBossWSUIMessages.Error_JBossWS_Basic_Editor_Different);
}
return labelControl;
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -16,7 +16,7 @@
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -26,10 +26,10 @@
PushButtonField button= null;
int style;
- private ButtonPressedAction buttonAction = new
ButtonPressedAction(JbossWSUIMessages.JBossWS_Button_Field_Editor_Browse) {
+ private ButtonPressedAction buttonAction = new
ButtonPressedAction(JBossWSUIMessages.JBossWS_Button_Field_Editor_Browse) {
@Override
public void run() {
- throw new
RuntimeException(JbossWSUIMessages.Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet);
+ throw new
RuntimeException(JBossWSUIMessages.Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet);
}
};
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -27,7 +27,7 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -41,9 +41,9 @@
@Override
public void doFillIntoGrid(Object parent) {
Assert.isTrue(parent instanceof Composite,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
Composite aComposite = (Composite) parent;
final Control[] controls = (Control[]) getEditorControls(aComposite);
@@ -78,7 +78,7 @@
@Override
public Object[] getEditorControls() {
if(controls.size()>0) return controls.toArray();
- else throw new
IllegalStateException(JbossWSUIMessages.JBossWS_Composite_Editor_This_Method_Can_Be_Invoked);
+ else throw new
IllegalStateException(JBossWSUIMessages.JBossWS_Composite_Editor_This_Method_Can_Be_Invoked);
}
@Override
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,1110 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.preferences;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+import org.jboss.tools.ws.ui.utils.UIUtils;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private CheckboxTableViewer tableView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private Map<JBossWSRuntime, JBossWSRuntime> changed = new
HashMap<JBossWSRuntime, JBossWSRuntime>();
+
+ private JBossWSRuntime checkedElement = new JBossWSRuntime();
+
+ private List<JBossWSRuntime> added = new ArrayList<JBossWSRuntime>();
+
+ private List<JBossWSRuntime> removed = new ArrayList<JBossWSRuntime>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing jbossWSRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossRuntimeListFieldEditor(String name, String label,
+ Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ /**
+ * TBD
+ *
+ * @return JBossWSRuntime;
+ */
+ public JBossWSRuntime getDefaultJBossWSRuntime() {
+ return checkedElement;
+ }
+
+ public void setDefaultJBossWSRuntime(JBossWSRuntime rt) {
+ checkedElement = rt;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossWSRuntime>
+ */
+ public List<JBossWSRuntime> getAddedJBossWSRuntimes() {
+ return added;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossWSRuntime>
+ */
+ public Map<JBossWSRuntime, JBossWSRuntime> getChangedJBossWSRuntimes() {
+ return changed;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossWSRuntime>
+ */
+ public List<JBossWSRuntime> getRemoved() {
+ return removed;
+ }
+
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new FormLayout());
+ createTableView();
+ createActionBar();
+
+ FormData tableData = new FormData();
+ tableData.left = new FormAttachment(0, 5);
+ tableData.right = new FormAttachment(actionPanel, -5);
+ tableData.top = new FormAttachment(0, 5);
+ tableData.bottom = new FormAttachment(100, -5);
+ tableView.getControl().setLayoutData(tableData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+ return new Control[] { root };
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createTableView() {
+ tableView = CheckboxTableViewer.newCheckList(root, SWT.V_SCROLL
+ | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
+
+ TableColumn tc1 = new TableColumn(tableView.getTable(), SWT.CENTER);
+ tc1.setWidth(TC_DEFAULT_WIDTH);
+ tc1.setResizable(false);
+
+ TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc2.setWidth(TC_NAME_WIDTH);
+ tc2.setText(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name);
+
+ TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc3.setWidth(TC_VERSION_WIDTH);
+ tc3
+ .setText(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version);
+
+ TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc4.setWidth(TC_PATH_WIDTH);
+ tc4.setText(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
+
+ tableView.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List<JBossWSRuntime>) inputElement).toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+ });
+
+ tableView.setLabelProvider(new ITableLabelProvider() {
+
+ private static final int TC_DEFAULT_NUMBER = 0;
+ private static final int TC_NAME_NUMBER = 1;
+ private static final int TC_VERSION_NUMBER = 2;
+ private static final int TC_PATH_NUMBER = 3;
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ JBossWSRuntime rt = (JBossWSRuntime) element;
+ if (columnIndex == TC_DEFAULT_NUMBER) {
+ return ""; //$NON-NLS-1$
+ }
+ if (columnIndex == TC_NAME_NUMBER) {
+ return rt.getName();
+ }
+ if (columnIndex == TC_VERSION_NUMBER) {
+ return rt.getVersion().toString();
+ }
+ if (columnIndex == TC_PATH_NUMBER) {
+ return rt.getHomeDir();
+ }
+ return ""; //$NON-NLS-1$
+ }
+ });
+
+ tableView.setInput(getValue());
+ tableView.getTable().setLinesVisible(true);
+ tableView.getTable().setHeaderVisible(true);
+ tableView.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ JBossWSRuntime selRt = (JBossWSRuntime) event.getElement();
+ if (event.getChecked()) {
+ JBossWSRuntime deselRt = null;
+ Object[] selRts = tableView.getCheckedElements();
+
+ for (int i = 0; i < selRts.length; i++) {
+ JBossWSRuntime rt = (JBossWSRuntime) selRts[i];
+ if (rt != selRt) {
+ deselRt = rt;
+ break;
+ }
+ }
+
+ if (deselRt != null) {
+ Object[] newChecked = new Object[selRts.length - 1];
+ checkedElement = null;
+ int i = 0;
+ for (Object object : selRts) {
+ JBossWSRuntime rt = (JBossWSRuntime) object;
+ if (rt == selRt) {
+ newChecked[i] = rt;
+ checkedElement = rt;
+ i++;
+ }
+ }
+ tableView.setCheckedElements(newChecked);
+ } else {
+ checkedElement = (JBossWSRuntime) event.getElement();
+ }
+ } else {
+ if (checkedElement == selRt) {
+ checkedElement = null;
+ }
+ }
+ pcs.firePropertyChange(getName(), null, getValue());
+ }
+ });
+
+ for (JBossWSRuntime rt : (List<JBossWSRuntime>) getValue()) {
+ if (rt.isDefault()) {
+ tableView.setChecked(rt, true);
+ checkedElement = rt;
+ }
+ }
+ }
+
+ protected void createActionBar() {
+ actionPanel = new ActionPanel(root, new BaseAction[] { new AddAction(),
+ new EditAction(), new RemoveAction() });
+ tableView.addSelectionChangedListener(actionPanel);
+ }
+
+ /**
+ * Checks all runtimes and set default one if user did not do it.
+ */
+ @SuppressWarnings("unchecked")
+ private void setDefaultRuntime() {
+ List<JBossWSRuntime> runtimes = (List<JBossWSRuntime>) getValue();
+ boolean checked = false;
+ for (JBossWSRuntime jbossWSRuntime : runtimes) {
+
+ if (checkedElement == jbossWSRuntime) {
+ checked = true;
+ tableView.setChecked(checkedElement, true);
+ break;
+ }
+ }
+ if (!checked && runtimes.size() > 0) {
+ if (tableView.getCheckedElements() == null
+ || tableView.getCheckedElements().length == 0) {
+ tableView.setChecked(runtimes.get(0), true);
+ checkedElement = runtimes.get(0);
+ }
+ }
+
+ }
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+ /**
+ * Wizard page for editing JBossWS Runtime parameters
+ *
+ */
+ public static class JBossWSRuntimeWizardPage extends WizardPage implements
+ PropertyChangeListener {
+
+ private static final String SRT_NAME = "name";
+ private static final String SRT_VERSION = "version";
+ private static final String SRT_HOMEDIR = "homeDir";
+
+ private static final int GL_PARENT_COLUMNS = 1;
+ private static final int GL_CONTENT_COLUMNS = 3;
+
+ List<JBossWSRuntime> value = null;
+
+ IFieldEditor name = createTextEditor(SRT_NAME,
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name2, "");
//$NON-NLS-1$
+
+ IFieldEditor version = createTextEditor(SRT_VERSION,
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version, "");
//$NON-NLS-1$
+
+ IFieldEditor homeDir = createBrowseFolderEditor(
+ SRT_HOMEDIR,
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Home_Folder,
+ ""); //$NON-NLS-1$
+
+ JBossWSRuntime current = null;
+
+ IFieldEditor jars = null;
+
+ public JBossWSRuntimeWizardPage(List<JBossWSRuntime> editedList) {
+ super(
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+
+ setMessage(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Create_A_Runtime);
+ setTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime);
+ value = editedList;
+ }
+
+ /**
+ * Create Wizard page content
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ public void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(GL_PARENT_COLUMNS, false));
+ GridData dg = new GridData();
+ dg.horizontalAlignment = GridData.FILL;
+ dg.grabExcessHorizontalSpace = true;
+ Composite root = new Composite(parent, SWT.NONE);
+ root.setLayoutData(dg);
+ GridLayout gl = new GridLayout(GL_CONTENT_COLUMNS, false);
+ root.setLayout(gl);
+ name.doFillIntoGrid(root);
+ name.addPropertyChangeListener(this);
+ version.doFillIntoGrid(root);
+ version.addPropertyChangeListener(this);
+ homeDir.doFillIntoGrid(root);
+ homeDir.addPropertyChangeListener(this);
+
+ jars = new JBossWSLibraryListFieldEditor("", "", current);
+ jars.doFillIntoGrid(root);
+ jars.addPropertyChangeListener(this);
+ setPageComplete(false);
+ setControl(root);
+ }
+
+ /**
+ * Process evt: setup default values based on JBossWS Home folder and
+ * validate user input
+ *
+ * @param evt
+ * PropertyChangeEvent describes changes in wizard
+ */
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if ("homeDir".equals(evt.getPropertyName())) {
+ if (name.getValueAsString() == null
+ || "".equals(name.getValueAsString().trim())
+ || this.getErrorMessage() != null) {
+ String homeDirName = homeDir.getValueAsString();
+ if (homeDirName != null && !"".equals(homeDirName.trim())) {
+ File folder = new File(homeDirName);
+ homeDirName = folder.getName();
+ }
+ name.setValue(homeDirName);
+ }
+ }
+
+ if (name.getValueAsString() == null || "".equals(//$NON-NLS-1$
+ name.getValueAsString().toString().trim())) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!name.getValueAsString().matches(
+ "[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct);
+ setPageComplete(false);
+ return;
+ }
+ for (JBossWSRuntime rt : value) {
+ if (current != null && current.getName().equals(rt.getName())) {
+ continue;
+ }
+ if (rt.getName().equals(name.getValueAsString())) {
+ setErrorMessage(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime
+ + name.getValueAsString()
+ + JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Already_Exists);
+ setPageComplete(false);
+ return;
+ }
+ }
+
+ JBossWSRuntime jarJbws = (JBossWSRuntime) jars.getValue();
+ if (current != null
+ && current.getName().equals(name.getValueAsString())
+ && current.getHomeDir().equals(homeDir.getValueAsString())
+ && current.getVersion().equals(version.getValueAsString())
+ && current.isUserConfigClasspath() == jarJbws
+ .isUserConfigClasspath()
+ && (!jarJbws.isUserConfigClasspath() || hasSameLibraies(
+ current.getLibraries(), jarJbws.getLibraries()))) {
+
+ setErrorMessage(null);
+ setPageComplete(false);
+ return;
+ }
+
+ if (jarJbws.isUserConfigClasspath()
+ && jarJbws.getLibraries().size() == 0) {
+ setErrorMessage("The library must contian at least one jar.");
+ setPageComplete(false);
+ return;
+ }
+
+ if (homeDir.getValueAsString() == null
+ || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!runtimeExist(homeDir.getValueAsString())) {
+ setErrorMessage(JBossWSUIMessages.Label_JBossWS_Runtime_Load_Error);
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+
+ private boolean hasSameLibraies(List<String> lib1, List<String> lib2) {
+ if (lib1.size() != lib2.size())
+ return false;
+ for (String jar : lib1) {
+ if (!lib2.contains(jar))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return JBossWS Runtime instance initialized by user input
+ *
+ * @return JBossWSRuntime instance
+ */
+ public JBossWSRuntime getRuntime() {
+ JBossWSRuntime newRt = new JBossWSRuntime();
+ newRt.setName(name.getValueAsString());
+ newRt.setVersion(version.getValueAsString());
+ newRt.setHomeDir(homeDir.getValueAsString());
+ JBossWSRuntime rt = (JBossWSRuntime) jars.getValue();
+ newRt.setLibraries(rt.getLibraries());
+ newRt.setUserConfigClasspath(rt.isUserConfigClasspath());
+ return newRt;
+ }
+
+ public IFieldEditor createTextEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor.addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue) });
+ return editor;
+ }
+
+ public IFieldEditor createBrowseFolderEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor
+ .addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue),
+ new ButtonFieldEditor(
+ name,
+ createSelectFolderAction(JBossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Browse),
+ defaultValue) });
+ return editor;
+ }
+
+ public ButtonFieldEditor.ButtonPressedAction createSelectFolderAction(
+ String buttonName) {
+ return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+ @Override
+ public void run() {
+ DirectoryDialog dialog = new DirectoryDialog(Display
+ .getCurrent().getActiveShell());
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ dialog
+ .setMessage(JBossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder);
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ String directory = dialog.open();
+ if (directory != null) {
+ getFieldEditor().setValue(directory);
+ }
+ }
+ };
+ }
+
+ private boolean runtimeExist(String path) {
+
+ File jbosswsHomeDir = new File(path);
+ if (!jbosswsHomeDir.isDirectory())
+ return false;
+ String[] newNode = { JBossWSUIMessages.Bin,
+ JBossWSUIMessages.Command };
+ String jbosswsBinPath = UIUtils.addNodesToPath(jbosswsHomeDir
+ .getAbsolutePath(), newNode);
+ if (new File(jbosswsBinPath).isFile()
+ && new File(UIUtils.addAnotherNodeToPath(jbosswsHomeDir
+ .getAbsolutePath(), JBossWSUIMessages.Client))
+ .isDirectory()
+ && new File(UIUtils
+ .addNodesToPath(jbosswsHomeDir.getAbsolutePath(),
+ new String[] { JBossWSUIMessages.Lib,
+ JBossWSUIMessages.Endorsed }))
+ .isDirectory()) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Wizard collect information and creates new JBossWSRuntime instances.
+ *
+ */
+ public static class JBossWSRuntimeNewWizard extends Wizard {
+
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossWSRuntime> added = null;
+ List<JBossWSRuntime> value = null;
+
+ public JBossWSRuntimeNewWizard(List<JBossWSRuntime> exist,
+ List<JBossWSRuntime> added) {
+ super();
+ setWindowTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(exist);
+ addPage(page1);
+ this.value = exist;
+ this.added = added;
+ }
+
+ /**
+ * Do finish steps
+ *
+ * @return boolean
+ */
+ @Override
+ public boolean performFinish() {
+ JBossWSRuntime rt = page1.getRuntime();
+ added.add(rt);
+ value.add(rt);
+
+ return true;
+ }
+
+ protected JBossWSRuntime getRuntime() {
+ return page1.getRuntime();
+ }
+
+ }
+
+ /**
+ * Wizard for editing JBossWS Runtime parameters: name and path to home
+ * folder
+ *
+ */
+ public static class JBossWSRuntimeEditWizard extends Wizard {
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossWSRuntime> added = null;
+ Map<JBossWSRuntime, JBossWSRuntime> changed = null;
+ List<JBossWSRuntime> value = null;
+ JBossWSRuntime source = null;
+
+ /**
+ * Constructor with almost all initialization parameters
+ *
+ * @param existing
+ * List<JBossWSRuntime> - edited list of JBossWS
+ * Runtimes
+ * @param source
+ * JBossWSRuntime - edited JBossWS Runtime
+ * @param added
+ * List<JBossWSRuntime> - TBD
+ * @param changed
+ * List<JBossWSRuntime> - TBD
+ */
+ public JBossWSRuntimeEditWizard(List<JBossWSRuntime> existing,
+ JBossWSRuntime source, List<JBossWSRuntime> added,
+ Map<JBossWSRuntime, JBossWSRuntime> changed) {
+ super();
+ setWindowTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(existing);
+ page1
+ .setMessage(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Modify_Runtime);
+ page1
+ .setTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ addPage(page1);
+ this.value = existing;
+ this.added = added;
+ this.changed = changed;
+ this.source = source;
+ page1.name.setValue(source.getName());
+ page1.version.setValue(source.getVersion());
+ page1.homeDir.setValue(source.getHomeDir());
+ page1.current = source;
+ }
+
+ /**
+ * Perform operations to finish editing JBossWS Runtime parameters
+ *
+ * @return boolean - always true
+ */
+ @Override
+ public boolean performFinish() {
+ JBossWSRuntime rt = page1.getRuntime();
+
+ if (added.contains(source) || changed.containsKey(source)) {
+ source.setName(rt.getName());
+ source.setHomeDir(rt.getHomeDir());
+ source.setVersion(rt.getVersion());
+ source.setUserConfigClasspath(rt.isUserConfigClasspath());
+ source.setLibraries(rt.getLibraries());
+ } else {
+ changed.put(rt, source);
+ if (source.isDefault()) {
+ rt.setDefault(true);
+ }
+ int i = value.indexOf(source);
+ if (i >= 0) {
+ value.set(i, rt);
+
+ } else {
+ value.remove(source);
+ value.add(rt);
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see
org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ JBossWSRuntime[] runtimes = new JBossWSRuntime[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<JBossWSRuntime> rts = new ArrayList<JBossWSRuntime>();
+ for (Object rt : ((IStructuredSelection) selection).toArray()) {
+ rts.add((JBossWSRuntime) rt);
+ }
+ runtimes = rts.toArray(new JBossWSRuntime[] {});
+ } else {
+ runtimes = new JBossWSRuntime[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ Wizard wiz = new JBossWSRuntimeNewWizard(
+ (List<JBossWSRuntime>) getValue(), added);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+ }
+
+ /**
+ * Action starts an editing selected JBossWS Runtime in Edit JBossWS Runtime
+ * dialog
+ *
+ */
+ public class EditAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Edit";
+
+ /**
+ * Create EditAction with default name
+ *
+ * @param text
+ */
+ public EditAction() {
+ super(ACTION_NAME);
+ }
+
+ /**
+ * Edit action is enabled when the only JBossWS Runtime is selected
+ */
+ @Override
+ protected void updateEnablement() {
+ // available when the only JBossWSRuntime is selected
+ setEnabled(runtimes.length == 1);
+ }
+
+ /**
+ * Start editing selected JBossWS Runtime in Edit JBossWS Runtime Wizard
+ * Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ JBossWSRuntime selected = runtimes[0];
+ Wizard wiz = new JBossWSRuntimeEditWizard(
+ (List<JBossWSRuntime>) getValue(), runtimes[0], added,
+ changed);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ JBossWSRuntime c = null;
+ if (changed.containsValue(selected)) {
+ c = findChangedRuntime(selected);
+ if (c != null) {
+ tableView.setSelection(new StructuredSelection(c));
+ }
+ }
+ if (c != null && c.isDefault()) {
+ checkedElement = c;
+ }
+ setDefaultRuntime();
+ }
+
+ private JBossWSRuntime findChangedRuntime(JBossWSRuntime source) {
+ for (JBossWSRuntime r : changed.keySet()) {
+ if (source == changed.get(r)) {
+ return r;
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(runtimes.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (JBossWSRuntime rt : runtimes) {
+ removeRuntime(rt);
+ }
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeRuntime(JBossWSRuntime r) {
+ boolean used = JBossWSRuntimeManager.isRuntimeUsed(r.getName());
+ String title = JBossWSUIMessages.JBossWS_Runtime_Delete_Confirm_Title;
+ String message = (used) ? NLS.bind(
+ JBossWSUIMessages.JBossWS_Runtime_Delete_Used_Confirm, r
+ .getName()) : NLS.bind(
+ JBossWSUIMessages.JBossWS_Runtime_Delete_Not_Used_Confirm,
+ r.getName());
+ boolean b = MessageDialog.openConfirm(tableView.getControl()
+ .getShell(), title, message);
+ if (b) {
+ if (changed.containsKey(r)) {
+ r = changed.remove(r);
+ }
+ removed.add(r);
+ if (added.contains(r)) {
+ added.remove(r);
+ }
+ ((List) getValue()).remove(r);
+ }
+ if (checkedElement == r) {
+ checkedElement = null;
+ }
+ }
+ }
+}
\ No newline at end of file
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,584 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.ui.JBossWSUIPlugin;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSLibraryListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private TreeViewer listView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private JBossWSRuntime tempJbws;
+
+
+
+
+ private Group jarGroup;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing jbossWSRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossWSLibraryListFieldEditor(String name, String label,
+ JBossWSRuntime jbws) {
+ super(name, label, jbws);
+ this.tempJbws = new JBossWSRuntime();
+ if(jbws != null){
+ this.tempJbws.setUserConfigClasspath(jbws.isUserConfigClasspath());
+ this.tempJbws.getLibraries().addAll(jbws.getLibraries());
+ }
+
+ }
+
+
+ public Object getValue(){
+ return this.tempJbws;
+ }
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new GridLayout());
+
+ createCheckButton(root);
+
+ jarGroup = new Group(root, SWT.BORDER);
+ jarGroup.setText("Library Jars");
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+
+
+ jarGroup.setLayoutData(gd);
+ jarGroup.setLayout(new FormLayout());
+
+ createListView(jarGroup);
+ createActionBar(jarGroup);
+
+ FormData listData = new FormData();
+ listData.left = new FormAttachment(0, 5);
+ listData.right = new FormAttachment(actionPanel, -5);
+ listData.top = new FormAttachment(0, 5);
+ listData.bottom = new FormAttachment(100, -5);
+ listView.getControl().setLayoutData(listData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+
+ setJarGroupStatus();
+ return new Control[] { root };
+ }
+
+ protected void createCheckButton(Composite parent){
+ final Button btnDefault = new Button(parent, SWT.CHECK);
+ btnDefault.setText(JBossWSUIMessages.JBossWS_Runtime_Check_Field_Default_Classpath);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ btnDefault.setLayoutData(gd);
+
+ btnDefault.setSelection(tempJbws.isUserConfigClasspath());
+ btnDefault.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ tempJbws.setUserConfigClasspath(btnDefault.getSelection());
+ setJarGroupStatus();
+ setValue(null);
+ }
+ });
+
+
+ }
+
+ protected void setJarGroupStatus(){
+ boolean isUserConfig = tempJbws.isUserConfigClasspath();
+ jarGroup.setEnabled(isUserConfig);
+ listView.getTree().setEnabled(isUserConfig);
+ actionPanel.setEnabled(isUserConfig);
+ }
+
+ protected void createListView(Composite parent) {
+ listView = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ listView.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ listView.setContentProvider(new ITreeContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof JBossWSRuntime) {
+ return ((JBossWSRuntime) inputElement).getLibraries().toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ });
+
+ listView.setLabelProvider(new ILabelProvider() {
+
+ Image jarImg;
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ if (jarImg == null){
+ ImageDescriptor jarImgDesc =
JBossWSUIPlugin.getImageDescriptor("obj16/jar_obj.gif");
+ jarImg = jarImgDesc.createImage();
+ }
+ return jarImg;
+ }
+
+ public String getText(Object element) {
+ String fullName = (String)element;
+ File jarFile = new File(fullName);
+ return jarFile.getName() + " - " + jarFile.getParentFile().toString();
+ }
+ });
+
+
+ listView.setInput(getValue());
+
+ }
+
+ protected void createActionBar(Composite parent) {
+ actionPanel = new ActionPanel(parent, new BaseAction[] { new AddAction(),
+ new RemoveAction() });
+ listView.addSelectionChangedListener(actionPanel);
+ }
+
+
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see
org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ String[] jars = new String[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<String> rts = new ArrayList<String>();
+ for (Object jarfile : ((IStructuredSelection) selection).toArray()) {
+ rts.add((String) jarfile);
+ }
+ jars = rts.toArray(new String[] {});
+ } else {
+ jars = new String[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ FileDialog dialog = new FileDialog(Display.getCurrent()
+ .getActiveShell(), SWT.MULTI);
+ dialog.setFilterExtensions(new String[] { "*.jar;*.zip" });
+ String fileName = dialog.open();
+ String[] fileNames = dialog.getFileNames();
+ if (fileName != null) {
+ File filePath = new File(fileName);
+ filePath = filePath.getParentFile();
+ for (int i = 0; i < fileNames.length; i++) {
+ IPath path = new Path(filePath.getAbsolutePath())
+ .append(fileNames[i]);
+ if (!tempJbws.getLibraries().contains(path.toOSString())) {
+ tempJbws.getLibraries().add(path.toOSString());
+ }
+ }
+
+ listView.refresh();
+ setValue(null);
+ }
+ }
+ }
+
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(jars.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (String jar : jars) {
+ tempJbws.getLibraries().remove(jar);
+ }
+ listView.refresh();
+ // just try to fire property change listener
+ setValue(null);
+ }
+
+
+ }
+}
\ No newline at end of file
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimePreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+
+ public JBossWSRuntimePreferencePage() {
+ super();
+ noDefaultAndApplyButton();
+ }
+
+ private static final int COLUMNS = 3;
+
+ JBossRuntimeListFieldEditor jbossWSRuntimes = new JBossRuntimeListFieldEditor(
+ "rtlist", JBossWSUIMessages.JBossWS_Preference_Page_Runtimes, new
ArrayList<JBossWSRuntime>(Arrays.asList(JBossWSRuntimeManager.getInstance().getRuntimes())));
//$NON-NLS-1$
+
+ /**
+ * Create contents of JBossWS preferences page. JBossWSRuntime list editor
+ * is created
+ *
+ * @return Control
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite root = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout(COLUMNS, false);
+ root.setLayout(gl);
+ jbossWSRuntimes.doFillIntoGrid(root);
+
+ return root;
+ }
+
+ /**
+ * Inherited from IWorkbenchPreferencePage
+ *
+ * @param workbench
+ * {@link IWorkbench}
+ *
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /**
+ * Save JBossWSRuntime list
+ */
+ @Override
+ protected void performApply() {
+ for (JBossWSRuntime rt : jbossWSRuntimes.getAddedJBossWSRuntimes()) {
+ JBossWSRuntimeManager.getInstance().addRuntime(rt);
+ }
+ jbossWSRuntimes.getAddedJBossWSRuntimes().clear();
+ for (JBossWSRuntime rt : jbossWSRuntimes.getRemoved()) {
+ JBossWSRuntimeManager.getInstance().removeRuntime(rt);
+ }
+ jbossWSRuntimes.getRemoved().clear();
+ JBossWSRuntime defaultRuntime = jbossWSRuntimes
+ .getDefaultJBossWSRuntime();
+ // reset default runtime
+ for (JBossWSRuntime jbossWSRuntime : JBossWSRuntimeManager
+ .getInstance().getRuntimes()) {
+ jbossWSRuntime.setDefault(false);
+ }
+ // set deafult runtime
+ if (defaultRuntime != null) {
+ defaultRuntime.setDefault(true);
+ }
+ jbossWSRuntimes.setDefaultJBossWSRuntime(null);
+ Map<JBossWSRuntime, JBossWSRuntime> changed = jbossWSRuntimes
+ .getChangedJBossWSRuntimes();
+ for (JBossWSRuntime c : changed.keySet()) {
+ JBossWSRuntime o = changed.get(c);
+ o.setHomeDir(c.getHomeDir());
+ o.setVersion(c.getVersion());
+ String oldName = o.getName();
+ String newName = c.getName();
+ if (!oldName.equals(newName)) {
+ JBossWSRuntimeManager.getInstance().changeRuntimeName(oldName,
+ newName);
+ }
+ o.setDefault(c.isDefault());
+ o.setUserConfigClasspath(c.isUserConfigClasspath());
+ o.setLibraries(c.getLibraries());
+ }
+ jbossWSRuntimes.getChangedJBossWSRuntimes().clear();
+
+ JBossWSRuntimeManager.getInstance().save();
+ }
+
+ /**
+ * Restore original preferences values
+ */
+ @Override
+ protected void performDefaults() {
+ setValid(true);
+ setMessage(null);
+ performApply();
+ }
+
+ /**
+ * See {@link PreferencePage} for details
+ *
+ * @return Boolean
+ */
+ @Override
+ public boolean performOk() {
+ performApply();
+ return super.performOk();
+ }
+
+ public JBossRuntimeListFieldEditor getJBossWSRuntimes() {
+ return jbossWSRuntimes;
+ }
+}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,1111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.preferences;
-
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TableColumn;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
-import org.jboss.tools.ws.ui.utils.UIUtils;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-
-/**
- * @author Grid Qian
- */
-public class JbossRuntimeListFieldEditor extends BaseFieldEditor {
-
- // ------------------------------------------------------------------------
- // Layout parameters
- // ------------------------------------------------------------------------
-
- static final int GL_COLUMNS = 2;
- static final int GL_HINT_HEIGHT = 200;
- static final int TC_DEFAULT_WIDTH = 21;
- static final int TC_NAME_WIDTH = 100;
- static final int TC_VERSION_WIDTH = 50;
- static final int TC_PATH_WIDTH = 100;
-
- // ------------------------------------------------------------------------
- // Field declarations
- // ------------------------------------------------------------------------
-
- private CheckboxTableViewer tableView = null;
-
- private Composite root = null;
-
- private ActionPanel actionPanel;
-
- private Map<JbossWSRuntime, JbossWSRuntime> changed = new
HashMap<JbossWSRuntime, JbossWSRuntime>();
-
- private JbossWSRuntime checkedElement = new JbossWSRuntime();
-
- private List<JbossWSRuntime> added = new ArrayList<JbossWSRuntime>();
-
- private List<JbossWSRuntime> removed = new ArrayList<JbossWSRuntime>();
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Control for editing jbossWSRuntime list
- *
- * @param name
- * String
- * @param label
- * String
- * @param defaultValue
- * Object
- */
- public JbossRuntimeListFieldEditor(String name, String label,
- Object defaultValue) {
- super(name, label, defaultValue);
- }
-
- /**
- * TBD
- *
- * @return JbossWSRuntime;
- */
- public JbossWSRuntime getDefaultJbossWSRuntime() {
- return checkedElement;
- }
-
- public void setDefaultJbossWSRuntime(JbossWSRuntime rt) {
- checkedElement = rt;
- }
-
- /**
- * TBD
- *
- * @return List<JbossWSRuntime>
- */
- public List<JbossWSRuntime> getAddedJbossWSRuntimes() {
- return added;
- }
-
- /**
- * TBD
- *
- * @return List<JbossWSRuntime>
- */
- public Map<JbossWSRuntime, JbossWSRuntime> getChangedJbossWSRuntimes() {
- return changed;
- }
-
- /**
- * TBD
- *
- * @return List<JbossWSRuntime>
- */
- public List<JbossWSRuntime> getRemoved() {
- return removed;
- }
-
- /**
- * TBD
- *
- * @param composite
- * Object - instance of Composite
- * @return Object[]
- */
- @Override
- public Object[] getEditorControls(Object composite) {
-
- root = new Composite((Composite) composite, SWT.NONE);
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- root.setLayoutData(gd);
-
- root.setLayout(new FormLayout());
- createTableView();
- createActionBar();
-
- FormData tableData = new FormData();
- tableData.left = new FormAttachment(0, 5);
- tableData.right = new FormAttachment(actionPanel, -5);
- tableData.top = new FormAttachment(0, 5);
- tableData.bottom = new FormAttachment(100, -5);
- tableView.getControl().setLayoutData(tableData);
-
- FormData actionsData = new FormData();
- actionsData.top = new FormAttachment(0, 5);
- actionsData.bottom = new FormAttachment(100, -5);
- actionsData.right = new FormAttachment(100, -5);
- actionPanel.setLayoutData(actionsData);
- return new Control[] { root };
- }
-
- @SuppressWarnings("unchecked")
- protected void createTableView() {
- tableView = CheckboxTableViewer.newCheckList(root, SWT.V_SCROLL
- | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
-
- TableColumn tc1 = new TableColumn(tableView.getTable(), SWT.CENTER);
- tc1.setWidth(TC_DEFAULT_WIDTH);
- tc1.setResizable(false);
-
- TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
- tc2.setWidth(TC_NAME_WIDTH);
- tc2.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name);
-
- TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
- tc3.setWidth(TC_VERSION_WIDTH);
- tc3
- .setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version);
-
- TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
- tc4.setWidth(TC_PATH_WIDTH);
- tc4.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
-
- tableView.setContentProvider(new IStructuredContentProvider() {
-
- @SuppressWarnings("unchecked")
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof List) {
- return ((List<JbossWSRuntime>) inputElement).toArray();
- } else {
- throw new IllegalArgumentException(
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
- + JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- viewer.refresh();
- }
- });
-
- tableView.setLabelProvider(new ITableLabelProvider() {
-
- private static final int TC_DEFAULT_NUMBER = 0;
- private static final int TC_NAME_NUMBER = 1;
- private static final int TC_VERSION_NUMBER = 2;
- private static final int TC_PATH_NUMBER = 3;
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- JbossWSRuntime rt = (JbossWSRuntime) element;
- if (columnIndex == TC_DEFAULT_NUMBER) {
- return ""; //$NON-NLS-1$
- }
- if (columnIndex == TC_NAME_NUMBER) {
- return rt.getName();
- }
- if (columnIndex == TC_VERSION_NUMBER) {
- return rt.getVersion().toString();
- }
- if (columnIndex == TC_PATH_NUMBER) {
- return rt.getHomeDir();
- }
- return ""; //$NON-NLS-1$
- }
- });
-
- tableView.setInput(getValue());
- tableView.getTable().setLinesVisible(true);
- tableView.getTable().setHeaderVisible(true);
- tableView.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- JbossWSRuntime selRt = (JbossWSRuntime) event.getElement();
- if (event.getChecked()) {
- JbossWSRuntime deselRt = null;
- Object[] selRts = tableView.getCheckedElements();
-
- for (int i = 0; i < selRts.length; i++) {
- JbossWSRuntime rt = (JbossWSRuntime) selRts[i];
- if (rt != selRt) {
- deselRt = rt;
- break;
- }
- }
-
- if (deselRt != null) {
- Object[] newChecked = new Object[selRts.length - 1];
- checkedElement = null;
- int i = 0;
- for (Object object : selRts) {
- JbossWSRuntime rt = (JbossWSRuntime) object;
- if (rt == selRt) {
- newChecked[i] = rt;
- checkedElement = rt;
- i++;
- }
- }
- tableView.setCheckedElements(newChecked);
- } else {
- checkedElement = (JbossWSRuntime) event.getElement();
- }
- } else {
- if (checkedElement == selRt) {
- checkedElement = null;
- }
- }
- pcs.firePropertyChange(getName(), null, getValue());
- }
- });
-
- for (JbossWSRuntime rt : (List<JbossWSRuntime>) getValue()) {
- if (rt.isDefault()) {
- tableView.setChecked(rt, true);
- checkedElement = rt;
- }
- }
- }
-
- protected void createActionBar() {
- actionPanel = new ActionPanel(root, new BaseAction[] { new AddAction(),
- new EditAction(), new RemoveAction() });
- tableView.addSelectionChangedListener(actionPanel);
- }
-
- /**
- * Checks all runtimes and set default one if user did not do it.
- */
- @SuppressWarnings("unchecked")
- private void setDefaultRuntime() {
- List<JbossWSRuntime> runtimes = (List<JbossWSRuntime>) getValue();
- boolean checked = false;
- for (JbossWSRuntime jbossWSRuntime : runtimes) {
-
- if (checkedElement == jbossWSRuntime) {
- checked = true;
- tableView.setChecked(checkedElement, true);
- break;
- }
- }
- if (!checked && runtimes.size() > 0) {
- if (tableView.getCheckedElements() == null
- || tableView.getCheckedElements().length == 0) {
- tableView.setChecked(runtimes.get(0), true);
- checkedElement = runtimes.get(0);
- }
- }
-
- }
-
- /**
- * Return array of Controls that forms and editor
- *
- * @return Control[]
- */
- @Override
- public Object[] getEditorControls() {
- return new Control[] { root };
- }
-
- /**
- * Return number of controls in editor
- *
- * @return int
- */
- @Override
- public int getNumberOfControls() {
- return 1;
- }
-
- /**
- * Fill wizard page with editors
- *
- * @param parent
- * Composite - parent composite
- */
- @Override
- public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
- Composite aComposite = (Composite) parent;
- getEditorControls(aComposite);
- GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
-
- GridData gd = new GridData();
- gd.horizontalSpan = gl.numColumns;
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
-
- ((Control) getEditorControls()[0]).setLayoutData(gd);
- }
-
- /**
- * Wizard page for editing JbossWS Runtime parameters
- *
- */
- public static class JbossWSRuntimeWizardPage extends WizardPage implements
- PropertyChangeListener {
-
- private static final String SRT_NAME = "name";
- private static final String SRT_VERSION = "version";
- private static final String SRT_HOMEDIR = "homeDir";
-
- private static final int GL_PARENT_COLUMNS = 1;
- private static final int GL_CONTENT_COLUMNS = 3;
-
- List<JbossWSRuntime> value = null;
-
- IFieldEditor name = createTextEditor(SRT_NAME,
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name2, "");
//$NON-NLS-1$
-
- IFieldEditor version = createTextEditor(SRT_VERSION,
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version, "");
//$NON-NLS-1$
-
- IFieldEditor homeDir = createBrowseFolderEditor(
- SRT_HOMEDIR,
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Home_Folder,
- ""); //$NON-NLS-1$
-
- JbossWSRuntime current = null;
-
- IFieldEditor jars = null;
-
- public JbossWSRuntimeWizardPage(List<JbossWSRuntime> editedList) {
- super(
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
-
- setMessage(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Create_A_Runtime);
- setTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime);
- value = editedList;
- }
-
- /**
- * Create Wizard page content
- *
- * @param parent
- * Composite - parent composite
- */
- public void createControl(Composite parent) {
- parent.setLayout(new GridLayout(GL_PARENT_COLUMNS, false));
- GridData dg = new GridData();
- dg.horizontalAlignment = GridData.FILL;
- dg.grabExcessHorizontalSpace = true;
- Composite root = new Composite(parent, SWT.NONE);
- root.setLayoutData(dg);
- GridLayout gl = new GridLayout(GL_CONTENT_COLUMNS, false);
- root.setLayout(gl);
- name.doFillIntoGrid(root);
- name.addPropertyChangeListener(this);
- version.doFillIntoGrid(root);
- version.addPropertyChangeListener(this);
- homeDir.doFillIntoGrid(root);
- homeDir.addPropertyChangeListener(this);
-
- jars = new JbwsLibraryListFieldEditor("", "", current);
- jars.doFillIntoGrid(root);
- jars.addPropertyChangeListener(this);
- setPageComplete(false);
- setControl(root);
- }
-
- /**
- * Process evt: setup default values based on JbossWS Home folder and
- * validate user input
- *
- * @param evt
- * PropertyChangeEvent describes changes in wizard
- */
- public void propertyChange(java.beans.PropertyChangeEvent evt) {
- if ("homeDir".equals(evt.getPropertyName())) {
- if (name.getValueAsString() == null
- || "".equals(name.getValueAsString().trim())
- || this.getErrorMessage() != null) {
- String homeDirName = homeDir.getValueAsString();
- if (homeDirName != null && !"".equals(homeDirName.trim())) {
- File folder = new File(homeDirName);
- homeDirName = folder.getName();
- }
- name.setValue(homeDirName);
- }
- }
-
- if (name.getValueAsString() == null || "".equals(//$NON-NLS-1$
- name.getValueAsString().toString().trim())) {
- setErrorMessage(JbossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty);
- setPageComplete(false);
- return;
- }
-
- if (!name.getValueAsString().matches(
- "[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
- setErrorMessage(JbossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct);
- setPageComplete(false);
- return;
- }
- for (JbossWSRuntime rt : value) {
- if (current != null && current.getName().equals(rt.getName())) {
- continue;
- }
- if (rt.getName().equals(name.getValueAsString())) {
- setErrorMessage(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime
- + name.getValueAsString()
- + JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Already_Exists);
- setPageComplete(false);
- return;
- }
- }
-
- JbossWSRuntime jarJbws = (JbossWSRuntime) jars.getValue();
- if (current != null
- && current.getName().equals(name.getValueAsString())
- && current.getHomeDir().equals(homeDir.getValueAsString())
- && current.getVersion().equals(version.getValueAsString())
- && current.isUserConfigClasspath() == jarJbws
- .isUserConfigClasspath()
- && (!jarJbws.isUserConfigClasspath() || hasSameLibraies(
- current.getLibraries(), jarJbws.getLibraries()))) {
-
- setErrorMessage(null);
- setPageComplete(false);
- return;
- }
-
- if (jarJbws.isUserConfigClasspath()
- && jarJbws.getLibraries().size() == 0) {
- setErrorMessage("The library must contian at least one jar.");
- setPageComplete(false);
- return;
- }
-
- if (homeDir.getValueAsString() == null
- || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
- setErrorMessage(JbossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty);
- setPageComplete(false);
- return;
- }
-
- if (!runtimeExist(homeDir.getValueAsString())) {
- setErrorMessage(JbossWSUIMessages.Label_JBossWS_Runtime_Load_Error);
- setPageComplete(false);
- return;
- }
-
- setErrorMessage(null);
- setPageComplete(true);
- }
-
- private boolean hasSameLibraies(List<String> lib1, List<String> lib2) {
- if (lib1.size() != lib2.size())
- return false;
- for (String jar : lib1) {
- if (!lib2.contains(jar))
- return false;
- }
-
- return true;
- }
-
- /**
- * Return JbossWS Runtime instance initialized by user input
- *
- * @return JbossWSRuntime instance
- */
- public JbossWSRuntime getRuntime() {
- JbossWSRuntime newRt = new JbossWSRuntime();
- newRt.setName(name.getValueAsString());
- newRt.setVersion(version.getValueAsString());
- newRt.setHomeDir(homeDir.getValueAsString());
- JbossWSRuntime rt = (JbossWSRuntime) jars.getValue();
- newRt.setLibraries(rt.getLibraries());
- newRt.setUserConfigClasspath(rt.isUserConfigClasspath());
- return newRt;
- }
-
- public IFieldEditor createTextEditor(String name, String label,
- String defaultValue) {
- CompositeEditor editor = new CompositeEditor(name, label,
- defaultValue);
- editor.addFieldEditors(new IFieldEditor[] {
- new LabelFieldEditor(name, label),
- new TextFieldEditor(name, label, defaultValue) });
- return editor;
- }
-
- public IFieldEditor createBrowseFolderEditor(String name, String label,
- String defaultValue) {
- CompositeEditor editor = new CompositeEditor(name, label,
- defaultValue);
- editor
- .addFieldEditors(new IFieldEditor[] {
- new LabelFieldEditor(name, label),
- new TextFieldEditor(name, label, defaultValue),
- new ButtonFieldEditor(
- name,
- createSelectFolderAction(JbossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Browse),
- defaultValue) });
- return editor;
- }
-
- public ButtonFieldEditor.ButtonPressedAction createSelectFolderAction(
- String buttonName) {
- return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
- @Override
- public void run() {
- DirectoryDialog dialog = new DirectoryDialog(Display
- .getCurrent().getActiveShell());
- dialog.setFilterPath(getFieldEditor().getValueAsString());
- dialog
- .setMessage(JbossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder);
- dialog.setFilterPath(getFieldEditor().getValueAsString());
- String directory = dialog.open();
- if (directory != null) {
- getFieldEditor().setValue(directory);
- }
- }
- };
- }
-
- private boolean runtimeExist(String path) {
-
- File jbosswsHomeDir = new File(path);
- if (!jbosswsHomeDir.isDirectory())
- return false;
- String[] newNode = { JbossWSUIMessages.Bin,
- JbossWSUIMessages.Command };
- String jbosswsBinPath = UIUtils.addNodesToPath(jbosswsHomeDir
- .getAbsolutePath(), newNode);
- if (new File(jbosswsBinPath).isFile()
- && new File(UIUtils.addAnotherNodeToPath(jbosswsHomeDir
- .getAbsolutePath(), JbossWSUIMessages.Client))
- .isDirectory()
- && new File(UIUtils
- .addNodesToPath(jbosswsHomeDir.getAbsolutePath(),
- new String[] { JbossWSUIMessages.Lib,
- JbossWSUIMessages.Endorsed }))
- .isDirectory()) {
- return true;
- }
- return false;
- }
- }
-
- /**
- * Wizard collect information and creates new JbossWSRuntime instances.
- *
- */
- public static class JbossWSRuntimeNewWizard extends Wizard {
-
- JbossWSRuntimeWizardPage page1 = null;
- List<JbossWSRuntime> added = null;
- List<JbossWSRuntime> value = null;
-
- public JbossWSRuntimeNewWizard(List<JbossWSRuntime> exist,
- List<JbossWSRuntime> added) {
- super();
- setWindowTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
- page1 = new JbossWSRuntimeWizardPage(exist);
- addPage(page1);
- this.value = exist;
- this.added = added;
- }
-
- /**
- * Do finish steps
- *
- * @return boolean
- */
- @Override
- public boolean performFinish() {
- JbossWSRuntime rt = page1.getRuntime();
- added.add(rt);
- value.add(rt);
-
- return true;
- }
-
- protected JbossWSRuntime getRuntime() {
- return page1.getRuntime();
- }
-
- }
-
- /**
- * Wizard for editing JbossWS Runtime parameters: name and path to home
- * folder
- *
- */
- public static class JbossWSRuntimeEditWizard extends Wizard {
- JbossWSRuntimeWizardPage page1 = null;
- List<JbossWSRuntime> added = null;
- Map<JbossWSRuntime, JbossWSRuntime> changed = null;
- List<JbossWSRuntime> value = null;
- JbossWSRuntime source = null;
-
- /**
- * Constructor with almost all initialization parameters
- *
- * @param existing
- * List<JbossWSRuntime> - edited list of JbossWS
- * Runtimes
- * @param source
- * JbossWSRuntime - edited JbossWS Runtime
- * @param added
- * List<JbossWSRuntime> - TBD
- * @param changed
- * List<JbossWSRuntime> - TBD
- */
- public JbossWSRuntimeEditWizard(List<JbossWSRuntime> existing,
- JbossWSRuntime source, List<JbossWSRuntime> added,
- Map<JbossWSRuntime, JbossWSRuntime> changed) {
- super();
- setWindowTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
- page1 = new JbossWSRuntimeWizardPage(existing);
- page1
- .setMessage(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Modify_Runtime);
- page1
- .setTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
- addPage(page1);
- this.value = existing;
- this.added = added;
- this.changed = changed;
- this.source = source;
- page1.name.setValue(source.getName());
- page1.version.setValue(source.getVersion());
- page1.homeDir.setValue(source.getHomeDir());
- page1.current = source;
- }
-
- /**
- * Perform operations to finish editing JbossWS Runtime parameters
- *
- * @return boolean - always true
- */
- @Override
- public boolean performFinish() {
- JbossWSRuntime rt = page1.getRuntime();
-
- if (added.contains(source) || changed.containsKey(source)) {
- source.setName(rt.getName());
- source.setHomeDir(rt.getHomeDir());
- source.setVersion(rt.getVersion());
- source.setUserConfigClasspath(rt.isUserConfigClasspath());
- source.setLibraries(rt.getLibraries());
- } else {
- changed.put(rt, source);
- if (source.isDefault()) {
- rt.setDefault(true);
- }
- int i = value.indexOf(source);
- if (i >= 0) {
- value.set(i, rt);
-
- } else {
- value.remove(source);
- value.add(rt);
- }
- }
- return true;
- }
- }
-
- /**
- * Composite that holds list of BaseActions and presents them as column of
- * buttons
- *
- */
- public static class ActionPanel extends Composite implements
- ISelectionChangedListener {
-
- private BaseAction[] actions = null;
-
- /**
- * Constructor creates panel with style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, int style, BaseAction[] actions) {
- super(parent, style);
- this.actions = actions;
- setLayout(new GridLayout(1, false));
- for (BaseAction action : this.actions) {
- new ActionButton(this, SWT.PUSH, action);
- }
- }
-
- /**
- * Constructor creates panel with default style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, BaseAction[] actions) {
- this(parent, SWT.NONE, actions);
- }
-
- /**
- * Listen to the selection changes and update actions state
- * (enable/disable)
- *
- * @param event
- * SelectionChangeEvent
- * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- for (BaseAction action : actions) {
- action.setSelection(event.getSelection());
- }
- }
- }
-
- /**
- * Class represents an BaseAction as SWT button control and runs action when
- * button is prtessed
- *
- */
- public static class ActionButton implements IPropertyChangeListener {
-
- private Button button;
- private BaseAction action;
-
- /**
- * Create Button control with parent control and style that represents
- * action
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param action
- * BaseAction
- */
- public ActionButton(Composite parent, int style, BaseAction action) {
- this.button = new Button(parent, style);
- this.action = action;
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL,
- GridData.CENTER, false, false);
-
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- this.button.setLayoutData(gd);
- this.action.addPropertyChangeListener(this);
- this.button.setText(action.getText());
- this.button.setEnabled(action.isEnabled());
- this.button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- ActionButton.this.action.run();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- }
-
- /**
- * Return SWT button control that calls provided action
- *
- * @return Control - button swt control
- */
- public Control getControl() {
- return button;
- }
-
- /**
- * Update enabled/disabled button state
- *
- * @param event
- * PropertyChangeEvent
- * @see
org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IAction.ENABLED)) {
- button.setEnabled(((Boolean) event.getNewValue())
- .booleanValue());
- }
- }
- }
-
- /**
- * Action that changes state enable/disable based on current table selection
- *
- */
- public abstract class BaseAction extends Action {
-
- JbossWSRuntime[] runtimes = new JbossWSRuntime[0];
-
- /**
- * Constructor creates action with provided name
- *
- * @param name
- * String - action name
- */
- public BaseAction(String name) {
- super(name);
- updateEnablement();
- }
-
- /**
- * Set current selection
- *
- * @param selection
- * ISelection - selected items
- */
- public void setSelection(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- List<JbossWSRuntime> rts = new ArrayList<JbossWSRuntime>();
- for (Object rt : ((IStructuredSelection) selection).toArray()) {
- rts.add((JbossWSRuntime) rt);
- }
- runtimes = rts.toArray(new JbossWSRuntime[] {});
- } else {
- runtimes = new JbossWSRuntime[0];
- }
- updateEnablement();
- }
-
- protected abstract void updateEnablement();
- }
-
- /**
- * Action that invokes New JbossWS Runtime Dialog
- *
- */
- public class AddAction extends BaseAction {
-
- static final String ACTION_NAME = "&Add";
-
- /**
- * Constructor create Add action with default name
- */
- public AddAction() {
- super(ACTION_NAME);
- // This action is always available
- setEnabled(true);
- }
-
- /**
- * Do nothing, because Add action should be always available
- */
- @Override
- protected void updateEnablement() {
- // Add button is always available
- }
-
- /**
- * Invoke New JbossWS Runtime Dialog
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- Wizard wiz = new JbossWSRuntimeNewWizard(
- (List<JbossWSRuntime>) getValue(), added);
- WizardDialog dialog = new WizardDialog(Display.getCurrent()
- .getActiveShell(), wiz);
- dialog.open();
- tableView.refresh();
- setDefaultRuntime();
- }
- }
-
- /**
- * Action starts an editing selected JbossWS Runtime in Edit JbossWS Runtime
- * dialog
- *
- */
- public class EditAction extends BaseAction {
-
- static final String ACTION_NAME = "&Edit";
-
- /**
- * Create EditAction with default name
- *
- * @param text
- */
- public EditAction() {
- super(ACTION_NAME);
- }
-
- /**
- * Edit action is enabled when the only JbossWS Runtime is selected
- */
- @Override
- protected void updateEnablement() {
- // available when the only JbossWSRuntime is selected
- setEnabled(runtimes.length == 1);
- }
-
- /**
- * Start editing selected JbossWS Runtime in Edit JbossWS Runtime Wizard
- * Dialog
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- JbossWSRuntime selected = runtimes[0];
- Wizard wiz = new JbossWSRuntimeEditWizard(
- (List<JbossWSRuntime>) getValue(), runtimes[0], added,
- changed);
- WizardDialog dialog = new WizardDialog(Display.getCurrent()
- .getActiveShell(), wiz);
- dialog.open();
- tableView.refresh();
- JbossWSRuntime c = null;
- if (changed.containsValue(selected)) {
- c = findChangedRuntime(selected);
- if (c != null) {
- tableView.setSelection(new StructuredSelection(c));
- }
- }
- if (c != null && c.isDefault()) {
- checkedElement = c;
- }
- setDefaultRuntime();
- }
-
- private JbossWSRuntime findChangedRuntime(JbossWSRuntime source) {
- for (JbossWSRuntime r : changed.keySet()) {
- if (source == changed.get(r)) {
- return r;
- }
- }
- return null;
- }
- }
-
- /**
- * Action deletes all selected JbossWS Runtimes. A warning message is shown
- * for used JbossWS Runtimes
- *
- */
- public class RemoveAction extends BaseAction {
-
- static final String ACTION_NAME = "&Remove";
-
- /**
- * Create DeleteAction action with default name
- */
- public RemoveAction() {
- super(ACTION_NAME);
- }
-
- @Override
- protected void updateEnablement() {
- setEnabled(runtimes.length > 0);
- }
-
- /**
- * Remove all selected JbossWS Runtimes one by one
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- for (JbossWSRuntime rt : runtimes) {
- removeRuntime(rt);
- }
- tableView.refresh();
- setDefaultRuntime();
- }
-
- @SuppressWarnings("unchecked")
- private void removeRuntime(JbossWSRuntime r) {
- boolean used = JbossWSRuntimeManager.isRuntimeUsed(r.getName());
- String title = JbossWSUIMessages.JBossWS_Runtime_Delete_Confirm_Title;
- String message = (used) ? NLS.bind(
- JbossWSUIMessages.JBossWS_Runtime_Delete_Used_Confirm, r
- .getName()) : NLS.bind(
- JbossWSUIMessages.JBossWS_Runtime_Delete_Not_Used_Confirm,
- r.getName());
- boolean b = MessageDialog.openConfirm(tableView.getControl()
- .getShell(), title, message);
- if (b) {
- if (changed.containsKey(r)) {
- r = changed.remove(r);
- }
- removed.add(r);
- if (added.contains(r)) {
- added.remove(r);
- }
- ((List) getValue()).remove(r);
- }
- if (checkedElement == r) {
- checkedElement = null;
- }
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Map;
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimePreferencePage extends PreferencePage implements
- IWorkbenchPreferencePage {
-
- public JbossWSRuntimePreferencePage() {
- super();
- noDefaultAndApplyButton();
- }
-
- private static final int COLUMNS = 3;
-
- JbossRuntimeListFieldEditor jbossWSRuntimes = new JbossRuntimeListFieldEditor(
- "rtlist", JbossWSUIMessages.JBossWS_Preference_Page_Runtimes, new
ArrayList<JbossWSRuntime>(Arrays.asList(JbossWSRuntimeManager.getInstance().getRuntimes())));
//$NON-NLS-1$
-
- /**
- * Create contents of JbossWS preferences page. JbossWSRuntime list editor
- * is created
- *
- * @return Control
- */
- @Override
- protected Control createContents(Composite parent) {
- Composite root = new Composite(parent, SWT.NONE);
- GridLayout gl = new GridLayout(COLUMNS, false);
- root.setLayout(gl);
- jbossWSRuntimes.doFillIntoGrid(root);
-
- return root;
- }
-
- /**
- * Inherited from IWorkbenchPreferencePage
- *
- * @param workbench
- * {@link IWorkbench}
- *
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * Save JbossWSRuntime list
- */
- @Override
- protected void performApply() {
- for (JbossWSRuntime rt : jbossWSRuntimes.getAddedJbossWSRuntimes()) {
- JbossWSRuntimeManager.getInstance().addRuntime(rt);
- }
- jbossWSRuntimes.getAddedJbossWSRuntimes().clear();
- for (JbossWSRuntime rt : jbossWSRuntimes.getRemoved()) {
- JbossWSRuntimeManager.getInstance().removeRuntime(rt);
- }
- jbossWSRuntimes.getRemoved().clear();
- JbossWSRuntime defaultRuntime = jbossWSRuntimes
- .getDefaultJbossWSRuntime();
- // reset default runtime
- for (JbossWSRuntime jbossWSRuntime : JbossWSRuntimeManager
- .getInstance().getRuntimes()) {
- jbossWSRuntime.setDefault(false);
- }
- // set deafult runtime
- if (defaultRuntime != null) {
- defaultRuntime.setDefault(true);
- }
- jbossWSRuntimes.setDefaultJbossWSRuntime(null);
- Map<JbossWSRuntime, JbossWSRuntime> changed = jbossWSRuntimes
- .getChangedJbossWSRuntimes();
- for (JbossWSRuntime c : changed.keySet()) {
- JbossWSRuntime o = changed.get(c);
- o.setHomeDir(c.getHomeDir());
- o.setVersion(c.getVersion());
- String oldName = o.getName();
- String newName = c.getName();
- if (!oldName.equals(newName)) {
- JbossWSRuntimeManager.getInstance().changeRuntimeName(oldName,
- newName);
- }
- o.setDefault(c.isDefault());
- o.setUserConfigClasspath(c.isUserConfigClasspath());
- o.setLibraries(c.getLibraries());
- }
- jbossWSRuntimes.getChangedJbossWSRuntimes().clear();
-
- JbossWSRuntimeManager.getInstance().save();
- }
-
- /**
- * Restore original preferences values
- */
- @Override
- protected void performDefaults() {
- setValid(true);
- setMessage(null);
- performApply();
- }
-
- /**
- * See {@link PreferencePage} for details
- *
- * @return Boolean
- */
- @Override
- public boolean performOk() {
- performApply();
- return super.performOk();
- }
-
- public JbossRuntimeListFieldEditor getJbossWSRuntimes() {
- return jbossWSRuntimes;
- }
-}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,586 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.preferences;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.ui.JbossWSUIPlugin;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbwsLibraryListFieldEditor extends BaseFieldEditor {
-
- // ------------------------------------------------------------------------
- // Layout parameters
- // ------------------------------------------------------------------------
-
- static final int GL_COLUMNS = 2;
- static final int GL_HINT_HEIGHT = 200;
- static final int TC_DEFAULT_WIDTH = 21;
- static final int TC_NAME_WIDTH = 100;
- static final int TC_VERSION_WIDTH = 50;
- static final int TC_PATH_WIDTH = 100;
-
- // ------------------------------------------------------------------------
- // Field declarations
- // ------------------------------------------------------------------------
-
- private TreeViewer listView = null;
-
- private Composite root = null;
-
- private ActionPanel actionPanel;
-
- private JbossWSRuntime tempJbws;
-
-
-
-
- private Group jarGroup;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Control for editing jbossWSRuntime list
- *
- * @param name
- * String
- * @param label
- * String
- * @param defaultValue
- * Object
- */
- public JbwsLibraryListFieldEditor(String name, String label,
- JbossWSRuntime jbws) {
- super(name, label, jbws);
- this.tempJbws = new JbossWSRuntime();
- if(jbws != null){
- this.tempJbws.setUserConfigClasspath(jbws.isUserConfigClasspath());
- this.tempJbws.getLibraries().addAll(jbws.getLibraries());
- }
-
- }
-
-
- public Object getValue(){
- return this.tempJbws;
- }
- /**
- * TBD
- *
- * @param composite
- * Object - instance of Composite
- * @return Object[]
- */
- @Override
- public Object[] getEditorControls(Object composite) {
-
- root = new Composite((Composite) composite, SWT.NONE);
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- root.setLayoutData(gd);
-
- root.setLayout(new GridLayout());
-
- createCheckButton(root);
-
- jarGroup = new Group(root, SWT.BORDER);
- jarGroup.setText("Library Jars");
- gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
-
-
- jarGroup.setLayoutData(gd);
- jarGroup.setLayout(new FormLayout());
-
- createListView(jarGroup);
- createActionBar(jarGroup);
-
- FormData listData = new FormData();
- listData.left = new FormAttachment(0, 5);
- listData.right = new FormAttachment(actionPanel, -5);
- listData.top = new FormAttachment(0, 5);
- listData.bottom = new FormAttachment(100, -5);
- listView.getControl().setLayoutData(listData);
-
- FormData actionsData = new FormData();
- actionsData.top = new FormAttachment(0, 5);
- actionsData.bottom = new FormAttachment(100, -5);
- actionsData.right = new FormAttachment(100, -5);
- actionPanel.setLayoutData(actionsData);
-
- setJarGroupStatus();
- return new Control[] { root };
- }
-
- protected void createCheckButton(Composite parent){
- final Button btnDefault = new Button(parent, SWT.CHECK);
- btnDefault.setText(JbossWSUIMessages.JBossWS_Runtime_Check_Field_Default_Classpath);
- GridData gd = new GridData();
- gd.horizontalSpan = 2;
- btnDefault.setLayoutData(gd);
-
- btnDefault.setSelection(tempJbws.isUserConfigClasspath());
- btnDefault.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- tempJbws.setUserConfigClasspath(btnDefault.getSelection());
- setJarGroupStatus();
- setValue(null);
- }
- });
-
-
- }
-
- protected void setJarGroupStatus(){
- boolean isUserConfig = tempJbws.isUserConfigClasspath();
- jarGroup.setEnabled(isUserConfig);
- listView.getTree().setEnabled(isUserConfig);
- actionPanel.setEnabled(isUserConfig);
- }
- @SuppressWarnings("unchecked")
- protected void createListView(Composite parent) {
- listView = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- listView.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
-
- listView.setContentProvider(new ITreeContentProvider() {
-
- @SuppressWarnings("unchecked")
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof JbossWSRuntime) {
- return ((JbossWSRuntime) inputElement).getLibraries().toArray();
- } else {
- throw new IllegalArgumentException(
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
- + JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- viewer.refresh();
- }
-
- public Object[] getChildren(Object parentElement) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getParent(Object element) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean hasChildren(Object element) {
- // TODO Auto-generated method stub
- return false;
- }
- });
-
- listView.setLabelProvider(new ILabelProvider() {
-
- Image jarImg;
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
-
- public Image getImage(Object element) {
- if (jarImg == null){
- ImageDescriptor jarImgDesc =
JbossWSUIPlugin.getImageDescriptor("obj16/jar_obj.gif");
- jarImg = jarImgDesc.createImage();
- }
- return jarImg;
- }
-
- public String getText(Object element) {
- String fullName = (String)element;
- File jarFile = new File(fullName);
- return jarFile.getName() + " - " + jarFile.getParentFile().toString();
- }
- });
-
-
- listView.setInput(getValue());
-
- }
-
- protected void createActionBar(Composite parent) {
- actionPanel = new ActionPanel(parent, new BaseAction[] { new AddAction(),
- new RemoveAction() });
- listView.addSelectionChangedListener(actionPanel);
- }
-
-
-
- /**
- * Return array of Controls that forms and editor
- *
- * @return Control[]
- */
- @Override
- public Object[] getEditorControls() {
- return new Control[] { root };
- }
-
- /**
- * Return number of controls in editor
- *
- * @return int
- */
- @Override
- public int getNumberOfControls() {
- return 1;
- }
-
- /**
- * Fill wizard page with editors
- *
- * @param parent
- * Composite - parent composite
- */
- @Override
- public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
- Composite aComposite = (Composite) parent;
- getEditorControls(aComposite);
- GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
-
- GridData gd = new GridData();
- gd.horizontalSpan = gl.numColumns;
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
-
- ((Control) getEditorControls()[0]).setLayoutData(gd);
- }
-
-
-
- /**
- * Composite that holds list of BaseActions and presents them as column of
- * buttons
- *
- */
- public static class ActionPanel extends Composite implements
- ISelectionChangedListener {
-
- private BaseAction[] actions = null;
-
- /**
- * Constructor creates panel with style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, int style, BaseAction[] actions) {
- super(parent, style);
- this.actions = actions;
- setLayout(new GridLayout(1, false));
- for (BaseAction action : this.actions) {
- new ActionButton(this, SWT.PUSH, action);
- }
- }
-
- /**
- * Constructor creates panel with default style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, BaseAction[] actions) {
- this(parent, SWT.NONE, actions);
- }
-
- /**
- * Listen to the selection changes and update actions state
- * (enable/disable)
- *
- * @param event
- * SelectionChangeEvent
- * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- for (BaseAction action : actions) {
- action.setSelection(event.getSelection());
- }
- }
- }
-
- /**
- * Class represents an BaseAction as SWT button control and runs action when
- * button is prtessed
- *
- */
- public static class ActionButton implements IPropertyChangeListener {
-
- private Button button;
- private BaseAction action;
-
- /**
- * Create Button control with parent control and style that represents
- * action
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param action
- * BaseAction
- */
- public ActionButton(Composite parent, int style, BaseAction action) {
- this.button = new Button(parent, style);
- this.action = action;
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL,
- GridData.CENTER, false, false);
-
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- this.button.setLayoutData(gd);
- this.action.addPropertyChangeListener(this);
- this.button.setText(action.getText());
- this.button.setEnabled(action.isEnabled());
- this.button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- ActionButton.this.action.run();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- }
-
- /**
- * Return SWT button control that calls provided action
- *
- * @return Control - button swt control
- */
- public Control getControl() {
- return button;
- }
-
- /**
- * Update enabled/disabled button state
- *
- * @param event
- * PropertyChangeEvent
- * @see
org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IAction.ENABLED)) {
- button.setEnabled(((Boolean) event.getNewValue())
- .booleanValue());
- }
- }
- }
-
- /**
- * Action that changes state enable/disable based on current table selection
- *
- */
- public abstract class BaseAction extends Action {
-
- String[] jars = new String[0];
-
- /**
- * Constructor creates action with provided name
- *
- * @param name
- * String - action name
- */
- public BaseAction(String name) {
- super(name);
- updateEnablement();
- }
-
- /**
- * Set current selection
- *
- * @param selection
- * ISelection - selected items
- */
- public void setSelection(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- List<String> rts = new ArrayList<String>();
- for (Object jarfile : ((IStructuredSelection) selection).toArray()) {
- rts.add((String) jarfile);
- }
- jars = rts.toArray(new String[] {});
- } else {
- jars = new String[0];
- }
- updateEnablement();
- }
-
- protected abstract void updateEnablement();
- }
-
- /**
- * Action that invokes New JbossWS Runtime Dialog
- *
- */
- public class AddAction extends BaseAction {
-
- static final String ACTION_NAME = "&Add";
-
- /**
- * Constructor create Add action with default name
- */
- public AddAction() {
- super(ACTION_NAME);
- // This action is always available
- setEnabled(true);
- }
-
- /**
- * Do nothing, because Add action should be always available
- */
- @Override
- protected void updateEnablement() {
- // Add button is always available
- }
-
- /**
- * Invoke New JbossWS Runtime Dialog
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- FileDialog dialog = new FileDialog(Display.getCurrent()
- .getActiveShell(), SWT.MULTI);
- dialog.setFilterExtensions(new String[] { "*.jar;*.zip" });
- String fileName = dialog.open();
- String[] fileNames = dialog.getFileNames();
- if (fileName != null) {
- File filePath = new File(fileName);
- filePath = filePath.getParentFile();
- for (int i = 0; i < fileNames.length; i++) {
- IPath path = new Path(filePath.getAbsolutePath())
- .append(fileNames[i]);
- if (!tempJbws.getLibraries().contains(path.toOSString())) {
- tempJbws.getLibraries().add(path.toOSString());
- }
- }
-
- listView.refresh();
- setValue(null);
- }
- }
- }
-
-
- /**
- * Action deletes all selected JbossWS Runtimes. A warning message is shown
- * for used JbossWS Runtimes
- *
- */
- public class RemoveAction extends BaseAction {
-
- static final String ACTION_NAME = "&Remove";
-
- /**
- * Create DeleteAction action with default name
- */
- public RemoveAction() {
- super(ACTION_NAME);
- }
-
- @Override
- protected void updateEnablement() {
- setEnabled(jars.length > 0);
- }
-
- /**
- * Remove all selected JbossWS Runtimes one by one
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- for (String jar : jars) {
- tempJbws.getLibraries().remove(jar);
- }
- listView.refresh();
- // just try to fire property change listener
- setValue(null);
- }
-
-
- }
-}
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -22,7 +22,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
*
@@ -68,8 +68,8 @@
@Override
public void doFillIntoGrid(Object aParent) {
- Assert.isTrue(aParent instanceof Composite,
JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite)aParent).getLayout() instanceof
GridLayout,JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Assert.isTrue(aParent instanceof Composite,
JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)aParent).getLayout() instanceof
GridLayout,JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
Composite aComposite = (Composite) aParent;
getEditorControls(aComposite);
GridLayout gl = (GridLayout)((Composite)aParent).getLayout();
Modified: trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF 2008-06-27 06:07:21
UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF 2008-06-27 08:19:24
UTC (rev 8979)
@@ -30,4 +30,4 @@
org.eclipse.jdt.core,
org.eclipse.ui.console;bundle-version="3.3.0",
org.eclipse.jface.text;bundle-version="3.4.0"
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Added:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.tools.ws.core.test.classpath.JBossWSRuntimeManagerTest;
+import org.jboss.tools.ws.core.test.command.JBossWSJavaFirstCommandTest;
+import org.jboss.tools.ws.core.test.command.JBossWSClientCommandTest;
+
+public class JBossWSCoreAllTests extends TestCase {
+ public static final String PLUGIN_ID = "org.jboss.tools.common.test";
+ public static Test suite ()
+ {
+ TestSuite suite = new TestSuite(JBossWSCoreAllTests.class.getName());
+ suite.addTestSuite(JBossWSRuntimeManagerTest.class);
+ suite.addTestSuite(JBossWSJavaFirstCommandTest.class);
+ suite.addTestSuite(JBossWSClientCommandTest.class);
+
+ return suite;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.core.test;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.jboss.tools.ws.core.test.classpath.JbossWSRuntimeManagerTest;
-import org.jboss.tools.ws.core.test.command.JavaFirstCommandTest;
-import org.jboss.tools.ws.core.test.command.WSClientCommandTest;
-
-public class JbossWSCoreAllTests extends TestCase {
- public static final String PLUGIN_ID = "org.jboss.tools.common.test";
- public static Test suite ()
- {
- TestSuite suite = new TestSuite(JbossWSCoreAllTests.class.getName());
- suite.addTestSuite(JbossWSRuntimeManagerTest.class);
- suite.addTestSuite(JavaFirstCommandTest.class);
- suite.addTestSuite(WSClientCommandTest.class);
-
- return suite;
- }
-}
\ No newline at end of file
Added:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.test.classpath;
+
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimeManagerTest extends TestCase {
+
+ JBossWSRuntimeManager manager;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ manager = JBossWSRuntimeManager.getInstance();
+ assertNotNull("Cannot obtainJBossWSRuntimeManager instance", manager);
+ if (manager.findRuntimeByName("JBossWS Runtime 4.2") != null)
+ return;
+ manager.addRuntime("JBossWS Runtime 4.2", "runtimelocation",
"4.2",
+ true);
+ }
+
+ public void testGetRuntimes() {
+ JBossWSRuntime[] rtms = manager.getRuntimes();
+ assertTrue("JBossWS runtime 'JBossWS Runtime 4.2' is not created",
+ rtms.length == 1);
+ assertTrue("JBossWS runtime 'JBossWS Runtime 4.2' is not created",
+ rtms[0].getName().equals("JBossWS Runtime 4.2"));
+ }
+
+ public void testFindRuntimeByName() {
+ JBossWSRuntime srt = manager.findRuntimeByName("JBossWS Runtime 4.2");
+ assertNotNull("Cannot find runtime 'JBossWS Runtime 4.2'", srt);
+ }
+
+ public void testGetDefaultRuntime() {
+ assertNotNull("Cannot obtain default runtime 'JBossWS Runtime 4.2'",
+ manager.getDefaultRuntime());
+ }
+}
Deleted:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.test.classpath;
-
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-
-import junit.framework.TestCase;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimeManagerTest extends TestCase {
-
- JbossWSRuntimeManager manager;
-
- protected void setUp() throws Exception {
- super.setUp();
- manager = JbossWSRuntimeManager.getInstance();
- assertNotNull("Cannot obtainJbossWSRuntimeManager instance", manager);
- if (manager.findRuntimeByName("JBossWS Runtime 4.2") != null)
- return;
- manager.addRuntime("JBossWS Runtime 4.2", "runtimelocation",
"4.2",
- true);
- }
-
- public void testGetRuntimes() {
- JbossWSRuntime[] rtms = manager.getRuntimes();
- assertTrue("JbossWS runtime 'JBossWS Runtime 4.2' is not created",
- rtms.length == 1);
- assertTrue("JbossWS runtime 'JBossWS Runtime 4.2' is not created",
- rtms[0].getName().equals("JBossWS Runtime 4.2"));
- }
-
- public void testFindRuntimeByName() {
- JbossWSRuntime srt = manager.findRuntimeByName("JBossWS Runtime 4.2");
- assertNotNull("Cannot find runtime 'JBossWS Runtime 4.2'", srt);
- }
-
- public void testGetDefaultRuntime() {
- assertNotNull("Cannot obtain default runtime 'JBossWS Runtime 4.2'",
- manager.getDefaultRuntime());
- }
-}
Modified:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -261,7 +261,7 @@
String jbosshome = System.getProperty(JBOSS_RUNTIME_42, JBOSSWS_HOME_DEFAULT);
File runtimelocation = new File(jbosshome);
- assertTrue("Please set Jboss EAP Home in system property:" +
JBOSS_RUNTIME_42, runtimelocation.exists());
+ assertTrue("Please set JBoss EAP Home in system property:" +
JBOSS_RUNTIME_42, runtimelocation.exists());
String cmdFileLocation = jbosshome + File.separator + "bin" + File.separator
+ "wsconsume.sh";
assertTrue(jbosshome + " is not a valid jboss EAP home", new
File(cmdFileLocation).exists());
Added:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.core.test.command;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaModel;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import
org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer.JBossWSRuntimeClasspathContainer;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
+import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
+import org.jboss.tools.ws.creation.core.commands.ClientSampleCreationCommand;
+import org.jboss.tools.ws.creation.core.commands.InitialClientCommand;
+import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
+import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.ui.wsrt.JBossWebServiceClient;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSClientCommandTest extends AbstractJBossWSCommandTest {
+
+ protected static final String JBOSSWS_HOME_DEFAULT =
"/home/grid/Software/jboss-4.2.2.GA";
+ private static final String RuntimeName;
+ private static final boolean isDeployed;
+
+ static {
+ RuntimeName = "testjbosswsruntime";
+ isDeployed = false;
+ }
+
+ public JBossWSClientCommandTest() {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
+ getJBossWSHomeFolder().toString(), "", true);
+
+ // create jbossws web project
+ fproject = createJBossWSProject("JBossWSTestProject",
+ isServerSupplied());
+ IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
+
+ assertTrue(wsdlFile.exists());
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ resourcesToCleanup.clear();
+ JBossWSRuntime runtime = JBossWSRuntimeManager.getInstance()
+ .findRuntimeByName(RuntimeName);
+ JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ }
+
+ public void testInitialClientCommand() throws CoreException,
+ ExecutionException {
+
+ IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ // model.setWsdlURI(wsdlFile.getLocation().toOSString());
+
+ WebServiceClientInfo info = new WebServiceClientInfo();
+ info.setWsdlURL(wsdlFile.getLocation().toOSString());
+ IWebServiceClient ws = new JBossWebServiceClient(info);
+
+ // test initial command
+ InitialClientCommand cmdInitial = new InitialClientCommand(model, ws,
+ WebServiceScenario.CLIENT);
+ IStatus status = cmdInitial.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ assertTrue(model.getServiceNames().contains("SOAPService"));
+ assertEquals(wsdlFile.getLocation().toOSString(), model.getWsdlURI());
+ assertTrue(model.getPortTypes().contains("Greeter"));
+ assertEquals("org.apache.hello_world_soap_http", model
+ .getCustomPackage());
+
+ }
+
+ public void testClientCodeGenerationCommand() throws ExecutionException {
+
+ ServiceModel model = createServiceModel();
+ IProject project = fproject.getProject();
+ // test wsdl2Javacommand
+ WSDL2JavaCommand cmdW2j = new WSDL2JavaCommand(model);
+ IStatus status = cmdW2j.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(project.getFile(
+ "src/org/apache/hello_world_soap_http/Greeter.java").exists());
+
+ // test ClientSampleCreationCommand
+ ClientSampleCreationCommand cmdImpl = new ClientSampleCreationCommand(
+ model);
+ status = cmdImpl.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(
+ "failed to generate sample class",
+ project
+ .getFile(
+ "src/org/apache/hello_world_soap_http/clientsample/ClientSample.java")
+ .exists());
+
+ }
+
+ public void testRemoveClientJarsCommand() throws ExecutionException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+
+ RemoveClientJarsCommand command = new RemoveClientJarsCommand(model);
+ IStatus status = command.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+ try {
+ IClasspathEntry[] entries = getJavaProjectByName(
+ fproject.getProject().getName()).getRawClasspath();
+
+ for (IClasspathEntry entry : entries) {
+ IClasspathContainer container = JavaCore.getClasspathContainer(
+ entry.getPath(), getJavaProjectByName(fproject
+ .getProject().getName()));
+ if (container instanceof JBossWSRuntimeClasspathContainer) {
+ boolean nojar = true;
+ for (IClasspathEntry jar : ((JBossWSRuntimeClasspathContainer) container)
+ .getClasspathEntries()) {
+ if (jar.getPath().toString().contains("jaxws-rt.jar")) {
+ nojar = false;
+ }
+ }
+ assertTrue(nojar);
+ }
+ }
+ } catch (JavaModelException e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ }
+
+ }
+
+ public static IJavaProject getJavaProjectByName(String projectName)
+ throws JavaModelException {
+
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
+ .getRoot());
+ model.open(null);
+
+ IJavaProject[] projects = model.getJavaProjects();
+
+ for (IJavaProject proj : projects) {
+ if (proj.getProject().getName().equals(projectName)) {
+ return proj;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ IDataModel createJBossWSDataModel(boolean isServerSupplied) {
+ IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
+ .create();
+ if (isServerSupplied) {
+ config
+ .setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
+ true);
+ } else {
+ config.setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
+ isDeployed);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
+ RuntimeName);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
+ getJBossWSHomeFolder().toString());
+ }
+ return config;
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,305 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.core.test.command;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.AbstractConsole;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleListener;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.TextConsole;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.ws.internal.wsrt.IWebService;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
+import org.jboss.tools.ws.creation.core.commands.InitialCommand;
+import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
+import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
+import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
+import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSJavaFirstCommandTest extends AbstractJBossWSCommandTest {
+ protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
+ protected static final IWorkbench wb = PlatformUI.getWorkbench();
+
+ protected static final String JBOSSWS_HOME_DEFAULT =
"/home/grid/Software/jboss-4.2.2.GA";
+ private static final String RuntimeName;
+ private static final boolean isDeployed;
+
+ static {
+ RuntimeName = "testjbosswsruntime";
+ isDeployed = false;
+ }
+
+ public JBossWSJavaFirstCommandTest() {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
+ getJBossWSHomeFolder().toString(), "", true);
+ // create jbossws web project
+ fproject = createJBossWSProject("JavaFirstTestProject",
+ isServerSupplied());
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ resourcesToCleanup.clear();
+ JBossWSRuntime runtime = JBossWSRuntimeManager.getInstance()
+ .findRuntimeByName(RuntimeName);
+ JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ }
+
+ public void testInitialCommand() throws CoreException, ExecutionException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ WebServiceInfo info = new WebServiceInfo();
+ info.setImplURL("org.example.www.helloworld.HelloWorld");
+ IWebService ws = new JBossWebService(info);
+
+ // test initial command
+ InitialCommand cmdInitial = new InitialCommand(model, ws,
+ WebServiceScenario.BOTTOMUP);
+ IStatus status = cmdInitial.execute(null, null);
+
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(model.getServiceClasses().get(0).equals(
+ "org.example.www.helloworld.HelloWorld"));
+ }
+
+ public void testValidateWSImplCommand() throws ExecutionException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ model.addServiceClasses("org.example.www.helloworld.HelloWorld");
+
+ ValidateWSImplCommand command = new ValidateWSImplCommand(model);
+ IStatus status = command.execute(null, null);
+
+ assertTrue(status.getMessage(), status.isOK());
+
+ }
+
+ public void testWSProviderInvokeCommand() throws ExecutionException, CoreException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ model.addServiceClasses("org.example.www.helloworld.HelloWorld");
+ model.setGenWSDL(true);
+ IProject project = fproject.getProject();
+
+ fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+ WSProviderInvokeCommand command = new WSProviderInvokeCommand(model);
+ IStatus status = command.execute(null, null);
+
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(project.getFile(
+ "src/org/example/www/helloworld/jaxws/SayHello.java").exists());
+ assertTrue(project.getFile("WebContent/wsdl/HelloWorldService.wsdl")
+ .exists());
+ }
+
+ public void testDeployResult() throws ExecutionException, CoreException,
+ IOException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+
+ WebServiceInfo info = new WebServiceInfo();
+ info.setImplURL("org.example.www.helloworld.HelloWorld");
+ IWebService ws = new JBossWebService(info);
+
+ // test initial command
+ AbstractDataModelOperation cmd = new InitialCommand(model, ws,
+ WebServiceScenario.BOTTOMUP);
+ IStatus status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+ cmd = new WSProviderInvokeCommand(model);
+ status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ cmd = new MergeWebXMLCommand(model);
+ status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ publishWebProject();
+
+ assertTrue(currentServer.getModules().length > 0);
+ String webServiceUrl =
"http://localhost:8080/JavaFirstTestProject/HelloWorld?wsdl";
+ URL url = new URL(webServiceUrl);
+ URLConnection conn = url.openConnection();
+
+ startup();
+
+ assertEquals("unable to start JBoss server", IServer.STATE_STARTED,
+ currentServer.getServerState());
+
+ conn.connect();
+ conn.getContent();
+
+ IProject pro = createProject("ClientTest");
+ model = new ServiceModel();
+ model.setWebProjectName("ClientTest");
+
+ cmd = new RemoveClientJarsCommand(model);
+ status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ pro.open(null);
+ pro.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ ILaunchManager launchManager = DebugPlugin.getDefault()
+ .getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType = launchManager
+ .getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
+ ILaunchConfigurationWorkingCopy wc = launchConfigurationType
+ .newInstance(null, "ClientSample");
+ wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES",
"1");
+ wc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE",
+ "org.example.www.helloworld.clientsample.ClientSample");
+ wc.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS",
"Test");
+ wc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR",
"ClientTest");
+ wc.doSave();
+ wc.launch(ILaunchManager.RUN_MODE, null);
+ IConsoleManager consolemanager = getConsoleManager();
+ checkText(consolemanager.getConsoles());
+ }
+
+ private void checkText(IConsole[] consoles) {
+ // test run result
+ for (IConsole console : consoles) {
+ if (console.getName().contains("ClientSample")) {
+ int i = 0;
+ while (i < 10
+ && !isContainString(
+ console,
+ JBossWSCreationCoreMessages.Client_Sample_Run_Over)) {
+ delay(1000);
+ i++;
+ }
+ assertTrue("Sample run over!", isContainString(console,
+ JBossWSCreationCoreMessages.Client_Sample_Run_Over));
+ }
+ }
+ }
+
+ public static boolean isContainString(IConsole console, String str) {
+ return ((TextConsole) console).getDocument().get().contains(str);
+ }
+
+ public static void delay(long durationInMilliseconds) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long t2 = System.currentTimeMillis() + durationInMilliseconds;
+ while (System.currentTimeMillis() < t2) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.update();
+ } else {
+ try {
+ Thread.sleep(durationInMilliseconds);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ public static IConsoleManager getConsoleManager() {
+ IConsoleManager consolemanager = ConsolePlugin.getDefault()
+ .getConsoleManager();
+
+ consolemanager.addConsoleListener(new IConsoleListener() {
+ public void consolesAdded(IConsole[] consoles) {
+ for (int i = 0; i < consoles.length; i++) {
+ ((AbstractConsole) consoles[i]).activate();
+ }
+
+ }
+
+ public void consolesRemoved(IConsole[] consoles) {
+ for (int i = 0; i < consoles.length; i++) {
+ ((AbstractConsole) consoles[i]).destroy();
+ }
+
+ }
+ });
+ return consolemanager;
+ }
+
+ @Override
+ IDataModel createJBossWSDataModel(boolean isServerSupplied) {
+ IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
+ .create();
+ if (isServerSupplied) {
+ config
+ .setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
+ true);
+ } else {
+ config.setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
+ isDeployed);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
+ RuntimeName);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
+ getJBossWSHomeFolder().toString());
+ }
+ return config;
+ }
+
+}
Modified:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -37,8 +37,8 @@
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
import org.jboss.tools.ws.creation.core.commands.ImplementationClassCreationCommand;
@@ -72,7 +72,7 @@
protected void setUp() throws Exception {
super.setUp();
- JbossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
getJBossWSHomeFolder().toString(), "", true);
+ JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
getJBossWSHomeFolder().toString(), "", true);
//create jbossws web project
fproject = createJBossWSProject("JBossWSTestProject", isServerSupplied());
@@ -87,8 +87,8 @@
// Wait until all jobs is finished to avoid delete project problems
super.tearDown();
resourcesToCleanup.clear();
- JbossWSRuntime runtime =
JbossWSRuntimeManager.getInstance().findRuntimeByName(RuntimeName);
- JbossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ JBossWSRuntime runtime =
JBossWSRuntimeManager.getInstance().findRuntimeByName(RuntimeName);
+ JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
Deleted:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.core.test.command;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.AbstractConsole;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleListener;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.TextConsole;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.ws.internal.wsrt.IWebService;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
-import org.jboss.tools.ws.creation.core.commands.InitialCommand;
-import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
-import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
-import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
-import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
-import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
-
-/**
- * @author Grid Qian
- */
-public class JavaFirstCommandTest extends AbstractJBossWSCommandTest {
- protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
- protected static final IWorkbench wb = PlatformUI.getWorkbench();
-
- protected static final String JBOSSWS_HOME_DEFAULT =
"/home/grid/Software/jboss-4.2.2.GA";
- private static final String RuntimeName;
- private static final boolean isDeployed;
-
- static {
- RuntimeName = "testjbosswsruntime";
- isDeployed = false;
- }
-
- public JavaFirstCommandTest() {
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- JbossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
- getJBossWSHomeFolder().toString(), "", true);
- // create jbossws web project
- fproject = createJBossWSProject("JavaFirstTestProject",
- isServerSupplied());
-
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
-
- resourcesToCleanup.clear();
- JbossWSRuntime runtime = JbossWSRuntimeManager.getInstance()
- .findRuntimeByName(RuntimeName);
- JbossWSRuntimeManager.getInstance().removeRuntime(runtime);
- }
-
- public void testInitialCommand() throws CoreException, ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- WebServiceInfo info = new WebServiceInfo();
- info.setImplURL("org.example.www.helloworld.HelloWorld");
- IWebService ws = new JBossWebService(info);
-
- // test initial command
- InitialCommand cmdInitial = new InitialCommand(model, ws,
- WebServiceScenario.BOTTOMUP);
- IStatus status = cmdInitial.execute(null, null);
-
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(model.getServiceClasses().get(0).equals(
- "org.example.www.helloworld.HelloWorld"));
- }
-
- public void testValidateWSImplCommand() throws ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.addServiceClasses("org.example.www.helloworld.HelloWorld");
-
- ValidateWSImplCommand command = new ValidateWSImplCommand(model);
- IStatus status = command.execute(null, null);
-
- assertTrue(status.getMessage(), status.isOK());
-
- }
-
- public void testWSProviderInvokeCommand() throws ExecutionException, CoreException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.addServiceClasses("org.example.www.helloworld.HelloWorld");
- model.setGenWSDL(true);
- IProject project = fproject.getProject();
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
-
- WSProviderInvokeCommand command = new WSProviderInvokeCommand(model);
- IStatus status = command.execute(null, null);
-
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(project.getFile(
- "src/org/example/www/helloworld/jaxws/SayHello.java").exists());
- assertTrue(project.getFile("WebContent/wsdl/HelloWorldService.wsdl")
- .exists());
- }
-
- public void testDeployResult() throws ExecutionException, CoreException,
- IOException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
-
- WebServiceInfo info = new WebServiceInfo();
- info.setImplURL("org.example.www.helloworld.HelloWorld");
- IWebService ws = new JBossWebService(info);
-
- // test initial command
- AbstractDataModelOperation cmd = new InitialCommand(model, ws,
- WebServiceScenario.BOTTOMUP);
- IStatus status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
-
- cmd = new WSProviderInvokeCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- cmd = new MergeWebXMLCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- publishWebProject();
-
- assertTrue(currentServer.getModules().length > 0);
- String webServiceUrl =
"http://localhost:8080/JavaFirstTestProject/HelloWorld?wsdl";
- URL url = new URL(webServiceUrl);
- URLConnection conn = url.openConnection();
-
- startup();
-
- assertEquals("unable to start JBoss server", IServer.STATE_STARTED,
- currentServer.getServerState());
-
- conn.connect();
- conn.getContent();
-
- IProject pro = createProject("ClientTest");
- model = new ServiceModel();
- model.setWebProjectName("ClientTest");
-
- cmd = new RemoveClientJarsCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- pro.open(null);
- pro.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- ILaunchManager launchManager = DebugPlugin.getDefault()
- .getLaunchManager();
- ILaunchConfigurationType launchConfigurationType = launchManager
- .getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
- ILaunchConfigurationWorkingCopy wc = launchConfigurationType
- .newInstance(null, "ClientSample");
- wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES",
"1");
- wc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE",
- "org.example.www.helloworld.clientsample.ClientSample");
- wc.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS",
"Test");
- wc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR",
"ClientTest");
- wc.doSave();
- wc.launch(ILaunchManager.RUN_MODE, null);
- IConsoleManager consolemanager = getConsoleManager();
- checkText(consolemanager.getConsoles());
- }
-
- private void checkText(IConsole[] consoles) {
- // test run result
- for (IConsole console : consoles) {
- if (console.getName().contains("ClientSample")) {
- int i = 0;
- while (i < 10
- && !isContainString(
- console,
- JBossWSCreationCoreMessages.Client_Sample_Run_Over)) {
- delay(1000);
- i++;
- }
- assertTrue("Sample run over!", isContainString(console,
- JBossWSCreationCoreMessages.Client_Sample_Run_Over));
- }
- }
- }
-
- public static boolean isContainString(IConsole console, String str) {
- return ((TextConsole) console).getDocument().get().contains(str);
- }
-
- public static void delay(long durationInMilliseconds) {
- Display display = Display.getCurrent();
- if (display != null) {
- long t2 = System.currentTimeMillis() + durationInMilliseconds;
- while (System.currentTimeMillis() < t2) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.update();
- } else {
- try {
- Thread.sleep(durationInMilliseconds);
- } catch (InterruptedException e) {
- }
- }
- }
-
- public static IConsoleManager getConsoleManager() {
- IConsoleManager consolemanager = ConsolePlugin.getDefault()
- .getConsoleManager();
-
- consolemanager.addConsoleListener(new IConsoleListener() {
- public void consolesAdded(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- ((AbstractConsole) consoles[i]).activate();
- }
-
- }
-
- public void consolesRemoved(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- ((AbstractConsole) consoles[i]).destroy();
- }
-
- }
- });
- return consolemanager;
- }
-
- @Override
- IDataModel createJBossWSDataModel(boolean isServerSupplied) {
- IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
- .create();
- if (isServerSupplied) {
- config
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- true);
- } else {
- config.setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
- isDeployed);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
- RuntimeName);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
- getJBossWSHomeFolder().toString());
- }
- return config;
- }
-
-}
Deleted:
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.core.test.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
-import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import
org.jboss.tools.ws.core.classpath.JbossWSRuntimeClassPathInitializer.JbossWSRuntimeClasspathContainer;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
-import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
-import org.jboss.tools.ws.creation.core.commands.ClientSampleCreationCommand;
-import org.jboss.tools.ws.creation.core.commands.InitialClientCommand;
-import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
-import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.ui.wsrt.JBossWebServiceClient;
-
-/**
- * @author Grid Qian
- */
-public class WSClientCommandTest extends AbstractJBossWSCommandTest {
-
- protected static final String JBOSSWS_HOME_DEFAULT =
"/home/grid/Software/jboss-4.2.2.GA";
- private static final String RuntimeName;
- private static final boolean isDeployed;
-
- static {
- RuntimeName = "testjbosswsruntime";
- isDeployed = false;
- }
-
- public WSClientCommandTest() {
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- JbossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
- getJBossWSHomeFolder().toString(), "", true);
-
- // create jbossws web project
- fproject = createJBossWSProject("JBossWSTestProject",
- isServerSupplied());
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
-
- assertTrue(wsdlFile.exists());
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- resourcesToCleanup.clear();
- JbossWSRuntime runtime = JbossWSRuntimeManager.getInstance()
- .findRuntimeByName(RuntimeName);
- JbossWSRuntimeManager.getInstance().removeRuntime(runtime);
- }
-
- public void testInitialClientCommand() throws CoreException,
- ExecutionException {
-
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- // model.setWsdlURI(wsdlFile.getLocation().toOSString());
-
- WebServiceClientInfo info = new WebServiceClientInfo();
- info.setWsdlURL(wsdlFile.getLocation().toOSString());
- IWebServiceClient ws = new JBossWebServiceClient(info);
-
- // test initial command
- InitialClientCommand cmdInitial = new InitialClientCommand(model, ws,
- WebServiceScenario.CLIENT);
- IStatus status = cmdInitial.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- assertTrue(model.getServiceNames().contains("SOAPService"));
- assertEquals(wsdlFile.getLocation().toOSString(), model.getWsdlURI());
- assertTrue(model.getPortTypes().contains("Greeter"));
- assertEquals("org.apache.hello_world_soap_http", model
- .getCustomPackage());
-
- }
-
- public void testClientCodeGenerationCommand() throws ExecutionException {
-
- ServiceModel model = createServiceModel();
- IProject project = fproject.getProject();
- // test wsdl2Javacommand
- WSDL2JavaCommand cmdW2j = new WSDL2JavaCommand(model);
- IStatus status = cmdW2j.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(project.getFile(
- "src/org/apache/hello_world_soap_http/Greeter.java").exists());
-
- // test ClientSampleCreationCommand
- ClientSampleCreationCommand cmdImpl = new ClientSampleCreationCommand(
- model);
- status = cmdImpl.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(
- "failed to generate sample class",
- project
- .getFile(
- "src/org/apache/hello_world_soap_http/clientsample/ClientSample.java")
- .exists());
-
- }
-
- public void testRemoveClientJarsCommand() throws ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
-
- RemoveClientJarsCommand command = new RemoveClientJarsCommand(model);
- IStatus status = command.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
- try {
- IClasspathEntry[] entries = getJavaProjectByName(
- fproject.getProject().getName()).getRawClasspath();
-
- for (IClasspathEntry entry : entries) {
- IClasspathContainer container = JavaCore.getClasspathContainer(
- entry.getPath(), getJavaProjectByName(fproject
- .getProject().getName()));
- if (container instanceof JbossWSRuntimeClasspathContainer) {
- boolean nojar = true;
- for (IClasspathEntry jar : ((JbossWSRuntimeClasspathContainer) container)
- .getClasspathEntries()) {
- if (jar.getPath().toString().contains("jaxws-rt.jar")) {
- nojar = false;
- }
- }
- assertTrue(nojar);
- }
- }
- } catch (JavaModelException e) {
- JBossWSCreationCore.getDefault().logError(e);
- }
-
- }
-
- public static IJavaProject getJavaProjectByName(String projectName)
- throws JavaModelException {
-
- IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
- .getRoot());
- model.open(null);
-
- IJavaProject[] projects = model.getJavaProjects();
-
- for (IJavaProject proj : projects) {
- if (proj.getProject().getName().equals(projectName)) {
- return proj;
- }
- }
-
- return null;
- }
-
- @Override
- IDataModel createJBossWSDataModel(boolean isServerSupplied) {
- IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
- .create();
- if (isServerSupplied) {
- config
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- true);
- } else {
- config.setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
- isDeployed);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
- RuntimeName);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
- getJBossWSHomeFolder().toString());
- }
- return config;
- }
-
-}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC
(rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC
(rev 8979)
@@ -10,4 +10,4 @@
org.jboss.tools.tests,
org.jboss.tools.ws.ui,
org.jboss.tools.ws.core
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.test;
+
+import org.jboss.tools.ws.ui.test.preferences.JBossWSRuntimePreferencePageTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSUIAllTests extends TestCase {
+ public static final String PLUGIN_ID = "org.jboss.tools.common.test";
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(JBossWSUIAllTests.class.getName());
+ suite.addTestSuite(JBossWSRuntimePreferencePageTest.class);
+
+ return suite;
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.test.preferences;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.jboss.tools.test.util.WorkbenchUtils;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeListConverter;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+import org.jboss.tools.ws.ui.preferences.JBossRuntimeListFieldEditor;
+import org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimePreferencePageTest extends TestCase {
+
+ /**
+ * Test that preference page is showed up without errors
+ */
+ public void testShowJBossWSRuntimePreferencePage() {
+
+ PreferenceDialog prefDialog = WorkbenchUtils
+ .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage");
+ try {
+ Object object = openPreferencepage(prefDialog);
+ assertTrue(
+ "Selected page is not an instance of JBossWSRuntimePreferencePage",
+ object instanceof JBossWSRuntimePreferencePage);
+ } finally {
+ prefDialog.close();
+ }
+ }
+
+ private Object openPreferencepage(PreferenceDialog prefDialog) {
+ prefDialog.setBlockOnOpen(false);
+ prefDialog.open();
+ return prefDialog.getSelectedPage();
+ }
+
+ /**
+ * Test correct contents in that preference page
+ */
+ @SuppressWarnings("unchecked")
+ public void testDisplayJBossWSRuntimePreferencePage() {
+ PreferenceDialog prefDialog = WorkbenchUtils
+ .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage");
+ JBossWSRuntimePreferencePage selectedPage = null;
+ try {
+ Object object = openPreferencepage(prefDialog);
+ String runtime = getRuntimeList();
+ selectedPage = (JBossWSRuntimePreferencePage) object;
+ JBossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
+ .getJBossWSRuntimes();
+ if (runtime.equals("")) {
+ assertTrue(
+ "The JBoss Ws Runtime locations are not displayed",
+ ((ArrayList<JBossWSRuntime>) jbossWSRuntimes.getValue())
+ .size() == 0);
+ } else {
+ JBossWSRuntimeListConverter converter = new JBossWSRuntimeListConverter();
+ Map<String, JBossWSRuntime> runtimes = converter
+ .getMap(runtime);
+ assertTrue(
+ "The JBoss Ws Runtime locations are not displayed",
+ runtimes.values().size() == ((ArrayList<JBossWSRuntime>) jbossWSRuntimes
+ .getValue()).size());
+ }
+ } finally {
+ prefDialog.close();
+ }
+
+ }
+
+ /**
+ * Set and Test correct contents in that preference page
+ */
+ @SuppressWarnings("unchecked")
+ public void testSetAndDisplayJBossWSRuntimePreferencePage() {
+ setRuntimeList();
+ PreferenceDialog prefDialog = WorkbenchUtils
+ .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage");
+ JBossWSRuntimePreferencePage selectedPage = null;
+ try {
+ Object object = openPreferencepage(prefDialog);
+ String runtime = getRuntimeList();
+ selectedPage = (JBossWSRuntimePreferencePage) object;
+ JBossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
+ .getJBossWSRuntimes();
+ assertTrue("The preference store for jboss ws runtime is wrong",
+ !runtime.equals(""));
+ JBossWSRuntimeListConverter converter = new JBossWSRuntimeListConverter();
+ Map<String, JBossWSRuntime> runtimes = converter.getMap(runtime);
+ assertTrue(
+ "The JBoss Ws Runtime locations are not displayed correctly",
+ runtimes.values().size() == ((ArrayList<JBossWSRuntime>) jbossWSRuntimes
+ .getValue()).size());
+ } finally {
+ prefDialog.close();
+ }
+
+ }
+
+ private void setRuntimeList() {
+ String jbosshome = System.getProperty("jbosstools.test.jboss.home.4.2",
+ "/home/grid/Software/jboss-4.2.2.GA");
+ String runtime = "name|jboss-4.2.2.GA|version|2.0|homeDir|" + jbosshome
+ + "|default|false|userConfig|true|libraries|" + jbosshome
+ + "/lib/commons-codec.jar,name|jboss|version|2.0|homeDir|"
+ + jbosshome + "|default|true|userConfig|false|libraries|";
+ JBossWSCorePlugin.getDefault().getPreferenceStore().setValue(
+ JBossWSCoreMessages.WS_Location, runtime);
+ IPreferenceStore store = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ JBossWSRuntimeManager.getInstance().load();
+
+ }
+
+ private String getRuntimeList() {
+ IPreferenceStore ps = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+ String runtimeListString = ps
+ .getString(JBossWSCoreMessages.WS_Location);
+ return runtimeListString;
+ }
+
+}
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java 2008-06-27
06:07:21 UTC (rev 8978)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java 2008-06-27
08:19:24 UTC (rev 8979)
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.test.preferences;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPersistentPreferenceStore;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.jboss.tools.test.util.WorkbenchUtils;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeListConverter;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-import org.jboss.tools.ws.ui.preferences.JbossRuntimeListFieldEditor;
-import org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage;
-
-import junit.framework.TestCase;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimePreferencePageTest extends TestCase {
-
- /**
- * Test that preference page is showed up without errors
- */
- public void testShowJbossWSRuntimePreferencePage() {
-
- PreferenceDialog prefDialog = WorkbenchUtils
- .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage");
- try {
- Object object = openPreferencepage(prefDialog);
- assertTrue(
- "Selected page is not an instance of JbossWSRuntimePreferencePage",
- object instanceof JbossWSRuntimePreferencePage);
- } finally {
- prefDialog.close();
- }
- }
-
- private Object openPreferencepage(PreferenceDialog prefDialog) {
- prefDialog.setBlockOnOpen(false);
- prefDialog.open();
- return prefDialog.getSelectedPage();
- }
-
- /**
- * Test correct contents in that preference page
- */
- @SuppressWarnings("unchecked")
- public void testDisplayJbossWSRuntimePreferencePage() {
- PreferenceDialog prefDialog = WorkbenchUtils
- .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage");
- JbossWSRuntimePreferencePage selectedPage = null;
- try {
- Object object = openPreferencepage(prefDialog);
- String runtime = getRuntimeList();
- selectedPage = (JbossWSRuntimePreferencePage) object;
- JbossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
- .getJbossWSRuntimes();
- if (runtime.equals("")) {
- assertTrue(
- "The JBoss Ws Runtime locations are not displayed",
- ((ArrayList<JbossWSRuntime>) jbossWSRuntimes.getValue())
- .size() == 0);
- } else {
- JbossWSRuntimeListConverter converter = new JbossWSRuntimeListConverter();
- Map<String, JbossWSRuntime> runtimes = converter
- .getMap(runtime);
- assertTrue(
- "The JBoss Ws Runtime locations are not displayed",
- runtimes.values().size() == ((ArrayList<JbossWSRuntime>) jbossWSRuntimes
- .getValue()).size());
- }
- } finally {
- prefDialog.close();
- }
-
- }
-
- /**
- * Set and Test correct contents in that preference page
- */
- @SuppressWarnings("unchecked")
- public void testSetAndDisplayJbossWSRuntimePreferencePage() {
- setRuntimeList();
- PreferenceDialog prefDialog = WorkbenchUtils
- .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage");
- JbossWSRuntimePreferencePage selectedPage = null;
- try {
- Object object = openPreferencepage(prefDialog);
- String runtime = getRuntimeList();
- selectedPage = (JbossWSRuntimePreferencePage) object;
- JbossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
- .getJbossWSRuntimes();
- assertTrue("The preference store for jboss ws runtime is wrong",
- !runtime.equals(""));
- JbossWSRuntimeListConverter converter = new JbossWSRuntimeListConverter();
- Map<String, JbossWSRuntime> runtimes = converter.getMap(runtime);
- assertTrue(
- "The JBoss Ws Runtime locations are not displayed correctly",
- runtimes.values().size() == ((ArrayList<JbossWSRuntime>) jbossWSRuntimes
- .getValue()).size());
- } finally {
- prefDialog.close();
- }
-
- }
-
- private void setRuntimeList() {
- String jbosshome = System.getProperty("jbosstools.test.jboss.home.4.2",
- "/home/grid/Software/jboss-4.2.2.GA");
- String runtime = "name|jboss-4.2.2.GA|version|2.0|homeDir|" + jbosshome
- + "|default|false|userConfig|true|libraries|" + jbosshome
- + "/lib/commons-codec.jar,name|jboss|version|2.0|homeDir|"
- + jbosshome + "|default|true|userConfig|false|libraries|";
- JbossWSCorePlugin.getDefault().getPreferenceStore().setValue(
- JbossWSCoreMessages.WS_Location, runtime);
- IPreferenceStore store = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- if (store instanceof IPersistentPreferenceStore) {
- try {
- ((IPersistentPreferenceStore) store).save();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- JbossWSRuntimeManager.getInstance().load();
-
- }
-
- private String getRuntimeList() {
- IPreferenceStore ps = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- String runtimeListString = ps
- .getString(JbossWSCoreMessages.WS_Location);
- return runtimeListString;
- }
-
-}