Author: adietish
Date: 2011-06-28 10:10:55 -0400 (Tue, 28 Jun 2011)
New Revision: 32404
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchConfigUtils.java
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-9215] created util class to set the launch config attributes. refactored the code
accordingly
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchConfigUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchConfigUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchConfigUtils.java 2011-06-28
14:10:55 UTC (rev 32404)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.rse.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+
+/**
+ * @author André Dietisheim
+ */
+public class RSELaunchConfigUtils {
+
+ 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 static boolean isDetectStartupCommand(ILaunchConfiguration launchConfig) throws
CoreException {
+ return isDetectStartupCommand(launchConfig, true);
+ }
+
+ public static boolean isDetectStartupCommand(ILaunchConfiguration launchConfig, boolean
defaultValue)
+ throws CoreException {
+ return launchConfig.getAttribute(DETECT_STARTUP_COMMAND, defaultValue);
+ }
+
+ public static void setDetectStartupCommand(boolean detectStartup,
ILaunchConfigurationWorkingCopy launchConfig) {
+ launchConfig.setAttribute(DETECT_STARTUP_COMMAND, detectStartup);
+ }
+
+ public static boolean isDetectShutdownCommand(ILaunchConfiguration launchConfig) throws
CoreException {
+ return isDetectShutdownCommand(launchConfig, true);
+ }
+
+ public static boolean isDetectShutdownCommand(ILaunchConfiguration launchConfig, boolean
defaultValue)
+ throws CoreException {
+ return launchConfig.getAttribute(DETECT_SHUTDOWN_COMMAND, defaultValue);
+ }
+
+ public static void setDetectShutdownCommand(boolean detectShutdown,
ILaunchConfigurationWorkingCopy launchConfig) {
+ launchConfig.setAttribute(DETECT_SHUTDOWN_COMMAND, detectShutdown);
+ }
+
+ public static void setStartupCommand(String startupCommand,
ILaunchConfigurationWorkingCopy launchConfig) {
+ launchConfig.setAttribute(RSE_STARTUP_COMMAND, startupCommand);
+ }
+
+ public static String getStartupCommand(ILaunchConfiguration launchConfig) throws
CoreException {
+ return getStartupCommand(launchConfig, (String) null);
+ }
+
+ public static String getStartupCommand(ILaunchConfiguration launchConfig, String
defaultCommand)
+ throws CoreException {
+ return launchConfig.getAttribute(RSE_STARTUP_COMMAND, defaultCommand);
+ }
+
+ public static void setShutdownCommand(String shutdownCommand,
ILaunchConfigurationWorkingCopy launchConfig) {
+ launchConfig.setAttribute(RSE_SHUTDOWN_COMMAND, shutdownCommand);
+ }
+
+ public static String getShutdownCommand(ILaunchConfiguration launchConfig) throws
CoreException {
+ return getShutdownCommand(launchConfig, (String) null);
+ }
+
+ public static String getShutdownCommand(ILaunchConfiguration launchConfig, String
defaultCommand)
+ throws CoreException {
+ return launchConfig.getAttribute(RSE_SHUTDOWN_COMMAND, defaultCommand);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchConfigUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2011-06-28
12:50:27 UTC (rev 32403)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java 2011-06-28
14:10:55 UTC (rev 32404)
@@ -52,12 +52,7 @@
public class RSELaunchDelegate implements StartLaunchDelegate,
IStartLaunchSetupParticipant {
- 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,
@@ -70,7 +65,7 @@
}
beh.setServerStarting();
- String command = configuration.getAttribute(RSE_STARTUP_COMMAND, (String)null);
+ String command = RSELaunchConfigUtils.getStartupCommand(configuration);
try {
ServerShellModel model = RSEHostShellModel.getInstance().getModel(beh.getServer());
IHostShell shell = model.createStartupShell("/", command, new String[]{},
new NullProgressMonitor());
@@ -128,7 +123,7 @@
config = behaviour.getServer().getLaunchConfiguration(false, new
NullProgressMonitor());
String defaultCmd = getDefaultStopCommand(behaviour.getServer(), true);
command2 = config == null ? defaultCmd :
- config.getAttribute(RSE_SHUTDOWN_COMMAND, defaultCmd);
+ RSELaunchConfigUtils.getShutdownCommand(config, defaultCmd);
behaviour.setServerStopping();
ServerShellModel model =
RSEHostShellModel.getInstance().getModel(behaviour.getServer());
model.executeRemoteCommand("/", command2, new String[]{}, new
NullProgressMonitor(), 10000, true);
@@ -166,18 +161,16 @@
public void setupLaunchConfiguration(
ILaunchConfigurationWorkingCopy workingCopy, IServer server)
throws CoreException {
- 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);
+ boolean detectStartupCommand = RSELaunchConfigUtils.isDetectStartupCommand(workingCopy,
true);
+ String currentStartupCmd = RSELaunchConfigUtils.getStartupCommand(workingCopy);
if( detectStartupCommand || currentStartupCmd == null ||
"".equals(currentStartupCmd)) {
- workingCopy.setAttribute(RSELaunchDelegate.RSE_STARTUP_COMMAND,
getDefaultLaunchCommand(workingCopy));
+ RSELaunchConfigUtils.setStartupCommand(getDefaultLaunchCommand(workingCopy),
workingCopy);
}
- String currentStopCmd =
workingCopy.getAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND, (String)null);
+ boolean detectShutdownCommand =
RSELaunchConfigUtils.isDetectShutdownCommand(workingCopy, true);
+ String currentStopCmd = RSELaunchConfigUtils.getShutdownCommand(workingCopy);
if( detectShutdownCommand || currentStopCmd == null ||
"".equals(currentStopCmd)) {
- workingCopy.setAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND,
getDefaultStopCommand(server));
+ RSELaunchConfigUtils.setShutdownCommand(getDefaultStopCommand(server), workingCopy);
}
/*
* /usr/lib/jvm/jre/bin/java -Dprogram.name=run.sh -server -Xms1530M -Xmx1530M
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 2011-06-28
12:50:27 UTC (rev 32403)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSELaunchTabProvider.java 2011-06-28
14:10:55 UTC (rev 32404)
@@ -27,6 +27,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
+import org.jboss.ide.eclipse.as.rse.core.RSELaunchConfigUtils;
import org.jboss.ide.eclipse.as.rse.core.RSELaunchDelegate;
import org.jboss.ide.eclipse.as.ui.UIUtil;
import
org.jboss.ide.eclipse.as.ui.launch.JBossLaunchConfigurationTabGroup.IJBossLaunchTabProvider;
@@ -121,16 +122,16 @@
this.initialConfig = configuration;
try {
- String startCommand =
configuration.getAttribute(RSELaunchDelegate.RSE_STARTUP_COMMAND, "");
+ String startCommand = RSELaunchConfigUtils.getStartupCommand(configuration);
startText.setText(startCommand);
- boolean detectStartCommand =
configuration.getAttribute(RSELaunchDelegate.DETECT_STARTUP_COMMAND, true);
+ boolean detectStartCommand =
RSELaunchConfigUtils.isDetectStartupCommand(configuration, true);
autoStartArgs.setSelection(detectStartCommand);
startText.setEditable(!detectStartCommand);
startText.setEnabled(!detectStartCommand);
- String stopCommand =
configuration.getAttribute(RSELaunchDelegate.RSE_SHUTDOWN_COMMAND, "");
+ String stopCommand = RSELaunchConfigUtils.getShutdownCommand(configuration);
stopText.setText(stopCommand);
- boolean detectStopCommand =
configuration.getAttribute(RSELaunchDelegate.DETECT_SHUTDOWN_COMMAND, true);
+ boolean detectStopCommand =
RSELaunchConfigUtils.isDetectShutdownCommand(configuration, true);
autoStopArgs.setSelection(detectStopCommand);
stopText.setEditable(!detectStopCommand);
stopText.setEnabled(!detectStopCommand);
@@ -140,10 +141,10 @@
}
}
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());
+ RSELaunchConfigUtils.setStartupCommand(startText.getText(), configuration);
+ RSELaunchConfigUtils.setShutdownCommand(stopText.getText(), configuration);
+ RSELaunchConfigUtils.setDetectStartupCommand(autoStartArgs.getSelection(),
configuration);
+ RSELaunchConfigUtils.setDetectShutdownCommand(autoStopArgs.getSelection(),
configuration);
}
public String getName() {
return RSEUIMessages.RSE_REMOTE_LAUNCH;