Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java48
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java16
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java39
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java26
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java8
5 files changed, 126 insertions, 11 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
index 91b23de07..2dd061548 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
@@ -237,6 +237,54 @@ public interface ILaunchManager {
* @since 2.0
*/
public IPersistableSourceLocator newSourceLocator(String identifier) throws CoreException;
+
+ /**
+ * When a lanuch configuration is created or moved, registered launch
+ * configuration listeners (see <code>ILaunchConfigurationListener</code>)
+ * are notified of an add notification for the new configuration. If the
+ * notification is the result of a move this method will return a handle to
+ * the launch configuration that the added launch configuration was moved
+ * from. This method returns <code>null</code> if the added launch
+ * configuration was not the result of a rename or move. This information is
+ * only available during the add notifcation call back
+ * <code>launchConfigurationAdded</code>.
+ * <p>
+ * Renaming a configuration is considered the same as moving a
+ * configuration.
+ * </p>
+ *
+ * @param addedConfiguration a launch configuration for which an add
+ * notification is being broadcast
+ * @return the launch configuration that the added launch configuration was
+ * moved from, or <code>null</code> if the add notification is not the
+ * result of a move
+ * @since 2.1
+ */
+ public ILaunchConfiguration getMovedFrom(ILaunchConfiguration addedConfiguration);
+
+ /**
+ * When a lanuch configuration is deleted or moved, registered launch
+ * configuration listeners (see <code>ILaunchConfigurationListener</code>)
+ * are notified of a remove notification for launch configuration that has
+ * been deleted. If the notification is the result of a move this method
+ * will return a handle to the launch configuration that the removed launch
+ * configuration was moved to. This method returns <code>null</code> if the
+ * removed launch configuration was not the result of a rename or move. This
+ * information is only available during the add notifcation call back
+ * <code>launchConfigurationRemoved</code>.
+ * <p>
+ * Renaming a configuration is considered the same as moving a
+ * configuration.
+ * </p>
+ *
+ * @param removedConfiguration a launch configuration for which a
+ * remove notification is being broadcast
+ * @return the launch configuration that the removed launch configuration
+ * was moved to, or <code>null</code> if the add notification is not the
+ * result of a move
+ * @since 2.1
+ */
+ public ILaunchConfiguration getMovedTo(ILaunchConfiguration removedConfiguration);
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
index 1dddac236..5fa0ab906 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
@@ -137,20 +137,26 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
if (isDirty()) {
IWorkspaceRunnable wr = new IWorkspaceRunnable() {
public void run(IProgressMonitor pm) throws CoreException {
+ // set up from/to information if this is a move
+ boolean moved = (!isNew() && isMoved());
+ if (moved) {
+ ILaunchConfiguration to = new LaunchConfiguration(getLocation());
+ ILaunchConfiguration from = getOriginal();
+ getLaunchManager().setMovedFromTo(from, to);
+ }
// write the new file
- LaunchConfigurationWorkingCopy.this.writeNewFile();
+ writeNewFile();
// delete the old file if this is not a new configuration
// or the file was renamed/moved
- if (!LaunchConfigurationWorkingCopy.this.isNew()) {
- if (LaunchConfigurationWorkingCopy.this.isMoved()) {
- LaunchConfigurationWorkingCopy.this.getOriginal().delete();
- }
+ if (moved) {
+ getOriginal().delete();
}
resetDirty();
}
};
ResourcesPlugin.getWorkspace().run(wr, null);
+ getLaunchManager().setMovedFromTo(null, null);
}
return new LaunchConfiguration(getLocation());
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
index 59ff19c68..1b7cdf53f 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
@@ -148,6 +148,12 @@ public class LaunchManager implements ILaunchManager, IResourceChangeListener {
* configuration elements.
*/
private Map fSourceLocators = null;
+
+ /**
+ * The handles of launch configurations being moved, or <code>null</code>
+ */
+ private ILaunchConfiguration fFrom;
+ private ILaunchConfiguration fTo;
/**
* Path to the local directory where local launch configurations
@@ -1202,4 +1208,37 @@ public class LaunchManager implements ILaunchManager, IResourceChangeListener {
fLaunchesListeners.remove(listener);
}
+ /**
+ * Indicates the given launch configuration is being moved from the given
+ * location to the new location.
+ *
+ * @param from the location a launch configuration is being moved from, or
+ * <code>null</code>
+ * @param to the location a launch configuration is being moved to,
+ * or <code>null</code>
+ */
+ protected void setMovedFromTo(ILaunchConfiguration from, ILaunchConfiguration to) {
+ fFrom = from;
+ fTo = to;
+ }
+ /**
+ * @see org.eclipse.debug.core.ILaunchManager#getMovedFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public ILaunchConfiguration getMovedFrom(ILaunchConfiguration addedConfiguration) {
+ if (addedConfiguration.equals(fTo)) {
+ return fFrom;
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchManager#getMovedTo(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public ILaunchConfiguration getMovedTo(ILaunchConfiguration removedConfiguration) {
+ if (removedConfiguration.equals(fFrom)) {
+ return fTo;
+ }
+ return null;
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
index 78de2de02..92dc8d540 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
@@ -13,6 +13,7 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationListener;
import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.ui.AbstractDebugView;
import org.eclipse.debug.ui.DebugUITools;
@@ -87,7 +88,7 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
treeViewer.addFilter(new LaunchGroupFilter(getLaunchGroup()));
treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
treeViewer.expandAll();
- DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this);
+ getLaunchManager().addLaunchConfigurationListener(this);
IPropertyChangeListener titleUpdater= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
@@ -161,18 +162,27 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
fCreateAction.dispose();
fDeleteAction.dispose();
fDuplicateAction.dispose();
- DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this);
+ getLaunchManager().removeLaunchConfigurationListener(this);
}
/**
* @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
*/
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+ TreeViewer viewer = getTreeViewer();
+ viewer.getControl().setRedraw(false);
try {
- getTreeViewer().add(configuration.getType(), configuration);
+ viewer.add(configuration.getType(), configuration);
+ // if moved, remove original now
+ ILaunchConfiguration from = getLaunchManager().getMovedFrom(configuration);
+ if (from != null) {
+ viewer.remove(from);
+ }
} catch (CoreException e) {
}
+ viewer.getControl().setRedraw(true);
getTreeViewer().setSelection(new StructuredSelection(configuration), true);
+
}
/**
@@ -185,6 +195,12 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
* @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
*/
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+ // if moved, ignore
+ ILaunchConfiguration to = getLaunchManager().getMovedTo(configuration);
+ if (to != null) {
+ return;
+ }
+
ILaunchConfigurationType type = null;
int typeIndex= -1; // The index of the deleted configuration's type
int configIndex= -1; // The index of the deleted configuration
@@ -263,6 +279,8 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
return fWorkingSetActionManager;
}
-
+ protected ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
index a2299391d..b4bbcb48c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
@@ -835,17 +835,21 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
}
}
+ ILaunchConfiguration original = fTabViewer.getOriginal();
+ if (original != null && newInput == null && getLaunchManager().getMovedTo(original) != null) {
+ // the current config is about to be deleted ignore this change
+ return;
+ }
updateButtons();
if (!isEqual(input, newInput)) {
ILaunchConfigurationTabGroup group = getTabGroup();
- ILaunchConfiguration original = fTabViewer.getOriginal();
if (original != null) {
boolean deleted = !original.exists();
boolean renamed = false;
if (newInput instanceof ILaunchConfiguration) {
ILaunchConfiguration lc = (ILaunchConfiguration)newInput;
- renamed = fTabViewer.getWorkingCopy().getName().equals(lc.getName());
+ renamed = getLaunchManager().getMovedFrom(lc) != null;
}
if (fTabViewer.isDirty() && !deleted && !renamed) {
boolean canReplace = showSaveChangesDialog();

Back to the top