summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Schmidt2012-07-31 00:52:09 (EDT)
committer Pawel Piech2012-07-31 00:58:56 (EDT)
commit62b504e71eb1a4be4649ec9bb698e74ad213211e (patch)
treee69f491572f900ef434dd9e220094cabebe288f4
parentc2d4c9a6feea6891ba94e5f8d6be73a2bd19d55c (diff)
downloadeclipse.platform.debug-62b504e71eb1a4be4649ec9bb698e74ad213211e.zip
eclipse.platform.debug-62b504e71eb1a4be4649ec9bb698e74ad213211e.tar.gz
eclipse.platform.debug-62b504e71eb1a4be4649ec9bb698e74ad213211e.tar.bz2
Bug 384460 - Provide Breakpoint Serialization/Deserialization API
-rw-r--r--org.eclipse.debug.ui/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointImportExport.properties4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java43
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportExportMessages.java3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpoints.java23
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java66
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java120
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java63
9 files changed, 305 insertions, 21 deletions
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
index 3c4e4a3..83926ff 100644
--- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.ui; singleton:=true
-Bundle-Version: 3.8.100.qualifier
+Bundle-Version: 3.9.0.qualifier
Bundle-Activator: org.eclipse.debug.internal.ui.DebugUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointImportExport.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointImportExport.properties
index db93e42..a17141a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointImportExport.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointImportExport.properties
@@ -7,6 +7,7 @@
#
# Contributors:
# IBM Corporation - initial API and implementation
+# Sebastian Schmidt - bug 384460
###############################################################################
WizardImportBreakpoints_0=Import Breakpoints
WizardImportBreakpointsPage_0=Import Breakpoints
@@ -16,6 +17,9 @@ WizardImportBreakpointsPage_3=&Update existing breakpoints
WizardImportBreakpointsPage_4=F&rom file:
WizardImportBreakpointsPage_5=Create breakpoint &working sets
WizardImportBreakpointsPage_6=Please specify a file to import.
+WizardImportBreakpointsSelectionPage_0=Select Breakpoints
+WizardImportBreakpointsSelectionPage_1=Select one or more breakpoints to import.
+WizardImportBreakpointsSelectionPage_2=Import Breakpoints
WizardExportBreakpoints_0=Export Breakpoints
WizardExportBreakpointsPage_0=Please specify a destination file.
WizardExportBreakpointsPage_1=Select one or more breakpoints to export.
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java
new file mode 100644
index 0000000..7c86447
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sebastian Schmidt and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sebastian Schmidt - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.importexport.breakpoints;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A decorator which attaches the node path of breakpoints.
+ */
+public class BreakpointsPathDecorator extends BaseLabelProvider implements ILabelDecorator {
+
+ public Image decorateImage(Image image, Object element) {
+ return null;
+ }
+
+ public String decorateText(String text, Object element) {
+ if (element instanceof IBreakpoint) {
+ IBreakpoint breakpoint = (IBreakpoint) element;
+ IMarker marker = breakpoint.getMarker();
+ if (marker == null) {
+ return null;
+ }
+ String path = marker.getAttribute(IImportExportConstants.IE_NODE_PATH, null);
+ if (path != null && path.length() > 0) {
+ return text + " [" + path + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ return null;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java
index 68e1100..ec6ddbd 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java
@@ -33,11 +33,9 @@ import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsViewer;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportExportMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportExportMessages.java
index 17083df..b3b1c22 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportExportMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportExportMessages.java
@@ -46,4 +46,7 @@ public class ImportExportMessages extends NLS {
public static String WizardExportBreakpointsPage_2;
public static String WizardExportBreakpointsPage_3;
public static String WizardImportBreakpointsPage_6;
+ public static String WizardImportBreakpointsSelectionPage_0;
+ public static String WizardImportBreakpointsSelectionPage_1;
+ public static String WizardImportBreakpointsSelectionPage_2;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpoints.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpoints.java
index ae00a53..6035c61 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpoints.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpoints.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2007, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,10 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Sebastian Schmidt - bug 384460
*******************************************************************************/
package org.eclipse.debug.internal.ui.importexport.breakpoints;
+import java.util.List;
+
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -34,7 +37,8 @@ import org.eclipse.ui.IWorkbench;
* wizdialog.open();
* </pre>
*
- * This class uses <code>WizardImportBreakpointsPage</code>
+ * This class uses <code>WizardImportBreakpointsPage</code> and
+ * <code>WizardImportBreakpointsSelectionPage</code>.
*
* @since 3.2
*
@@ -44,7 +48,9 @@ public class WizardImportBreakpoints extends Wizard implements IImportWizard {
/*
* The main page
*/
- private WizardImportBreakpointsPage fMainPage = null;
+ private WizardImportBreakpointsPage fMainPage;
+
+ private WizardImportBreakpointsSelectionPage fSelectionPage;
/**
* Identifier for dialog settings section for the import wizard.
@@ -71,8 +77,10 @@ public class WizardImportBreakpoints extends Wizard implements IImportWizard {
super.addPages();
fMainPage = new WizardImportBreakpointsPage(ImportExportMessages.WizardImportBreakpoints_0);
addPage(fMainPage);
+ fSelectionPage = new WizardImportBreakpointsSelectionPage(ImportExportMessages.WizardImportBreakpointsSelectionPage_0);
+ addPage(fSelectionPage);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.IWizard#dispose()
*/
@@ -85,7 +93,8 @@ public class WizardImportBreakpoints extends Wizard implements IImportWizard {
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
public boolean performFinish() {
- return fMainPage.finish();
+ List selectedBreakpoints = fSelectionPage.getSelectedMarkers();
+ return fMainPage.finish(selectedBreakpoints);
}
/* (non-Javadoc)
@@ -95,4 +104,8 @@ public class WizardImportBreakpoints extends Wizard implements IImportWizard {
setWindowTitle(ImportExportMessages.WizardImportBreakpoints_0);
setNeedsProgressMonitor(true);
}
+
+ public boolean needsProgressMonitor() {
+ return true;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java
index 3b67b08..0d03321 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java
@@ -13,8 +13,15 @@ package org.eclipse.debug.internal.ui.importexport.breakpoints;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
@@ -22,6 +29,7 @@ import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.ImportBreakpointsOperation;
import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
@@ -197,14 +205,51 @@ public class WizardImportBreakpointsPage extends WizardPage implements Listener
* @return if the import operation was successful or not
*/
public boolean finish() {
+ return finish(null);
+ }
+
+ public boolean finish(final List selectedMarkers) {
try {
saveWidgetState();
- getContainer().run(false,
- true,
- new ImportBreakpointsOperation(
- fFileNameField.getText().trim(),
- fAutoRemoveDuplicates.getSelection(),
- fAutoCreateWorkingSets.getSelection()));
+ getContainer().run(false, true,
+ new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ ImportBreakpointsOperation operation = new ImportBreakpointsOperation(
+ fFileNameField.getText().trim(),
+ fAutoRemoveDuplicates.getSelection(),
+ fAutoCreateWorkingSets.getSelection());
+ operation.run(monitor);
+ if(selectedMarkers != null) {
+ removeUncheckedBreakpoints(operation.getImportedBreakpoints());
+ }
+ }
+
+ private void removeUncheckedBreakpoints(IBreakpoint[] importedBreakpoints) {
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ for(int i = 0; i < importedBreakpoints.length; i++) {
+ boolean selected = false;
+ for(int j = 0; j < selectedMarkers.size(); j++) {
+ try {
+ Map importedMarkerAttributes = importedBreakpoints[i].getMarker().getAttributes();
+ Map selectedMarkerAttributes = ((IMarker) selectedMarkers.get(j)).getAttributes();
+ if(importedMarkerAttributes.equals(selectedMarkerAttributes)) {
+ selected = true;
+ break;
+ }
+ } catch (CoreException e) {
+ DebugPlugin.log(e);
+ }
+ }
+ if(!selected) {
+ try {
+ manager.removeBreakpoint(importedBreakpoints[i], true);
+ } catch (CoreException e) {
+ DebugPlugin.log(e);
+ }
+ }
+ }
+ }
+ });
}
catch (InterruptedException e) {
DebugPlugin.log(e);
@@ -216,5 +261,12 @@ public class WizardImportBreakpointsPage extends WizardPage implements Listener
}
return true;
}
-
+
+ public Text getFileNameField() {
+ return fFileNameField;
+ }
+
+ public boolean getAutoRemoveDuplicates() {
+ return fAutoRemoveDuplicates.getSelection();
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java
new file mode 100644
index 0000000..cf873f2
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sebastian Schmidt and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sebastian Schmidt - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.importexport.breakpoints;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.internal.core.BreakpointManager;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.SWTFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
+import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
+import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsViewer;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.ImportBreakpointsOperation;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.8
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class WizardImportBreakpointsSelectionPage extends WizardPage {
+
+ private EmbeddedBreakpointsViewer fTView;
+ private boolean fIsVisible;
+
+ protected WizardImportBreakpointsSelectionPage(String pageName) {
+ super(pageName, ImportExportMessages.WizardImportBreakpointsSelectionPage_2, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ setDescription(ImportExportMessages.WizardImportBreakpointsSelectionPage_1);
+ Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
+ SWTFactory.createLabel(composite, ImportExportMessages.WizardExportBreakpointsPage_2, 1);
+ BreakpointManager breakpointManager = new BreakpointManager();
+ fTView = new EmbeddedBreakpointsViewer(composite, breakpointManager, null);
+ BreakpointsViewer viewer = fTView.getViewer();
+ viewer.setLabelProvider(new DecoratingLabelProvider((ILabelProvider) viewer.getLabelProvider(), new BreakpointsPathDecorator()));
+ setControl(composite);
+ }
+
+ public List getSelectedMarkers() {
+ if(!fIsVisible) {
+ return null;
+ }
+ List markers = new ArrayList();
+ List breakpoints = fTView.getCheckedElements().toList();
+ for(int i = 0; i < breakpoints.size(); i++) {
+ markers.add(((IBreakpoint) breakpoints.get(i)).getMarker());
+ }
+ return markers;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (visible) {
+ fIsVisible = true;
+ try {
+ updateBreakpointsPreviewList(fTView);
+ } catch (Exception e) {
+ setErrorMessage(e.getMessage());
+ }
+ } else {
+ fIsVisible = false;
+ }
+
+ super.setVisible(visible);
+ }
+
+ private void updateBreakpointsPreviewList(final EmbeddedBreakpointsViewer currentTView) throws InvocationTargetException, InterruptedException {
+ getContainer().run(false, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ WizardImportBreakpointsPage mainPage = (WizardImportBreakpointsPage) getWizard().getPage(
+ ImportExportMessages.WizardImportBreakpoints_0);
+ ImportBreakpointsOperation operation = new ImportBreakpointsOperation(mainPage.getFileNameField().getText()
+ .trim(), mainPage.getAutoRemoveDuplicates(), false, false);
+ operation.run(monitor);
+ BreakpointContainer breakpointManager = new BreakpointContainer(null, null);
+ IBreakpoint[] importedBreakpoints = operation.getImportedBreakpoints();
+ for(int i = 0; i < importedBreakpoints.length; i++) {
+ breakpointManager.addBreakpoint(importedBreakpoints[i], new ModelDelta(null, IModelDelta.ADDED));
+ }
+ currentTView.getViewer().setInput(breakpointManager);
+ currentTView.getViewer().refresh();
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#getImage()
+ */
+ public Image getImage() {
+ return DebugUITools.getImage(IInternalDebugUIConstants.IMG_WIZBAN_IMPORT_BREAKPOINTS);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java
index f7c3fcb..f9ff707 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Sebastian Schmidt - bug 384460
*******************************************************************************/
package org.eclipse.debug.ui.actions;
@@ -78,6 +79,8 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
*/
private StringBuffer fBuffer = null;
+ private boolean fImportBreakpoints = true;
+
/**
* Constructs an operation to import breakpoints.
*
@@ -90,9 +93,27 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
* workspace.
*/
public ImportBreakpointsOperation(String fileName, boolean overwrite, boolean createWorkingSets) {
+ this(fileName, overwrite, createWorkingSets, true);
+ }
+
+ /**
+ * Constructs an operation to import breakpoints.
+ *
+ * @param fileName the file to read breakpoints from - the file should have been
+ * created from an export operation
+ * @param overwrite whether imported breakpoints will overwrite existing equivalent breakpoints
+ * @param createWorkingSets whether breakpoint working sets should be created. Breakpoints
+ * are exported with information about the breakpoint working sets they belong to. Those
+ * working sets can be optionally re-created on import if they do not already exist in the
+ * workspace.
+ * @param importBreakpoints whether breakpoints should be imported and registered
+ * @since 3.8
+ */
+ public ImportBreakpointsOperation(String fileName, boolean overwrite, boolean createWorkingSets, boolean importBreakpoints) {
fFileName = fileName;
fOverwriteAll = overwrite;
fCreateWorkingSets = createWorkingSets;
+ fImportBreakpoints = importBreakpoints;
}
/**
@@ -109,9 +130,28 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
* @since 3.5
*/
public ImportBreakpointsOperation(StringBuffer buffer, boolean overwrite, boolean createWorkingSets) {
+ this(buffer, overwrite, createWorkingSets, true);
+ }
+
+ /**
+ * Constructs an operation to import breakpoints from a string buffer. The buffer
+ * must contain a memento created an {@link ExportBreakpointsOperation}.
+ *
+ * @param buffer the string buffer to read breakpoints from - the file should have been
+ * created from an export operation
+ * @param overwrite whether imported breakpoints will overwrite existing equivalent breakpoints
+ * @param createWorkingSets whether breakpoint working sets should be created. Breakpoints
+ * are exported with information about the breakpoint working sets they belong to. Those
+ * working sets can be optionally re-created on import if they do not already exist in the
+ * workspace.
+ * @param importBreakpoints whether breakpoints should be imported and registered
+ * @since 3.8
+ */
+ public ImportBreakpointsOperation(StringBuffer buffer, boolean overwrite, boolean createWorkingSets, boolean importBreakpoints) {
fBuffer = buffer;
fOverwriteAll = overwrite;
fCreateWorkingSets = createWorkingSets;
+ fImportBreakpoints = importBreakpoints;
}
/* (non-Javadoc)
@@ -137,7 +177,14 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
return;
}
attributes = collectBreakpointProperties(nodes[i]);
- IResource resource = workspace.findMember((String) attributes.get(IImportExportConstants.IE_NODE_PATH));
+
+ IResource resource;
+ if(fImportBreakpoints) {
+ resource = workspace.findMember((String) attributes.get(IImportExportConstants.IE_NODE_PATH));
+ } else {
+ resource = workspace;
+ }
+
// filter resource breakpoints that do not exist in this workspace
if(resource != null) {
try {
@@ -151,7 +198,11 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
}
else {
if(fOverwriteAll) {
- marker.setAttributes(null);
+ if(!fImportBreakpoints) {
+ marker = resource.createMarker((String) attributes.get(IImportExportConstants.IE_NODE_TYPE));
+ } else {
+ marker.setAttributes(null);
+ }
restoreBreakpoint(marker, attributes, participants);
}
}
@@ -159,7 +210,7 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
fCurrentWorkingSetProperty = null;
localmonitor.worked(1);
}
- if(fAdded.size() > 0) {
+ if(fAdded.size() > 0 && fImportBreakpoints) {
fManager.addBreakpoints((IBreakpoint[])fAdded.toArray(new IBreakpoint[fAdded.size()]));
}
}
@@ -229,12 +280,12 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
map.put(IImportExportConstants.IE_BP_ENABLED, memento.getBoolean(IImportExportConstants.IE_BP_ENABLED));
map.put(IImportExportConstants.IE_BP_PERSISTANT, memento.getBoolean(IImportExportConstants.IE_BP_PERSISTANT));
map.put(IImportExportConstants.IE_BP_REGISTERED, memento.getBoolean(IImportExportConstants.IE_BP_REGISTERED));
-
+
//collect attributes from the 'marker' node
IMemento child = memento.getChild(IImportExportConstants.IE_NODE_MARKER);
map.put(IImportExportConstants.IE_NODE_TYPE, child.getString(IImportExportConstants.IE_NODE_TYPE));
map.put(IMarker.LINE_NUMBER, child.getInteger(IMarker.LINE_NUMBER));
-
+
//copy all the marker attributes to the map
IMemento[] children = child.getChildren(IImportExportConstants.IE_NODE_ATTRIB);
for(int i = 0; i < children.length; i++) {
@@ -298,7 +349,7 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
breakpoint.setPersisted(((Boolean)attributes.get(IImportExportConstants.IE_BP_PERSISTANT)).booleanValue());
breakpoint.setRegistered(((Boolean)attributes.get(IImportExportConstants.IE_BP_REGISTERED)).booleanValue());
fAdded.add(breakpoint);
- if (fCreateWorkingSets && fCurrentWorkingSetProperty != null) {
+ if (fImportBreakpoints && fCreateWorkingSets && fCurrentWorkingSetProperty != null) {
String[] names = fCurrentWorkingSetProperty.split("\\" + IImportExportConstants.DELIMITER); //$NON-NLS-1$
updateWorkingSets(names, breakpoint);
}