Author: Grid.Qian
Date: 2008-06-05 06:41:43 -0400 (Thu, 05 Jun 2008)
New Revision: 8567
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/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.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
Removed:
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/JbossWSRuntime.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeListConverter.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeManager.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
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/command/JbossWSRuntimeCommand.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/preferences/BaseField.java
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/IFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/INamedElement.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/LabelFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/PushButtonField.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextField.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java
Log:
JBIDE-2261: modify some classes location for other plugins calling them
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-05 09:38:40 UTC
(rev 8566)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-06-05 10:41:43 UTC
(rev 8567)
@@ -12,7 +12,9 @@
org.eclipse.core.resources,
org.eclipse.jst.ws,
org.eclipse.jdt.core,
- org.eclipse.jdt.launching
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.jst.jsf.ui
Eclipse-LazyStart: true
Bundle-Vendor: %PLUGIN_PROVIDER
Export-Package: org.jboss.tools.ws.core,
Copied:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java
(from rev 8556,
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/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-05
10:41:43 UTC (rev 8567)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Grid Qian
+ */
+public class JbossWSRuntime {
+
+ String name = null;
+
+ String homeDir = null;
+
+ boolean defaultRt = false;
+
+ /**
+ * Default constructor
+ */
+ public JbossWSRuntime() {
+ }
+
+ /**
+ * 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;
+ }
+
+}
Modified:
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-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -65,7 +65,7 @@
public IClasspathEntry[] getClasspathEntries() {
if (entries == null) {
ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- IPath wsPath = JbossWSCoreUtils.getJbossWSRuntimePath();
+ IPath wsPath = JbossWSCoreUtils.getJbossWSRuntimePath(null);
if (wsPath != null) {
IPath libPath = wsPath.append(JbossWSCoreMessages.DIR_LIB);
list.addAll(Arrays.asList(getEntries(libPath)));
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-05
10:41:43 UTC (rev 8567)
@@ -0,0 +1,94 @@
+package org.jboss.tools.ws.core.classpath;
+
+
+import java.util.HashMap;
+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 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 NAME = "name";
+
+ /**
+ * 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 (DEFAULT.equals(name)) {
+ rt.setDefault(Boolean.parseBoolean(value));
+ }
+ }
+ result.put(rt.getName(), rt);
+ }
+
+ return result;
+ }
+
+ /**
+ * 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(HOME_DIR).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getHomeDir());
+ buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isDefault());
+ if (i != runtimes.length - 1) {
+ buffer.append(COMMA);
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
Copied:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java
(from rev 8556,
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/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-05
10:41:43 UTC (rev 8567)
@@ -0,0 +1,274 @@
+/*******************************************************************************
+ * 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.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+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.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() {
+ IPreferenceStore ps = JbossWSCorePlugin.getDefault().getPreferenceStore();
+
+ String runtimeListString = ps.getString(JbossWSCoreMessages.WS_LOCATION);
+
+ runtimes = converter.getMap(runtimeListString);
+ }
+
+ /**
+ * 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,
+ boolean defaultRt) {
+ JbossWSRuntime jbossWSRt = new JbossWSRuntime();
+ jbossWSRt.setHomeDir(path);
+ jbossWSRt.setName(name);
+ 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;
+ }
+
+ /**
+ * 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(
+ "jbosswsruntimelocation",
+ 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;
+ }
+
+ /**
+ * If project has JbossWS facet then this method returns default JbossWS runtime for
proper version of facet.
+ * Otherwise return first default runtime.
+ * @param project
+ * @return
+ */
+ public static JbossWSRuntime getDefaultRuntimeForProject(IProject project) {
+ if(project==null) {
+ throw new IllegalArgumentException("Project must not be null.");
+ }
+ try {
+ IProjectFacet facet =
ProjectFacetsManager.getProjectFacet("jbossws.core");
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ if(facetedProject!=null) {
+ return getInstance().getDefaultRuntime();
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ }
+ return getInstance().getDefaultRuntime();
+ }
+
+ /**
+ * 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) {
+ IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+// for (int i = 0; i < ps.length; i++) {
+// ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
+// if (sp != null && oldName.equals(sp.getRuntimeName())) {
+// sp.setRuntimeName(newName);
+// }
+// }
+ }
+}
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -45,7 +45,7 @@
IStatus status = Status.OK_STATUS;
// copy lib jars to project's folder
- IPath wsPath = JbossWSCoreUtils.getJbossWSRuntimePath();
+ IPath wsPath = JbossWSCoreUtils.getJbossWSRuntimePath(null);
IPath libPath = null;
try {
libPath = wsPath.append(JbossWSCoreMessages.DIR_LIB);
Modified:
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-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -15,6 +15,8 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -37,6 +39,8 @@
import org.eclipse.jst.ws.internal.common.J2EEUtils;
import org.eclipse.osgi.util.NLS;
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.messages.JbossWSCoreMessages;
/**
@@ -219,16 +223,29 @@
return file;
}
}
-
- public static IPath getJbossWSRuntimePath() {
+
+ public static IPath getJbossWSRuntimePath(String runtimeName) {
+ Map<String, JbossWSRuntime> runtimes = new HashMap<String,
JbossWSRuntime>();
+ JbossWSRuntimeListConverter converter = new JbossWSRuntimeListConverter();
IPreferenceStore ps = JbossWSCorePlugin.getDefault()
.getPreferenceStore();
String runtimeLocation = ps.getString(JbossWSCoreMessages.WS_LOCATION);
-
- if(runtimeLocation == null || runtimeLocation.equals("")){
+ runtimes = converter.getMap(runtimeLocation);
+ if (runtimeLocation == null || runtimeLocation.equals("")) {
return null;
}
- return new Path(runtimeLocation);
- }
+ if (runtimeName == null || runtimeName.equals("")) {
+ for (JbossWSRuntime rt : runtimes.values()) {
+ if (rt.isDefault()) {
+ return new Path(rt.getHomeDir());
+ }
+ }
+ return null;
+ }
+ if (runtimes.get(runtimeName) != null) {
+ return new Path(runtimes.get(runtimeName).getHomeDir());
+ }
+ return null;
+ }
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseField.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseField.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseField.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -16,6 +16,9 @@
import org.eclipse.swt.widgets.Control;
+/**
+ * @author Grid Qian
+ */
public abstract class BaseField {
public static final String PROPERTY_NAME = "value"; //$NON-NLS-1$
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-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -22,14 +22,10 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Widget;
import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
/**
@@ -95,16 +91,10 @@
}
- /**
- *
- */
public void addPropertyChangeListener(PropertyChangeListener listener) {
pcs.addPropertyChangeListener(listener);
}
- /**
- *
- */
public void removePropertyChangeListener(PropertyChangeListener listener) {
pcs.removePropertyChangeListener(listener);
}
@@ -125,61 +115,32 @@
return labelControl;
}
- /**
- *
- * @return
- */
public Label getLabelControl() {
return createLabelControl(null);
}
- /**
- *
- */
public abstract Object[] getEditorControls(Object composite);
-
- /**
- *
- */
+
public abstract Object[] getEditorControls();
-
- /**
- *
- * @return
- */
+
public Control[] getSwtControls() {
return (Control[])getEditorControls();
}
- /**
- *
- */
public abstract int getNumberOfControls();
- /**
- *
- */
public Object getValue() {
return value;
}
- /**
- *
- */
public String getValueAsString() {
return getValue().toString();
}
- /**
- *
- */
public boolean isEnabled() {
return this.enabled ;
}
- /**
- *
- */
public void setEnabled(boolean enabled) {
this.enabled = enabled;
Control[] controls = getSwtControls();
@@ -206,9 +167,6 @@
}
}
- /**
- *
- */
public boolean setFocus() {
return true;
}
@@ -223,24 +181,14 @@
pcs.firePropertyChange(nameText,oldValue,newValue);
}
- /**
- *
- */
public void setValueAsString(String stringValue) {
value = stringValue;
}
- /**
- *
- */
public String getName() {
return nameText;
}
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#dispose()
- */
public void dispose() {
PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
for (int i = 0; i < listeners.length; i++) {
@@ -249,10 +197,6 @@
}
}
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#dispose(org.eclipse.swt.events.DisposeEvent)
- */
public void dispose(DisposeEvent e) {
dispose();
for (DisposeListener disposeListener : disposeListeners) {
@@ -261,26 +205,14 @@
disposeListeners.clear();
}
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#addDisposeListener(org.eclipse.swt.events.DisposeListener)
- */
public void addDisposeListener(DisposeListener listener) {
disposeListeners.add(listener);
}
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#removeDisposeListener(org.eclipse.swt.events.DisposeListener)
- */
public void removeDisposeListener(DisposeListener listener) {
disposeListeners.remove(listener);
}
- /**
- *
- * @return
- */
public String getLabelText() {
return labelText;
}
@@ -292,22 +224,13 @@
public void setLabelText(String labelText) {
this.labelText = labelText;
}
-
- /**
- *
- */
+
private boolean editable = true;
-
- /**
- *
- */
+
public boolean isEditable() {
return editable;
}
- /**
- *
- */
public void setEditable(boolean aEditable) {
this.editable = aEditable;
}
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-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -19,8 +19,7 @@
import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
/**
- * @author eskimo
- *
+ * @author Grid Qian
*/
public class ButtonFieldEditor extends BaseFieldEditor {
@@ -104,9 +103,6 @@
}
}
- /* (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
- */
@Override
public int getNumberOfControls() {
return 1;
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-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -30,8 +30,7 @@
import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
/**
- * @author eskimo
- *
+ * @author Grid Qian
*/
public class CompositeEditor extends BaseFieldEditor implements PropertyChangeListener {
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/IFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/IFieldEditor.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/IFieldEditor.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -27,16 +27,8 @@
*/
public Object[] getEditorControls(Object composite);
- /**
- *
- * @return
- */
public Object[] getEditorControls();
- /**
- *
- * @return
- */
public int getNumberOfControls();
/**
@@ -69,10 +61,6 @@
*/
public void removePropertyChangeListener(PropertyChangeListener listener);
- /**
- *
- * @return
- */
public boolean isEditable();
/**
@@ -81,16 +69,8 @@
*/
public void setEditable(boolean aEdiatble);
- /**
- * @return
- *
- */
public boolean setFocus();
- /**
- *
- * @return
- */
public boolean isEnabled();
/**
@@ -99,9 +79,6 @@
*/
public void setEnabled(boolean enabled);
- /**
- *
- */
public void dispose();
/**
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/INamedElement.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/INamedElement.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/INamedElement.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -18,27 +18,12 @@
public abstract String getName();
- /**
- *
- * @return
- */
public abstract Object getValue();
- /**
- *
- */
public abstract void setValue(Object newValue);
- /**
- *
- * @return
- */
public abstract String getValueAsString();
-
- /**
- *
- * @param aValue
- */
+
public abstract void setValueAsString(String aValue);
}
\ No newline at end of file
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-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -1,999 +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;
-
-/**
- * @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 List<JbossWSRuntime> checkedElements = new
ArrayList<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 List<JbossWSRuntime>
- */
- public List<JbossWSRuntime> getDefaultJbossWSRuntimes() {
- return checkedElements;
- }
-
- /**
- * 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_PATH_WIDTH);
- tc3.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_INSTANCEOF_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_PATH_NUMBER = 2;
-
- 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_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];
- checkedElements.clear();
- int i = 0;
- for (Object object : selRts) {
- JbossWSRuntime rt = (JbossWSRuntime) object;
- if (rt == selRt) {
- newChecked[i] = rt;
- checkedElements.add(rt);
- i++;
- }
- }
- tableView.setCheckedElements(newChecked);
- } else {
- checkedElements.add((JbossWSRuntime)event.getElement());
- }
- } else {
- checkedElements.remove(selRt);
- }
- pcs.firePropertyChange(getName(), null, getValue());
- }
- });
-
- for (JbossWSRuntime rt : (List<JbossWSRuntime>) getValue()) {
- if (rt.isDefault()) {
- tableView.setChecked(rt, true);
- checkedElements.add(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 setDefaultRuntimes() {
- List<JbossWSRuntime> runtimes = (List<JbossWSRuntime>)getValue();
- for (JbossWSRuntime jbossWSRuntime : runtimes) {
- boolean checked = false;
- for(JbossWSRuntime checkedElement: checkedElements) {
- if(checkedElement == jbossWSRuntime) {
- checked = true;
- break;
- }
- }
- if(!checked) {
- tableView.setChecked(jbossWSRuntime, true);
- checkedElements.add(jbossWSRuntime);
- }
- }
- }
-
- /**
- * 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.JBOSSWS_BASIC_EDITOR_COMPOSITE);
- Assert
- .isTrue(
- ((Composite) parent).getLayout() instanceof GridLayout,
- JbossWSUIMessages.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_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 homeDir = createBrowseFolderEditor(
- SRT_HOMEDIR,
- JbossWSUIMessages.JBOSSWS_RUNTIME_LIST_FIELD_EDITOR_HOME_FOLDER,
- ""); //$NON-NLS-1$
-
- JbossWSRuntime current = 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);
- homeDir.doFillIntoGrid(root);
- homeDir.addPropertyChangeListener(this);
- name.doFillIntoGrid(root);
- name.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())) {
- 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.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.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;
- }
- }
-
- if (current != null
- && current.getName().equals(name.getValueAsString())
- && current.getHomeDir().equals(homeDir.getValueAsString())) {
- setErrorMessage(null);
- setPageComplete(false);
- return;
- }
-
- if (homeDir.getValueAsString() == null
- || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
- setErrorMessage(JbossWSUIMessages.JBOSSWS_RUNTIME_LIST_FIELD_EDITOR_PATH_TO_HOME_DIRECTORY_CANNOT_BE_EMPTY);
- setPageComplete(false);
- return;
- }
-
- setErrorMessage(null);
- setPageComplete(true);
- }
-
- /**
- * Return JbossWS Runtime instance initialized by user input
- *
- * @return JbossWSRuntime instance
- */
- public JbossWSRuntime getRuntime() {
- JbossWSRuntime newRt = new JbossWSRuntime();
- newRt.setName(name.getValueAsString());
- newRt.setHomeDir(homeDir.getValueAsString());
- 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);
- }
- }
- };
- }
- }
-
- /**
- * 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;
- }
- }
-
- /**
- * Wizard for editing JbossWS Runrtime parameters: name, version 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.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 (rt.getName().equals(source.getName())
- && rt.getHomeDir().equals(source.getHomeDir())) {
- return true;
- }
- if (added.contains(source) || changed.containsKey(source)) {
- source.setName(rt.getName());
- source.setHomeDir(rt.getName());
- } else {
- changed.put(rt, source);
- 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();
- setDefaultRuntimes();
- }
- }
-
- /**
- * 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();
- if (changed.containsValue(selected)) {
- JbossWSRuntime c = findChangedRuntime(selected);
- if (c != null) {
- tableView.setSelection(new StructuredSelection(c));
- }
- }
- }
-
- 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();
- setDefaultRuntimes();
- }
-
- @SuppressWarnings("unchecked")
- private void removeRuntime(JbossWSRuntime r) {
- boolean used = 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);
- }
- checkedElements.remove(r);
- }
-
- private boolean isRuntimeUsed(String runtimeName) {
-// IProject[] ps = ResourcesPlugin.getWorkspace().getRoot()
-// .getProjects();
-// for (int i = 0; i < ps.length; i++) {
-// ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
-// if (sp != null && runtimeName.equals(sp.getRuntimeName())) {
-// return true;
-// }
-// }
- return false;
- }
- }
-}
\ No newline at end of file
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-05
10:41:43 UTC (rev 8567)
@@ -0,0 +1,1021 @@
+/*******************************************************************************
+ * 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.core.classpath.JbossWSRuntime;
+
+/**
+ * @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_PATH_WIDTH);
+ tc3.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_INSTANCEOF_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_PATH_NUMBER = 2;
+
+ 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_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;
+ break;
+ }
+ }
+ if (!checked) {
+ 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.JBOSSWS_BASIC_EDITOR_COMPOSITE);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JbossWSUIMessages.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_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 homeDir = createBrowseFolderEditor(
+ SRT_HOMEDIR,
+ JbossWSUIMessages.JBOSSWS_RUNTIME_LIST_FIELD_EDITOR_HOME_FOLDER,
+ ""); //$NON-NLS-1$
+
+ JbossWSRuntime current = 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);
+ homeDir.doFillIntoGrid(root);
+ homeDir.addPropertyChangeListener(this);
+ name.doFillIntoGrid(root);
+ name.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())) {
+ 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.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.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;
+ }
+ }
+
+ if (current != null
+ && current.getName().equals(name.getValueAsString())
+ && current.getHomeDir().equals(homeDir.getValueAsString())) {
+ setErrorMessage(null);
+ setPageComplete(false);
+ return;
+ }
+
+ if (homeDir.getValueAsString() == null
+ || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
+ setErrorMessage(JbossWSUIMessages.JBOSSWS_RUNTIME_LIST_FIELD_EDITOR_PATH_TO_HOME_DIRECTORY_CANNOT_BE_EMPTY);
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+
+ /**
+ * Return JbossWS Runtime instance initialized by user input
+ *
+ * @return JbossWSRuntime instance
+ */
+ public JbossWSRuntime getRuntime() {
+ JbossWSRuntime newRt = new JbossWSRuntime();
+ newRt.setName(name.getValueAsString());
+ newRt.setHomeDir(homeDir.getValueAsString());
+ 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);
+ }
+ }
+ };
+ }
+ }
+
+ /**
+ * 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;
+ }
+ }
+
+ /**
+ * Wizard for editing JbossWS Runrtime parameters: name, version 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.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 (rt.getName().equals(source.getName())
+ && rt.getHomeDir().equals(source.getHomeDir())) {
+ return true;
+ }
+ if (added.contains(source) || changed.containsKey(source)) {
+ source.setName(rt.getName());
+ source.setHomeDir(rt.getName());
+ } else {
+ changed.put(rt, source);
+ 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();
+ if (changed.containsValue(selected)) {
+ JbossWSRuntime c = findChangedRuntime(selected);
+ if (c != null) {
+ tableView.setSelection(new StructuredSelection(c));
+ }
+ }
+ }
+
+ 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 = 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;
+ }
+ }
+
+ private boolean isRuntimeUsed(String runtimeName) {
+ // IProject[] ps = ResourcesPlugin.getWorkspace().getRoot()
+ // .getProjects();
+ // for (int i = 0; i < ps.length; i++) {
+ // ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
+ // if (sp != null && runtimeName.equals(sp.getRuntimeName())) {
+ // return true;
+ // }
+ // }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntime.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntime.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntime.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -1,128 +0,0 @@
-package org.jboss.tools.ws.ui.preferences;
-
-public class JbossWSRuntime {
-
- String name = null;
-
- String homeDir = null;
-
- boolean defaultRt = false;
-
- /**
- * Default constructor
- */
- public JbossWSRuntime() {
- }
-
- /**
- * 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;
- }
-
- /**
- * Calculate path to seam-gen
- *
- * @return absolute path to seam-gen folder
- */
- public String getSeamGenDir() {
- return getHomeDir() + "/seam-gen"; //$NON-NLS-1$
- }
-
- /**
- * Calculate path to source templates
- *
- * @return absolute path to source templates
- */
- public String getSrcTemplatesDir() {
- return getSeamGenDir() + "/src"; //$NON-NLS-1$
- }
-
- /**
- * Calculate path to view templates
- *
- * @return absolute path to view templates
- */
- public String getViewTemplatesDir() {
- return getSeamGenDir() + "/view"; //$NON-NLS-1$
- }
-
- /**
- * Calculate path to resource templates
- *
- * @return absolute path to resource templates
- */
- public String getResourceTemplatesDir() {
- return getSeamGenDir() + "/resources"; //$NON-NLS-1$
- }
-
- /**
- * Calculate path to test templates
- *
- * @return absolute path to test templates
- */
- public String getTestTemplatesDir() {
- return getSeamGenDir() + "/test"; //$NON-NLS-1$
- }
-
- /**
- * Calculate path to templates root directory
- *
- * @return absolute path to templates root directory
- */
- public String getTemplatesDir() {
- return getSeamGenDir();
- }
-
-}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeListConverter.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeListConverter.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeListConverter.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -1,87 +0,0 @@
-package org.jboss.tools.ws.ui.preferences;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-public class JbossWSRuntimeListConverter {
-
- /*
- * Constants definitions
- */
- private static final String REGEXP_ESCAPE = "\\";
- private static final String COMMA = ",";
- 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 NAME = "name";
-
- /**
- * Load String to SeamRuntime map from String
- * @param input
- * String representation of map
- * @return
- * Map<String, SeamRuntime> 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 (DEFAULT.equals(name)) {
- rt.setDefault(Boolean.parseBoolean(value));
- }
- }
- result.put(rt.getName(), rt);
- }
-
- return result;
- }
-
- /**
- * Convert map String to SeamRUntime to string representation
- * @param runtimeMap
- * Map<String, SeamRuntime> - map of String to Seam Runtime to convert
- * in String
- * @return
- * String representation of String to Seam 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(HOME_DIR).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].getHomeDir());
- buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].isDefault());
- if (i != runtimes.length - 1) {
- buffer.append(COMMA);
- }
- }
- return buffer.toString();
- }
- }
-
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeManager.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeManager.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimeManager.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -1,259 +0,0 @@
-package org.jboss.tools.ws.ui.preferences;
-
-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 org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-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.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
-
-public class JbossWSRuntimeManager {
-
- private static JbossWSRuntimeListConverter converter = new
JbossWSRuntimeListConverter();
-
- private Map<String, JbossWSRuntime> runtimes = new HashMap<String,
JbossWSRuntime>();
-
- /**
- * Private constructor
- */
- private JbossWSRuntimeManager() {
- IPreferenceStore ps = JbossWSCorePlugin.getDefault().getPreferenceStore();
-
- String runtimeListString = ps.getDefaultString("jbosswsruntimelocation");
-
- runtimes = converter.getMap(runtimeListString);
- }
-
- /**
- * 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 SeamRuntimeManaher instance
- *
- * @return
- * SeamRuntimeManager instance
- */
- public static JbossWSRuntimeManager getInstance() {
- return JbossWSRuntimeManagerHolder.INSTANCE;
- }
-
- /**
- * Return Array of configured SeamRuntimes
- *
- * @return
- * SeamRuntime[]
- */
- public JbossWSRuntime[] getRuntimes() {
- Collection<JbossWSRuntime> c = runtimes.values();
- return c.toArray(new JbossWSRuntime[runtimes.size()]);
- }
-
- /**
- * Add new SeamRuntime
- *
- * @param runtime
- * SeamRuntime
- */
- 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 SeamRuntime 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,
- boolean defaultRt) {
- JbossWSRuntime seamRt = new JbossWSRuntime();
- seamRt.setHomeDir(path);
- seamRt.setName(name);
- seamRt.setDefault(defaultRt);
- addRuntime(seamRt);
- }
-
- /**
- * Return SeamRuntime by given name
- *
- * @param name
- * String - SeamRuntime name
- * @return
- * SeamRuntime - found SeamRuntime instance or null
- */
- public JbossWSRuntime findRuntimeByName(String name) {
- for (JbossWSRuntime seamRuntime : runtimes.values()) {
- if (seamRuntime.getName().equals(name)) {
- return seamRuntime;
- }
- }
- return null;
- }
-
- /**
- * Remove given SeamRuntime from manager
- * @param rt
- * SeamRuntime
- */
- 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(
- "jbosswsruntimelocation",
- 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 SeamRuntime
- *
- * @return
- * SeamRuntime
- */
- public JbossWSRuntime getDefaultRuntime() {
- for (JbossWSRuntime rt : runtimes.values()) {
- if (rt.isDefault()) {
- return rt;
- }
- }
- return null;
- }
-
- /**
- * If project has seam facet then this method returns default seam runtime for proper
version of facet.
- * Otherwise return first default runtime.
- * @param project
- * @return
- */
- public static JbossWSRuntime getDefaultRuntimeForProject(IProject project) {
- if(project==null) {
- throw new IllegalArgumentException("Project must not be null.");
- }
- try {
- IProjectFacet facet =
ProjectFacetsManager.getProjectFacet("jbossws.core");
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- if(facetedProject!=null) {
- return getInstance().getDefaultRuntime();
- }
- } catch (CoreException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- }
- return getInstance().getDefaultRuntime();
- }
-
- /**
- * Return list of available SeamRuntime names
- *
- * @return
- * List<String>
- */
- public List<String> getRuntimeNames() {
- JbossWSRuntime[] rts = getRuntimes();
- List<String> result = new ArrayList<String>();
- for (JbossWSRuntime seamRuntime : rts) {
- result.add(seamRuntime.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 seamRuntime : rts) {
- result.add(seamRuntime.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) {
- IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-// for (int i = 0; i < ps.length; i++) {
-// ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
-// if (sp != null && oldName.equals(sp.getRuntimeName())) {
-// sp.setRuntimeName(newName);
-// }
-// }
- }
-}
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/LabelFieldEditor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/LabelFieldEditor.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/LabelFieldEditor.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -15,8 +15,7 @@
import org.eclipse.swt.widgets.Control;
/**
- * @author eskimo
- *
+ * @author Grid Qian
*/
public class LabelFieldEditor extends BaseFieldEditor {
@@ -24,52 +23,34 @@
super(name, label, ""); //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#doFillIntoGrid(java.lang.Object)
- */
@Override
public void doFillIntoGrid(Object parent) {
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getEditorControls(java.lang.Object)
- */
@Override
public Object[] getEditorControls(Object composite) {
// TODO Auto-generated method stub
return new Control[]{createLabelControl((Composite)composite)};
}
- /* (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getEditorControls()
- */
@Override
public Object[] getEditorControls() {
return getEditorControls(null);
}
- /* (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#isEditable()
- */
@Override
public boolean isEditable() {
// TODO Auto-generated method stub
return false;
}
-
- /* (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#save(java.lang.Object)
- */
+
public void save(Object object) {
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#setEditable(boolean)
- */
@Override
public void setEditable(boolean ediatble) {
// TODO Auto-generated method stub
@@ -80,9 +61,6 @@
public void setValue(Object value) {
}
- /* (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
- */
@Override
public int getNumberOfControls() {
// TODO Auto-generated method stub
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/PushButtonField.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/PushButtonField.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/PushButtonField.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * 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 org.eclipse.swt.SWT;
@@ -7,7 +18,7 @@
import org.jboss.tools.ws.ui.preferences.ButtonFieldEditor.ButtonPressedAction;
/**
- * @author eskimo
+ * @author Grid Qian
*
*/
public class PushButtonField extends BaseField {
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextField.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextField.java 2008-06-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextField.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -17,6 +17,9 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
+/**
+ * @author Grid Qian
+ */
public class TextField extends BaseField implements ModifyListener{
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-05
09:38:40 UTC (rev 8566)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java 2008-06-05
10:41:43 UTC (rev 8567)
@@ -26,14 +26,11 @@
/**
*
- * @author eskimo
+ * @author Grid Qian
*
*/
public class TextFieldEditor extends BaseFieldEditor implements PropertyChangeListener{
- /**
- *
- */
public static final int UNLIMITED = -1;
protected int style = -1;
@@ -60,28 +57,15 @@
setEditable(editable);
}
- /**
- *
- */
protected TextField fTextField = null;
- /**
- *
- */
protected int fWidthInChars = 0;
- /**
- *
- */
@Override
public Object[] getEditorControls() {
return new Control[] {getTextControl()};
}
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#doFillIntoGrid(java.lang.Object)
- */
@Override
public void doFillIntoGrid(Object aParent) {
Assert.isTrue(aParent instanceof Composite,
JbossWSUIMessages.JBOSSWS_BASIC_EDITOR_COMPOSITE);
@@ -120,17 +104,10 @@
return fTextField.getTextControl();
}
- /**
- *
- */
protected void updateWidgetValues() {
setValueAsString(getValueAsString());
}
- /**
- *
- * @return
- */
protected int getInitialStyle() {
if(this.style >= 0) return style;
return SWT.SINGLE | SWT.BORDER;
@@ -173,9 +150,6 @@
return (value != null) ? value.toString() : ""; //$NON-NLS-1$
}
- /**
- *
- */
@Override
public int getNumberOfControls() {
return 2;
@@ -191,10 +165,6 @@
return fTextField!=null?fTextField.getTextControl():null;
}
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#setFocus()
- */
@Override
public boolean setFocus() {
boolean setfocus = false;
@@ -203,9 +173,6 @@
return setfocus;
}
- /**
- *
- */
@Override
public Object[] getEditorControls(Object composite) {
return new Control[]{getTextControl((Composite)composite)};
@@ -231,18 +198,12 @@
}
}
- /**
- *
- */
@Override
public void setEditable(boolean aEditable) {
super.setEditable(aEditable);
if(getTextControl()!=null) getTextControl().setEditable(aEditable);
}
- /**
- *
- */
public void propertyChange(PropertyChangeEvent evt) {
super.setValue(evt.getNewValue());
}