GERONIMODEVTOOLS-795: Add support for PortOffset and saving port information into config-substitution file. Also, other improvements to editing server configuration (ensure unsaved changes are not used until saved, and fix undo functionality)
git-svn-id: https://svn.apache.org/repos/asf/geronimo/devtools/eclipse-plugin/trunk@1459957 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
index 47f49ca..8067450 100644
--- a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
+++ b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
@@ -1574,10 +1574,12 @@
}
public MBeanServerConnection getServerConnection() throws Exception {
- String host = getServer().getHost();
- String user = getGeronimoServer().getAdminID();
- String password = getGeronimoServer().getAdminPassword();
- String port = getGeronimoServer().getRMINamingPort();
+ GeronimoServerDelegate delegate = getServerDelegate();
+
+ String host = delegate.getServer().getHost();
+ String user = delegate.getAdminID();
+ String password = delegate.getAdminPassword();
+ String port = String.valueOf(delegate.getActualRMINamingPort());
JMXConnectorInfo connectorInfo = new JMXConnectorInfo(user, password, host, port);
// Using the classloader that loads the current's class as the default classloader when creating the JMXConnector
diff --git a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
index a8e3ce2..b7e296d 100644
--- a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
+++ b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
@@ -20,11 +20,9 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
-import java.util.Map;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
@@ -42,6 +40,7 @@
import org.apache.geronimo.st.v30.core.internal.Trace;
import org.apache.geronimo.st.v30.core.osgi.AriesHelper;
import org.apache.geronimo.st.v30.core.osgi.OsgiConstants;
+import org.apache.geronimo.st.v30.core.util.ConfigSubstitutionsHelper;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -54,6 +53,7 @@
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerPort;
import org.eclipse.wst.server.core.ServerUtil;
@@ -88,6 +88,8 @@
public static final String PROPERTY_RMI_PORT = "RMIRegistry";
public static final String PROPERTY_HTTP_PORT = "WebConnector";
+
+ public static final String PROPERTY_PORT_OFFSET = "PortOffset";
public static final String PROPERTY_CLEAN_OSGI_BUNDLE_CACHE = "cleanOSGiBundleCache";
@@ -171,7 +173,8 @@
* @see org.apache.geronimo.st.v30.core.IGeronimoServer#getDeployerURL()
*/
public String getDeployerURL() {
- return "deployer:geronimo:jmx://" + getServer().getHost() + ":" + getRMINamingPort();
+ String host = getServer().getHost();
+ return "deployer:geronimo:jmx://" + host + ":" + getActualRMINamingPort();
}
/*
@@ -181,7 +184,7 @@
*/
public String getJMXServiceURL() {
String host = getServer().getHost();
- return "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + getRMINamingPort() + "/JMXConnector";
+ return "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + getActualRMINamingPort() + "/JMXConnector";
}
/*
@@ -445,8 +448,8 @@
Trace.tracePoint("Entry", Activator.traceCore, "GeronimoServerDelegate.getServerPorts");
List<ServerPort> ports = new ArrayList<ServerPort>();
- ports.add(new ServerPort(PROPERTY_HTTP_PORT, "Web Connector", Integer.parseInt(getHTTPPort()), "http"));
- ports.add(new ServerPort(PROPERTY_RMI_PORT, "RMI Naming", Integer.parseInt(getRMINamingPort()), "rmi"));
+ ports.add(new ServerPort(PROPERTY_HTTP_PORT, "Web Connector", getActualHTTPPort(), "http"));
+ ports.add(new ServerPort(PROPERTY_RMI_PORT, "RMI Naming", getActualRMINamingPort(), "rmi"));
ServerPort[] serverPorts = ports.toArray(new ServerPort[ports.size()]);
Trace.tracePoint("Entry", Activator.traceCore, "GeronimoServerDelegate.getServerPorts", serverPorts);
@@ -503,7 +506,7 @@
String host = getServer().getHost();
StringBuilder urlSB = new StringBuilder("http://");
urlSB.append(host);
- int port = Integer.parseInt(getHTTPPort());
+ int port = getActualHTTPPort();
port = ServerMonitorManager.getInstance().getMonitoredPort(getServer(), port, "web");
if (port != 80) {
urlSB.append(":").append(port);
@@ -545,29 +548,61 @@
public void setDefaults(IProgressMonitor monitor) {
Trace.tracePoint("Entry", Activator.traceCore, "GeronimoServerDelegate.setDefaults", monitor);
suspendArgUpdates();
+
setAdminID("system");
setAdminPassword("manager");
setHTTPPort("8080");
setRMINamingPort("1099");
+ setPortOffset(0);
setConsoleLogLevel(CONSOLE_INFO);
setCleanOSGiBundleCache(false);
setRefreshOSGiBundle(false);
setKarafShell(false);
- setPingDelay(new Integer(10000));
- setMaxPings(new Integer(40));
- setPingInterval(new Integer(5000));
+ setPingDelay(10000);
+ setMaxPings(40);
+ setPingInterval(5000);
setPublishTimeout(900000);
setInPlaceSharedLib(false);
setRunFromWorkspace(false);
setSelectClasspathContainers(false);
+
+ IServer server = getServer();
+ if (server != null) {
+ IRuntime runtime = server.getRuntime();
+ if (runtime != null) {
+ ConfigSubstitutionsHelper configSubstitutions = new ConfigSubstitutionsHelper(runtime.getLocation());
+ configSubstitutions.load();
+ setAttribute(configSubstitutions, ConfigSubstitutionsHelper.PORT_OFFSET, PROPERTY_PORT_OFFSET);
+ setAttribute(configSubstitutions, ConfigSubstitutionsHelper.HTTP_PORT, PROPERTY_HTTP_PORT);
+ setAttribute(configSubstitutions, ConfigSubstitutionsHelper.NAMING_PORT, PROPERTY_RMI_PORT);
+ }
+ }
+
resumeArgUpdates();
Trace.tracePoint("Exit", Activator.traceCore, "GeronimoServerDelegate.setDefaults", monitor);
}
+
+ private void setAttribute(ConfigSubstitutionsHelper configSubstitutions, String substProperty, String property) {
+ String value = configSubstitutions.getProperty(substProperty);
+ if (value != null) {
+ setAttribute(property, value);
+ }
+ }
@Override
public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
Trace.tracePoint("Enter", Activator.traceCore, "GeronimoServerDelegate.saveConfiguration", monitor);
super.saveConfiguration(monitor);
+
+ if (SocketUtil.isLocalhost(getServer().getHost())) {
+ ConfigSubstitutionsHelper configSubstitutions = new ConfigSubstitutionsHelper(getServer().getRuntime().getLocation());
+ configSubstitutions.load();
+ configSubstitutions.setProperty(ConfigSubstitutionsHelper.PORT_OFFSET, String.valueOf(getPortOffset()));
+ configSubstitutions.setProperty(ConfigSubstitutionsHelper.HTTP_PORT, getHTTPPort());
+ configSubstitutions.setProperty(ConfigSubstitutionsHelper.NAMING_PORT, getRMINamingPort());
+ configSubstitutions.store();
+ }
+
Trace.tracePoint("Exit", Activator.traceCore, "GeronimoServerDelegate.saveConfiguration", monitor);
}
@@ -582,10 +617,10 @@
// PROPERTY_ADMIN_ID
//
public String getAdminID() {
- return getInstanceProperty(PROPERTY_ADMIN_ID);
+ return getAttribute(PROPERTY_ADMIN_ID, "system");
}
public void setAdminID(String value) {
- setInstanceProperty(PROPERTY_ADMIN_ID, value);
+ setAttribute(PROPERTY_ADMIN_ID, value);
}
@@ -593,45 +628,62 @@
// PROPERTY_ADMIN_PW
//
public String getAdminPassword() {
- String password = getInstanceProperty(PROPERTY_ADMIN_PW);
+ String password = getAttribute(PROPERTY_ADMIN_PW, "manager");
return password == null ? null : (String) EncryptionManager.decrypt(password);
}
public void setAdminPassword(String value) {
String password = value == null ? null : EncryptionManager.encrypt(value);
- setInstanceProperty(PROPERTY_ADMIN_PW, password);
+ setAttribute(PROPERTY_ADMIN_PW, password);
}
//
+ // PROPERTY_PORT_OFFSET
+ //
+ public int getPortOffset() {
+ return getAttribute(PROPERTY_PORT_OFFSET, 0);
+ }
+
+ public void setPortOffset(int value) {
+ setAttribute(PROPERTY_PORT_OFFSET, value);
+ }
+
+ //
// PROPERTY_RMI_PORT
//
public String getRMINamingPort() {
- return getInstanceProperty(PROPERTY_RMI_PORT);
+ return getAttribute(PROPERTY_RMI_PORT, "1099");
}
public void setRMINamingPort(String value) {
- setInstanceProperty(PROPERTY_RMI_PORT, value);
+ setAttribute(PROPERTY_RMI_PORT, value);
}
-
-
+ public int getActualRMINamingPort() {
+ int port = getAttribute(PROPERTY_RMI_PORT, 1099);
+ return port + getPortOffset();
+ }
+
//
// PROPERTY_HTTP_PORT
//
public String getHTTPPort() {
- return getInstanceProperty(PROPERTY_HTTP_PORT);
+ return getAttribute(PROPERTY_HTTP_PORT, "8080");
}
public void setHTTPPort(String value) {
- setInstanceProperty(PROPERTY_HTTP_PORT, value);
+ setAttribute(PROPERTY_HTTP_PORT, value);
}
-
+ public int getActualHTTPPort() {
+ int port = getAttribute(PROPERTY_HTTP_PORT, 8080);
+ return port + getPortOffset();
+ }
//
// PROPERTY_LOG_LEVEL
//
public String getConsoleLogLevel() {
- return getInstanceProperty(PROPERTY_LOG_LEVEL);
+ return getAttribute(PROPERTY_LOG_LEVEL, CONSOLE_INFO);
}
public void setConsoleLogLevel(String value) {
- setInstanceProperty(PROPERTY_LOG_LEVEL, value);
+ setAttribute(PROPERTY_LOG_LEVEL, value);
updateProgramArgsFromProperties();
}
@@ -640,12 +692,11 @@
// CLEAR_OSGI_BUNDLE_CACHE
//
public boolean isCleanOSGiBundleCache() {
- String enable = getInstanceProperty(PROPERTY_CLEAN_OSGI_BUNDLE_CACHE);
- return Boolean.valueOf(enable);
+ return getAttribute(PROPERTY_CLEAN_OSGI_BUNDLE_CACHE, false);
}
public void setCleanOSGiBundleCache(boolean value) {
- setInstanceProperty(PROPERTY_CLEAN_OSGI_BUNDLE_CACHE, Boolean.toString(value));
+ setAttribute(PROPERTY_CLEAN_OSGI_BUNDLE_CACHE, value);
updateProgramArgsFromProperties();
}
@@ -653,12 +704,11 @@
// REFRESH_OSGI_BUNDLE
//
public boolean isRefreshOSGiBundle() {
- String enable = getInstanceProperty(PROPERTY_REFRESH_OSGI_BUNDLE);
- return Boolean.valueOf(enable);
+ return getAttribute(PROPERTY_REFRESH_OSGI_BUNDLE, false);
}
public void setRefreshOSGiBundle(boolean value) {
- setInstanceProperty(PROPERTY_REFRESH_OSGI_BUNDLE, Boolean.toString(value));
+ setAttribute(PROPERTY_REFRESH_OSGI_BUNDLE, value);
}
@@ -947,7 +997,7 @@
// PROPERTY_VM_ARGS
//
public String getVMArgs() {
- String superVMArgs = getInstanceProperty(PROPERTY_VM_ARGS);
+ String superVMArgs = getAttribute(PROPERTY_VM_ARGS);
if (superVMArgs != null && superVMArgs.trim().length() > 0) {
return superVMArgs;
}
@@ -984,7 +1034,7 @@
}
public void setVMArgs(String value) {
- setInstanceProperty(PROPERTY_VM_ARGS, value);
+ setAttribute(PROPERTY_VM_ARGS, value);
}
public Set<String> getVMArgsSet() {
@@ -999,7 +1049,7 @@
// PROPERTY_PROGRAM_ARGS
//
public String getProgramArgs() {
- String superVMArgs = getInstanceProperty(PROPERTY_PROGRAM_ARGS);
+ String superVMArgs = getAttribute(PROPERTY_PROGRAM_ARGS);
if (superVMArgs != null && superVMArgs.trim().length() > 0) {
return superVMArgs;
}
@@ -1020,19 +1070,18 @@
}
public void setProgramArgs(String value) {
- setInstanceProperty(PROPERTY_PROGRAM_ARGS, value);
+ setAttribute(PROPERTY_PROGRAM_ARGS, value);
}
-
+
//
// PROPERTY_PING_DELAY
//
public int getPingDelay() {
- String pingDelay = getInstanceProperty(PROPERTY_PING_DELAY);
- return Integer.parseInt(pingDelay);
+ return getAttribute(PROPERTY_PING_DELAY, 10000);
}
- public void setPingDelay(Integer delay) {
- setInstanceProperty(PROPERTY_PING_DELAY, delay.toString());
+ public void setPingDelay(int delay) {
+ setAttribute(PROPERTY_PING_DELAY, delay);
}
@@ -1040,11 +1089,10 @@
// PROPERTY_PING_INTERVAL
//
public int getPingInterval() {
- String pingInterval = getInstanceProperty(PROPERTY_PING_INTERVAL);
- return Integer.parseInt(pingInterval);
+ return getAttribute(PROPERTY_PING_INTERVAL, 5000);
}
- public void setPingInterval(Integer interval) {
- setInstanceProperty(PROPERTY_PING_INTERVAL, interval.toString());
+ public void setPingInterval(int interval) {
+ setAttribute(PROPERTY_PING_INTERVAL, interval);
}
@@ -1052,11 +1100,10 @@
// PROPERTY_MAX_PINGS
//
public int getMaxPings() {
- String maxPings = getInstanceProperty(PROPERTY_MAX_PINGS);
- return Integer.parseInt(maxPings);
+ return getAttribute(PROPERTY_MAX_PINGS, 40);
}
- public void setMaxPings(Integer maxPings) {
- setInstanceProperty(PROPERTY_MAX_PINGS, maxPings.toString());
+ public void setMaxPings(int maxPings) {
+ setAttribute(PROPERTY_MAX_PINGS, maxPings);
}
@@ -1064,11 +1111,11 @@
// PROPERTY_PUBLISH_TIMEOUT
//
public long getPublishTimeout() {
- String timeout = getInstanceProperty(PROPERTY_PUBLISH_TIMEOUT);
- return Long.parseLong(timeout);
+ String value = getAttribute(PROPERTY_PUBLISH_TIMEOUT, "900000");
+ return Long.parseLong(value);
}
public void setPublishTimeout(long timeout) {
- setInstanceProperty(PROPERTY_PUBLISH_TIMEOUT, Long.toString(timeout));
+ setAttribute(PROPERTY_PUBLISH_TIMEOUT, String.valueOf(timeout));
}
@@ -1187,23 +1234,9 @@
}
return null;
}
-
- public String getInstanceProperty(String name) {
- return (String) getServerInstanceProperties().get(name);
- }
-
- public void setInstanceProperty(String name, String value) {
- Map map = getServerInstanceProperties();
- map.put(name, value);
- setServerInstanceProperties(map);
- }
-
- public Map getServerInstanceProperties() {
- return getAttribute(GeronimoRuntimeDelegate.SERVER_INSTANCE_PROPERTIES, new HashMap());
- }
-
- public void setServerInstanceProperties(Map map) {
- setAttribute(GeronimoRuntimeDelegate.SERVER_INSTANCE_PROPERTIES, map);
+
+ private String getAttribute(String name) {
+ return getAttribute(name, (String) null);
}
}
diff --git a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/util/ConfigSubstitutionsHelper.java b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/util/ConfigSubstitutionsHelper.java
new file mode 100644
index 0000000..46698d4
--- /dev/null
+++ b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/util/ConfigSubstitutionsHelper.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.core.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Properties;
+
+import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.st.v30.core.Activator;
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.eclipse.core.runtime.IPath;
+
+
+public class ConfigSubstitutionsHelper {
+
+ private static final String INSTRUCTION = ("# Put variables and their substitution values in this file. \n"
+ + "# They will be used when processing the corresponding config.xml. \n"
+ + "# Values in this file can be overridden by environment variables and system properties \n"
+ + "# by prefixing the property name with 'org.apache.geronimo.config.substitution.' \n"
+ + "# For example, an entry such as hostName=localhost \n"
+ + "# can be overridden by an environment variable or system property org.apache.geronimo.config.substitution.hostName=foo \n"
+ + "# When running multiple instances of Geronimo choose a PortOffset value such that none of the ports conflict. \n"
+ + "# For example, try PortOffset=10 \n");
+
+ public static final String PORT_OFFSET = "PortOffset";
+ public static final String NAMING_PORT = "NamingPort";
+ public static final String HTTP_PORT = "HTTPPort";
+
+ private final File configSubstitutionsFile;
+ private Properties properties;
+ private boolean dirty;
+
+ public ConfigSubstitutionsHelper(IPath installDirectory) {
+ configSubstitutionsFile = installDirectory.append("var/config/config-substitutions.properties").toFile();
+ }
+
+ public void load() {
+ properties = new Properties();
+ InputStream in = null;
+ try {
+ in = new FileInputStream(configSubstitutionsFile);
+ properties.load(in);
+ } catch (Exception e) {
+ // ignore - file does not have to be there
+ } finally {
+ IOUtils.close(in);
+ }
+ }
+
+ public void store() {
+ if (dirty) {
+ save();
+ dirty = false;
+ }
+ }
+
+ private void save() {
+ OutputStream out = null;
+ try {
+ out = new FileOutputStream(configSubstitutionsFile);
+ properties.store(out, INSTRUCTION);
+ } catch (Exception e) {
+ Trace.trace(Trace.ERROR, "Error saving config-substitutions.properties file", e, Activator.traceCore);
+ } finally {
+ IOUtils.close(out);
+ }
+ }
+
+ public String getProperty(String name) {
+ return properties.getProperty(name);
+ }
+
+ public String getProperty(String name, String defaultValue) {
+ return properties.getProperty(name, defaultValue);
+ }
+
+ public void setProperty(String name, String value) {
+ Object oldValue = properties.setProperty(name, value);
+ if (oldValue == null || !oldValue.equals(value)) {
+ dirty = true;
+ }
+ }
+}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/NumericVerifyListener.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/NumericVerifyListener.java
new file mode 100644
index 0000000..b4abe7a
--- /dev/null
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/NumericVerifyListener.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.ui;
+
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+
+public class NumericVerifyListener implements VerifyListener {
+
+ @Override
+ public void verifyText(VerifyEvent e) {
+ String text = e.text;
+ int length = text.length();
+ for (int i = 0; i < length; i++) {
+ char ch = text.charAt(i);
+ if (!('0' <= ch && ch <= '9')) {
+ e.doit = false;
+ break;
+ }
+ }
+ }
+}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoConsoleAction.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoConsoleAction.java
index 036d193..b65de92 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoConsoleAction.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoConsoleAction.java
@@ -66,7 +66,7 @@
if (server != null) {
GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
return new URL("http://" + server.getHost() + ":"
- + gs.getHTTPPort() + "/console/");
+ + gs.getActualHTTPPort() + "/console/");
}
return null;
}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/CheckSetPropertyCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/CheckSetPropertyCommand.java
new file mode 100644
index 0000000..9a9a922
--- /dev/null
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/CheckSetPropertyCommand.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.ui.commands;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+
+public class CheckSetPropertyCommand extends SetPropertyCommand {
+
+ private Button checkButton;
+
+ public CheckSetPropertyCommand(IServerWorkingCopy server, String propertyName, Button checkButton) {
+ super(server, propertyName, boolean.class, checkButton.getSelection());
+ this.checkButton = checkButton;
+ }
+
+ public IStatus undo(IProgressMonitor monitor, IAdaptable adapt) {
+ IStatus status = super.undo(monitor, adapt);
+ if (status.isOK()) {
+ checkButton.setData("undo");
+ boolean value = !((Boolean)newValue).booleanValue();
+ checkButton.setSelection(value);
+ // setSelection does not fire Selection event so have to do it manually
+ checkButton.notifyListeners(SWT.Selection, new Event());
+ }
+ return status;
+ }
+
+}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/ServerCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/ServerCommand.java
index 9b70157..32631fd 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/ServerCommand.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/ServerCommand.java
@@ -16,17 +16,22 @@
*/
package org.apache.geronimo.st.v30.ui.commands;
+import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
import org.eclipse.core.commands.operations.AbstractOperation;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IServerWorkingCopy;
/**
* @version $Rev$ $Date$
*/
public abstract class ServerCommand extends AbstractOperation {
+
protected IServerWorkingCopy server;
+ protected GeronimoServerDelegate gs;
public ServerCommand(IServerWorkingCopy server, String name) {
super(name);
@@ -37,17 +42,25 @@
public IStatus execute(IProgressMonitor monitor, IAdaptable adapt) {
execute();
- return null;
+ return Status.OK_STATUS;
}
public abstract void undo();
public IStatus undo(IProgressMonitor monitor, IAdaptable adapt) {
undo();
- return null;
+ return Status.OK_STATUS;
}
public IStatus redo(IProgressMonitor monitor, IAdaptable adapt) {
return execute(monitor, adapt);
}
+
+ protected GeronimoServerDelegate getGeronimoServerDelegate() {
+ gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+ if (gs == null) {
+ gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
+ }
+ return gs;
+ }
}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetCleanOSGiBundleCacheCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetCleanOSGiBundleCacheCommand.java
deleted file mode 100644
index e4e7d3c..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetCleanOSGiBundleCacheCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetCleanOSGiBundleCacheCommand extends ServerCommand {
-
- boolean value;
-
- boolean oldValue;
-
- /**
- * @param server
- * @param name
- */
- public SetCleanOSGiBundleCacheCommand(IServerWorkingCopy server, boolean value) {
- super(server, "SetCleanOSGiBundleCacheCommand");
- this.value = value;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#execute()
- */
- public void execute() {
- GeronimoServerDelegate gs = getGeronimoServer();
- oldValue = gs.isCleanOSGiBundleCache();
- gs.setCleanOSGiBundleCache(value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#undo()
- */
- public void undo() {
- getGeronimoServer().setCleanOSGiBundleCache(oldValue);
- }
-
- private GeronimoServerDelegate getGeronimoServer() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- if (gs == null) {
- gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
- }
- return gs;
- }
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetHTTPPortCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetHTTPPortCommand.java
deleted file mode 100644
index 2e128e3..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetHTTPPortCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetHTTPPortCommand extends ServerCommand {
-
- protected String name;
-
- protected String oldName;
-
- GeronimoServerDelegate gs;
-
- /**
- * @param server
- * @param name
- */
- public SetHTTPPortCommand(IServerWorkingCopy server, String name) {
- super(server, name);
- this.name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#execute()
- */
- public void execute() {
- gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- if (gs == null) {
- gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
- }
- oldName = gs.getHTTPPort();
- gs.setHTTPPort(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#undo()
- */
- public void undo() {
- if (gs != null) {
- gs.setHTTPPort(oldName);
- }
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellCommand.java
deleted file mode 100644
index a44f58e..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetKarafShellCommand extends ServerCommand {
-
- boolean value;
-
- boolean oldValue;
-
- /**
- * @param server
- * @param name
- */
- public SetKarafShellCommand(IServerWorkingCopy server, boolean value) {
- super(server, "SetKarafShellCommand");
- this.value = value;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#execute()
- */
- public void execute() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- oldValue = gs.isKarafShell();
- gs.setKarafShell(value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#undo()
- */
- public void undo() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- gs.setKarafShell(oldValue);
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellKeepAliveCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellKeepAliveCommand.java
deleted file mode 100644
index 24aae23..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellKeepAliveCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- *
- *
- * @version $Rev$ $Date$
- */
-public class SetKarafShellKeepAliveCommand extends ServerCommand {
- int value;
- int oldValue;
- Text text;
- GeronimoServerDelegate serverDelegate;
- /**
- * @param server
- * @param name
- */
- public SetKarafShellKeepAliveCommand(IServerWorkingCopy server, Text text, int value) {
- super(server, "SetKarafShellKeepAliveCommand");
- this.text = text;
- this.value = value;
- this.serverDelegate = (GeronimoServerDelegate) server.getOriginal().getAdapter(GeronimoServerDelegate.class);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#execute()
- */
- public void execute() {
- oldValue = serverDelegate.getKarafShellKeepAlive();
- server.setAttribute(GeronimoServerDelegate.PROPERTY_KARAF_SHELL_KEEPALIVE, value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#undo()
- */
- public void undo() {
- text.setText(Integer.toString(oldValue));
- server.setAttribute(GeronimoServerDelegate.PROPERTY_KARAF_SHELL_KEEPALIVE, oldValue);
- }
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellPortCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellPortCommand.java
deleted file mode 100644
index 6a3ebcf..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellPortCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- *
- *
- * @version $Rev$ $Date$
- */
-public class SetKarafShellPortCommand extends ServerCommand{
- int value;
- int oldValue;
- Text text;
- GeronimoServerDelegate serverDelegate;
- /**
- * @param server
- * @param name
- */
- public SetKarafShellPortCommand(IServerWorkingCopy server, Text text, int value) {
- super(server, "SetKarafShellPortCommand");
- this.text = text;
- this.value = value;
- this.serverDelegate = (GeronimoServerDelegate) server.getOriginal().getAdapter(GeronimoServerDelegate.class);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#execute()
- */
- public void execute() {
- oldValue = serverDelegate.getKarafShellPort();
- server.setAttribute(GeronimoServerDelegate.PROPERTY_KARAF_SHELL_PORT, value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#undo()
- */
- public void undo() {
- text.setText(Integer.toString(oldValue));
- server.setAttribute(GeronimoServerDelegate.PROPERTY_KARAF_SHELL_PORT, oldValue);
- }
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellTimeoutCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellTimeoutCommand.java
deleted file mode 100644
index 06a3105..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetKarafShellTimeoutCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- *
- *
- * @version $Rev$ $Date$
- */
-public class SetKarafShellTimeoutCommand extends ServerCommand {
- int value;
- int oldValue;
- Text text;
- GeronimoServerDelegate serverDelegate;
- /**
- * @param server
- * @param name
- */
- public SetKarafShellTimeoutCommand(IServerWorkingCopy server, Text text, int value) {
- super(server, "SetKarafShellTimeoutCommand");
- this.text = text;
- this.value = value;
- this.serverDelegate = (GeronimoServerDelegate) server.getOriginal().getAdapter(GeronimoServerDelegate.class);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#execute()
- */
- public void execute() {
- oldValue = serverDelegate.getKarafShellTimeout();
- server.setAttribute(GeronimoServerDelegate.PROPERTY_KARAF_SHELL_TIMEOUT, value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#undo()
- */
- public void undo() {
- text.setText(Integer.toString(oldValue));
- server.setAttribute(GeronimoServerDelegate.PROPERTY_KARAF_SHELL_TIMEOUT, oldValue);
- }
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetNoRedeployCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetNoRedeployCommand.java
deleted file mode 100644
index c7d3dca..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetNoRedeployCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetNoRedeployCommand extends ServerCommand {
-
- boolean value;
-
- boolean oldValue;
-
- /**
- * @param server
- * @param name
- */
- public SetNoRedeployCommand(IServerWorkingCopy server, boolean value) {
- super(server, "SetNoRedeployCommand");
- this.value = value;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#execute()
- */
- public void execute() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- oldValue = gs.isNoRedeploy();
- gs.setNoRedeploy(value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#undo()
- */
- public void undo() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- gs.setNoRedeploy(oldValue);
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPasswordCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPasswordCommand.java
deleted file mode 100644
index 1326e12..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPasswordCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetPasswordCommand extends ServerCommand {
-
- protected String name;
-
- protected String oldName;
-
- GeronimoServerDelegate gs;
-
- /**
- * @param server
- * @param name
- */
- public SetPasswordCommand(IServerWorkingCopy server, String name) {
- super(server, name);
- this.name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#execute()
- */
- public void execute() {
- gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- if (gs == null) {
- gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
- }
- oldName = gs.getAdminPassword();
- gs.setAdminPassword(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#undo()
- */
- public void undo() {
- if (gs != null) {
- gs.setAdminPassword(oldName);
- }
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPropertyCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPropertyCommand.java
new file mode 100644
index 0000000..5278cbc
--- /dev/null
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPropertyCommand.java
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.ui.commands;
+
+import java.lang.reflect.Method;
+
+import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
+import org.apache.geronimo.st.v30.ui.Activator;
+import org.apache.geronimo.st.v30.ui.internal.Trace;
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+
+public class SetPropertyCommand extends AbstractOperation {
+
+ protected final IServerWorkingCopy server;
+ protected GeronimoServerDelegate gs;
+
+ protected Object newValue;
+ protected Object oldValue;
+
+ private final String propertyName;
+ private final Class<?> propertyType;
+
+ private Method getterMethod;
+ private Method setterMethod;
+
+ public SetPropertyCommand(IServerWorkingCopy server, String propertyName, Class<?> propertyType, Object newValue) {
+ super(propertyName);
+ this.server = server;
+ this.propertyName = propertyName;
+ this.propertyType = propertyType;
+ this.newValue = newValue;
+ }
+
+ private void init() throws Exception {
+ try {
+ this.getterMethod = GeronimoServerDelegate.class.getMethod("get" + propertyName);
+ } catch (NoSuchMethodException e) {
+ this.getterMethod = GeronimoServerDelegate.class.getMethod("is" + propertyName);
+ }
+
+ String setterName = "set" + propertyName;
+ this.setterMethod = GeronimoServerDelegate.class.getMethod(setterName, new Class[] {propertyType} );
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable adapt) {
+ try {
+ init();
+ } catch (Exception e) {
+ Trace.trace(Trace.ERROR, "Internal operation error", e, Activator.logUi);
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, "Internal operation error", e);
+ }
+
+ GeronimoServerDelegate gs = getGeronimoServerDelegate();
+
+ try {
+ oldValue = getterMethod.invoke(gs);
+ setterMethod.invoke(gs, new Object[] {newValue});
+ } catch (Exception e) {
+ Trace.trace(Trace.ERROR, "Error setting " + propertyName + " property", e, Activator.logUi);
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, "Error setting " + propertyName + " property", e);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ public IStatus undo(IProgressMonitor monitor, IAdaptable adapt) {
+ if (gs != null) {
+ try {
+ setterMethod.invoke(gs, new Object[] {oldValue});
+ } catch (Exception e) {
+ Trace.trace(Trace.ERROR, "Error unsetting " + propertyName + " property", e, Activator.logUi);
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, "Error unsetting " + propertyName + " property", e);
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ public IStatus redo(IProgressMonitor monitor, IAdaptable adapt) {
+ return execute(monitor, adapt);
+ }
+
+ protected GeronimoServerDelegate getGeronimoServerDelegate() {
+ gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+ if (gs == null) {
+ gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
+ }
+ return gs;
+ }
+}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPublishTimeoutCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPublishTimeoutCommand.java
index 5c8a733..0ff35dd 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPublishTimeoutCommand.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetPublishTimeoutCommand.java
@@ -16,42 +16,39 @@
*/
package org.apache.geronimo.st.v30.ui.commands;
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Spinner;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+
/**
* @version $Rev$ $Date$
*
* Command to change the server's auto-publish setting.
*/
-public class SetPublishTimeoutCommand extends ServerCommand {
- protected long timeOut;
- protected long oldTimeOut;
-
+public class SetPublishTimeoutCommand extends SetPropertyCommand {
+
+ private Spinner spinner;
+
/**
* SetServerAutoPublishDefaultCommand constructor.
*
* @param server a server
* @param time a publish time
*/
- public SetPublishTimeoutCommand(IServerWorkingCopy server, long timeOut) {
- super(server, "SetServerAutoPublishTimeOutCommand");
- this.timeOut = timeOut;
+ public SetPublishTimeoutCommand(IServerWorkingCopy server, Spinner spinner) {
+ super(server, "PublishTimeout", long.class, spinner.getSelection() * 1000);
+ this.spinner = spinner;
}
- /**
- * Execute the command.
- */
- public void execute() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- oldTimeOut = gs.getPublishTimeout();
- gs.setPublishTimeout(timeOut);
+ public IStatus undo(IProgressMonitor monitor, IAdaptable adapt) {
+ IStatus status = super.undo(monitor, adapt);
+ if (status.isOK()) {
+ int value = (int) ((Long)oldValue).longValue() / 1000;
+ spinner.setSelection(value);
+ }
+ return status;
}
-
- /**
- * Undo the command.
- */
- public void undo() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- gs.setPublishTimeout(oldTimeOut);
- }
+
}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetRMIPortCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetRMIPortCommand.java
deleted file mode 100644
index 000abf2..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetRMIPortCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetRMIPortCommand extends ServerCommand {
-
- protected String name;
-
- protected String oldName;
-
- GeronimoServerDelegate gs;
-
- /**
- * @param server
- * @param name
- */
- public SetRMIPortCommand(IServerWorkingCopy server, String name) {
- super(server, name);
- this.name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#execute()
- */
- public void execute() {
- gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- if (gs == null) {
- gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
- }
- oldName = gs.getRMINamingPort();
- gs.setRMINamingPort(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#undo()
- */
- public void undo() {
- if (gs != null) {
- gs.setRMINamingPort(oldName);
- }
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetRefreshOSGiBundleCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetRefreshOSGiBundleCommand.java
deleted file mode 100644
index 4ae3ef1..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetRefreshOSGiBundleCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetRefreshOSGiBundleCommand extends ServerCommand {
-
-
- boolean value;
-
- boolean oldValue;
-
- public SetRefreshOSGiBundleCommand(IServerWorkingCopy server, boolean value) {
- super(server, "SetRefreshOSGiBundleCommand");
- this.value = value;
-
- }
-
- @Override
- public void execute() {
- GeronimoServerDelegate gs = getGeronimoServer();
- oldValue = gs.isRefreshOSGiBundle();
- gs.setRefreshOSGiBundle(value);
- }
-
- @Override
- public void undo() {
- getGeronimoServer().setRefreshOSGiBundle(oldValue);
- }
-
- private GeronimoServerDelegate getGeronimoServer() {
- GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- if (gs == null) {
- gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
- }
- return gs;
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetServerInstancePropertyCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetServerInstancePropertyCommand.java
deleted file mode 100644
index 859ffa1..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetServerInstancePropertyCommand.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetServerInstancePropertyCommand extends ServerCommand {
-
- Object value;
- Object oldValue;
- Class valueType;
-
- String setterName;
- String getterName;
-
- Class adapterClass;
- Object adaptedClass;
-
- public SetServerInstancePropertyCommand(IServerWorkingCopy server, Object value, String setterName, Class valueType, Class adapterClass) {
- super(server, value.toString());
- this.value = value;
- this.setterName = setterName;
- this.getterName = "get" + setterName.split("set")[1];
- this.valueType = valueType;
- this.adapterClass = adapterClass;
- }
-
- /* (non-Javadoc)
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#execute()
- */
- public void execute() {
- adaptedClass = server.getAdapter(adapterClass);
- if (adaptedClass == null) {
- adaptedClass = server.loadAdapter(adapterClass, new NullProgressMonitor());
- }
- try {
- Method getterMethod = adaptedClass.getClass().getMethod(getterName, new Class[]{});
- oldValue = getterMethod.invoke(adaptedClass, new Object[]{});
-
- Method setterMethod = adaptedClass.getClass().getMethod(setterName, new Class[]{valueType});
- setterMethod.invoke(adaptedClass, new Object[]{value});
- } catch (Exception e) {
- //TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.geronimo.st.v30.ui.commands.ServerCommand#undo()
- */
- public void undo() {
- if(adaptedClass != null) {
- try {
- Method setterMethod = adaptedClass.getClass().getMethod(setterName, new Class[]{String.class});
- setterMethod.invoke(adaptedClass, new Object[]{oldValue});
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetUsernameCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetUsernameCommand.java
deleted file mode 100644
index 6d074f4..0000000
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/SetUsernameCommand.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geronimo.st.v30.ui.commands;
-
-import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SetUsernameCommand extends ServerCommand {
-
- protected String name;
-
- protected String oldName;
-
- GeronimoServerDelegate gs;
-
- /**
- * @param server
- * @param name
- */
- public SetUsernameCommand(IServerWorkingCopy server, String name) {
- super(server, name);
- this.name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#execute()
- */
- public void execute() {
- gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
- if (gs == null) {
- gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
- }
- oldName = gs.getAdminID();
- gs.setAdminID(name);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#undo()
- */
- public void undo() {
- if (gs != null) {
- gs.setAdminID(oldName);
- }
- }
-
-}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/TextSetPropertyCommand.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/TextSetPropertyCommand.java
new file mode 100644
index 0000000..2691493
--- /dev/null
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/commands/TextSetPropertyCommand.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.ui.commands;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+
+public class TextSetPropertyCommand extends SetPropertyCommand {
+
+ private Text text;
+
+ public TextSetPropertyCommand(IServerWorkingCopy server, String propertyName, Class<?> propertyType, Object newValue, Text text) {
+ super(server, propertyName, propertyType, newValue);
+ this.text = text;
+ }
+
+ public IStatus undo(IProgressMonitor monitor, IAdaptable adapt) {
+ IStatus status = super.undo(monitor, adapt);
+ if (status.isOK()) {
+ text.setData("undo");
+ text.setText(String.valueOf(oldValue));
+ }
+ return status;
+ }
+
+}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoServerWizardFragment.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoServerWizardFragment.java
index 4095d70..4b12858 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoServerWizardFragment.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoServerWizardFragment.java
@@ -18,12 +18,7 @@
import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
import org.apache.geronimo.st.v30.ui.Activator;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TextCellEditor;
+import org.apache.geronimo.st.v30.ui.sections.PortEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -31,14 +26,9 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerPort;
import org.eclipse.wst.server.core.TaskModel;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
@@ -54,10 +44,6 @@
protected Text password;
- protected Table ports;
-
- protected TableViewer viewer;
-
/* (non-Javadoc)
* @see org.eclipse.wst.server.ui.wizard.WizardFragment#hasComposite()
*/
@@ -124,98 +110,59 @@
Group portsGroup = new Group(parent, SWT.SHADOW_IN);
portsGroup.setText(Messages.specifyPorts);
- portsGroup.setLayout(new GridLayout(2, true));
- GridData gd = new GridData();
- gd.verticalIndent = 15;
- gd.horizontalAlignment = GridData.FILL;
- gd.horizontalSpan = 2;
- portsGroup.setLayoutData(gd);
- // ports
- ports = new Table(portsGroup, SWT.V_SCROLL | SWT.H_SCROLL
- | SWT.FULL_SELECTION);
- ports.setHeaderVisible(true);
- ports.setLinesVisible(false);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ layout.marginHeight = 5;
+ layout.marginWidth = 10;
+ layout.verticalSpacing = 5;
+ layout.horizontalSpacing = 15;
+ portsGroup.setLayout(layout);
+
+ GridData gd = new GridData();
+ gd.verticalIndent = 15;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.horizontalSpan = 2;
+ portsGroup.setLayoutData(gd);
- TableColumn col = new TableColumn(ports, SWT.NONE);
- col.setText(Messages.portName);
- col.setResizable(false);
- ColumnWeightData colData = new ColumnWeightData(15, 100, false);
- TableLayout tableLayout = new TableLayout();
- tableLayout.addColumnData(colData);
-
- col = new TableColumn(ports, SWT.NONE);
- col.setText(Messages.portValue);
- col.setResizable(false);
- colData = new ColumnWeightData(8, 100, false);
- tableLayout.addColumnData(colData);
-
-
- GridData data = new GridData(GridData.FILL_HORIZONTAL
- | GridData.VERTICAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- data.heightHint = 100;
- ports.setLayoutData(data);
- ports.setLayout(tableLayout);
-
- viewer = new TableViewer(ports);
- viewer.setColumnProperties(new String[] { "name", "port" });
-
- fillTable(ports);
- addCellEditor(ports);
+ PortEditor editor = new ServerWizardPortEditor(getServer());
+ editor.init(portsGroup);
}
- private void addCellEditor(Table ports) {
- viewer.setCellEditors(new CellEditor[] { null,
- new TextCellEditor(ports) });
+ class ServerWizardPortEditor extends PortEditor {
- ICellModifier cellModifier = new ICellModifier() {
- public Object getValue(Object element, String property) {
- ServerPort sp = (ServerPort) element;
- return sp.getPort() + "";
- }
-
- public boolean canModify(Object element, String property) {
- return "port".equals(property);
- }
-
- public void modify(Object element, String property, Object value) {
- Item item = (Item) element;
- ServerPort sp = (ServerPort) item.getData();
- GeronimoServerDelegate gs = getGeronimoServer();
- gs.setInstanceProperty(sp.getId(), (String) value);
- changePortNumber(sp.getId(), Integer.parseInt((String) value));
- }
- };
-
- viewer.setCellModifier(cellModifier);
- }
-
- private void fillTable(Table ports) {
- ServerPort[] serverPorts = getServer().getServerPorts(null);
- if (serverPorts != null) {
- for (int i = 0; i < serverPorts.length; i++) {
- ServerPort port = serverPorts[i];
- TableItem item = new TableItem(ports, SWT.NONE);
- String[] s = new String[] { port.getName(),
- Integer.toString(port.getPort()) };
- item.setText(s);
- item.setImage(Activator.getImage(Activator.IMG_PORT));
- item.setData(port);
- }
+ public ServerWizardPortEditor(IServerWorkingCopy server) {
+ super(server);
}
- }
- protected void changePortNumber(String id, int port) {
- TableItem[] items = ports.getItems();
- int size = items.length;
- for (int i = 0; i < size; i++) {
- ServerPort sp = (ServerPort) items[i].getData();
- if (sp.getId().equals(id)) {
- items[i].setData(new ServerPort(id, sp.getName(), port, sp.getProtocol()));
- items[i].setText(1, port + "");
- return;
- }
+ @Override
+ protected void setPortOffset(Text portOffset) {
+ getGeronimoServer().setPortOffset(Integer.parseInt(portOffset.getText()));
}
+
+ @Override
+ protected void setRmiPort(Text rmiPort) {
+ getGeronimoServer().setRMINamingPort(rmiPort.getText());
+ }
+
+ @Override
+ protected void setHttpPort(Text httpPort) {
+ getGeronimoServer().setHTTPPort(httpPort.getText());
+ }
+
+ @Override
+ protected Label createLabel(Composite parent, String text) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(text);
+ return label;
+ }
+
+ @Override
+ protected Text createText(Composite parent, String value, int style) {
+ Text text = new Text(parent, style);
+ text.setText(value);
+ return text;
+ }
+
}
private String getServerName() {
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.java
index f33971c..026d44b 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.java
@@ -89,6 +89,7 @@
public static String debug;
public static String httpPort;
public static String rmiPort;
+ public static String portOffset;
public static String username;
public static String password;
public static String console;
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties
index 1772bf8..d1185f3 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties
@@ -92,6 +92,7 @@
editorSectionPortsDescription=Specify the ports for this server instance.
httpPort=HTTP Port:
rmiPort=RMI Naming Port:
+portOffset=Port Offset:
editorSectionLogLevelTitle=Console Output
editorSectionLogLevelDescription=Select the server console output log level.
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/PortEditor.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/PortEditor.java
new file mode 100644
index 0000000..c9143c1
--- /dev/null
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/PortEditor.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.ui.sections;
+
+import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
+import org.apache.geronimo.st.v30.ui.NumericVerifyListener;
+import org.apache.geronimo.st.v30.ui.internal.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+
+public abstract class PortEditor {
+
+ private IServerWorkingCopy server;
+ private Text portOffset;
+ private Text httpPort;
+ private Text rmiPort;
+ private Label rmiPortLabel;
+ private Label httpPortLabel;
+
+ public PortEditor(IServerWorkingCopy server) {
+ this.server = server;
+ }
+
+ public void init(Composite composite) {
+
+ final GeronimoServerDelegate delegate = getGeronimoServer();
+
+ // ------- Label and text field for the port offset -------
+ createLabel(composite, Messages.portOffset);
+
+ portOffset = createText(composite, String.valueOf(delegate.getPortOffset()), SWT.BORDER);
+ portOffset.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ portOffset.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (portOffset.getData() == null) {
+ setPortOffset(portOffset);
+ } else {
+ portOffset.setData(null);
+ }
+ httpPortLabel.setText(getActualHttpPortText());
+ rmiPortLabel.setText(getActualRmiPortText());
+ }
+ });
+ portOffset.addVerifyListener(new NumericVerifyListener());
+
+ createLabel(composite, "");
+
+
+ // ------- Label and text field for the http port -------
+ createLabel(composite, Messages.httpPort);
+
+ httpPort = createText(composite, delegate.getHTTPPort(), SWT.BORDER);
+ httpPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ httpPort.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (httpPort.getData() == null) {
+ setHttpPort(httpPort);
+ } else {
+ httpPort.setData(null);
+ }
+ httpPortLabel.setText(getActualHttpPortText());
+ }
+ });
+ httpPort.addVerifyListener(new NumericVerifyListener());
+
+ httpPortLabel = createItalicLabel(composite, getActualHttpPortText());
+ httpPortLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+
+ // ------- Label and text field for the rmi port -------
+ createLabel(composite, Messages.rmiPort);
+
+ rmiPort = createText(composite, delegate.getRMINamingPort(), SWT.BORDER);
+ rmiPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ rmiPort.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (rmiPort.getData() == null) {
+ setRmiPort(rmiPort);
+ } else {
+ rmiPort.setData(null);
+ }
+ rmiPortLabel.setText(getActualRmiPortText());
+ }
+ });
+ rmiPort.addVerifyListener(new NumericVerifyListener());
+
+ rmiPortLabel = createItalicLabel(composite, getActualRmiPortText());
+ rmiPortLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ }
+
+ private String getActualRmiPortText() {
+ GeronimoServerDelegate delegate = getGeronimoServer();
+ return "Actual: " + delegate.getActualRMINamingPort() + " ";
+ }
+
+ private String getActualHttpPortText() {
+ GeronimoServerDelegate delegate = getGeronimoServer();
+ return "Actual: " + delegate.getActualHTTPPort() + " ";
+ }
+
+ protected abstract void setPortOffset(Text portOffset);
+
+ protected abstract void setRmiPort(Text rmiPort);
+
+ protected abstract void setHttpPort(Text httpPort);
+
+
+
+ protected Label createItalicLabel(Composite parent, String text) {
+ Label l = createLabel(parent, text);
+ FontData fontData = l.getFont().getFontData()[0];
+ Font font = new Font(l.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC));
+ l.setFont(font);
+ return l;
+ }
+
+ protected abstract Label createLabel(Composite parent, String text);
+
+ protected abstract Text createText(Composite parent, String value, int style);
+
+ protected GeronimoServerDelegate getGeronimoServer() {
+ GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+ if (gs == null)
+ gs = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, null);
+ return gs;
+ }
+
+}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorCleanOSGiBundleCacheSection.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorCleanOSGiBundleCacheSection.java
index dee7eff..e613889 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorCleanOSGiBundleCacheSection.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorCleanOSGiBundleCacheSection.java
@@ -17,7 +17,7 @@
package org.apache.geronimo.st.v30.ui.sections;
import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.apache.geronimo.st.v30.ui.commands.SetCleanOSGiBundleCacheCommand;
+import org.apache.geronimo.st.v30.ui.commands.CheckSetPropertyCommand;
import org.apache.geronimo.st.v30.ui.internal.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -76,7 +76,11 @@
cleanOGSiBundelCache.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- execute(new SetCleanOSGiBundleCacheCommand(server, cleanOGSiBundelCache.getSelection()));
+ if (cleanOGSiBundelCache.getData() == null) {
+ execute(new CheckSetPropertyCommand(server, "CleanOSGiBundleCache", cleanOGSiBundelCache));
+ } else {
+ cleanOGSiBundelCache.setData(null);
+ }
}
public void widgetDefaultSelected(SelectionEvent e) {
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java
index de61c09..c675575 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java
@@ -17,10 +17,9 @@
package org.apache.geronimo.st.v30.ui.sections;
import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.apache.geronimo.st.v30.ui.commands.SetKarafShellCommand;
-import org.apache.geronimo.st.v30.ui.commands.SetKarafShellKeepAliveCommand;
-import org.apache.geronimo.st.v30.ui.commands.SetKarafShellPortCommand;
-import org.apache.geronimo.st.v30.ui.commands.SetKarafShellTimeoutCommand;
+import org.apache.geronimo.st.v30.ui.NumericVerifyListener;
+import org.apache.geronimo.st.v30.ui.commands.CheckSetPropertyCommand;
+import org.apache.geronimo.st.v30.ui.commands.TextSetPropertyCommand;
import org.apache.geronimo.st.v30.ui.internal.Messages;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
@@ -125,7 +124,11 @@
}
private void executeAndEnableWidgets() {
- execute(new SetKarafShellCommand(server, enable.getSelection()));
+ if (enable.getData() == null) {
+ execute(new CheckSetPropertyCommand(server, "KarafShell", enable));
+ } else {
+ enable.setData(null);
+ }
timeout.setEnabled(enable.getSelection());
keepAlive.setEnabled(enable.getSelection());
port.setEnabled(enable.getSelection());
@@ -139,10 +142,16 @@
timeout.setToolTipText(Messages.karafShellTimeout);
timeout.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- Integer value = Integer.valueOf(timeout.getText());
- execute(new SetKarafShellTimeoutCommand(server, timeout, value));
+ if (timeout.getData() == null) {
+ int value = Integer.parseInt(timeout.getText());
+ execute(new TextSetPropertyCommand(server, "KarafShellTimeout", int.class, value, timeout));
+ } else {
+ timeout.setData(null);
+ }
}
});
+ timeout.addVerifyListener(new NumericVerifyListener());
+
// create keep alive field
createLabel(subComp1, Messages.karafShellkeepAlive, toolkit);
keepAlive = toolkit.createText(subComp1, Integer.toString(gsdCopy.getKarafShellKeepAlive()), SWT.BORDER);
@@ -150,10 +159,16 @@
keepAlive.setToolTipText(Messages.karafShellkeepAlive);
keepAlive.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- Integer value = Integer.valueOf(keepAlive.getText());
- execute(new SetKarafShellKeepAliveCommand(server, keepAlive, value));
+ if (keepAlive.getData() == null) {
+ int value = Integer.parseInt(keepAlive.getText());
+ execute(new TextSetPropertyCommand(server, "KarafShellKeepAlive", int.class, value, keepAlive));
+ } else {
+ keepAlive.setData(null);
+ }
}
});
+ keepAlive.addVerifyListener(new NumericVerifyListener());
+
// create port field
createLabel(subComp1, Messages.karafShellPort, toolkit);
port = toolkit.createText(subComp1, Integer.toString(gsdCopy.getKarafShellPort()), SWT.BORDER);
@@ -161,9 +176,14 @@
port.setToolTipText(Messages.karafShellPort);
port.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- Integer value = Integer.valueOf(port.getText());
- execute(new SetKarafShellPortCommand(server, port, value));
+ if (port.getData() == null) {
+ int value = Integer.parseInt(port.getText());
+ execute(new TextSetPropertyCommand(server, "KarafShellPort", int.class, value, port));
+ } else {
+ port.setData(null);
+ }
}
});
+ port.addVerifyListener(new NumericVerifyListener());
}
}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPortsSection.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPortsSection.java
index 609128c..76d56a4 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPortsSection.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPortsSection.java
@@ -16,29 +16,24 @@
*/
package org.apache.geronimo.st.v30.ui.sections;
-import org.apache.geronimo.st.v30.ui.commands.SetHTTPPortCommand;
-import org.apache.geronimo.st.v30.ui.commands.SetRMIPortCommand;
+import org.apache.geronimo.st.v30.ui.commands.TextSetPropertyCommand;
import org.apache.geronimo.st.v30.ui.internal.Messages;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
/**
* @version $Rev$ $Date$
*/
public class ServerEditorPortsSection extends AbstractServerEditorSection {
-
- Text httpPort;
-
- Text rmiPort;
-
+
public ServerEditorPortsSection() {
super();
}
@@ -58,8 +53,9 @@
section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Composite composite = toolkit.createComposite(section);
+
GridLayout layout = new GridLayout();
- layout.numColumns = 2;
+ layout.numColumns = 3;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
@@ -67,42 +63,47 @@
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
section.setClient(composite);
-
- // ------- Label and text field for the http port -------
- createLabel(composite, Messages.httpPort, toolkit);
-
- httpPort = toolkit.createText(composite, getHTTPPort(), SWT.BORDER);
- httpPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- httpPort.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- execute(new SetHTTPPortCommand(server, httpPort.getText()));
- }
- });
-
- // ------- Label and text field for the rmi port -------
- createLabel(composite, Messages.rmiPort, toolkit);
-
- rmiPort = toolkit.createText(composite, getRMIPort(), SWT.BORDER);
- rmiPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- rmiPort.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- execute(new SetRMIPortCommand(server, rmiPort.getText()));
- }
- });
+
+ PortEditor editor = new ServerEditorPortEditor(toolkit, server);
+ editor.init(composite);
}
- private String getHTTPPort() {
- if (gs != null) {
- return gs.getHTTPPort();
- }
- return "";
- }
+ private class ServerEditorPortEditor extends PortEditor {
- private String getRMIPort() {
- if (gs != null) {
- return gs.getRMINamingPort();
+ FormToolkit toolkit;
+
+ public ServerEditorPortEditor(FormToolkit toolkit, IServerWorkingCopy server) {
+ super(server);
+ this.toolkit = toolkit;
}
- return "";
+
+ @Override
+ protected Text createText(Composite parent, String value, int style) {
+ return toolkit.createText(parent, value, style);
+ }
+
+ @Override
+ protected Label createLabel(Composite parent, String value) {
+ return ServerEditorPortsSection.this.createLabel(parent, value, toolkit);
+ }
+
+ @Override
+ protected void setPortOffset(Text portOffset) {
+ int value = Integer.parseInt(portOffset.getText());
+ execute(new TextSetPropertyCommand(server, "PortOffset", int.class, value, portOffset));
+ }
+
+ @Override
+ protected void setRmiPort(Text rmiPort) {
+ String value = rmiPort.getText();
+ execute(new TextSetPropertyCommand(server, "RMINamingPort", String.class, value, rmiPort));
+ }
+
+ @Override
+ protected void setHttpPort(Text httpPort) {
+ String value = httpPort.getText();
+ execute(new TextSetPropertyCommand(server, "HTTPPort", String.class, value, httpPort));
+ }
}
}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPublishAdvancedSection.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPublishAdvancedSection.java
index 250043a..1895331 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPublishAdvancedSection.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorPublishAdvancedSection.java
@@ -17,10 +17,9 @@
package org.apache.geronimo.st.v30.ui.sections;
import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.apache.geronimo.st.v30.ui.commands.SetNoRedeployCommand;
+import org.apache.geronimo.st.v30.ui.commands.CheckSetPropertyCommand;
import org.apache.geronimo.st.v30.ui.commands.SetNoRedeployFilePatternCommand;
import org.apache.geronimo.st.v30.ui.commands.SetPublishTimeoutCommand;
-import org.apache.geronimo.st.v30.ui.commands.SetRefreshOSGiBundleCommand;
import org.apache.geronimo.st.v30.ui.internal.Messages;
import org.apache.geronimo.st.v30.ui.wizards.ListEditorWizard;
import org.eclipse.jface.wizard.Wizard;
@@ -86,13 +85,17 @@
publishTimeout = new Spinner(composite, SWT.BORDER);
publishTimeout.setMinimum(0);
- publishTimeout.setIncrement(5);
- publishTimeout.setMaximum(900);
+ publishTimeout.setIncrement(60);
+ publishTimeout.setMaximum(60 * 60 * 4); // 4 hours
publishTimeout.setSelection((int) gs.getPublishTimeout() / 1000);
publishTimeout.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- execute(new SetPublishTimeoutCommand(server, publishTimeout.getSelection() * 1000));
+ if (publishTimeout.getData() == null) {
+ execute(new SetPublishTimeoutCommand(server, publishTimeout));
+ } else {
+ publishTimeout.setData(null);
+ }
}
});
@@ -100,7 +103,11 @@
refreshOSGiBundle.setSelection(gs.isRefreshOSGiBundle());
refreshOSGiBundle.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- execute(new SetRefreshOSGiBundleCommand(server, refreshOSGiBundle.getSelection()));
+ if (refreshOSGiBundle.getData() == null) {
+ execute(new CheckSetPropertyCommand(server, "RefreshOSGiBundle", refreshOSGiBundle));
+ } else {
+ refreshOSGiBundle.setData(null);
+ }
}
});
Label refreshOSGiLabel = toolkit.createLabel(composite, Messages.refreshOSGiBundleDescription, SWT.WRAP);
@@ -175,7 +182,11 @@
noRedeploy.setEnabled(!(server.getServerType().supportsRemoteHosts() && !SocketUtil.isLocalhost(server.getHost())));
noRedeploy.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- execute(new SetNoRedeployCommand(server, noRedeploy.getSelection()));
+ if (noRedeploy.getData() == null) {
+ execute(new CheckSetPropertyCommand(server, "NoRedeploy", noRedeploy));
+ } else {
+ noRedeploy.setData(null);
+ }
includesEditor.setEnabled(noRedeploy.getSelection());
excludesEditor.setEnabled(noRedeploy.getSelection());
}
@@ -184,6 +195,7 @@
}
});
+
noRedeploy.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
Label noRedeployLabel = toolkit.createLabel(composite, Messages.noRedeployOptionDescription, SWT.WRAP);
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorSecuritySection.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorSecuritySection.java
index 719a427..9df32fd 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorSecuritySection.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorSecuritySection.java
@@ -19,8 +19,7 @@
import org.apache.geronimo.st.v30.core.operations.GeronimoAccountManager;
import org.apache.geronimo.st.v30.ui.Activator;
import org.apache.geronimo.st.v30.ui.CommonMessages;
-import org.apache.geronimo.st.v30.ui.commands.SetPasswordCommand;
-import org.apache.geronimo.st.v30.ui.commands.SetUsernameCommand;
+import org.apache.geronimo.st.v30.ui.commands.TextSetPropertyCommand;
import org.apache.geronimo.st.v30.ui.internal.Messages;
import org.apache.geronimo.st.v30.ui.internal.Trace;
import org.apache.geronimo.st.v30.ui.wizards.ManageAccountWizard;
@@ -37,7 +36,6 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
@@ -96,7 +94,12 @@
username.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
username.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- execute(new SetUsernameCommand(server, username.getText()));
+ if (username.getData() == null) {
+ String value = username.getText();
+ execute(new TextSetPropertyCommand(server, "AdminID", String.class, value, username));
+ } else {
+ username.setData(null);
+ }
}
});
@@ -107,7 +110,12 @@
password.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
password.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- execute(new SetPasswordCommand(server, password.getText()));
+ if (password.getData() == null) {
+ String value = password.getText();
+ execute(new TextSetPropertyCommand(server, "AdminPassword", String.class, value, password));
+ } else {
+ password.setData(null);
+ }
}
});
// ----- Button manage account -----
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorStartupSection.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorStartupSection.java
index 039fe53..a3c4752 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorStartupSection.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorStartupSection.java
@@ -16,8 +16,8 @@
*/
package org.apache.geronimo.st.v30.ui.sections;
-import org.apache.geronimo.st.v30.core.IGeronimoServer;
-import org.apache.geronimo.st.v30.ui.commands.SetServerInstancePropertyCommand;
+import org.apache.geronimo.st.v30.ui.NumericVerifyListener;
+import org.apache.geronimo.st.v30.ui.commands.TextSetPropertyCommand;
import org.apache.geronimo.st.v30.ui.internal.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -82,10 +82,15 @@
pingDelay.setToolTipText(Messages.pingDelayTooltip);
pingDelay.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- Integer value = Integer.valueOf(pingDelay.getText());
- execute(new SetServerInstancePropertyCommand(server, value, "setPingDelay", Integer.class, IGeronimoServer.class));
+ if (pingDelay.getData() == null) {
+ int value = Integer.parseInt(pingDelay.getText());
+ execute(new TextSetPropertyCommand(server, "PingDelay", int.class, value, pingDelay));
+ } else {
+ pingDelay.setData(null);
+ }
}
});
+ pingDelay.addVerifyListener(new NumericVerifyListener());
// ------- Label and text field for the ping interval -------
createLabel(composite, Messages.pingInterval, toolkit);
@@ -94,10 +99,15 @@
pingInterval.setToolTipText(Messages.pingIntervalTooltip);
pingInterval.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- Integer value = Integer.valueOf(pingInterval.getText());
- execute(new SetServerInstancePropertyCommand(server, value, "setPingInterval", Integer.class, IGeronimoServer.class));
+ if (pingInterval.getData() == null) {
+ int value = Integer.parseInt(pingInterval.getText());
+ execute(new TextSetPropertyCommand(server, "PingInterval", int.class, value, pingInterval));
+ } else {
+ pingInterval.setData(null);
+ }
}
});
+ pingInterval.addVerifyListener(new NumericVerifyListener());
// ------- Label and text field for the max pings -------
createLabel(composite, Messages.maxPings, toolkit);
@@ -106,10 +116,15 @@
maxPings.setToolTipText(Messages.maxPingsTooltip);
maxPings.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- Integer value = Integer.valueOf(maxPings.getText());
- execute(new SetServerInstancePropertyCommand(server, value, "setMaxPings", Integer.class, IGeronimoServer.class));
+ if (maxPings.getData() == null) {
+ int value = Integer.parseInt(maxPings.getText());
+ execute(new TextSetPropertyCommand(server, "MaxPings", int.class, value, maxPings));
+ } else {
+ maxPings.setData(null);
+ }
}
});
+ maxPings.addVerifyListener(new NumericVerifyListener());
}
public String getMaxPings() {