Author: koen.aers(a)jboss.com
Date: 2012-06-04 11:37:24 -0400 (Mon, 04 Jun 2012)
New Revision: 41685
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeRuntimesPreferences.java
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/preferences/ForgeStartupPreferencePage.java
Log:
JBIDE-11998: Make a preference option that can toggle launching Forge in RUN/DEBUG mode
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeRuntimesPreferences.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeRuntimesPreferences.java 2012-06-04
15:29:33 UTC (rev 41684)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeRuntimesPreferences.java 2012-06-04
15:37:24 UTC (rev 41685)
@@ -37,6 +37,7 @@
public static final String PREF_FORGE_RUNTIMES =
"org.jboss.tools.forge.core.runtimes";
public static final String PREF_FORGE_STARTUP =
"org.jboss.tools.forge.core.startup";
+ public static final String PREF_FORGE_START_IN_DEBUG =
"org.jboss.tools.forge.core.startInDebug";
public static final ForgeRuntimesPreferences INSTANCE = new ForgeRuntimesPreferences();
@@ -64,6 +65,10 @@
}
+ public boolean getStartInDebug() {
+ return getForgeCorePreferences().getBoolean(PREF_FORGE_START_IN_DEBUG, false);
+ }
+
private IEclipsePreferences getForgeCorePreferences() {
return InstanceScope.INSTANCE.getNode(ForgeCorePlugin.PLUGIN_ID);
}
@@ -152,13 +157,25 @@
public void setStartup(boolean startup) {
try {
- IEclipsePreferences eclipsePreferences = getForgeCorePreferences();
- eclipsePreferences.putBoolean(PREF_FORGE_STARTUP, startup);
- eclipsePreferences.flush();
+ setBoolean(PREF_FORGE_STARTUP, startup);
} catch (BackingStoreException e) {
ForgeCorePlugin.log(e);
}
}
+
+ public void setStartInDebug(boolean startup) {
+ try {
+ setBoolean(PREF_FORGE_START_IN_DEBUG, startup);
+ } catch (BackingStoreException e) {
+ ForgeCorePlugin.log(e);
+ }
+ }
+
+ private void setBoolean(String prefKey, boolean startup) throws BackingStoreException {
+ IEclipsePreferences eclipsePreferences = getForgeCorePreferences();
+ eclipsePreferences.putBoolean(prefKey, startup);
+ eclipsePreferences.flush();
+ }
public void addPreferenceChangeListener(IPreferenceChangeListener listener) {
getForgeCorePreferences().addPreferenceChangeListener(listener);
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java 2012-06-04
15:29:33 UTC (rev 41684)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java 2012-06-04
15:37:24 UTC (rev 41685)
@@ -17,6 +17,7 @@
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.jboss.tools.forge.core.ForgeCorePlugin;
+import org.jboss.tools.forge.core.preferences.ForgeRuntimesPreferences;
public class ForgeLaunchHelper {
@@ -65,7 +66,7 @@
if (workingCopy != null) {
try {
LAUNCH_MANAGER.addLaunchListener(new ForgeLaunchListener(launchConfigurationName));
- launch = workingCopy.doSave().launch(ILaunchManager.RUN_MODE, null, false, true);
+ launch = workingCopy.doSave().launch(getLaunchMode(), null, false, true);
} catch (CoreException e) {
ForgeCorePlugin.log(new RuntimeException("Problem while launching working
copy.", e));
}
@@ -73,8 +74,11 @@
return launch;
}
+ private static String getLaunchMode() {
+ return ForgeRuntimesPreferences.INSTANCE.getStartInDebug() ?
+ ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE;
+ }
-
private static ILaunchConfigurationWorkingCopy createWorkingCopy(String name, String
location) {
ILaunchConfigurationWorkingCopy result = null;
try {
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/preferences/ForgeStartupPreferencePage.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/preferences/ForgeStartupPreferencePage.java 2012-06-04
15:29:33 UTC (rev 41684)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/preferences/ForgeStartupPreferencePage.java 2012-06-04
15:37:24 UTC (rev 41685)
@@ -15,11 +15,13 @@
IWorkbenchPreferencePage {
private Button startupButton;
+ private Button startInDebugButton;
protected Control createContents(Composite parent) {
noDefaultAndApplyButton();
Composite clientArea = createClientArea(parent);
createStartupButton(clientArea);
+ createStartInDebugButton(clientArea);
return null;
}
@@ -30,12 +32,19 @@
startupButton.setSelection(ForgeRuntimesPreferences.INSTANCE.getStartup());
}
+ private void createStartInDebugButton(Composite parent) {
+ startInDebugButton = new Button(parent, SWT.CHECK);
+ startInDebugButton.setText("Start Forge in Debug Mode." );
+ startInDebugButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ startInDebugButton.setSelection(ForgeRuntimesPreferences.INSTANCE.getStartInDebug());
+ }
+
private Composite createClientArea(Composite parent) {
Composite clientArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
- layout.numColumns = 2;
+ layout.numColumns = 1;
clientArea.setLayout(layout);
- GridData gridData = new GridData(GridData.FILL_BOTH);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
clientArea.setLayoutData(gridData);
return clientArea;
}
@@ -44,6 +53,7 @@
public boolean performOk() {
ForgeRuntimesPreferences.INSTANCE.setStartup(startupButton.getSelection());
+ ForgeRuntimesPreferences.INSTANCE.setStartInDebug(startInDebugButton.getSelection());
return true;
}
}
Show replies by date