Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2002-11-08 04:03:26 +0000
committerDarin Wright2002-11-08 04:03:26 +0000
commitee44db66c3b342118ba2da075c71353c4fb3f023 (patch)
tree3479ab9fa3920f6a7a55d0861de3822d627c1e9c /org.eclipse.debug.ui
parenta4c44466a4d42a731020ab3c68baa9229e57a0a2 (diff)
downloadeclipse.platform.debug-ee44db66c3b342118ba2da075c71353c4fb3f023.tar.gz
eclipse.platform.debug-ee44db66c3b342118ba2da075c71353c4fb3f023.tar.xz
eclipse.platform.debug-ee44db66c3b342118ba2da075c71353c4fb3f023.zip
launch history management
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ILaunchHistoryChangedListener.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugDropDownAction.java35
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugLastAction.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchDropDownAction.java43
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchHistoryLaunchAction.java47
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchLastAction.java38
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunDropDownAction.java34
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunLastAction.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationDialog.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationHistoryElement.java110
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java724
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java376
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugHistoryPreferenceTab.java66
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferencePage.java222
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferenceTab.java118
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunHistoryPreferenceTab.java67
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java300
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java12
21 files changed, 1050 insertions, 1220 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ILaunchHistoryChangedListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ILaunchHistoryChangedListener.java
index 1262e0ff6..bcdf7eb57 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ILaunchHistoryChangedListener.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ILaunchHistoryChangedListener.java
@@ -12,9 +12,10 @@ Contributors:
**********************************************************************/
/**
- * Implementors of this interface are notified whenever a change is made to the launch history.
- * This could be an addition or deletion from either of the run or debug histories, or change
- * to the last launched item.
+ * Implementors of this interface are notified whenever there is a change is
+ * made to the launch history. This could be an addition or deletion from either
+ * of the run or debug histories, a change to the last launched item, or a
+ * change in favorites.
*/
public interface ILaunchHistoryChangedListener {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugDropDownAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugDropDownAction.java
index d9f79fc41..41fde7c87 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugDropDownAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugDropDownAction.java
@@ -1,13 +1,14 @@
package org.eclipse.debug.internal.ui.actions;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+This file is made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+**********************************************************************/
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.actions.DebugAction;
public class DebugDropDownAction extends LaunchDropDownAction {
@@ -29,20 +30,6 @@ public class DebugDropDownAction extends LaunchDropDownAction {
}
/**
- * @see LaunchDropDownAction#getHistory()
- */
- public LaunchConfigurationHistoryElement[] getHistory() {
- return DebugUIPlugin.getLaunchConfigurationManager().getDebugHistory();
- }
-
- /**
- * @see LaunchDropDownAction#getFavorites()
- */
- public LaunchConfigurationHistoryElement[] getFavorites() {
- return DebugUIPlugin.getLaunchConfigurationManager().getDebugFavorites();
- }
-
- /**
* @see LaunchDropDownAction#getLastLaunchPrefix()
*/
protected String getLastLaunchPrefix() {
@@ -55,5 +42,13 @@ public class DebugDropDownAction extends LaunchDropDownAction {
protected String getStaticTooltip() {
return ActionMessages.getString("DebugDropDownAction.Debug_1"); //$NON-NLS-1$
}
+
+ /**
+ * @see org.eclipse.debug.internal.ui.actions.LaunchDropDownAction#getLaunchGroupId()
+ */
+ public String getLaunchGroupId() {
+ return IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP;
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugLastAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugLastAction.java
index 6552da41a..103979af0 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugLastAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugLastAction.java
@@ -12,6 +12,7 @@ Contributors:
**********************************************************************/
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.IDebugUIConstants;
/**
* Relaunches the last debug-mode launch
@@ -24,4 +25,11 @@ public class DebugLastAction extends RelaunchLastAction {
public String getMode() {
return ILaunchManager.DEBUG_MODE;
}
+
+ /**
+ * @see org.eclipse.debug.internal.ui.actions.LaunchDropDownAction#getLaunchGroupId()
+ */
+ public String getLaunchGroupId() {
+ return IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchDropDownAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchDropDownAction.java
index d4e6ecceb..52a7c73e2 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchDropDownAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchDropDownAction.java
@@ -8,11 +8,19 @@ http://www.eclipse.org/legal/cpl-v10.html
**********************************************************************/
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
+import org
+ .eclipse
+ .debug
+ .internal
+ .ui
+ .launchConfigurations
+ .LaunchConfigurationManager;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
@@ -116,10 +124,10 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
* Updates this action's tooltip to correspond to the most recent launch.
*/
protected void updateTooltip() {
- LaunchConfigurationHistoryElement lastLaunched = getLastLaunch();
+ ILaunchConfiguration lastLaunched = getLastLaunch();
String tooltip= fOriginalTooltip;
if (lastLaunched != null) {
- tooltip= getLastLaunchPrefix() + lastLaunched.getLaunchConfiguration().getName();
+ tooltip= getLastLaunchPrefix() + lastLaunched.getName();
} else {
tooltip= getStaticTooltip();
}
@@ -146,8 +154,8 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
/**
* Return the last launch that occurred in the workspace.
*/
- protected LaunchConfigurationHistoryElement getLastLaunch() {
- return DebugUIPlugin.getLaunchConfigurationManager().getLastLaunch();
+ protected ILaunchConfiguration getLastLaunch() {
+ return DebugUIPlugin.getLaunchConfigurationManager().getLastLaunch(getLaunchGroupId());
}
/**
@@ -176,14 +184,14 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
* Create the drop-down menu based on whether the config style pref is set
*/
protected Menu createMenu(Menu menu) {
- LaunchConfigurationHistoryElement[] historyList= getHistory();
- LaunchConfigurationHistoryElement[] favoriteList = getFavorites();
+ ILaunchConfiguration[] historyList= getHistory();
+ ILaunchConfiguration[] favoriteList = getFavorites();
// Add any favorites
int total = 0;
for (int i = 0; i < favoriteList.length; i++) {
- LaunchConfigurationHistoryElement launch= favoriteList[i];
- RelaunchHistoryLaunchAction newAction= new RelaunchHistoryLaunchAction(launch);
+ ILaunchConfiguration launch= favoriteList[i];
+ RelaunchHistoryLaunchAction newAction= new RelaunchHistoryLaunchAction(launch, getMode());
createMenuForAction(menu, newAction, total + 1);
total++;
}
@@ -199,8 +207,8 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
// Add history launches next
for (int i = 0; i < historyList.length; i++) {
- LaunchConfigurationHistoryElement launch= historyList[i];
- RelaunchHistoryLaunchAction newAction= new RelaunchHistoryLaunchAction(launch);
+ ILaunchConfiguration launch= historyList[i];
+ RelaunchHistoryLaunchAction newAction= new RelaunchHistoryLaunchAction(launch, getMode());
createMenuForAction(menu, newAction, total+1);
total++;
}
@@ -280,12 +288,16 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
/**
* Returns an array of previous launches applicable to this drop down.
*/
- public abstract LaunchConfigurationHistoryElement[] getHistory();
+ public ILaunchConfiguration[] getHistory() {
+ return LaunchConfigurationManager.getDefault().getLaunchHistory(getLaunchGroupId()).getHistory();
+ }
/**
* Returns an array of favorites applicable to this drop down.
*/
- public abstract LaunchConfigurationHistoryElement[] getFavorites();
+ public ILaunchConfiguration[] getFavorites() {
+ return LaunchConfigurationManager.getDefault().getLaunchHistory(getLaunchGroupId()).getFavorites();
+ }
/**
* Returns the mode (e.g., 'run' or 'debug') of this drop down.
@@ -293,6 +305,11 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
public abstract String getMode();
/**
+ * Returns the launch group of this drop down.
+ */
+ public abstract String getLaunchGroupId();
+
+ /**
* Return the String to use as the first part of the tooltip for this action
* when there is no launch history.
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java
index 37c0f7436..bf55d9787 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java
@@ -11,7 +11,6 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
public class RelaunchActionDelegate extends AbstractDebugActionDelegate {
@@ -27,11 +26,7 @@ public class RelaunchActionDelegate extends AbstractDebugActionDelegate {
relaunch((IProcess)object);
}
}
-
- public static void relaunch(LaunchConfigurationHistoryElement history) {
- relaunch(history.getLaunchConfiguration(), history.getMode());
- }
-
+
public static void relaunch(IDebugElement element) {
relaunch(element.getLaunch());
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchHistoryLaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchHistoryLaunchAction.java
index 21ffdb562..ae768c27f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchHistoryLaunchAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchHistoryLaunchAction.java
@@ -1,20 +1,17 @@
package org.eclipse.debug.internal.ui.actions;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+This file is made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+**********************************************************************/
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugPluginImages;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.help.WorkbenchHelp;
/**
@@ -22,23 +19,16 @@ import org.eclipse.ui.help.WorkbenchHelp;
*/
public class RelaunchHistoryLaunchAction extends Action {
- protected LaunchConfigurationHistoryElement fLaunch;
+ private ILaunchConfiguration fConfiguration;
+ private String fMode;
- public RelaunchHistoryLaunchAction(LaunchConfigurationHistoryElement launch) {
+ public RelaunchHistoryLaunchAction(ILaunchConfiguration configuration, String mode) {
super();
- fLaunch= launch;
- setText(launch.getLabel());
+ fConfiguration = configuration;
+ fMode = mode;
+ setText(configuration.getName());
ImageDescriptor descriptor= null;
- if (launch.getLaunchConfiguration() != null) {
- descriptor = DebugUITools.getDefaultImageDescriptor(launch.getLaunchConfiguration());
- } else {
- if (launch.getMode().equals(ILaunchManager.DEBUG_MODE)) {
- descriptor= DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_ACT_DEBUG);
- } else {
- descriptor= DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_ACT_RUN);
- }
- }
-
+ descriptor = DebugUITools.getDefaultImageDescriptor(configuration);
if (descriptor != null) {
setImageDescriptor(descriptor);
}
@@ -51,13 +41,6 @@ public class RelaunchHistoryLaunchAction extends Action {
* @see IAction
*/
public void run() {
- if (!DebugUITools.saveAndBuildBeforeLaunch()) {
- return;
- }
- BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
- public void run() {
- RelaunchActionDelegate.relaunch(fLaunch);
- }
- });
+ DebugUITools.launch(fConfiguration, fMode);
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchLastAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchLastAction.java
index 838bba6bc..a300b9560 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchLastAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchLastAction.java
@@ -10,8 +10,13 @@ import java.text.MessageFormat;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationDialog;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
+import org
+ .eclipse
+ .debug
+ .internal
+ .ui
+ .launchConfigurations
+ .LaunchConfigurationDialog;
import org
.eclipse
.debug
@@ -24,8 +29,6 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
@@ -55,20 +58,12 @@ public abstract class RelaunchLastAction implements IWorkbenchWindowActionDelega
*/
public void run(IAction action){
try {
- final LaunchConfigurationHistoryElement historyElement = getLastLaunch();
- if (historyElement != null) {
- final ILaunchConfiguration historyConfig = historyElement.getLaunchConfiguration();
- if (historyConfig.supportsMode(getMode())) {
- if (!DebugUITools.saveAndBuildBeforeLaunch()) {
- return;
- }
- BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
- public void run() {
- RelaunchActionDelegate.relaunch(historyConfig, getMode());
- }
- });
+ final ILaunchConfiguration configuration = getLastLaunch();
+ if (configuration != null) {
+ if (configuration.supportsMode(getMode())) {
+ DebugUITools.launch(configuration, getMode());
} else {
- String configName = historyElement.getLaunchConfiguration().getName();
+ String configName = configuration.getName();
String title = ActionMessages.getString("RelaunchLastAction.Cannot_relaunch_1"); //$NON-NLS-1$
String message = MessageFormat.format(ActionMessages.getString("RelaunchLastAction.Cannot_relaunch_[{0}]_because_it_does_not_support_{2}_mode_2"), new String[] {configName, getMode()}); //$NON-NLS-1$
MessageDialog.openError(getShell(), title, message);
@@ -105,8 +100,8 @@ public abstract class RelaunchLastAction implements IWorkbenchWindowActionDelega
/**
* Return the last launch that occurred in the workspace.
*/
- protected LaunchConfigurationHistoryElement getLastLaunch() {
- return DebugUIPlugin.getLaunchConfigurationManager().getLastLaunch();
+ protected ILaunchConfiguration getLastLaunch() {
+ return DebugUIPlugin.getLaunchConfigurationManager().getLastLaunch(getLaunchGroupId());
}
protected Shell getShell() {
@@ -117,6 +112,11 @@ public abstract class RelaunchLastAction implements IWorkbenchWindowActionDelega
* Returns the mode (run or debug) of this action.
*/
public abstract String getMode();
+
+ /**
+ * Returns the launch group id of this action.
+ */
+ public abstract String getLaunchGroupId();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunDropDownAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunDropDownAction.java
index 6566d9042..aa4301b70 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunDropDownAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunDropDownAction.java
@@ -1,13 +1,14 @@
package org.eclipse.debug.internal.ui.actions;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+This file is made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+**********************************************************************/
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.actions.RunAction;
public class RunDropDownAction extends LaunchDropDownAction {
@@ -28,20 +29,6 @@ public class RunDropDownAction extends LaunchDropDownAction {
}
/**
- * @see LaunchDropDownAction#getHistory()
- */
- public LaunchConfigurationHistoryElement[] getHistory() {
- return DebugUIPlugin.getLaunchConfigurationManager().getRunHistory();
- }
-
- /**
- * @see LaunchDropDownAction#getFavorites()
- */
- public LaunchConfigurationHistoryElement[] getFavorites() {
- return DebugUIPlugin.getLaunchConfigurationManager().getRunFavorites();
- }
-
- /**
* @see LaunchDropDownAction#getLastLaunchPrefix()
*/
protected String getLastLaunchPrefix() {
@@ -53,5 +40,12 @@ public class RunDropDownAction extends LaunchDropDownAction {
protected String getStaticTooltip() {
return ActionMessages.getString("RunDropDownAction.Run_1"); //$NON-NLS-1$
}
+ /**
+ * @see org.eclipse.debug.internal.ui.actions.LaunchDropDownAction#getLaunchGroupId()
+ */
+ public String getLaunchGroupId() {
+ return IDebugUIConstants.ID_RUN_LAUNCH_GROUP;
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunLastAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunLastAction.java
index 9d69ef4c0..2273fcaa6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunLastAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunLastAction.java
@@ -12,6 +12,7 @@ Contributors:
**********************************************************************/
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.IDebugUIConstants;
/**
* Relaunches the last run-mode launch
@@ -24,4 +25,11 @@ public class RunLastAction extends RelaunchLastAction {
public String getMode() {
return ILaunchManager.RUN_MODE;
}
+
+ /**
+ * @see org.eclipse.debug.internal.ui.actions.LaunchDropDownAction#getLaunchGroupId()
+ */
+ public String getLaunchGroupId() {
+ return IDebugUIConstants.ID_RUN_LAUNCH_GROUP;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationDialog.java
index 0cfbba0b5..1a4ec838c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationDialog.java
@@ -709,11 +709,7 @@ public class LaunchConfigurationDialog extends TitleAreaDialog
* Return the last launched configuration in the workspace.
*/
protected ILaunchConfiguration getLastLaunchedWorkbenchConfiguration() {
- LaunchConfigurationHistoryElement historyElement = DebugUIPlugin.getLaunchConfigurationManager().getLastLaunch();
- if (historyElement != null) {
- return historyElement.getLaunchConfiguration();
- }
- return null;
+ return DebugUIPlugin.getLaunchConfigurationManager().getLastLaunch(getLaunchGroup().getIdentifier());
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationHistoryElement.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationHistoryElement.java
deleted file mode 100644
index 99e510168..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationHistoryElement.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.eclipse.debug.internal.ui.launchConfigurations;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.ui.IDebugUIConstants;
-
-/**
- * A wrapper for entries in a launch history list.
- */
-public class LaunchConfigurationHistoryElement {
- /**
- * The launch configuration
- */
- private ILaunchConfiguration fLaunchConfiguration;
-
- /**
- * The mode in which the launch configuration was launched
- */
- private String fMode;
-
- public LaunchConfigurationHistoryElement(ILaunchConfiguration launchConfiguration,
- String mode) {
- setLaunchConfiguration(launchConfiguration);
- setMode(mode);
- }
-
- /**
- * Sets the launch configuration for this history element
- */
- private void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) {
- fLaunchConfiguration = launchConfiguration;
- }
-
- /**
- * Returns the launch configuration for this history element
- */
- public ILaunchConfiguration getLaunchConfiguration() {
- return fLaunchConfiguration;
- }
-
- /**
- * Sets the mode for this history element
- */
- private void setMode(String mode) {
- fMode = mode;
- }
-
- /**
- * Returns the mode for this history element
- */
- public String getMode() {
- return fMode;
- }
-
- /**
- * Returns the label for this history element
- */
- public String getLabel() {
- return DebugUIPlugin.getDefaultLabelProvider().getText(getLaunchConfiguration());
- }
-
- /**
- * Returns whether this history element represents
- * a favorite launch configuration.
- *
- * @return whether this history element represents
- * a favorite launch configuration
- */
- public boolean isFavorite() {
- if (getLaunchConfiguration() != null) {
- try {
- if (getMode().equals(ILaunchManager.DEBUG_MODE)) {
- return getLaunchConfiguration().getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false);
- } else {
- return getLaunchConfiguration().getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false);
- }
- } catch (CoreException e) {
- DebugUIPlugin.log(e);
- }
- }
- return false;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o instanceof LaunchConfigurationHistoryElement) {
- LaunchConfigurationHistoryElement e= (LaunchConfigurationHistoryElement)o;
- return getLaunchConfiguration().equals(e.getLaunchConfiguration()) &&
- getMode().equals(e.getMode());
- }
- return false;
- }
-
- /**
- * @see Object#hashCode()
- */
- public int hashCode() {
- return getLaunchConfiguration().hashCode();
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
index df9a43962..13dd4222e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
@@ -12,14 +12,13 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
-import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -34,8 +33,6 @@ import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationListener;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchListener;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.DebugPluginImages;
@@ -44,64 +41,32 @@ import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-public class LaunchConfigurationManager implements ILaunchListener,
- ILaunchConfigurationListener,
- IPropertyChangeListener,
- ILaunchHistoryChangedListener {
+public class LaunchConfigurationManager implements ILaunchListener {
/**
* The singleton instance of the launch configuration manager
*/
private static LaunchConfigurationManager fgLaunchConfigurationManager;
- /**
- * The length of the Run & Debug history lists.
- */
- protected int fMaxHistorySize;
-
- /**
- * The most recent debug launches
- */
- private Vector fDebugHistory;
-
- /**
- * The most recent run launches
- */
- private Vector fRunHistory;
-
- /**
- * The most recent debug launches
- */
- protected Vector fDebugFavorites;
/**
- * The most recent run launches
- */
- protected Vector fRunFavorites;
-
- protected boolean fHistoryInitialized= false;
-
- /**
- * Launch group extensions, keyed by identifier.
+ * Launch group extensions, keyed by launch group identifier.
*/
protected Map fLaunchGroups;
/**
- * The list of most recent launches, independent of mode.
- * This list may be empty, but should never be <code>null</code>.
- */
- protected List fLastLaunchList;
+ * Launch histories keyed by launch group identifier
+ */
+ protected Map fLaunchHistories;
/**
* The list of registered implementors of <code>ILaunchHistoryChangedListener</code>
@@ -122,6 +87,11 @@ public class LaunchConfigurationManager implements ILaunchListener,
* Cache of launch configuration tab images with error overlays
*/
protected ImageRegistry fErrorImages = null;
+
+ /**
+ * true when restoring launch history
+ */
+ protected boolean fRestoring = false;
/**
* The name of the file used to persist the launch history.
@@ -138,39 +108,15 @@ public class LaunchConfigurationManager implements ILaunchListener,
private static final String HISTORY_MEMENTO_ATT = "memento"; //$NON-NLS-1$
private static final String HISTORY_MODE_ATT = "mode"; //$NON-NLS-1$
- private LaunchConfigurationManager() {
- setEmptyLaunchHistories();
- fMaxHistorySize = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_HISTORY_SIZE);
- fLastLaunchList = new ArrayList(fMaxHistorySize);
+ private LaunchConfigurationManager() {
ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
launchManager.addLaunchListener(this);
- launchManager.addLaunchConfigurationListener(this);
//update histories for launches already registered
ILaunch[] launches= launchManager.getLaunches();
for (int i = 0; i < launches.length; i++) {
launchAdded(launches[i]);
}
- DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- addLaunchHistoryListener(this);
- }
-
- protected void setRunHistoryVector(Vector runHistory) {
- fRunHistory = runHistory;
- }
-
- protected Vector getRunHistoryVector() {
- initializeHistory();
- return fRunHistory;
- }
-
- protected void setDebugHistoryVector(Vector debugHistory) {
- fDebugHistory = debugHistory;
- }
-
- protected Vector getDebugHistoryVector() {
- initializeHistory();
- return fDebugHistory;
}
public static LaunchConfigurationManager getDefault() {
@@ -189,8 +135,7 @@ public class LaunchConfigurationManager implements ILaunchListener,
* @param launchConfiguration * @return boolean */
public static boolean isVisible(ILaunchConfiguration launchConfiguration) {
try {
- return !(launchConfiguration.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false)) &&
- launchConfiguration.getType().getCategory() == null;
+ return !(launchConfiguration.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false));
} catch (CoreException e) {
DebugUIPlugin.log(e);
}
@@ -207,9 +152,13 @@ public class LaunchConfigurationManager implements ILaunchListener,
public void shutdown() throws CoreException {
ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
launchManager.removeLaunchListener(this);
- launchManager.removeLaunchConfigurationListener(this);
- removeLaunchHistoryListener(this);
- DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+ if (fLaunchHistories != null) {
+ Iterator histories = fLaunchHistories.values().iterator();
+ while (histories.hasNext()) {
+ LaunchHistory history = (LaunchHistory)histories.next();
+ history.dispose();
+ }
+ }
}
/**
@@ -231,7 +180,6 @@ public class LaunchConfigurationManager implements ILaunchListener,
* @see ILaunchListener#launchAdded(ILaunch)
*/
public void launchAdded(final ILaunch launch) {
- updateHistories(launch);
removeTerminatedLaunches(launch);
}
@@ -248,256 +196,15 @@ public class LaunchConfigurationManager implements ILaunchListener,
}
}
- protected void updateFavorites(ILaunchConfiguration config) {
- try {
- if (config.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false)) {
- addDebugFavorite(config);
- removeLaunchConfigurationFromHistoryList(getDebugHistoryVector(), config);
- } else {
- removeDebugFavorite(config);
- }
- if (config.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false)) {
- addRunFavorite(config);
- removeLaunchConfigurationFromHistoryList(getRunHistoryVector(), config);
- } else {
- removeRunFavorite(config);
- }
- } catch (CoreException e) {
- DebugUIPlugin.log(e);
- }
- }
-
- /**
- * @see ILaunchConfigurationListener#launchConfigurationAdded(ILaunchConfiguration)
- */
- public void launchConfigurationAdded(ILaunchConfiguration config) {
- updateFavorites(config);
- }
-
- /**
- * @see ILaunchConfigurationListener#launchConfigurationChanged(ILaunchConfiguration)
- */
- public void launchConfigurationChanged(ILaunchConfiguration config) {
- if (!config.isWorkingCopy()) {
- updateFavorites(config);
- }
- }
-
- /**
- * If the deleted config appeared in either of the history lists, delete it from the list(s).
- *
- * @see ILaunchConfigurationListener#launchConfigurationRemoved(ILaunchConfiguration)
- */
- public void launchConfigurationRemoved(ILaunchConfiguration config) {
- boolean modified = removeLaunchConfigurationFromHistoryList(getRunHistoryVector(), config);
- modified |= removeLaunchConfigurationFromHistoryList(getDebugHistoryVector(), config);
- modified |= removeLaunchConfigurationFromHistoryList(fDebugFavorites, config);
- modified |= removeLaunchConfigurationFromHistoryList(fRunFavorites, config);
- modified |= removeLaunchConfigurationFromHistoryList(fLastLaunchList, config);
-
- if (modified) {
- fireLaunchHistoryChanged();
- }
- }
-
- /**
- * Remove the specified launch configuration from the specified history list. If the
- * configuration does not appear in the list, this method does nothing. Return <code>true</code>
- * if the configuration was removed, <code>false</code> otherwise.
- */
- protected boolean removeLaunchConfigurationFromHistoryList(List list, ILaunchConfiguration config) {
- ListIterator iterator = list.listIterator();
- while (iterator.hasNext()) {
- LaunchConfigurationHistoryElement element = (LaunchConfigurationHistoryElement) iterator.next();
- ILaunchConfiguration elementConfig = element.getLaunchConfiguration();
- if (config.equals(elementConfig)) {
- iterator.remove();
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns an array of the most recent debug launches, which can be empty.
- *
- * @return an array of launches
- */
- public LaunchConfigurationHistoryElement[] getDebugHistory() {
- return getHistoryArray(getDebugHistoryVector());
- }
-
- /**
- * Returns an array of the favorite debug launches, which can be empty.
- *
- * @return an array of launches
- */
- public LaunchConfigurationHistoryElement[] getDebugFavorites() {
- return getHistoryArray(fDebugFavorites);
- }
-
- /**
- * Sets the favorite debug launches, which can be empty.
- *
- * @param favorites an array of launches
- */
- public void setDebugFavorites(Vector favorites) {
- fDebugFavorites = favorites;
- }
-
- /**
- * Sets the recent debug launches, which can be empty.
- *
- * @param hsitory an array of launches
- */
- public void setDebugHistory(Vector history) {
- setDebugHistoryVector(history);
- fireLaunchHistoryChanged();
- }
-
- /**
- * Sets the recent run launches, which can be empty.
- *
- * @param hsitory an array of launches
- */
- public void setRunHistory(Vector history) {
- setRunHistoryVector(history);
- fireLaunchHistoryChanged();
- }
-
- /**
- * Sets the favorite run launches, which can be empty.
- *
- * @param favorites an array of launches
- */
- public void setRunFavorites(Vector favorites) {
- fRunFavorites = favorites;
- }
-
- /**
- * Returns an array of the most recent run launches, which can be empty.
- *
- * @return an array of launches
- */
- public LaunchConfigurationHistoryElement[] getRunHistory() {
- return getHistoryArray(getRunHistoryVector());
- }
-
- /**
- * Returns an array of the favorite run launches, which can be empty.
- *
- * @return an array of launches
- */
- public LaunchConfigurationHistoryElement[] getRunFavorites() {
- return getHistoryArray(fRunFavorites);
- }
-
- protected LaunchConfigurationHistoryElement[] getHistoryArray(Vector history) {
- LaunchConfigurationHistoryElement[] array = new LaunchConfigurationHistoryElement[history.size()];
- history.copyInto(array);
- return array;
- }
-
/**
- * Returns the most recent launch, or <code>null</code> if there
- * have been no launches.
+ * Returns the most recent launch for the given group, or <code>null</code>
+ * if none.
*
* @return the last launch, or <code>null</code> if none
*/
- public LaunchConfigurationHistoryElement getLastLaunch() {
- initializeHistory();
- if (!fLastLaunchList.isEmpty()) {
- return (LaunchConfigurationHistoryElement) fLastLaunchList.get(0);
- }
- return null;
- }
-
- /**
- * Erase both (run & debug) launch histories and the last launched list.
- */
- protected void setEmptyLaunchHistories() {
- setRunHistoryVector(new Vector(fMaxHistorySize));
- setDebugHistoryVector(new Vector(fMaxHistorySize));
- setRunFavorites(new Vector(fMaxHistorySize));
- setDebugFavorites(new Vector(fMaxHistorySize));
- fLastLaunchList = new ArrayList(fMaxHistorySize);
- fireLaunchHistoryChanged();
- }
-
- /**
- * Given a launch, try to add it to both of the run & debug histories.
- * If either history was modified, fire a history modified notification.
- */
- protected void updateHistories(ILaunch launch) {
- boolean modified = updateHistory(ILaunchManager.DEBUG_MODE, getDebugHistoryVector(), fDebugFavorites, launch);
- modified |= updateHistory(ILaunchManager.RUN_MODE, getRunHistoryVector(), fRunFavorites, launch);
- if (modified) {
- fireLaunchHistoryChanged();
- }
- }
-
- /**
- * Add the given launch to the specified history if the launcher supports the mode.
- * Return <code>true</code> if the history was modified, <code>false</code> otherwise.
- */
- protected boolean updateHistory(String mode, Vector history, Vector favorites, ILaunch launch) {
-
- // First make sure the launch configuration exists, supports the mode of the history list,
- // and isn't private
- ILaunchConfiguration launchConfig = launch.getLaunchConfiguration();
- if (launchConfig == null) {
- return false;
- }
- try {
- if (!launchConfig.supportsMode(mode) || !isVisible(launchConfig)) {
- return false;
- }
- } catch (CoreException ce) {
- return false;
- }
-
- // Create a new history item
- LaunchConfigurationHistoryElement item= new LaunchConfigurationHistoryElement(launchConfig, mode);
-
- // Update the most recent launch list
- boolean modified = false;
- if (launch.getLaunchMode().equals(mode)) {
- int index = findConfigInHistoryList(fLastLaunchList, launchConfig);
- if (index > 0) {
- fLastLaunchList.remove(item);
- }
- if (index != 0) {
- fLastLaunchList.add(0, item);
- modified = true;
- }
- }
-
- // Look for an equivalent launch in the favorites
- int index = findConfigInHistoryList(favorites, item.getLaunchConfiguration());
- if (index >= 0) {
- // a favorite, do not add to history
- return modified;
- }
-
- // Look for an equivalent launch in the history list
- index = findConfigInHistoryList(history, item.getLaunchConfiguration());
-
- //It's already listed as the most recent launch, so nothing to do
- if (index == 0) {
- return modified;
- }
-
- // Make it the top item in the list, removing it from it's previous location, if there was one
- if (index > 0) {
- history.remove(index);
- }
- history.add(0, item);
-
- if (history.size() > fMaxHistorySize) {
- history.remove(history.size() - 1);
- }
-
- return true;
+ public ILaunchConfiguration getLastLaunch(String groupId) {
+ LaunchHistory history = getLaunchHistory(groupId);
+ return history.getRecentLaunch();
}
/**
@@ -528,177 +235,37 @@ public class LaunchConfigurationManager implements ILaunchListener,
listener.launchHistoryChanged();
}
}
-
- /**
- * Returns whether the given config is displayed in the favorites
- * menu
- *
- * @param config launch configuration
- * @return whether the given config is displayed in the favorites
- * menu
- */
- public boolean isDebugFavorite(ILaunchConfiguration config) {
- return (findConfigInHistoryList(fDebugFavorites, config)) >= 0;
- }
-
- /**
- * Returns whether the given config is displayed in the favorites
- * menu
- *
- * @param config launch configuration
- * @return whether the given config is displayed in the favorites
- * menu
- */
- public boolean isRunFavorite(ILaunchConfiguration config) {
- return(findConfigInHistoryList(fRunFavorites, config)) >= 0;
- }
-
- /**
- * Adds the given config to the debug favorites. Has no
- * effect if already a debug favorite.
- *
- * @param config launch configuration
- */
- public void addDebugFavorite(ILaunchConfiguration config) {
- if (!isDebugFavorite(config)) {
- LaunchConfigurationHistoryElement hist = new LaunchConfigurationHistoryElement(config, ILaunchManager.DEBUG_MODE);
- fDebugFavorites.add(hist);
- }
- }
-
- /**
- * Adds the given config to the run favorites. Has no
- * effect if already a run favorite.
- *
- * @param config launch configuration
- */
- public void addRunFavorite(ILaunchConfiguration config) {
- if (!isRunFavorite(config)) {
- LaunchConfigurationHistoryElement hist = new LaunchConfigurationHistoryElement(config, ILaunchManager.RUN_MODE);
- fRunFavorites.add(hist);
- }
- }
-
- /**
- * Removes the given config from the debug favorites. Has no
- * effect if not a favorite.
- *
- * @param config launch configuration
- */
- public void removeDebugFavorite(ILaunchConfiguration config) {
- int index = findConfigInHistoryList(fDebugFavorites, config);
- if (index >= 0) {
- fDebugFavorites.remove(index);
- }
- }
-
- /**
- * Adds the given config to the run favorites. Has no
- * effect if already a run favorite.
- *
- * @param config launch configuration
- */
- public void removeRunFavorite(ILaunchConfiguration config) {
- int index = findConfigInHistoryList(fRunFavorites, config);
- if (index >= 0) {
- fRunFavorites.remove(index);
- }
- }
-
- /**
- * Find the specified history element in the specified list and return the index at which
- * it was found. Return -1 if the element wasn't found in the list.
- */
- protected int findConfigInHistoryList(List list, ILaunchConfiguration config) {
- for (int i = 0; i < list.size(); i++) {
- LaunchConfigurationHistoryElement historyElement = (LaunchConfigurationHistoryElement) list.get(i);
- if (historyElement != null) {
- ILaunchConfiguration historyConfig = historyElement.getLaunchConfiguration();
- if ((historyConfig != null) && historyConfig.equals(config)) {
- return i;
- }
- }
- }
-
- // Element wasn't in list
- return -1;
- }
-
- /**
- * Find the specified history element in the history list for the mode that is not the one
- * specified. For example, if mode is 'debug', the 'run' list is searched.
- */
- protected int findConfigInOtherHistoryList(String mode, ILaunchConfiguration config) {
- Vector historyList = getOtherHistoryList(mode);
- return findConfigInHistoryList(historyList, config);
- }
-
- /**
- * Return the 'other' history list from the mode specified. For example, if
- * mode is 'debug', return the 'run' history list.
- */
- protected Vector getOtherHistoryList(String mode) {
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- return getRunHistoryVector();
- } else {
- return getDebugHistoryVector();
- }
- }
-
+
protected String getHistoryAsXML() throws IOException, CoreException {
- org.w3c.dom.Document doc = new DocumentImpl();
+ Document doc = new DocumentImpl();
Element historyRootElement = doc.createElement(HISTORY_ROOT_NODE);
doc.appendChild(historyRootElement);
- List all = new ArrayList(getDebugHistoryVector().size() + fDebugFavorites.size() + getRunHistoryVector().size() + fRunFavorites.size());
- all.addAll(fDebugFavorites);
- all.addAll(fRunFavorites);
- all.addAll(getDebugHistoryVector());
- all.addAll(getRunHistoryVector());
-
-
- Iterator iter = all.iterator();
- while (iter.hasNext()) {
- Element historyElement = getHistoryEntryAsXMLElement(doc, (LaunchConfigurationHistoryElement)iter.next());
- if (historyElement != null) {
- historyRootElement.appendChild(historyElement);
+ Iterator histories = fLaunchHistories.values().iterator();
+ while (histories.hasNext()) {
+ LaunchHistory history = (LaunchHistory)histories.next();
+ createEntry(doc, historyRootElement, history.getLaunchGroup().getMode(), history.getHistory());
+ createEntry(doc, historyRootElement, history.getLaunchGroup().getMode(), history.getFavorites());
+ ILaunchConfiguration configuration = history.getRecentLaunch();
+ if (configuration != null) {
+ Element last = doc.createElement(HISTORY_LAST_LAUNCH_NODE);
+ last.setAttribute(HISTORY_MEMENTO_ATT, configuration.getMemento());
+ last.setAttribute(HISTORY_MODE_ATT, history.getLaunchGroup().getMode());
+ historyRootElement.appendChild(last);
}
}
- if (!fLastLaunchList.isEmpty()) {
- Element recent = getRecentLaunchAsXMLElement(doc, (LaunchConfigurationHistoryElement) fLastLaunchList.get(0));
- if (recent != null) {
- historyRootElement.appendChild(recent);
- }
- }
-
+
return DebugUIPlugin.serializeDocument(doc);
}
-
- protected Element getHistoryEntryAsXMLElement(org.w3c.dom.Document doc, LaunchConfigurationHistoryElement element) throws CoreException {
- Element entry = doc.createElement(HISTORY_LAUNCH_NODE);
- return setAttributes(entry, element);
- }
-
- protected Element getRecentLaunchAsXMLElement(org.w3c.dom.Document doc, LaunchConfigurationHistoryElement element) throws CoreException {
- Element entry = doc.createElement(HISTORY_LAST_LAUNCH_NODE);
- return setAttributes(entry, element);
- }
-
- protected Element setAttributes(Element entry, LaunchConfigurationHistoryElement element) throws CoreException {
- if (element == null) {
- return null;
- }
- ILaunchConfiguration config = element.getLaunchConfiguration();
- if (config instanceof ILaunchConfigurationWorkingCopy) {
- config = ((ILaunchConfigurationWorkingCopy)config).getOriginal();
+
+ protected void createEntry(Document doc, Element historyRootElement, String mode, ILaunchConfiguration[] configurations) throws CoreException {
+ for (int i = 0; i < configurations.length; i++) {
+ ILaunchConfiguration configuration = configurations[i];
+ Element launch = doc.createElement(HISTORY_LAUNCH_NODE);
+ launch.setAttribute(HISTORY_MEMENTO_ATT, configuration.getMemento());
+ launch.setAttribute(HISTORY_MODE_ATT, mode);
+ historyRootElement.appendChild(launch);
}
- if (config == null) {
- return null;
- }
- String memento = config.getMemento();
- entry.setAttribute(HISTORY_MEMENTO_ATT, memento);
- entry.setAttribute(HISTORY_MODE_ATT, element.getMode());
- return entry;
}
protected IPath getHistoryFilePath() {
@@ -710,6 +277,9 @@ public class LaunchConfigurationManager implements ILaunchListener,
* the most recent launch.
*/
protected void persistLaunchHistory() throws IOException, CoreException {
+ if (fRestoring) {
+ return;
+ }
IPath historyPath = getHistoryFilePath();
String osHistoryPath = historyPath.toOSString();
String xml = getHistoryAsXML();
@@ -719,23 +289,14 @@ public class LaunchConfigurationManager implements ILaunchListener,
FileOutputStream stream = new FileOutputStream(file);
stream.write(xml.getBytes("UTF8")); //$NON-NLS-1$
stream.close();
+ fireLaunchHistoryChanged();
}
/**
- * Restore the launch history if it hasn't already been done.
- */
- protected void initializeHistory() {
- if (!fHistoryInitialized) {
- fHistoryInitialized = true;
- restoreLaunchHistory();
- }
- }
-
- /**
- * Find the XML history file and parse it. Place the corresponding history elements
- * in the appropriate history lists, and set the most recent launch.
+ * Find the XML history file and parse it. Place the corresponding configs
+ * in the appropriate history, and set the most recent launch.
*/
- protected void restoreLaunchHistory() {
+ private void restoreLaunchHistory() {
// Find the history file
IPath historyPath = getHistoryFilePath();
String osHistoryPath = historyPath.toOSString();
@@ -745,6 +306,7 @@ public class LaunchConfigurationManager implements ILaunchListener,
if (!file.exists()) {
return;
}
+
FileInputStream stream= null;
Element rootHistoryElement= null;
try {
@@ -773,8 +335,10 @@ public class LaunchConfigurationManager implements ILaunchListener,
return;
}
- // For each child of the root node, construct a history element wrapper and add it to
- // the appropriate history list, or set the most recent launch
+ // For each child of the root node, construct a launch config handle and add it to
+ // the appropriate history, or set the most recent launch
+ Collection l = fLaunchHistories.values();
+ LaunchHistory[] histories = (LaunchHistory[])l.toArray(new LaunchHistory[l.size()]);
NodeList list = rootHistoryElement.getChildNodes();
int length = list.getLength();
for (int i = 0; i < length; ++i) {
@@ -783,49 +347,59 @@ public class LaunchConfigurationManager implements ILaunchListener,
if (type == Node.ELEMENT_NODE) {
Element entry = (Element) node;
if (entry.getNodeName().equalsIgnoreCase(HISTORY_LAUNCH_NODE)) {
- LaunchConfigurationHistoryElement item = createHistoryElement(entry);
- if (item != null) {
- if (item.isFavorite()) {
- if (item.getMode().equals(ILaunchManager.DEBUG_MODE)) {
- fDebugFavorites.add(item);
- } else {
- fRunFavorites.add(item);
- }
- } else {
- if (item.getMode().equals(ILaunchManager.DEBUG_MODE)) {
- getDebugHistoryVector().add(item);
- } else {
- getRunHistoryVector().add(item);
- }
- }
- }
- } else if (entry.getNodeName().equalsIgnoreCase(HISTORY_LAST_LAUNCH_NODE)) {
- fLastLaunchList.add(0, createHistoryElement(entry));
+ createHistoryElement(entry, histories);
+ } else if (entry.getNodeName().equalsIgnoreCase(HISTORY_LAST_LAUNCH_NODE)) {
+ createRecentElement(entry, histories);
}
}
}
}
/**
- * Construct & return a <code>LaunchConfigurationHistoryElement</code> corresponding to
- * the specified XML element.
+ * Construct a launch configuration corresponding to the specified XML
+ * element, and place it in the approriate history.
*/
- protected LaunchConfigurationHistoryElement createHistoryElement(Element entry) {
+ private void createHistoryElement(Element entry, LaunchHistory[] histories) {
String memento = entry.getAttribute(HISTORY_MEMENTO_ATT);
- String mode = entry.getAttribute(HISTORY_MODE_ATT);
- LaunchConfigurationHistoryElement hist = null;
+ String mode = entry.getAttribute(HISTORY_MODE_ATT);
try {
ILaunchConfiguration launchConfig = DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(memento);
if (launchConfig.exists()) {
- hist = new LaunchConfigurationHistoryElement(launchConfig, mode);
+ for (int i = 0; i < histories.length; i++) {
+ LaunchHistory history = histories[i];
+ if (history.accepts(launchConfig) && history.getLaunchGroup().getMode().equals(mode)) {
+ history.addHistory(launchConfig);
+ }
+ }
}
} catch (CoreException e) {
DebugUIPlugin.log(e);
}
- return hist;
}
/**
+ * Construct a launch configuration corresponding to the specified XML
+ * element, and place it in the approriate history's recent launch
+ */
+ private void createRecentElement(Element entry, LaunchHistory[] histories) {
+ String memento = entry.getAttribute(HISTORY_MEMENTO_ATT);
+ String mode = entry.getAttribute(HISTORY_MODE_ATT);
+ try {
+ ILaunchConfiguration launchConfig = DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(memento);
+ if (launchConfig.exists()) {
+ for (int i = 0; i < histories.length; i++) {
+ LaunchHistory history = histories[i];
+ if (history.accepts(launchConfig) && history.getLaunchGroup().getMode().equals(mode)) {
+ history.setRecentLaunch(launchConfig);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ }
+ }
+
+ /**
* Load all registered extensions of the 'launch shortcut' extension point.
*/
private void loadLaunchShortcuts() {
@@ -846,16 +420,18 @@ public class LaunchConfigurationManager implements ILaunchListener,
* Load all registered extensions of the 'launch groups' extension point.
*/
private void loadLaunchGroups() {
- // Get the configuration elements
- IPluginDescriptor descriptor= DebugUIPlugin.getDefault().getDescriptor();
- IExtensionPoint extensionPoint= descriptor.getExtensionPoint(IDebugUIConstants.EXTENSION_POINT_LAUNCH_GROUPS);
- IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
-
- // Load the configuration elements into a Map
- fLaunchGroups = new HashMap(infos.length);
- for (int i = 0; i < infos.length; i++) {
- LaunchGroupExtension ext = new LaunchGroupExtension(infos[i]);
- fLaunchGroups.put(ext.getIdentifier(), ext);
+ if (fLaunchGroups == null) {
+ // Get the configuration elements
+ IPluginDescriptor descriptor= DebugUIPlugin.getDefault().getDescriptor();
+ IExtensionPoint extensionPoint= descriptor.getExtensionPoint(IDebugUIConstants.EXTENSION_POINT_LAUNCH_GROUPS);
+ IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
+
+ // Load the configuration elements into a Map
+ fLaunchGroups = new HashMap(infos.length);
+ for (int i = 0; i < infos.length; i++) {
+ LaunchGroupExtension ext = new LaunchGroupExtension(infos[i]);
+ fLaunchGroups.put(ext.getIdentifier(), ext);
+ }
}
}
@@ -909,50 +485,6 @@ public class LaunchConfigurationManager implements ILaunchListener,
}
/**
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IDebugUIConstants.PREF_MAX_HISTORY_SIZE)) {
- IPreferenceStore prefs = DebugUIPlugin.getDefault().getPreferenceStore();
- int newValue = prefs.getInt(IDebugUIConstants.PREF_MAX_HISTORY_SIZE);
- if (fMaxHistorySize != newValue) {
- shortenHistoryLists(newValue);
- fMaxHistorySize = newValue;
- fireLaunchHistoryChanged();
- }
- }
- }
-
- /**
- * Adjust the lengths of the history lists, throwing away any entries that are past the new end
- * of the lists.
- */
- protected void shortenHistoryLists(int newLength) {
- if (newLength < getRunHistoryVector().size()) {
- setRunHistoryVector(new Vector(getRunHistoryVector().subList(0, newLength)));
- }
- if (newLength < getDebugHistoryVector().size()) {
- setDebugHistoryVector(new Vector(getDebugHistoryVector().subList(0, newLength)));
- }
- if (newLength < fLastLaunchList.size()) {
- fLastLaunchList = new ArrayList(fLastLaunchList.subList(0, newLength));
- }
- }
-
- /**
- * @see ILaunchHistoryChangedListener#launchHistoryChanged()
- */
- public void launchHistoryChanged() {
- try {
- persistLaunchHistory();
- } catch (IOException e) {
- DebugUIPlugin.log(e);
- } catch (CoreException ce) {
- DebugUIPlugin.log(ce);
- }
- }
-
- /**
* Returns the image used to display an error in the given tab
*/
public Image getErrorTabImage(ILaunchConfigurationTab tab) {
@@ -987,6 +519,48 @@ public class LaunchConfigurationManager implements ILaunchListener,
}
/**
+ * Return all defined launch groups
+ *
+ * @return all defined launch groups
+ */
+ public LaunchGroupExtension[] getLaunchGroups() {
+ if (fLaunchGroups == null) {
+ loadLaunchGroups();
+ }
+ Collection groups = fLaunchGroups.values();
+ return (LaunchGroupExtension[])groups.toArray(new LaunchGroupExtension[groups.size()]);
+ }
+
+ /**
+ * Return the launch history with the given group id, or <code>null</code>
+ *
+ * @return the launch history with the given group id, or <code>null</code>
+ */
+ public LaunchHistory getLaunchHistory(String id) {
+ if (fLaunchHistories == null) {
+ loadLaunchHistories();
+ }
+ return (LaunchHistory)fLaunchHistories.get(id);
+ }
+
+ /**
+ * Restore launch history
+ */
+ private void loadLaunchHistories() {
+ if (fLaunchHistories == null) {
+ fRestoring = true;
+ LaunchGroupExtension[] groups = getLaunchGroups();
+ fLaunchHistories = new HashMap(groups.length);
+ for (int i = 0; i < groups.length; i++) {
+ LaunchGroupExtension extension = groups[i];
+ fLaunchHistories.put(extension.getIdentifier(), new LaunchHistory(extension));
+ }
+ restoreLaunchHistory();
+ fRestoring = false;
+ }
+ }
+
+ /**
* Returns the default lanuch group for the given mode.
*
* @param mode * @return launch group */
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
index 4e086163f..65974b768 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
@@ -14,7 +14,7 @@ CommonTab.&Common_15=&Common
CommonTab.&Run_11=&Run
CommonTab.Debu&g_12=Debu&g
CommonTab.Debug_mode_9=D&ebug mode
-CommonTab.Display_in_favorites_menu__10=Display in favorites menu:
+CommonTab.Display_in_favorites_menu__10=Display in fa&vorites menu:
CommonTab.Invalid_shared_configuration_location_14=Invalid shared configuration location
CommonTab.L&ocal_3=L&ocal
CommonTab.Location_of_shared_confi&guration__5=&Location of shared configuration:
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java
new file mode 100644
index 000000000..d0c24d68f
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java
@@ -0,0 +1,376 @@
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+This file is made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+**********************************************************************/
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationListener;
+import org.eclipse.debug.core.ILaunchListener;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * A history of launches and favorites for a launch group
+ */
+public class LaunchHistory implements ILaunchListener, IPropertyChangeListener, ILaunchConfigurationListener {
+
+ private LaunchGroupExtension fGroup;
+
+ private List fHistory = new ArrayList();
+ private List fFavorites = new ArrayList();
+ private boolean fDirty = false;
+ private ILaunchConfiguration fRecentLaunch;
+
+ /**
+ * Creates a new launch history for the given launch group
+ */
+ public LaunchHistory(LaunchGroupExtension group) {
+ fGroup = group;
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ manager.addLaunchListener(this);
+ manager.addLaunchConfigurationListener(this);
+ DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+ }
+
+ /**
+ * Disposes this history
+ */
+ public void dispose() {
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ manager.removeLaunchListener(this);
+ manager.removeLaunchConfigurationListener(this);
+ DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug.core.ILaunch)
+ */
+ public void launchAdded(ILaunch launch) {
+ if (accepts(launch)) {
+ addHistory(launch.getLaunchConfiguration());
+ setRecentLaunch(launch.getLaunchConfiguration());
+ }
+ }
+
+ /**
+ * Adds the givev configuration to this hisotry
+ *
+ * @param configuration */
+ protected void addHistory(ILaunchConfiguration configuration) {
+ clearDirty();
+ if (fFavorites.contains(configuration)) {
+ return;
+ }
+ // might be reconstructing history
+ if (checkIfFavorite(configuration)) {
+ return;
+ }
+ int index = fHistory.indexOf(configuration);
+ if (index < 0) {
+ fHistory.add(0, configuration);
+ resizeHistory();
+ setDirty();
+ } else if (index > 0) {
+ // move to first
+ for (int i = index; i > 0; i--) {
+ fHistory.set(i, fHistory.get(i -1));
+ }
+ fHistory.set(0, configuration);
+ setDirty();
+ }
+ save();
+ }
+
+ /**
+ * Saves if dirty
+ */
+ private void save() {
+ if (isDirty()) {
+ try {
+ LaunchConfigurationManager.getDefault().persistLaunchHistory();
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ } catch (IOException e) {
+ DebugUIPlugin.log(e);
+ }
+ }
+ }
+
+ /**
+ * Clears the dirty flag
+ */
+ private void clearDirty() {
+ fDirty = false;
+ }
+
+ /**
+ * Sets the dirty flag
+ */
+ private void setDirty() {
+ fDirty = true;
+ }
+
+ /**
+ * Returns the dirty state
+ */
+ private boolean isDirty() {
+ return fDirty;
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch)
+ */
+ public void launchChanged(ILaunch launch) {
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch)
+ */
+ public void launchRemoved(ILaunch launch) {
+ }
+
+ /**
+ * Returns the most recently launched configuration in this history, or
+ * <code>null</code> if none.
+ *
+ * @return the most recently launched configuration in this history, or
+ * <code>null</code> if none */
+ public ILaunchConfiguration getRecentLaunch() {
+ return fRecentLaunch;
+ }
+
+ /**
+ * Sets the most recently launched configuration in this history, or
+ * <code>null</code> if none.
+ */
+ protected void setRecentLaunch(ILaunchConfiguration configuration) {
+ if (accepts(configuration)) {
+ if (!configuration.equals(fRecentLaunch)) {
+ fRecentLaunch = configuration;
+ setDirty();
+ save();
+ }
+ }
+ }
+
+ /**
+ * Returns the launch configuration in this history, in most recently
+ * launched order.
+ *
+ * @return launch history */
+ public ILaunchConfiguration[] getHistory() {
+ return (ILaunchConfiguration[])fHistory.toArray(new ILaunchConfiguration[fHistory.size()]);
+ }
+
+ /**
+ * Returns the favorite launch configurations in this history, in the order
+ * they were created.
+ *
+ * @return launch favorites */
+ public ILaunchConfiguration[] getFavorites() {
+ return (ILaunchConfiguration[])fFavorites.toArray(new ILaunchConfiguration[fFavorites.size()]);
+ }
+
+ /**
+ * Sets this container's launch history.
+ *
+ * @param history */
+ public void setHistory(ILaunchConfiguration[] history) {
+ fHistory = new ArrayList(history.length);
+ for (int i = 0; i < history.length; i++) {
+ fHistory.add(history[i]);
+ }
+ resizeHistory();
+ setDirty();
+ save();
+ }
+
+ /**
+ * Sets this container's favorites.
+ *
+ * @param favorites
+ */
+ public void setFavorites(ILaunchConfiguration[] favorites) {
+ fFavorites = new ArrayList(favorites.length);
+ for (int i = 0; i < favorites.length; i++) {
+ fFavorites.add(favorites[i]);
+ }
+ setDirty();
+ save();
+ }
+
+ /**
+ * Adds the given configuration to the favorites list.
+ *
+ * @param configuration */
+ public void addFavorite(ILaunchConfiguration configuration) {
+ clearDirty();
+ if (!fFavorites.contains(configuration)) {
+ fFavorites.add(configuration);
+ fHistory.remove(configuration);
+ setDirty();
+ }
+ save();
+ }
+
+ /**
+ * Returns the launch group associated with this history
+ *
+ * @return group */
+ public LaunchGroupExtension getLaunchGroup() {
+ return fGroup;
+ }
+
+ /**
+ * Returns whether the given launch is included in the group assocaited with
+ * this launch history.
+ *
+ * @param launch * @return boolean */
+ protected boolean accepts(ILaunch launch) {
+ ILaunchConfiguration configuration = launch.getLaunchConfiguration();
+ if (configuration == null) {
+ return false;
+ }
+ return accepts(configuration);
+ }
+
+ /**
+ * Returns whether the given configruation is included in the group
+ * associated with this launch history.
+ *
+ * @param launch
+ * @return boolean
+ */
+ public boolean accepts(ILaunchConfiguration configuration) {
+ try {
+ if (configuration.getType().supportsMode(getLaunchGroup().getMode())) {
+ String launchCategory = null;
+ launchCategory = configuration.getCategory();
+ String category = getLaunchGroup().getCategory();
+ if (launchCategory == null || category == null) {
+ return launchCategory == category;
+ }
+ return category.equals(launchCategory) && LaunchConfigurationManager.isVisible(configuration);
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IDebugUIConstants.PREF_MAX_HISTORY_SIZE)) {
+ resizeHistory();
+ save();
+ }
+ }
+
+ /**
+ * The max history size has changed - remove any histories if current
+ * collection is too long.
+ */
+ protected void resizeHistory() {
+ int max = getMaxHistorySize();
+ while (fHistory.size() > max) {
+ fHistory.remove(fHistory.size() - 1);
+ setDirty();
+ }
+ }
+
+ /**
+ * Returns the maximum number of entries allowed in this history
+ *
+ * @return the maximum number of entries allowed in this history */
+ protected int getMaxHistorySize() {
+ return DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_HISTORY_SIZE);
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+ checkIfFavorite(configuration);
+ }
+
+ /**
+ * Adds the given config to the favorites list if it is a favorite, and
+ * returns whether the config was added to the favorites list.
+ *
+ * @param configuration
+ * @return whether added to the favorites list
+ */
+ protected boolean checkIfFavorite(ILaunchConfiguration configuration) {
+ // update favorites
+ if (configuration.isWorkingCopy()) {
+ return false;
+ }
+ try {
+ List favoriteGroups = configuration.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null);
+ if (favoriteGroups == null) {
+ // check deprecated attributes for backwards compatibility
+ String groupId = getLaunchGroup().getIdentifier();
+ boolean fav = false;
+ if (groupId.equals(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP)) {
+ fav = configuration.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false);
+ } else if (groupId.equals(IDebugUIConstants.ID_RUN_LAUNCH_GROUP)) {
+ fav = configuration.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false);
+ }
+ if (fav) {
+ addFavorite(configuration);
+ return true;
+ }
+ } else if (favoriteGroups.contains(getLaunchGroup().getIdentifier())) {
+ addFavorite(configuration);
+ return true;
+ }
+ } catch (CoreException e) {
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void launchConfigurationChanged(ILaunchConfiguration configuration) {
+ checkIfFavorite(configuration);
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+ boolean removed = fHistory.remove(configuration);
+ removed = fFavorites.remove(configuration) || removed;
+ if (removed) {
+ setDirty();
+ save();
+ if (configuration.equals(fRecentLaunch)) {
+ if (fHistory.isEmpty()) {
+ if (!fFavorites.isEmpty()) {
+ fRecentLaunch = (ILaunchConfiguration)fFavorites.get(0);
+ }
+ } else {
+ fRecentLaunch = (ILaunchConfiguration)fHistory.get(0);
+ }
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugHistoryPreferenceTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugHistoryPreferenceTab.java
deleted file mode 100644
index 40b25c5be..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugHistoryPreferenceTab.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.eclipse.debug.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
-
-/**
- * Debug favorites and history
- */
-public class DebugHistoryPreferenceTab extends LaunchHistoryPreferenceTab {
-
- /**
- * @see LaunchHistoryPreferenceTab#getFavoritesLabel()
- */
- protected String getFavoritesLabel() {
- return DebugPreferencesMessages.getString("DebugHistoryPreferenceTab.Favorite_Debug_Confi&gurations__1"); //$NON-NLS-1$
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getRecentLabel()
- */
- protected String getRecentLabel() {
- return DebugPreferencesMessages.getString("DebugHistoryPreferenceTab.Recent_Debug_&Launches__2"); //$NON-NLS-1$
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getInitialFavorites()
- */
- protected ILaunchConfiguration[] getInitialFavorites() {
- LaunchConfigurationHistoryElement[] favs = DebugUIPlugin.getLaunchConfigurationManager().getDebugFavorites();
- ILaunchConfiguration[] configs = new ILaunchConfiguration[favs.length];
- for (int i = 0; i < favs.length; i++) {
- configs[i] = favs[i].getLaunchConfiguration();
- }
- return configs;
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getIntialRecents()
- */
- protected ILaunchConfiguration[] getInitialRecents() {
- LaunchConfigurationHistoryElement[] favs = DebugUIPlugin.getLaunchConfigurationManager().getDebugHistory();
- ILaunchConfiguration[] configs = new ILaunchConfiguration[favs.length];
- for (int i = 0; i < favs.length; i++) {
- configs[i] = favs[i].getLaunchConfiguration();
- if (configs[i] == null) {
- // not using launch configs
- return new ILaunchConfiguration[0];
- }
- }
- return configs;
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getMode()
- */
- protected String getMode() {
- return ILaunchManager.DEBUG_MODE;
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferencePage.java
index afff0b3f1..6ff9aaee4 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferencePage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferencePage.java
@@ -1,31 +1,32 @@
package org.eclipse.debug.internal.ui.preferences;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+This file is made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+**********************************************************************/
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
+import org
+ .eclipse
+ .debug
+ .internal
+ .ui
+ .launchConfigurations
+ .LaunchConfigurationManager;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
@@ -46,15 +47,10 @@ public class LaunchHistoryPreferencePage extends PreferencePage implements IWork
private IntegerFieldEditor fHistoryMaxEditor;
/**
- * Debug tab.
- */
- protected LaunchHistoryPreferenceTab fDebugTab;
-
- /**
- * Run tab.
+ * History tabs.
*/
- protected LaunchHistoryPreferenceTab fRunTab;
-
+ protected LaunchHistoryPreferenceTab[] fTabs;
+
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
@@ -85,33 +81,40 @@ public class LaunchHistoryPreferencePage extends PreferencePage implements IWork
gd.horizontalSpan= 2;
tabFolder.setLayoutData(gd);
- TabItem tab = new TabItem(tabFolder, SWT.NONE);
- tab.setText(DebugPreferencesMessages.getString("LaunchHistoryPreferencePage.De&bug_1")); //$NON-NLS-1$
- tab.setImage(DebugPluginImages.getImage(IDebugUIConstants.IMG_ACT_DEBUG));
- tab.setControl(createDebugTab(tabFolder));
+ // create tabs (debug and run first)
+ LaunchConfigurationManager manager = LaunchConfigurationManager.getDefault();
+ LaunchGroupExtension[] groups = manager.getLaunchGroups();
+ fTabs = new LaunchHistoryPreferenceTab[groups.length];
+ LaunchHistory history = manager.getLaunchHistory(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP);
+ fTabs[0] = createTab(history, tabFolder);
+ history = manager.getLaunchHistory(IDebugUIConstants.ID_RUN_LAUNCH_GROUP);
+ fTabs[1] = createTab(history, tabFolder);
- tab = new TabItem(tabFolder, SWT.NONE);
- tab.setText(DebugPreferencesMessages.getString("LaunchHistoryPreferencePage.&Run_2")); //$NON-NLS-1$
- tab.setImage(DebugPluginImages.getImage(IDebugUIConstants.IMG_ACT_RUN));
- tab.setControl(createRunTab(tabFolder));
-
+ // create other tabs
+ int index = 2;
+ for (int i = 0; i < groups.length; i++) {
+ LaunchGroupExtension extension = groups[i];
+ String id = extension.getIdentifier();
+ if (!(id.equals(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP) || id.equals(IDebugUIConstants.ID_RUN_LAUNCH_GROUP))) {
+ history = manager.getLaunchHistory(id);
+ fTabs[index] = createTab(history, tabFolder);
+ index++;
+ }
+ }
return composite;
}
- /**
- * Creates the control for the debug favorites
- */
- protected Control createDebugTab(Composite parent) {
- setDebugTab(new DebugHistoryPreferenceTab());
- return getDebugTab().createControl(parent);
- }
-
- /**
- * Creates the control for the debug favorites
- */
- protected Control createRunTab(Composite parent) {
- setRunTab(new RunHistoryPreferenceTab());
- return getRunTab().createControl(parent);
+ protected LaunchHistoryPreferenceTab createTab(LaunchHistory history, TabFolder tabFolder) {
+ TabItem tab = new TabItem(tabFolder, SWT.NONE);
+ tab.setText(history.getLaunchGroup().getLabel());
+ ImageDescriptor descriptor = history.getLaunchGroup().getImageDescriptor();
+ if (descriptor != null) {
+ tab.setImage(descriptor.createImage());
+ // TODO: dispose image
+ }
+ LaunchHistoryPreferenceTab prefTab = new LaunchHistoryPreferenceTab(history);
+ tab.setControl(prefTab.createControl(tabFolder));
+ return prefTab;
}
/**
@@ -122,72 +125,14 @@ public class LaunchHistoryPreferencePage extends PreferencePage implements IWork
}
/**
- * Returns the run tab.
- *
- * @return a launch history preference tab
- */
- protected LaunchHistoryPreferenceTab getRunTab() {
- return fRunTab;
- }
-
- /**
- * Sets the run tab.
- *
- * @param tab launch history preference tab
- */
- private void setRunTab(LaunchHistoryPreferenceTab tab) {
- fRunTab = tab;
- }
-
- /**
- * Returns the debug tab.
- *
- * @return a launch history preference tab
- */
- protected LaunchHistoryPreferenceTab getDebugTab() {
- return fDebugTab;
- }
-
- /**
- * Sets the debug tab.
- *
- * @param tab launch history preference tab
- */
- private void setDebugTab(LaunchHistoryPreferenceTab tab) {
- fDebugTab = tab;
- }
-
- /**
* @see PreferencePage#performOk()
*/
public boolean performOk() {
- ILaunchConfiguration[] debugOriginals = getDebugTab().getInitialFavorites();
- ILaunchConfiguration[] runOriginals = getRunTab().getInitialFavorites();
-
- LaunchConfigurationManager manager= DebugUIPlugin.getLaunchConfigurationManager();
- // debug favorites
- Vector list = convertToHistoryElements(getDebugTab().getFavorites(), ILaunchManager.DEBUG_MODE);
- manager.setDebugFavorites(list);
-
- // debug recent history
- list = convertToHistoryElements(getDebugTab().getRecents(), ILaunchManager.DEBUG_MODE);
- manager.setDebugHistory(list);
-
- // run favorites
- list = convertToHistoryElements(getRunTab().getFavorites(), ILaunchManager.RUN_MODE);
- manager.setRunFavorites(list);
-
- // run recent history
- list = convertToHistoryElements(getRunTab().getRecents(), ILaunchManager.RUN_MODE);
- manager.setRunHistory(list);
-
- // update config attributes for favorites
- List current = getDebugTab().getFavorites();
- updateAttributes(debugOriginals, current, IDebugUIConstants.ATTR_DEBUG_FAVORITE);
-
- current = getRunTab().getFavorites();
- updateAttributes(runOriginals, current, IDebugUIConstants.ATTR_RUN_FAVORITE);
+ for (int i = 0; i < fTabs.length; i++) {
+ LaunchHistoryPreferenceTab tab = fTabs[i];
+ tab.performOK();
+ }
fHistoryMaxEditor.store();
@@ -196,66 +141,13 @@ public class LaunchHistoryPreferencePage extends PreferencePage implements IWork
}
/**
- * Update the 'favorite' attributes to reflect the current list.
- */
- protected void updateAttributes(ILaunchConfiguration[] originals, List current, String attribute) {
- List added = new ArrayList(current);
- List removed = new ArrayList();
-
- for (int i = 0; i < originals.length; i++) {
- added.remove(originals[i]);
- if (!current.contains(originals[i])) {
- removed.add(originals[i]);
- }
- }
-
- try {
- Iterator a = added.iterator();
- while (a.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration)a.next();
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(attribute, true);
- wc.doSave();
- }
-
- Iterator r = removed.iterator();
- while (r.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration)r.next();
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(attribute, (String)null);
- wc.doSave();
- }
- } catch (CoreException e) {
- DebugUIPlugin.log(e);
- }
- }
-
- /**
- * Converts the list of launch configurations to a vector
- * of history elements.
- *
- * @param configs list of configs
- * @param mode the mode for the history elements
- * @return vector of history elements corresponding to the
- * given launch configurations
- */
- protected Vector convertToHistoryElements(List configs, String mode) {
- Vector v = new Vector(configs.size());
- Iterator iter = configs.iterator();
- while (iter.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration)iter.next();
- LaunchConfigurationHistoryElement hist = new LaunchConfigurationHistoryElement(config, mode);
- v.add(hist);
- }
- return v;
- }
-
- /**
* @see PreferencePage#performDefaults()
*/
protected void performDefaults() {
- getDebugTab().performDefaults();
- getRunTab().performDefaults();
+ for (int i = 0; i < fTabs.length; i++) {
+ LaunchHistoryPreferenceTab tab = fTabs[i];
+ tab.performDefaults();
+ }
fHistoryMaxEditor.loadDefault();
super.performDefaults();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferenceTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferenceTab.java
index b35214deb..d9dc30e34 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferenceTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchHistoryPreferenceTab.java
@@ -1,9 +1,11 @@
package org.eclipse.debug.internal.ui.preferences;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+This file is made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+**********************************************************************/
import java.util.ArrayList;
import java.util.Iterator;
@@ -12,6 +14,7 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.SWTUtil;
import org
@@ -21,7 +24,9 @@ import org
.ui
.launchConfigurations
.LaunchConfigurationManager;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -44,7 +49,7 @@ import org.eclipse.ui.model.WorkbenchViewerSorter;
/**
* Tab for favorite and recent history lists
*/
-public abstract class LaunchHistoryPreferenceTab {
+public class LaunchHistoryPreferenceTab {
/**
* Table of favorite launch configurations
@@ -76,6 +81,22 @@ public abstract class LaunchHistoryPreferenceTab {
private List fRecents;
/**
+ * Launch group. */
+ private LaunchHistory fLaunchHistory;
+
+ /**
+ * Constructs a launch history preference tab for the given launch history
+ *
+ * @param history */
+ public LaunchHistoryPreferenceTab(LaunchHistory history) {
+ fLaunchHistory = history;
+ }
+
+ protected LaunchHistory getLaunchHistory() {
+ return fLaunchHistory;
+ }
+
+ /**
* Creates the control for this tab
*/
protected Control createControl(Composite parent) {
@@ -87,7 +108,7 @@ public abstract class LaunchHistoryPreferenceTab {
topComp.setLayoutData(gd);
Label favoritesLabel = new Label(topComp, SWT.LEFT);
- favoritesLabel.setText(getFavoritesLabel());
+ favoritesLabel.setText("Fa&vorites:");
gd = new GridData();
gd.horizontalSpan = 2;
favoritesLabel.setLayoutData(gd);
@@ -157,7 +178,7 @@ public abstract class LaunchHistoryPreferenceTab {
createSpacer(topComp, 1);
Label recent = new Label(topComp, SWT.LEFT);
- recent.setText(getRecentLabel());
+ recent.setText("&Launch History:");
gd = new GridData();
gd.horizontalSpan = 2;
recent.setLayoutData(gd);
@@ -392,27 +413,23 @@ public abstract class LaunchHistoryPreferenceTab {
/**
* Returns the mode of this page - run or debug.
*/
- protected abstract String getMode();
-
- /**
- * Returns the label for the favorites table.
- */
- protected abstract String getFavoritesLabel();
+ protected String getMode() {
+ return getLaunchHistory().getLaunchGroup().getMode();
+ }
/**
* Returns the initial content for the favorites list
*/
- protected abstract ILaunchConfiguration[] getInitialFavorites();
-
- /**
- * Returns the label for the recent launch table.
- */
- protected abstract String getRecentLabel();
+ protected ILaunchConfiguration[] getInitialFavorites() {
+ return getLaunchHistory().getFavorites();
+ }
/**
* Returns the initial content for the recent table
*/
- protected abstract ILaunchConfiguration[] getInitialRecents();
+ protected ILaunchConfiguration[] getInitialRecents() {
+ return getLaunchHistory().getHistory();
+ }
/**
* Content provider for favorites table
@@ -540,4 +557,65 @@ public abstract class LaunchHistoryPreferenceTab {
handleFavoriteSelectionChanged();
handleRecentSelectionChanged();
}
+
+ /**
+ * Method performOK.
+ */
+ public void performOK() {
+ ILaunchConfiguration[] initial = getInitialFavorites();
+ List current = getFavorites();
+ String groupId = getLaunchHistory().getLaunchGroup().getIdentifier();
+
+ // removed favorites
+ for (int i = 0; i < initial.length; i++) {
+ ILaunchConfiguration configuration = initial[i];
+ if (current.contains(configuration)) {
+ } else {
+ // remove fav attributes
+ try {
+ ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
+ workingCopy.setAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, (String)null);
+ workingCopy.setAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, (String)null);
+ List groups = workingCopy.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null);
+ if (groups != null) {
+ groups.remove(groupId);
+ if (groups.isEmpty()) {
+ groups = null;
+ }
+ workingCopy.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, groups);
+ }
+ workingCopy.doSave();
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ }
+ }
+ }
+ // update added favorites
+ Iterator favs = current.iterator();
+ while (favs.hasNext()) {
+ ILaunchConfiguration configuration = (ILaunchConfiguration)favs.next();
+ try {
+ List groups = configuration.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null);
+ if (groups == null) {
+ groups = new ArrayList();
+ }
+ if (!groups.contains(groupId)) {
+ groups.add(groupId);
+ ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
+ workingCopy.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, groups);
+ workingCopy.doSave();
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ }
+ }
+
+ fLaunchHistory.setFavorites(getArray(current));
+ fLaunchHistory.setHistory(getArray(getRecents()));
+ }
+
+ protected ILaunchConfiguration[] getArray(List list) {
+ return (ILaunchConfiguration[])list.toArray(new ILaunchConfiguration[list.size()]);
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunHistoryPreferenceTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunHistoryPreferenceTab.java
deleted file mode 100644
index c79533ebb..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunHistoryPreferenceTab.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.eclipse.debug.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationHistoryElement;
-
-/**
- * Run favorites and history
- */
-public class RunHistoryPreferenceTab extends LaunchHistoryPreferenceTab {
-
- /**
- * @see LaunchHistoryPreferenceTab#getFavoritesLabel()
- */
- protected String getFavoritesLabel() {
- return DebugPreferencesMessages.getString("RunHistoryPreferenceTab.Favorite_Run_Confi&gurations__1"); //$NON-NLS-1$
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getRecentLabel()
- */
- protected String getRecentLabel() {
- return DebugPreferencesMessages.getString("RunHistoryPreferenceTab.Recent_Run_&Launches__2"); //$NON-NLS-1$
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getInitialFavorites()
- */
- protected ILaunchConfiguration[] getInitialFavorites() {
- LaunchConfigurationHistoryElement[] favs = DebugUIPlugin.getLaunchConfigurationManager().getRunFavorites();
- ILaunchConfiguration[] configs = new ILaunchConfiguration[favs.length];
- for (int i = 0; i < favs.length; i++) {
- configs[i] = favs[i].getLaunchConfiguration();
- }
- return configs;
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getInitialRecents()
- */
- protected ILaunchConfiguration[] getInitialRecents() {
- LaunchConfigurationHistoryElement[] favs = DebugUIPlugin.getLaunchConfigurationManager().getRunHistory();
- ILaunchConfiguration[] configs = new ILaunchConfiguration[favs.length];
- for (int i = 0; i < favs.length; i++) {
- configs[i] = favs[i].getLaunchConfiguration();
- if (configs[i] == null) {
- // not using launch configs
- return new ILaunchConfiguration[0];
- }
- }
- return configs;
- }
-
- /**
- * @see LaunchHistoryPreferenceTab#getMode()
- */
- protected String getMode() {
- return ILaunchManager.RUN_MODE;
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
index e994a1f26..b71e195b5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
@@ -7,6 +7,12 @@ which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v10.html
**********************************************************************/
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -18,8 +24,34 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsMessages;
+import org
+ .eclipse
+ .debug
+ .internal
+ .ui
+ .launchConfigurations
+ .LaunchConfigurationManager;
+import org
+ .eclipse
+ .debug
+ .internal
+ .ui
+ .launchConfigurations
+ .LaunchConfigurationsMessages;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -31,6 +63,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IPerspectiveDescriptor;
@@ -86,14 +119,9 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
private Label fSwitchToLabel;
/**
- * The check box specifying run favoite
+ * Check box list for specifying favorites
*/
- private Button fRunFavoriteButton;
-
- /**
- * The check box specifying debug favoite
- */
- private Button fDebugFavoriteButton;
+ private CheckboxTableViewer fFavoritesTable;
/**
* Constant for the name of the drop-down choice 'None' for perspectives.
@@ -222,22 +250,39 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
createVerticalSpacer(comp, 1);
Composite favComp = new Composite(comp, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ favComp.setLayoutData(gd);
GridLayout favLayout = new GridLayout();
favLayout.marginHeight = 0;
favLayout.marginWidth = 0;
- favLayout.numColumns = 1;
+ favLayout.numColumns = 2;
+ favLayout.makeColumnsEqualWidth = true;
favComp.setLayout(favLayout);
Label favLabel = new Label(favComp, SWT.HORIZONTAL | SWT.LEFT);
favLabel.setText(LaunchConfigurationsMessages.getString("CommonTab.Display_in_favorites_menu__10")); //$NON-NLS-1$
+ gd = new GridData(GridData.BEGINNING);
+ gd.horizontalSpan = 2;
+ favLabel.setLayoutData(gd);
+
+ createVerticalSpacer(favComp, 2);
- setRunFavoriteButton(new Button(favComp, SWT.CHECK));
- getRunFavoriteButton().setText(LaunchConfigurationsMessages.getString("CommonTab.&Run_11")); //$NON-NLS-1$
- getRunFavoriteButton().addSelectionListener(fBasicSelectionListener);
-
- setDebugFavoriteButton(new Button(favComp, SWT.CHECK));
- getDebugFavoriteButton().setText(LaunchConfigurationsMessages.getString("CommonTab.Debu&g_12")); //$NON-NLS-1$
- getDebugFavoriteButton().addSelectionListener(fBasicSelectionListener);
+ fFavoritesTable = CheckboxTableViewer.newCheckList(favComp, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+ Control table = fFavoritesTable.getControl();
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ table.setLayoutData(gd);
+ fFavoritesTable.setContentProvider(new FavoritesContentProvider());
+ fFavoritesTable.setLabelProvider(new FavoritesLabelProvider());
+ fFavoritesTable.addCheckStateListener(
+ new ICheckStateListener() {
+ /**
+ * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
+ */
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+ });
}
@@ -500,23 +545,32 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
}
private void updateFavoritesFromConfig(ILaunchConfiguration config) {
- ILaunchConfigurationType type = null;
- boolean isDebug = false;
- boolean isRun = false;
+ fFavoritesTable.setInput(config);
+ fFavoritesTable.setCheckedElements(new Object[]{});
try {
- type = config.getType();
- isDebug = config.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false);
- isRun = config.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false);
- } catch (CoreException ce) {
- getDebugFavoriteButton().setEnabled(false);
- getRunFavoriteButton().setEnabled(false);
- return;
+ List groups = config.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, new ArrayList());
+ if (groups.isEmpty()) {
+ // check old attributes for backwards compatible
+ if (config.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false)) {
+ groups.add(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP);
+ }
+ if (config.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false)) {
+ groups.add(IDebugUIConstants.ID_RUN_LAUNCH_GROUP);
+ }
+ }
+ if (!groups.isEmpty()) {
+ List list = new ArrayList();
+ Iterator iterator = groups.iterator();
+ while (iterator.hasNext()) {
+ String id = (String)iterator.next();
+ LaunchGroupExtension extension = LaunchConfigurationManager.getDefault().getLaunchGroup(id);
+ list.add(extension);
+ }
+ fFavoritesTable.setCheckedElements(list.toArray());
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
}
- getDebugFavoriteButton().setEnabled(type.supportsMode(ILaunchManager.DEBUG_MODE));
- getRunFavoriteButton().setEnabled(type.supportsMode(ILaunchManager.RUN_MODE));
- getDebugFavoriteButton().setSelection(isDebug);
- getRunFavoriteButton().setSelection(isRun);
-
}
/**
@@ -607,16 +661,52 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
* and will be missing for older configs.
*/
private void updateConfigFromFavorites(ILaunchConfigurationWorkingCopy config) {
- if (getDebugFavoriteButton().getSelection()) {
- config.setAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, true);
- } else {
+ try {
+ Object[] checked = fFavoritesTable.getCheckedElements();
+ boolean debug = config.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false);
+ boolean run = config.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false);
+ if (debug || run) {
+ // old attributes
+ List groups = new ArrayList();
+ int num = 0;
+ if (debug) {
+ groups.add(LaunchConfigurationManager.getDefault().getLaunchGroup(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP));
+ num++;
+ }
+ if (run) {
+ num++;
+ groups.add(LaunchConfigurationManager.getDefault().getLaunchGroup(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP));
+ }
+ // see if there are any changes
+ if (num == checked.length) {
+ boolean different = false;
+ for (int i = 0; i < checked.length; i++) {
+ if (!groups.contains(checked[i])) {
+ different = true;
+ break;
+ }
+ }
+ if (!different) {
+ return;
+ }
+ }
+ }
+ // erase old attributes (if any)
config.setAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, (String)null);
- }
- if (getRunFavoriteButton().getSelection()) {
- config.setAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, true);
- } else {
config.setAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, (String)null);
- }
+ // new attribute
+ List groups = null;
+ for (int i = 0; i < checked.length; i++) {
+ LaunchGroupExtension group = (LaunchGroupExtension)checked[i];
+ if (groups == null) {
+ groups = new ArrayList();
+ }
+ groups.add(group.getIdentifier());
+ }
+ config.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, groups);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ }
}
/**
@@ -674,46 +764,6 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
}
/**
- * Returns the check box used to specify a config
- * as a debug favorite.
- *
- * @return check box
- */
- private Button getDebugFavoriteButton() {
- return fDebugFavoriteButton;
- }
-
- /**
- * Sets the check box used to specify a config
- * as a debug favorite.
- *
- * @param button check box
- */
- private void setDebugFavoriteButton(Button button) {
- fDebugFavoriteButton = button;
- }
-
- /**
- * Returns the check box used to specify a config
- * as a run favorite.
- *
- * @return check box
- */
- private Button getRunFavoriteButton() {
- return fRunFavoriteButton;
- }
-
- /**
- * Sets the check box used to specify a config
- * as a run favorite.
- *
- * @param button check box
- */
- private void setRunFavoriteButton(Button button) {
- fRunFavoriteButton = button;
- }
-
- /**
* @see ILaunchConfigurationTab#getName()
*/
public String getName() {
@@ -734,5 +784,97 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
return DebugUITools.getImage(IDebugUIConstants.IMG_PERSPECTIVE_DEBUG);
}
+ class FavoritesContentProvider implements IStructuredContentProvider {
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ LaunchGroupExtension[] groups = LaunchConfigurationManager.getDefault().getLaunchGroups();
+ List possibleGroups = new ArrayList();
+ ILaunchConfiguration configuration = (ILaunchConfiguration)inputElement;
+ for (int i = 0; i < groups.length; i++) {
+ LaunchGroupExtension extension = groups[i];
+ LaunchHistory history = LaunchConfigurationManager.getDefault().getLaunchHistory(extension.getIdentifier());
+ if (history.accepts(configuration)) {
+ possibleGroups.add(extension);
+ }
+ }
+ return possibleGroups.toArray();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(
+ Viewer viewer,
+ Object oldInput,
+ Object newInput) {
+ }
+
+ }
+
+ class FavoritesLabelProvider implements ITableLabelProvider {
+
+ private Map fImages = new HashMap();
+
+ /**
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ Image image = (Image)fImages.get(element);
+ if (image == null) {
+ ImageDescriptor descriptor = ((LaunchGroupExtension)element).getImageDescriptor();
+ if (descriptor != null) {
+ image = descriptor.createImage();
+ fImages.put(element, image);
+ }
+ }
+ return image;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ return ((LaunchGroupExtension)element).getLabel();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+ */
+ public void dispose() {
+ Iterator images = fImages.values().iterator();
+ while (images.hasNext()) {
+ Image image = (Image)images.next();
+ image.dispose();
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
+ */
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
index 69150ccc7..60c688aac 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
@@ -356,27 +356,29 @@ public class DebugUITools {
* @param mode launch mode - run or debug
*/
public static void launch(final ILaunchConfiguration configuration, final String mode) {
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(DebugUIPlugin.getShell());
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- configuration.launch(mode, monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
+ if (saveAndBuildBeforeLaunch()) {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(DebugUIPlugin.getShell());
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ configuration.launch(mode, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ };
+ try {
+ dialog.run(true, true, runnable);
+ } catch (InvocationTargetException e) {
+ Throwable targetException = e.getTargetException();
+ Throwable t = e;
+ if (targetException instanceof CoreException) {
+ t = targetException;
}
- }
- };
- try {
- dialog.run(true, true, runnable);
- } catch (InvocationTargetException e) {
- Throwable targetException = e.getTargetException();
- Throwable t = e;
- if (targetException instanceof CoreException) {
- t = targetException;
+ DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), "Error", "Exception occurred during launch", t);
+ } catch (InterruptedException e) {
+ // cancelled
}
- DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), "Error", "Exception occurred during launch", t);
- } catch (InterruptedException e) {
- // cancelled
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
index 6b0c26587..59227182a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
@@ -602,6 +602,7 @@ public interface IDebugUIConstants {
* <code>false</code> if absent.
*
* @since 2.0
+ * @deprecated use <code>ATTR_FAVORITE_GROUPS</code> instead
*/
public static final String ATTR_DEBUG_FAVORITE = PLUGIN_ID + ".debugFavorite"; //$NON-NLS-1$
@@ -611,9 +612,20 @@ public interface IDebugUIConstants {
* <code>false</code> if absent.
*
* @since 2.0
+ * @deprecated use <code>ATTR_FAVORITE_GROUPS</code> instead
*/
public static final String ATTR_RUN_FAVORITE = PLUGIN_ID + ".runFavorite"; //$NON-NLS-1$
+ /**
+ * Launch configuration attribute - a list of launch group identifiers
+ * representing the favorite histories a launch configuration should appear
+ * in. When <code>null</code>, the configuration does not appear in any
+ * favorite lists.
+ *
+ * @since 2.1
+ */
+ public static final String ATTR_FAVORITE_GROUPS = PLUGIN_ID + ".favoriteGroups"; //$NON-NLS-1$
+
// Extension points
/**

Back to the top