Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugDropDownAction.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java135
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchDropDownAction.java16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchHistoryElement.java97
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchActionDelegate.java72
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchHistoryLaunchAction.java13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RunDropDownAction.java2
7 files changed, 225 insertions, 117 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugDropDownAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugDropDownAction.java
index 9a81ef577..569a0d9e9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugDropDownAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugDropDownAction.java
@@ -10,6 +10,7 @@ import org.eclipse.debug.core.ILaunchManager;
public class DebugDropDownAction extends LaunchDropDownAction {
+
public DebugDropDownAction() {
super(new DebugAction());
}
@@ -20,12 +21,14 @@ public class DebugDropDownAction extends LaunchDropDownAction {
public String getMode() {
return ILaunchManager.DEBUG_MODE;
}
-
+
/**
* @see LaunchDropDownAction
*/
- public ILaunch[] getHistory() {
+ public LaunchHistoryElement[] getHistory() {
return DebugUIPlugin.getDefault().getDebugHistory();
}
+
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index df46a2cbc..2b5f664b1 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -10,8 +10,7 @@ import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.debug.core.*;
import org.eclipse.debug.core.model.*;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.debug.ui.IDebugUIEventFilter;
+import org.eclipse.debug.ui.*;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ImageRegistry;
@@ -29,17 +28,23 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
* The Debug UI Plugin.
*
*/
-public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChangedListener,
+public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChangedListener,
IDebugEventListener,
ISelectionListener,
IDocumentListener,
ILaunchListener,
IResourceChangeListener {
+
/**
* The singleton debug plugin instance
*/
private static DebugUIPlugin fgDebugUIPlugin= null;
+
+ /**
+ * A utility presentation used to obtain labels
+ */
+ protected static IDebugModelPresentation fgPresentation = null;
/**
* The selection providers for the debug UI
@@ -81,26 +86,12 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
/**
* The most recent debug launches
*/
- protected ILaunch[] fDebugHistory = new ILaunch[MAX_HISTORY_SIZE];
+ protected Vector fDebugHistory = new Vector(MAX_HISTORY_SIZE);
/**
- * The launched resources for the most recent debug launches.
- * The position of each resource corresponds to the position of the
- * associated launch in fDebugHistory.
- */
- protected IResource[] fDebugHistoryResources = new IResource[MAX_HISTORY_SIZE];
-
- /**
* The most recent run launches
*/
- protected ILaunch[] fRunHistory = new ILaunch[MAX_HISTORY_SIZE];
-
- /**
- * The launched resources for the most recent run launches
- * The position of each resource corresponds to the position of the
- * associated launch in fRunHistory.
- */
- protected IResource[] fRunHistoryResources = new IResource[MAX_HISTORY_SIZE];
+ protected Vector fRunHistory = new Vector(MAX_HISTORY_SIZE);
/**
* Event filters for the debug UI
@@ -581,7 +572,13 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
public static DebugUIPlugin getDefault() {
return fgDebugUIPlugin;
}
-
+
+ public static IDebugModelPresentation getModelPresentation() {
+ if (fgPresentation == null) {
+ fgPresentation = new DelegatingModelPresentation();
+ }
+ return fgPresentation;
+ }
public static IWorkbenchWindow getActiveWorkbenchWindow() {
return getDefault().getWorkbench().getActiveWorkbenchWindow();
}
@@ -1106,8 +1103,8 @@ public static Object createExtension(final IConfigurationElement element, final
*
* @return an array of launches
*/
- public ILaunch[] getDebugHistory() {
- return fDebugHistory;
+ public LaunchHistoryElement[] getDebugHistory() {
+ return getHistoryArray(fDebugHistory);
}
/**
@@ -1115,8 +1112,14 @@ public static Object createExtension(final IConfigurationElement element, final
*
* @return an array of launches
*/
- public ILaunch[] getRunHistory() {
- return fRunHistory;
+ public LaunchHistoryElement[] getRunHistory() {
+ return getHistoryArray(fRunHistory);
+ }
+
+ protected LaunchHistoryElement[] getHistoryArray(Vector history) {
+ LaunchHistoryElement[] array = new LaunchHistoryElement[history.size()];
+ history.copyInto(array);
+ return array;
}
/**
@@ -1133,24 +1136,30 @@ public static Object createExtension(final IConfigurationElement element, final
* Adjust all histories for the given deleted resource.
*/
protected void updateHistoriesForDeletedResource(IResource deletedResource) {
- updateHistoryForDeletedResource(deletedResource, fDebugHistory, fDebugHistoryResources);
- updateHistoryForDeletedResource(deletedResource, fRunHistory, fRunHistoryResources);
+ updateHistoryForDeletedResource(deletedResource, fDebugHistory);
+ updateHistoryForDeletedResource(deletedResource, fRunHistory);
}
/**
* Remove the given resource from the resource history, and remove the corresponding
* launch from the launch history.
*/
- protected void updateHistoryForDeletedResource(IResource deletedResource, ILaunch[] launchHistory, IResource[] resourceHistory) {
- int resourceLength = resourceHistory.length;
- for (int i = 0; i < resourceLength; i++) {
- if (deletedResource.equals(resourceHistory[i])) {
- if (i < resourceLength - 1) {
- System.arraycopy(resourceHistory, i + 1, resourceHistory, i, resourceLength - (i + 1));
- System.arraycopy(launchHistory, i + 1, launchHistory, i, resourceLength - (i + 1));
+ protected void updateHistoryForDeletedResource(IResource deletedResource, Vector history) {
+ List remove = null;
+ Iterator iter = history.iterator();
+ while (iter.hasNext()) {
+ LaunchHistoryElement element = (LaunchHistoryElement)iter.next();
+ if (deletedResource.equals(element.getResource())) {
+ if (remove == null) {
+ remove = new ArrayList(1);
}
- resourceHistory[resourceLength - 1]= null;
- launchHistory[resourceLength - 1]= null;
+ remove.add(element);
+ }
+ }
+ if (remove != null) {
+ iter = remove.iterator();
+ while (iter.hasNext()) {
+ history.remove(iter.next());
}
}
}
@@ -1160,61 +1169,51 @@ public static Object createExtension(final IConfigurationElement element, final
*/
protected void updateHistories(ILaunch launch) {
if (isVisible(launch.getLauncher())) {
+ String elementMemento = launch.getLauncher().getDelegate().getLaunchMemento(launch.getElement());
+ if (elementMemento == null) {
+ return;
+ }
IResource resource= getResourceForLaunch(launch);
- String launchMode= launch.getLaunchMode();
- String otherLaunchMode= launchMode == ILaunchManager.DEBUG_MODE ? ILaunchManager.RUN_MODE : ILaunchManager.DEBUG_MODE;
- ILaunch[] history= launchMode == ILaunchManager.DEBUG_MODE ? fDebugHistory : fRunHistory;
- ILaunch[] otherHistory= otherLaunchMode == ILaunchManager.RUN_MODE ? fRunHistory : fDebugHistory;
- IResource[] resourceHistory= launchMode == ILaunchManager.DEBUG_MODE ? fDebugHistoryResources : fRunHistoryResources;
- IResource[] otherResourceHistory= otherLaunchMode == ILaunchManager.RUN_MODE ? fRunHistoryResources : fDebugHistoryResources;
- updateHistory(history, launchMode, launch, resource, resourceHistory);
- updateHistory(otherHistory, otherLaunchMode, launch, resource, otherResourceHistory);
+ updateHistory(ILaunchManager.DEBUG_MODE, fDebugHistory, launch, resource, elementMemento);
+ updateHistory(ILaunchManager.RUN_MODE, fRunHistory, launch, resource, elementMemento);
}
}
/**
- * Add the given launch to the given history (whose mode is specified by
- * historyMode) if the launcher used by the launch supports the history mode.
+ * Add the given launch to the debug history if the
+ * launcher supports the debug mode.
*/
- protected void updateHistory(ILaunch[] history, String historyMode, ILaunch launch, IResource resource, IResource[] resourceHistory) {
+ protected void updateHistory(String mode, Vector history, ILaunch launch, IResource resource, String memento) {
// First make sure the launcher used supports the mode of the history list
ILauncher launcher= launch.getLauncher();
Set supportedLauncherModes= launcher.getModes();
- if (!supportedLauncherModes.contains(historyMode)) {
+ if (!supportedLauncherModes.contains(mode)) {
return;
}
- // Look for the launch in the history list
+ // create new history item
+ LaunchHistoryElement item= new LaunchHistoryElement(launcher.getIdentifier(), memento, mode, getModelPresentation().getText(launch), resource);
+
+ // Look for an equivalent launch in the history list
int index;
boolean found= false;
- for (index= 0; index < history.length; index++) {
- ILaunch historyLaunch= history[index];
- if (historyLaunch != null && historyLaunch.getElement().equals(launch.getElement()) &&
- launcher.equals(historyLaunch.getLauncher())) {
- found= true;
- break;
- }
- }
+
+ index = history.indexOf(item);
//It's already listed as the most recent launch, so nothing to do
- if (index == 0 && found) {
+ if (index == 0) {
return;
}
// It's in the history, but not the most recent, so make it the most recent
- if (found) {
- //removes from old position
- System.arraycopy(history, index + 1, history, index, history.length - (index + 1));
- System.arraycopy(resourceHistory, index + 1, resourceHistory, index, resourceHistory.length - (index + 1));
+ if (index > 0) {
+ history.remove(item);
}
-
- // It's not in the history, so add it to the beginning, removing the last
- // launch in the list if the list is already at maximum size
- System.arraycopy(history, 0, history, 1, history.length - 1);
- System.arraycopy(resourceHistory, 0, resourceHistory, 1, resourceHistory.length - 1);
- history[0]= launch;
- resourceHistory[0]= resource;
+ history.add(0, item);
+ if (history.size() > MAX_HISTORY_SIZE) {
+ history.remove(history.size() - 1);
+ }
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchDropDownAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchDropDownAction.java
index fea3e1bce..81a529c7c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchDropDownAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchDropDownAction.java
@@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.MenuItem;
*/
public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDelegate {
+
private ExecutionAction fLaunchAction;
/**
@@ -47,15 +48,13 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
*/
public Menu getMenu(Control parent) {
Menu menu= new Menu(parent);
- ILaunch[] historyList= getHistory();
+ LaunchHistoryElement[] historyList= getHistory();
int count= 0;
for (int i = 0; i < historyList.length; i++) {
- ILaunch launch= historyList[i];
- if (launch != null) {
- RelaunchHistoryLaunchAction newAction= new RelaunchHistoryLaunchAction(launch, getMode());
- createMenuForAction(menu, newAction);
- count++;
- }
+ LaunchHistoryElement launch= historyList[i];
+ RelaunchHistoryLaunchAction newAction= new RelaunchHistoryLaunchAction(launch);
+ createMenuForAction(menu, newAction);
+ count++;
}
if (count > 0) {
new MenuItem(menu, SWT.SEPARATOR);
@@ -87,11 +86,12 @@ public abstract class LaunchDropDownAction implements IWorkbenchWindowPulldownDe
/**
* Returns an array of previous launches applicable to this drop down
*/
- public abstract ILaunch[] getHistory();
+ public abstract LaunchHistoryElement[] getHistory();
/**
* Returns the mode (e.g., 'run' or 'debug') of this drop down
*/
public abstract String getMode();
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchHistoryElement.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchHistoryElement.java
new file mode 100644
index 000000000..4266c97a3
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchHistoryElement.java
@@ -0,0 +1,97 @@
+package org.eclipse.debug.internal.ui;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.resources.IResource;
+
+ /**
+ * Stores information required to re-launch a
+ * previous launch.
+ */
+public class LaunchHistoryElement {
+
+ /**
+ * The identifier of the launcher used
+ */
+ protected String fLauncherIdentifier= null;
+
+ /**
+ * The memento of the launched element
+ */
+ protected String fMemento= null;
+
+ /**
+ * The launch mode
+ */
+ protected String fMode=null;
+
+ /**
+ * The label of the launch
+ */
+ protected String fLabel=null;
+
+ /**
+ * The resource associated with the launched element
+ */
+ protected IResource fResource;
+
+ public LaunchHistoryElement(String launcherId, String elementMemento, String mode, String label, IResource resource) {
+ fLauncherIdentifier = launcherId;
+ fMemento = elementMemento;
+ fMode = mode;
+ fLabel = label;
+ fResource = resource;
+ }
+
+ /**
+ * Returns the identifier of the launcher that was
+ * invoked.
+ */
+ public String getLauncherIdentifier() {
+ return fLauncherIdentifier;
+ }
+
+ /**
+ * Returns the memento of the element that was
+ * launched.
+ */
+ public String getElementMemento() {
+ return fMemento;
+ }
+
+ /**
+ * Returns the mode of the lanuch.
+ */
+ public String getMode() {
+ return fMode;
+ }
+
+ /**
+ * Returns the label of the launch
+ */
+ public String getLabel() {
+ return fLabel;
+ }
+
+ /**
+ * Returns the resource associated with the launched element
+ */
+ public IResource getResource() {
+ return fResource;
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof LaunchHistoryElement) {
+ LaunchHistoryElement e= (LaunchHistoryElement)o;
+ return
+ getLauncherIdentifier().equals(e.getLauncherIdentifier()) &&
+ getElementMemento().equals(e.getElementMemento()) &&
+ getMode().equals(getMode());
+ }
+ return false;
+ }
+}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchActionDelegate.java
index 8bb5a1f32..3a96be7ba 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchActionDelegate.java
@@ -6,9 +6,7 @@ package org.eclipse.debug.internal.ui;
*/
import java.text.MessageFormat;
-
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILauncher;
+import org.eclipse.debug.core.*;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.jface.action.IAction;
@@ -26,40 +24,54 @@ public class RelaunchActionDelegate extends ControlActionDelegate {
* @see ControlActionDelegate
*/
protected void doAction(Object object) {
- relaunch(object, null);
- }
-
- /**
- * Re-launches the launch of the given object.
- */
- public static void relaunch(Object object) {
- relaunch(object, null);
+ if (object instanceof IDebugElement) {
+ relaunch((IDebugElement)object);
+ } else if (object instanceof ILaunch) {
+ relaunch((ILaunch)object);
+ } else if (object instanceof IProcess) {
+ relaunch((IProcess)object);
+ }
}
/**
* Re-launches the launch of the given object in the specified mode.
*/
- public static void relaunch(Object object, String mode) {
- ILaunch launch= null;
- if (object instanceof IDebugElement) {
- launch= ((IDebugElement)object).getLaunch();
- } else if (object instanceof ILaunch) {
- launch= (ILaunch)object;
- } else if (object instanceof IProcess) {
- launch= ((IProcess)object).getLaunch();
- }
- if (launch != null) {
- ILauncher launcher= launch.getLauncher();
- Object element= launch.getElement();
- String launchMode= (mode == null) ? launch.getLaunchMode() : mode;
- boolean ok= launcher.launch(new Object[]{element}, launchMode);
- if (!ok) {
- String string= DebugUIUtils.getResourceString(LAUNCH_ERROR_MESSAGE);
- String message= MessageFormat.format(string, new String[] {launcher.getLabel()});
- MessageDialog.openError(DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), DebugUIUtils.getResourceString(LAUNCH_ERROR_TITLE), message);
- }
+ public static void relaunch(ILauncher launcher, String mode, Object element) {
+ boolean ok= launcher.launch(new Object[]{element}, mode);
+ if (!ok) {
+ String string= DebugUIUtils.getResourceString(LAUNCH_ERROR_MESSAGE);
+ String message= MessageFormat.format(string, new String[] {launcher.getLabel()});
+ MessageDialog.openError(DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), DebugUIUtils.getResourceString(LAUNCH_ERROR_TITLE), message);
+ }
+ }
+
+ public static void relaunch(LaunchHistoryElement history) {
+ ILauncher[] launchers = DebugPlugin.getDefault().getLaunchManager().getLaunchers();
+ for (int i = 0; i < launchers.length; i++) {
+ if (launchers[i].getIdentifier().equals(history.getLauncherIdentifier())) {
+ Object element = launchers[i].getDelegate().getLaunchObject(history.getElementMemento());
+ relaunch(launchers[i], history.getMode(), element);
+ return;
+ }
}
}
+
+ public static void relaunch(IDebugElement element) {
+ relaunch(element.getLaunch());
+ }
+
+ public static void relaunch(IProcess process) {
+ relaunch(process.getLaunch());
+ }
+
+ public static void relaunch(ILaunch launch) {
+ relaunch(launch.getLauncher(), launch.getLaunchMode(), launch.getElement());
+ }
+
+ public static void relaunch(ILaunch launch, String mode) {
+ relaunch(launch.getLauncher(), mode, launch.getElement());
+ }
+
/**
* @see ControlActionDelegate
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchHistoryLaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchHistoryLaunchAction.java
index 8d1db6cf9..9d2d7906c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchHistoryLaunchAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RelaunchHistoryLaunchAction.java
@@ -12,17 +12,14 @@ import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchMana
*/
public class RelaunchHistoryLaunchAction extends Action {
- protected static final DelegatingModelPresentation fgPresentation= new DelegatingModelPresentation();
- protected ILaunch fLaunch;
- protected String fMode;
+ protected LaunchHistoryElement fLaunch;
- public RelaunchHistoryLaunchAction(ILaunch launch, String mode) {
+ public RelaunchHistoryLaunchAction(LaunchHistoryElement launch) {
super();
fLaunch= launch;
- fMode= mode;
- setText(fgPresentation.getLaunchText(launch));
+ setText(launch.getLabel());
ImageDescriptor descriptor= null;
- if (launch.getLaunchMode().equals(ILaunchManager.DEBUG_MODE)) {
+ if (launch.getMode().equals(ILaunchManager.DEBUG_MODE)) {
descriptor= DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_ACT_DEBUG);
} else {
descriptor= DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_ACT_RUN);
@@ -42,7 +39,7 @@ public class RelaunchHistoryLaunchAction extends Action {
public void run() {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
- RelaunchActionDelegate.relaunch(fLaunch, fMode);
+ RelaunchActionDelegate.relaunch(fLaunch);
}
});
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RunDropDownAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RunDropDownAction.java
index 7e645d63f..fd2804165 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RunDropDownAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/RunDropDownAction.java
@@ -24,7 +24,7 @@ public class RunDropDownAction extends LaunchDropDownAction {
/**
* @see LaunchDropDownAction
*/
- public ILaunch[] getHistory() {
+ public LaunchHistoryElement[] getHistory() {
return DebugUIPlugin.getDefault().getRunHistory();
}
}

Back to the top