Author: rob.stryker(a)jboss.com
Date: 2010-09-22 06:54:39 -0400 (Wed, 22 Sep 2010)
New Revision: 25082
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSELaunchTabProvider.java
Log:
JBIDE-7121 - updating launch config UI to more fit user expectations
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java 2010-09-22
10:37:35 UTC (rev 25081)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java 2010-09-22
10:54:39 UTC (rev 25082)
@@ -36,6 +36,7 @@
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
+import
org.jboss.ide.eclipse.as.core.server.internal.launch.AbstractJBossLaunchConfigType;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.IStartLaunchSetupParticipant;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.StartLaunchDelegate;
@@ -49,7 +50,10 @@
public static final String RSE_STARTUP_COMMAND =
"org.jboss.ide.eclipse.as.rse.core.RSELaunchDelegate.STARTUP_COMMAND";
public static final String RSE_SHUTDOWN_COMMAND =
"org.jboss.ide.eclipse.as.rse.core.RSELaunchDelegate.SHUTDOWN_COMMAND";
+ public static final String DETECT_STARTUP_COMMAND =
"org.jboss.ide.eclipse.as.rse.core.RSELaunchDelegate.DETECT_STARTUP_COMMAND";
+ public static final String DETECT_SHUTDOWN_COMMAND =
"org.jboss.ide.eclipse.as.rse.core.RSELaunchDelegate.DETECT_SHUTDOWN_COMMAND";
+
public void actualLaunch(
JBossServerStartupLaunchConfiguration launchConfig,
ILaunchConfiguration configuration, String mode, ILaunch launch,
@@ -195,46 +199,18 @@
public void setupLaunchConfiguration(
ILaunchConfigurationWorkingCopy workingCopy, IServer server)
throws CoreException {
- String rseHome = server.getAttribute(RSEUtils.RSE_SERVER_HOME_DIR, "");
+ boolean detectStartupCommand, detectShutdownCommand;
+ detectStartupCommand = workingCopy.getAttribute(DETECT_STARTUP_COMMAND, true);
+ detectShutdownCommand = workingCopy.getAttribute(DETECT_SHUTDOWN_COMMAND, true);
+
String currentStartupCmd =
workingCopy.getAttribute(RSELaunchDelegate.RSE_STARTUP_COMMAND, (String)null);
- if( currentStartupCmd == null || "".equals(currentStartupCmd)) {
- // initialize startup command to something reasonable
- String currentArgs =
workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
""); //$NON-NLS-1$
- String currentVMArgs =
workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
""); //$NON-NLS-1$
-
- currentVMArgs= ArgsUtil.setArg(currentVMArgs, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
- new Path(rseHome).append(
- IJBossRuntimeResourceConstants.LIB).append(
- IJBossRuntimeResourceConstants.ENDORSED).toOSString(), true);
-
- String libPath = new Path(rseHome).append(IJBossRuntimeResourceConstants.BIN)
- .append(IJBossRuntimeResourceConstants.NATIVE).toOSString();
- currentVMArgs= ArgsUtil.setArg(currentVMArgs, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JAVA_LIB_PATH,
- libPath, true);
-
-
- String cmd = "java " + currentVMArgs + "-classpath " +
- new Path(rseHome).append(IJBossRuntimeResourceConstants.BIN).append(
- IJBossRuntimeResourceConstants.START_JAR).toString() + IJBossRuntimeConstants.SPACE
+
- IJBossRuntimeConstants.START_MAIN_TYPE + IJBossRuntimeConstants.SPACE + currentArgs
+ "&";
- workingCopy.setAttribute(RSELaunchDelegate.RSE_STARTUP_COMMAND, cmd);
+ if( detectStartupCommand || currentStartupCmd == null ||
"".equals(currentStartupCmd)) {
+ workingCopy.setAttribute(RSELaunchDelegate.RSE_STARTUP_COMMAND,
getDefaultLaunchCommand(workingCopy));
}
String currentStopCmd =
workingCopy.getAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND, (String)null);
- if( currentStopCmd == null || "".equals(currentStopCmd)) {
- JBossServer jbs = ServerConverter.getJBossServer(server);
- // initialize stop command to something reasonable
- String username = jbs.getUsername();
- String pass = jbs.getPassword();
-
- String stop = new
Path(rseHome).append(IJBossRuntimeResourceConstants.BIN).append(IJBossRuntimeResourceConstants.SHUTDOWN_SH).toString()
+
- IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.SHUTDOWN_STOP_ARG +
IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.SHUTDOWN_SERVER_ARG +
- IJBossRuntimeConstants.SPACE + server.getHost() + IJBossRuntimeConstants.SPACE +
- IJBossRuntimeConstants.SHUTDOWN_USER_ARG + IJBossRuntimeConstants.SPACE +
- username + IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.SHUTDOWN_PASS_ARG +
IJBossRuntimeConstants.SPACE + pass;
- workingCopy.setAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND, stop);
+ if( detectShutdownCommand || currentStopCmd == null ||
"".equals(currentStopCmd)) {
+ workingCopy.setAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND,
getDefaultStopCommand(server));
}
/*
* /usr/lib/jvm/jre/bin/java -Dprogram.name=run.sh -server -Xms1530M -Xmx1530M
@@ -251,6 +227,54 @@
*/
}
+ public static String getDefaultStopCommand(IServer server) {
+ String rseHome = server.getAttribute(RSEUtils.RSE_SERVER_HOME_DIR, "");
+ JBossServer jbs = ServerConverter.getJBossServer(server);
+ // initialize stop command to something reasonable
+ String username = jbs.getUsername();
+ String pass = jbs.getPassword();
+
+ String stop = new
Path(rseHome).append(IJBossRuntimeResourceConstants.BIN).append(IJBossRuntimeResourceConstants.SHUTDOWN_SH).toString()
+
+ IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.SHUTDOWN_STOP_ARG +
IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.SHUTDOWN_SERVER_ARG +
+ IJBossRuntimeConstants.SPACE + server.getHost() + IJBossRuntimeConstants.SPACE +
+ IJBossRuntimeConstants.SHUTDOWN_USER_ARG + IJBossRuntimeConstants.SPACE +
+ username + IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.SHUTDOWN_PASS_ARG +
IJBossRuntimeConstants.SPACE + pass;
+ return stop;
+ }
+
+ public static IServer findServer(ILaunchConfiguration config) throws CoreException {
+ String serverId = config.getAttribute("server-id", (String)null);
+ JBossServer jbs = AbstractJBossLaunchConfigType.findJBossServer(serverId);
+ return jbs.getServer();
+ }
+
+ public static String getDefaultLaunchCommand(ILaunchConfiguration config) throws
CoreException {
+ IServer server = findServer(config);
+ String rseHome = server.getAttribute(RSEUtils.RSE_SERVER_HOME_DIR, "");
+ // initialize startup command to something reasonable
+ String currentArgs =
config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
""); //$NON-NLS-1$
+ String currentVMArgs =
config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
//$NON-NLS-1$
+
+ currentVMArgs= ArgsUtil.setArg(currentVMArgs, null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
+ new Path(rseHome).append(
+ IJBossRuntimeResourceConstants.LIB).append(
+ IJBossRuntimeResourceConstants.ENDORSED).toOSString(), true);
+
+ String libPath = new Path(rseHome).append(IJBossRuntimeResourceConstants.BIN)
+ .append(IJBossRuntimeResourceConstants.NATIVE).toOSString();
+ currentVMArgs= ArgsUtil.setArg(currentVMArgs, null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JAVA_LIB_PATH,
+ libPath, true);
+
+
+ String cmd = "java " + currentVMArgs + "-classpath " +
+ new Path(rseHome).append(IJBossRuntimeResourceConstants.BIN).append(
+ IJBossRuntimeResourceConstants.START_JAR).toString() + IJBossRuntimeConstants.SPACE
+
+ IJBossRuntimeConstants.START_MAIN_TYPE + IJBossRuntimeConstants.SPACE + currentArgs
+ "&";
+ return cmd;
+ }
+
protected static IShellService findShellService(JBossServerBehavior behaviour) throws
CoreException {
String connectionName = RSEUtils.getRSEConnectionName(behaviour.getServer());
IHost host = RSEUtils.findHost(connectionName);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSELaunchTabProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSELaunchTabProvider.java 2010-09-22
10:37:35 UTC (rev 25081)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSELaunchTabProvider.java 2010-09-22
10:54:39 UTC (rev 25082)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.rse.ui;
import org.eclipse.core.runtime.CoreException;
@@ -7,14 +18,14 @@
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.ide.eclipse.as.rse.core.RSELaunchDelegate;
import org.jboss.ide.eclipse.as.ui.UIUtil;
@@ -31,49 +42,99 @@
public static class RSERemoteLaunchTab extends AbstractLaunchConfigurationTab {
- private Text startText;
- private Text stopText;
+ private Text startText,stopText;
+ private Button autoStartArgs, autoStopArgs;
+ private ILaunchConfiguration initialConfig;
+
public void createControl(Composite parent) {
createUI(parent);
addListeners();
}
public void createUI(Composite parent) {
- Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_HORIZONTAL);
+ Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_HORIZONTAL|
GridData.FILL_VERTICAL);
setControl(comp);
comp.setLayout(new FormLayout());
Group startGroup = new Group(comp, SWT.NONE);
startGroup.setText("Start Command");
- FormData data = UIUtil.createFormData2(0, 5, 0, 75, 0, 5, 100, -5);
+ FormData data = UIUtil.createFormData2(0, 5, 0, 150, 0, 5, 100, -5);
startGroup.setLayoutData(data);
startGroup.setLayout(new FormLayout());
+
+ autoStartArgs = new Button(startGroup, SWT.CHECK);
+ autoStartArgs.setText("Automatically calculate");
+ data = UIUtil.createFormData2(null, 0, 100, -5, 0, 5, 100, -5);
+ autoStartArgs.setLayoutData(data);
+
startText = new Text(startGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP);
- data = UIUtil.createFormData2(0, 5, 100, -5, 0, 5, 100, -5);
+ data = UIUtil.createFormData2(0, 5, autoStartArgs, -5, 0, 5, 100, -5);
startText.setLayoutData(data);
-
+
+ // start stop group
Group stopGroup = new Group(comp, SWT.NONE);
stopGroup.setText("Stop Command");
- data = UIUtil.createFormData2(startGroup, 5, startGroup, 150, 0, 5, 100, -5);
+ data = UIUtil.createFormData2(startGroup, 5, startGroup, 300, 0, 5, 100, -5);
stopGroup.setLayoutData(data);
stopGroup.setLayout(new FormLayout());
+
+ autoStopArgs = new Button(stopGroup, SWT.CHECK);
+ autoStopArgs.setText("Automatically calculate");
+ data = UIUtil.createFormData2(null, 0, 100, -5, 0, 5, 100, -5);
+ autoStopArgs.setLayoutData(data);
+
+
stopText = new Text(stopGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP);
- data = UIUtil.createFormData2(0, 5, 100, -5, 0, 5, 100, -5);
+ data = UIUtil.createFormData2(0, 5, autoStopArgs, -5, 0, 5, 100, -5);
stopText.setLayoutData(data);
}
protected void addListeners() {
+ autoStartArgs.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ startText.setEditable(!autoStartArgs.getSelection());
+ startText.setEnabled(!autoStartArgs.getSelection());
+ if( autoStartArgs.getSelection()) {
+ String command = null;
+ try {
+ command = RSELaunchDelegate.getDefaultLaunchCommand(initialConfig);
+ startText.setText(command);
+ } catch(CoreException ce) {
+ // TODO
+ }
+ }
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }});
+ autoStopArgs.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ stopText.setEditable(!autoStopArgs.getSelection());
+ stopText.setEnabled(!autoStopArgs.getSelection());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }});
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
}
public void initializeFrom(ILaunchConfiguration configuration) {
+ this.initialConfig = configuration;
+
try {
String startCommand =
configuration.getAttribute(RSELaunchDelegate.RSE_STARTUP_COMMAND, "");
startText.setText(startCommand);
+ boolean detectStartCommand =
configuration.getAttribute(RSELaunchDelegate.DETECT_STARTUP_COMMAND, true);
+ autoStartArgs.setSelection(detectStartCommand);
+ startText.setEditable(!detectStartCommand);
+ startText.setEnabled(!detectStartCommand);
String stopCommand =
configuration.getAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND, "");
stopText.setText(stopCommand);
+ boolean detectStopCommand =
configuration.getAttribute(RSELaunchDelegate.DETECT_SHUTDOWN_COMMAND, true);
+ autoStopArgs.setSelection(detectStopCommand);
+ stopText.setEditable(!detectStopCommand);
+ stopText.setEnabled(!detectStopCommand);
+
} catch( CoreException ce) {
// TODO
}
@@ -81,6 +142,8 @@
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(RSELaunchDelegate.RSE_STARTUP_COMMAND,
startText.getText());
configuration.setAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND,
stopText.getText());
+ configuration.setAttribute(RSELaunchDelegate.DETECT_STARTUP_COMMAND,
autoStartArgs.getSelection());
+ configuration.setAttribute(RSELaunchDelegate.DETECT_SHUTDOWN_COMMAND,
autoStopArgs.getSelection());
}
public String getName() {
return "RSE Remote Launch";