From ad1ecb6394ad4152f438564c4ab5656e799db7b4 Mon Sep 17 00:00:00 2001
From: Darin Wright
Date: Wed, 7 Sep 2005 22:04:35 +0000
Subject: Bug 41057 - Option to export and import break points at the
Breakpoints view
---
.../.settings/org.eclipse.core.resources.prefs | 3 +
.../icons/full/dtool16/export_wiz.gif | Bin 0 -> 142 bytes
.../icons/full/dtool16/import_wiz.gif | Bin 0 -> 143 bytes
.../icons/full/etool16/export_wiz.gif | Bin 0 -> 329 bytes
.../icons/full/etool16/import_wiz.gif | Bin 0 -> 327 bytes
org.eclipse.debug.ui/plugin.properties | 8 +-
org.eclipse.debug.ui/plugin.xml | 41 +-
.../internal/ui/IInternalDebugUIConstants.java | 16 +
.../breakpoints/BreakpointImportExport.properties | 37 ++
.../breakpoints/ExportBreakpoints.java | 65 +++
.../importexport/breakpoints/ExportOperation.java | 113 +++++
.../breakpoints/IImportExportConstants.java | 185 +++++++
.../breakpoints/ImportBreakpoints.java | 59 +++
.../breakpoints/ImportExportMessages.java | 53 ++
.../importexport/breakpoints/ImportOperation.java | 277 ++++++++++
.../breakpoints/TransientBreakpointsViewer.java | 260 ++++++++++
.../breakpoints/WizardExportBreakpoints.java | 92 ++++
.../breakpoints/WizardExportBreakpointsPage.java | 314 ++++++++++++
.../breakpoints/WizardImportBreakpoints.java | 85 ++++
.../breakpoints/WizardImportBreakpointsPage.java | 194 +++++++
.../views/breakpoints/BreakpointSetOrganizer.java | 557 ++++++++++++---------
.../breakpoints/BreakpointWorkingSetCache.java | 108 ++++
.../breakpoints/BreakpointWorkingSetPage.java | 180 +------
.../breakpoints/BreakpointsContentProvider.java | 2 +-
.../ui/org/eclipse/debug/ui/IDebugUIConstants.java | 7 +
25 files changed, 2272 insertions(+), 384 deletions(-)
create mode 100644 org.eclipse.debug.ui/.settings/org.eclipse.core.resources.prefs
create mode 100644 org.eclipse.debug.ui/icons/full/dtool16/export_wiz.gif
create mode 100644 org.eclipse.debug.ui/icons/full/dtool16/import_wiz.gif
create mode 100644 org.eclipse.debug.ui/icons/full/etool16/export_wiz.gif
create mode 100644 org.eclipse.debug.ui/icons/full/etool16/import_wiz.gif
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointImportExport.properties
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportBreakpoints.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportOperation.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/IImportExportConstants.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportExportMessages.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportOperation.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/TransientBreakpointsViewer.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpoints.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpoints.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java
(limited to 'org.eclipse.debug.ui')
diff --git a/org.eclipse.debug.ui/.settings/org.eclipse.core.resources.prefs b/org.eclipse.debug.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..5db69dda8
--- /dev/null
+++ b/org.eclipse.debug.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Mon Aug 29 14:12:44 EDT 2005
+eclipse.preferences.version=1
+encoding//ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointImportExport.properties=8859_1
diff --git a/org.eclipse.debug.ui/icons/full/dtool16/export_wiz.gif b/org.eclipse.debug.ui/icons/full/dtool16/export_wiz.gif
new file mode 100644
index 000000000..3f89cd90e
Binary files /dev/null and b/org.eclipse.debug.ui/icons/full/dtool16/export_wiz.gif differ
diff --git a/org.eclipse.debug.ui/icons/full/dtool16/import_wiz.gif b/org.eclipse.debug.ui/icons/full/dtool16/import_wiz.gif
new file mode 100644
index 000000000..cd4474182
Binary files /dev/null and b/org.eclipse.debug.ui/icons/full/dtool16/import_wiz.gif differ
diff --git a/org.eclipse.debug.ui/icons/full/etool16/export_wiz.gif b/org.eclipse.debug.ui/icons/full/etool16/export_wiz.gif
new file mode 100644
index 000000000..5a0837d1e
Binary files /dev/null and b/org.eclipse.debug.ui/icons/full/etool16/export_wiz.gif differ
diff --git a/org.eclipse.debug.ui/icons/full/etool16/import_wiz.gif b/org.eclipse.debug.ui/icons/full/etool16/import_wiz.gif
new file mode 100644
index 000000000..d38085ad9
Binary files /dev/null and b/org.eclipse.debug.ui/icons/full/etool16/import_wiz.gif differ
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index ac0b9a119..46221fbe1 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -349,4 +349,10 @@ preferenceKeywords.general=run debug breakpoints variables color
preferenceKeywords.console=console stdout stderr color
preferenceKeywords.launching=launching build
preferenceKeywords.stringSubstitution=variables
-preferenceKeywords.viewManagement=views
\ No newline at end of file
+preferenceKeywords.viewManagement=views
+
+exportBreakpoints.label=E&xport Breakpoints...
+importBreakpoints.label=I&mport Breakpoints...
+exportBreakpoints.name=Breakpoints
+importBreakpoints.description=Import breakpoints from the local file system.
+exportBreakpoints.description=Export breakpoints to the local file system.
\ No newline at end of file
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 710c37ce8..458d5cbe2 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -430,7 +430,7 @@
class="org.eclipse.debug.internal.ui.actions.RetargetToggleLineBreakpointAction"
menubarPath="org.eclipse.ui.run/breakpointGroup"
id="org.eclipse.debug.ui.actions.ToggleBreakpoint">
-
+
+ * This class provides the aciton event for both the context menu in breakpoints view + * and the drop down menu inn the breakpoints view. + *
+ *+ * The action simply calls the wizard to export breakpoints. + *
+ * @see WizardExportBreakpoints + * @see WizardExportBreakpointsPage + * + * @since 3.2 + */ +public class ExportBreakpoints extends AbstractDebugActionDelegate { + + /** + * This method actually performs the execution of the action event + * + * @param action IAction the action + */ + public void run(IAction action) { + IViewPart fViewpart = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().findView(IDebugUIConstants.ID_BREAKPOINT_VIEW); + WizardExportBreakpoints wiz = new WizardExportBreakpoints(); + wiz.init(DebugUIPlugin.getDefault().getWorkbench(), (IStructuredSelection)fViewpart.getViewSite().getSelectionProvider().getSelection()); + WizardDialog wizdialog = new WizardDialog(DebugUIPlugin.getShell(), wiz); + wizdialog.setBlockOnOpen(true); + wizdialog.open(); + }//end run + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#update(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + protected void update(IAction action, ISelection s) { + getAction().setEnabled(DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints()); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(java.lang.Object) + */ + protected void doAction(Object element) throws DebugException {} +}//end class diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportOperation.java new file mode 100644 index 000000000..4675b3698 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportOperation.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.debug.internal.ui.importexport.breakpoints; + +import java.io.FileWriter; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.XMLMemento; + +/** + * Performs the export operation for the breakpoint export wizard + * + * @see WizardExportBreakpointsPage + * @since 3.2 + */ +public class ExportOperation implements IRunnableWithProgress { + + private Object[] fBreakpoints = null; + private IPath fPath = null; + private boolean fExists = false; + + /** + * Default constructor + * @param viewer the viewer where we get the breakpoints from to export + * @param path the path.file to export the breakpoints to + * @param autoOverwrite if we should automatically overwrite an existing file + */ + public ExportOperation(Object[] breakpoints, IPath path, boolean exists) { + fBreakpoints = breakpoints; + fPath = path; + fExists = exists; + }//end constructor + + /* (non-Javadoc) + * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) + */ + public void run(IProgressMonitor monitor) throws InvocationTargetException { + XMLMemento memento = XMLMemento.createWriteRoot(IImportExportConstants.IE_NODE_BREAKPOINTS); + IBreakpoint breakpoint = null; + IMarker marker = null; + IMemento root = null, child = null; + IResource resource = null; + monitor.beginTask(ImportExportMessages.ExportOperation_0, fBreakpoints.length); + try { + for (int i = 0; i < fBreakpoints.length; i++) { + if(fBreakpoints[i] instanceof IBreakpoint) { + breakpoint = (IBreakpoint)fBreakpoints[i]; + //in the event we are in workingset view, we can have multiple selection of the same breakpoint + //so do a simple check for it + marker = breakpoint.getMarker(); + root = memento.createChild(IImportExportConstants.IE_NODE_BREAKPOINT); + root.putString(IImportExportConstants.IE_BP_ENABLED, Boolean.toString(breakpoint.isEnabled())); + root.putString(IImportExportConstants.IE_BP_REGISTERED, Boolean.toString(breakpoint.isRegistered())); + root.putString(IImportExportConstants.IE_BP_PERSISTANT, Boolean.toString(breakpoint.isPersisted())); + //write out the resource info + resource = marker.getResource(); + child = root.createChild(IImportExportConstants.IE_NODE_RESOURCE); + child.putString(IImportExportConstants.IE_NODE_PATH, resource.getFullPath().toPortableString()); + child.putInteger(IImportExportConstants.IE_NODE_TYPE, resource.getType()); + //a generalized (name, value) pairing for attributes each stored as an ATTRIB element + root = root.createChild(IImportExportConstants.IE_NODE_MARKER); + root.putString(IImportExportConstants.IE_NODE_TYPE, marker.getType()); + root.putString(IImportExportConstants.TYPENAME, marker.getAttribute(IImportExportConstants.TYPENAME).toString()); + Object val = marker.getAttribute(IMarker.LINE_NUMBER); + root.putString(IMarker.LINE_NUMBER, (val != null) ? val.toString() : null); + val = marker.getAttribute(IImportExportConstants.CHARSTART); + root.putString(IImportExportConstants.CHARSTART, (val != null) ? val.toString() : null); + for(java.util.Iterator iter = marker.getAttributes().keySet().iterator(); iter.hasNext();) { + String iterval = iter.next().toString(); + if(!iterval.equals(IMarker.LINE_NUMBER) & !iterval.equals(IImportExportConstants.TYPENAME)) { + child = root.createChild(IImportExportConstants.IE_NODE_ATTRIB); + child.putString(IImportExportConstants.IE_NODE_NAME, iterval); + child.putString(IImportExportConstants.IE_NODE_VALUE, marker.getAttribute(iterval).toString()); + }//end if + }//end for + }// end if + }//end for + }//end try + catch(CoreException e) {throw new InvocationTargetException(e);} + try { + if(fExists) { + memento.save(new FileWriter(fPath.toPortableString())); + }//end if + else { + if(fPath.toFile().createNewFile()) { + memento.save(new FileWriter(fPath.toPortableString())); + }//end if + }//end else + }// end try + catch (java.io.IOException ioe) { + DebugPlugin.log(ioe); + throw new InvocationTargetException(ioe); + }//end catch + }//end run +}//end class diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/IImportExportConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/IImportExportConstants.java new file mode 100644 index 000000000..e1b1f4799 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/IImportExportConstants.java @@ -0,0 +1,185 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.debug.internal.ui.importexport.breakpoints; + +/** + * + * XML tag constants for importing and exporting breakpoints + */ +public interface IImportExportConstants { + + /** + *+ * The name for the top level node in the XMLMemento for storing/restoring breakpoint information. + * + * General formulation of the XMLMemento is as follows: + * + * breakpoints := (breakpoint)* + * + * breakpoint := resource + * + * resource := (marker)+ + * + * marker := (attribs)+ + *
+ * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + * + */ + public static final String IE_NODE_BREAKPOINTS = "breakpoints"; //$NON-NLS-1$ + + /** + * The name of the node type for each of the imported or exported breakpoints + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_BREAKPOINT = "breakpoint"; //$NON-NLS-1$ + + /** + * The ID for the classname node for exporting breakpoints from the wizards. + * This ID is searchable from the listing of XMLMementos gathered from the BreakPointManager. + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + * @see XMLMemento->getChild(String) + */ + public static final String IE_NODE_CLASSNAME = "classname"; //$NON-NLS-1$ + + /** + *+ * The generalized ID for each of the values stored in a markers' attribute map. + * Since a marker can have any number of attributes and or values, we use a + * (name, value) paring in the XMLmemento to store them, without having a dependence upon what the attribute + * is or what type it is. + *
+ * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_VALUE = "value"; //$NON-NLS-1$ + + /** + * Each breakpoint has an associated resource, which is described with this element + * name + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_RESOURCE = "resource"; //$NON-NLS-1$ + + /** + * To validate the resource when filtering importable breakpoints we need to know its path. + * This is the the name of XMLMemento node that stores that path. + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_PATH = "path"; //$NON-NLS-1$ + + /** + * To filter the type of path searched for within the workspace to allow for the filtering of + * breakpoints for import, we need to know the type to filter for. + * + * This is the name of the XMLMemento node that stores the type of the resource + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_TYPE = "type"; //$NON-NLS-1$ + + /** + * The name for the marker node in the corresponding XMLMemento + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_MARKER = "marker"; //$NON-NLS-1$ + + /** + * The name for a marker attribute node in the corresponding XMLMemento + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_ATTRIB = "attrib"; //$NON-NLS-1$ + + /** + * The generalized name for the "name" node used in marker attribute nodes. + * This is the other ID in the (name, value) pairing used to describe attributes + * of markers. + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_NODE_NAME = "name"; //$NON-NLS-1$ + + /** + * The name of the enabled attribute, which is part of the breakpoint node information + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_BP_ENABLED = "enabled"; //$NON-NLS-1$ + + /** + * The name of the registered attribute, whic is part of the breakpoint node information + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + */ + public static final String IE_BP_REGISTERED = "registered"; //$NON-NLS-1$ + + /** + * The name of the persistant attribute for breakpoint information + */ + public static final String IE_BP_PERSISTANT = "persistant"; //$NON-NLS-1$ + + /** + * The default file extension for breakpoint export files + */ + public static final String EXTENSION = "bkpt"; //$NON-NLS-1$ + + /** + * The typename of the breakpoints + */ + public static final String TYPENAME = "org.eclipse.jdt.debug.core.typeName"; //$NON-NLS-1$ + + /** + * The typename for a method attribute + */ + public static final String METHODNAME = "org.eclipse.jdt.debug.core.methodName"; //$NON-NLS-1$ + + /** + * the charstart attribute from a marker + */ + public static final String CHARSTART = "charStart"; //$NON-NLS-1$ + + /** + * the name of the workingsets node + */ + public static final String IE_NODE_WORKINGSETS = "workingsets"; //$NON-NLS-1$ + + /** + * The name of the workingset node + */ + public static final String IE_NODE_WORKINGSET = "workingset"; //$NON-NLS-1$ + + /** + * The name of the id attribute, reusable for a general attribute called id + */ + public static final String IE_NODE_ID = "id"; //$NON-NLS-1$ + + /** + * The delimiter for the listing of working sets that a marker belongs to + */ + public static final String DELIMITER = "<;#>"; //$NON-NLS-1$ +}//end interface diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java new file mode 100644 index 000000000..604a34717 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c)2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.debug.internal.ui.importexport.breakpoints; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardDialog; + +/** + * This class provides the aciton event for both the context menu in breakpoints view + * and the drop down menu in the breakpoints view. + *+ * The action simply calls the wizard to import breakpoints. + *
+ * + * @see WizardImportBreakpoints + * @see WizardImportBreakpointsPage + * + * @since 3.2 + */ +public class ImportBreakpoints extends AbstractDebugActionDelegate { + + /** + * Opens import wizard + * + * @param action IAction the action + */ + public void run(IAction action) { + WizardImportBreakpoints wiz = new WizardImportBreakpoints(); + wiz.init(DebugUIPlugin.getDefault().getWorkbench(), null); + WizardDialog wizdialog = new WizardDialog(DebugUIPlugin.getShell(), wiz); + wizdialog.setBlockOnOpen(true); + wizdialog.open(); + }//end run + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(java.lang.Object) + */ + protected void doAction(Object element) throws DebugException {} + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#update(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + protected void update(IAction action, ISelection s) { + getAction().setEnabled(true); + }//end update +}//end class 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 new file mode 100644 index 000000000..23a099592 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportExportMessages.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.importexport.breakpoints; + +import org.eclipse.osgi.util.NLS; + +public class ImportExportMessages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.importexport.breakpoints.BreakpointImportExport"; //$NON-NLS-1$ + + private ImportExportMessages() { + } + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, ImportExportMessages.class); + } + + public static String WizardImportBreakpoints_0; + public static String WizardExportBreakpoints_0; + public static String WizardBreakpointsPage_0; + public static String WizardBreakpointsPage_1; + public static String WizardBreakpointsPage_2; + public static String WizardBreakpointsPage_3; + public static String WizardBreakpointsPage_4; + public static String WizardBreakpointsPage_5; + public static String WizardBreakpointsPage_6; + public static String WizardBreakpointsPage_7; + public static String WizardBreakpointsPage_8; + public static String WizardBreakpointsPage_12; + public static String ImportExportOperations_0; + public static String ImportExportOperations_1; + public static String ImportExportOperations_2; + public static String ImportExportOperations_3; + public static String ImportOperation_0; + public static String WizardImportBreakpointsPage_0; + public static String WizardImportBreakpointsPage_1; + public static String WizardImportBreakpointsPage_2; + public static String WizardImportBreakpointsPage_3; + public static String WizardImportBreakpointsPage_4; + public static String ExportOperation_0; + public static String WizardImportBreakpointsPage_5; + public static String WizardExportBreakpointsPage_0; + public static String WizardExportBreakpointsPage_1; + public static String WizardImportBreakpointsPage_6; +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportOperation.java new file mode 100644 index 000000000..4d4c0243b --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportOperation.java @@ -0,0 +1,277 @@ +/******************************************************************************* + * Copyright (c) 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.debug.internal.ui.importexport.breakpoints; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +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.BreakpointManager; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.IWorkingSetManager; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.XMLMemento; + +/** + * Performs the import for the breakpoint import wizard + * + * @see WizardImportBreakpointsPage + * @since 3.2 + */ +public class ImportOperation implements IRunnableWithProgress { + + private boolean fOverwriteAll = false; + private File fInputfile = null; + private boolean fCreateWorkingSets = false; + + /** + * The default constructor + * @param inputfile the file to read breakpoints from + * @param autoOverwrite if we should automatically overwrite breakpoints without prompt + */ + public ImportOperation(File inputfile, boolean autoOverwrite, boolean createWorkingSets) { + fInputfile = inputfile; + fOverwriteAll = autoOverwrite; + fCreateWorkingSets = createWorkingSets; + }//end constructor + + /* (non-Javadoc) + * @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor) + */ + public void run(IProgressMonitor monitor) throws InvocationTargetException { + doImport(monitor); + }//end run + + /** + * The method thta actually perfoms the import operation. + *+ * The operation is abstracted so that JUnit testing can be applied, also so that + * it can be run in a workspace runnable with progress. + *
+ * + * @param monitor the progress monitor to use + */ + private void doImport(final IProgressMonitor monitor) { + IWorkspaceRunnable wr = new IWorkspaceRunnable() { + public void run(IProgressMonitor wmonitor) throws CoreException { + try { + XMLMemento memento = XMLMemento.createReadRoot(new FileReader(fInputfile)); + IMemento[] nodes = memento.getChildren(IImportExportConstants.IE_NODE_BREAKPOINT); + IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); + IMemento node = null; + monitor.beginTask(ImportExportMessages.ImportOperation_0, nodes.length); + for(int i = 0; i < nodes.length; i++) { + if(!monitor.isCanceled()) { + node = nodes[i].getChild(IImportExportConstants.IE_NODE_RESOURCE); + IResource resource = workspace.findMember(node.getString(IImportExportConstants.IE_NODE_PATH)); + //filter resource breakpoints that do not exist in this workspace + if(resource != null) { + //create a marker, we must do each one, as a straight copy set values as Objects, destroying + //the actual value types that they are. + node = nodes[i].getChild(IImportExportConstants.IE_NODE_MARKER); + IMarker marker = findGeneralMarker(resource, + node.getString(IMarker.LINE_NUMBER), + node.getString(IImportExportConstants.IE_NODE_TYPE), + node.getString(IImportExportConstants.TYPENAME), + node.getInteger(IImportExportConstants.CHARSTART)); + //if the marker does not exist, create it, otherwise clear it attributes to be restored + if(marker == null) { + marker = resource.createMarker(node.getString(IImportExportConstants.IE_NODE_TYPE)); + restoreBreakpoint(marker, nodes[i]); + }//end if + else { + if(fOverwriteAll) { + marker.setAttributes(null); + restoreBreakpoint(marker, nodes[i]); + }//end if + }//end else + }//end if + monitor.worked(i+1); + }//end if not canceled + else { + return; + }//end else + }//end for + }//end try + catch(FileNotFoundException e) {DebugPlugin.log(e);} + catch(CoreException e){DebugPlugin.log(e);} + }//end run + }; + try { + ResourcesPlugin.getWorkspace().run(wr, monitor); + }//end try + catch(CoreException e) {DebugPlugin.log(e);} + }//end doImport + + /** + * Restores a breakpoint on the given marker with information from the passed memento + * @param marker the marker to restore to + * @param node the memento to get the restore information from + */ + private void restoreBreakpoint(IMarker marker, IMemento node) { + BreakpointManager manager = (BreakpointManager)DebugPlugin.getDefault().getBreakpointManager(); + IMemento[] childnodes = null; + IMemento child = null; + try { + //get the marker attributes + child = node.getChild(IImportExportConstants.IE_NODE_MARKER); + marker.setAttribute(IMarker.LINE_NUMBER, child.getInteger(IMarker.LINE_NUMBER)); + marker.setAttribute(IImportExportConstants.IE_NODE_TYPE, child.getString(IImportExportConstants.IE_NODE_TYPE)); + marker.setAttribute(IImportExportConstants.TYPENAME, child.getString(IImportExportConstants.TYPENAME)); + marker.setAttribute(IImportExportConstants.CHARSTART, child.getString(IImportExportConstants.CHARSTART)); + childnodes = child.getChildren(IImportExportConstants.IE_NODE_ATTRIB); + String workingsets = ""; //$NON-NLS-1$ + for(int j = 0; j < childnodes.length; j++) { + //get the attribute and try to convert it to either Integer, Boolean or leave it alone (String) + String name = childnodes[j].getString(IImportExportConstants.IE_NODE_NAME), + value = childnodes[j].getString(IImportExportConstants.IE_NODE_VALUE); + if(value != null & name != null) { + if(name.equals(IInternalDebugUIConstants.WORKING_SET_NAME)) { + workingsets = value; + }//end if + try { + marker.setAttribute(name, Integer.valueOf(value)); + }//end try + catch(NumberFormatException e) { + if(value.equalsIgnoreCase("false") || value.equalsIgnoreCase("true")) { //$NON-NLS-1$ //$NON-NLS-2$ + marker.setAttribute(name, Boolean.valueOf(value)); + }//end if + else { + marker.setAttribute(name, value); + }//end else + }//end catch + }//end if + }//end for + //create the breakpoint + IBreakpoint breakpoint = manager.createBreakpoint(marker); + breakpoint.setEnabled(Boolean.valueOf(node.getString(IImportExportConstants.IE_BP_ENABLED)).booleanValue()); + breakpoint.setPersisted(Boolean.valueOf(node.getString(IImportExportConstants.IE_BP_PERSISTANT)).booleanValue()); + breakpoint.setRegistered(Boolean.valueOf(node.getString(IImportExportConstants.IE_BP_REGISTERED)).booleanValue()); + //if the breakpoint does not already exist ignore the need to prompt, just add it + IBreakpoint existing = breakpointExists(breakpoint); + if(existing == null) { + manager.addBreakpoint(breakpoint); + }//end if + else { + existing.setMarker(marker); + manager.fireBreakpointChanged(existing); + breakpoint = existing; + }//end else + if(fCreateWorkingSets) { + String[] names = workingsets.split("\\"+IImportExportConstants.DELIMITER); //$NON-NLS-1$ + for(int m = 1; m < names.length; m++) { + createWorkingSet(names[m], breakpoint); + }//end for + }//end if + }//end try + catch(CoreException e){DebugPlugin.log(e);} + } + + /** + * Creates a working set and sets the values + * @param breakpoint the restored breakpoint to add to the new workingset + */ + private void createWorkingSet(String setname, IAdaptable element) { + IWorkingSetManager wsmanager = PlatformUI.getWorkbench().getWorkingSetManager(); + IWorkingSet set = wsmanager.getWorkingSet(setname); + if(set == null) { + set = wsmanager.createWorkingSet(setname, new IAdaptable[] {}); + set.setId(IDebugUIConstants.BREAKPOINT_WORKINGSET_ID); + wsmanager.addWorkingSet(set); + }//end if + IAdaptable[] elements = set.getElements(); + IAdaptable[] newElements = new IAdaptable[elements.length + 1]; + newElements[newElements.length-1] = (IBreakpoint)element; + System.arraycopy(elements, 0, newElements, 0, elements.length); + set.setElements(newElements); + } + + /** + * This method is used internally to search the pre-existing listing of breakpoints to find a + * non-specific one + * + * @param breakpoint the breakpoint to search for + * @return IBreakpoint the breakpoint if found or null otherwise + */ + private IBreakpoint breakpointExists(IBreakpoint breakpoint) { + IMarker marker = breakpoint.getMarker(); + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + try { + Integer value = (Integer)marker.getAttribute(IMarker.LINE_NUMBER); + String typename = marker.getAttribute(IImportExportConstants.TYPENAME).toString(); + String type = marker.getType(); + Integer charstart = (Integer)marker.getAttribute(IImportExportConstants.CHARSTART); + IMarker localmarker = findGeneralMarker(marker.getResource(), + (value != null ? value.toString() : null), + type, + typename, + charstart); + return (localmarker != null ? manager.getBreakpoint(localmarker) : null); + }//end try + catch(CoreException e) {DebugPlugin.log(e);} + return null; + }//end breakpointExists + + /** + * This method is used internally to find a non-specific marker on a given resource. + * With this method we can search for similar markers even though they may have differing ids + * + * @param resource the resource to search for the marker + * @param line the line number or null + * @param type the type of the marker + * @param typename the typename of the marker + * @return the marker if found, or null + */ + private IMarker findGeneralMarker(IResource resource, String line, String type, String typename, Integer charstart) { + try { + IMarker[] markers = resource.findMarkers(null, false, IResource.DEPTH_ZERO); + if(type != null & typename != null) { + for(int i = 0; i < markers.length; i++) { + Object localline = markers[i].getAttribute(IMarker.LINE_NUMBER), + localtypename = markers[i].getAttribute(IImportExportConstants.TYPENAME); + String localtype = markers[i].getType(); + if(type.equals(localtype) & typename.equals(localtypename)) { + if(localline != null & line != null) { + if(line.equals(localline.toString())) { + //compare their charstarts + if(charstart.toString().equals(markers[i].getAttribute(IImportExportConstants.CHARSTART).toString())) { + return markers[i]; + }//end if + }//end if + }//end if + else { + return markers[i]; + }//end else + }//end if + }//end for + }//end if + }//end try + catch(Exception e) {e.printStackTrace();} + return null; + }//end findGeneralMarker +}//end class diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/TransientBreakpointsViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/TransientBreakpointsViewer.java new file mode 100644 index 000000000..27c1c5042 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/TransientBreakpointsViewer.java @@ -0,0 +1,260 @@ +/******************************************************************************* + * Copyright (c) 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.debug.internal.ui.importexport.breakpoints; + +import java.util.ArrayList; +import java.util.Vector; + +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer; +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsContentProvider; +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsLabelProvider; +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView; +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsViewer; +import org.eclipse.debug.internal.ui.views.breakpoints.IBreakpointOrganizer; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.util.Assert; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeViewerListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeExpansionEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IViewPart; + +/** + * This class creates a simplified debug view that can be used in wizards etc., to emulate the current debug view + * + * @see WizardExportBreakpointsPage + * @see WizardImportBreakpointsPage + * + * @since 3.2 + */ +public class TransientBreakpointsViewer { + + //widgets + private IStructuredSelection fSelection = null; + private BreakpointsView fView = null; + private BreakpointsContentProvider fProvider = null; + private Tree fTree = null; + private BreakpointsViewer fViewer = null; + private ICheckStateListener fCheckListener = new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + updateCheckedState(event.getElement(), event.getChecked()); + } + }; + + //constants + private static final int HEIGHT_HINT = 150; + + /** + * This constructor uses the selection from the debug view to initialize its selection + * + *+ * Neither parent nor input can be null + *
+ * + * @param parent the parent to add this composite to + * @param input the input to the viewer + */ + public TransientBreakpointsViewer(Composite parent, Object input) { + Assert.isNotNull(parent); + Assert.isNotNull(input); + createControl(parent, input, null); + }//end constructor + + /** + * This constructor allows a specific selction to be used in stead of the default + * + * @param parent the parent composite to add this one to + * @param input the input to the viewer + * @param selection the selection to set on the viewer + */ + public TransientBreakpointsViewer(Composite parent, Object input, IStructuredSelection selection) { + Assert.isNotNull(parent); + Assert.isNotNull(input); + createControl(parent, input, selection); + } + + /** + * Creates the control initialized to the current view, selection, and organization of the breakpoints view + * @param parent the parent composite to add this one to. + * + * @param parent the parent composite to add this one to + * @param input the input for the viewer + * @param selection the selection for the viewer to be initialized to. If null the selection from the breakpoints view is used + */ + private void createControl(Composite parent, Object input, IStructuredSelection selection) { + fSelection = selection; + if(fSelection == null) { + IViewPart fViewpart = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().findView(IDebugUIConstants.ID_BREAKPOINT_VIEW); + fSelection = (IStructuredSelection)fViewpart.getViewSite().getSelectionProvider().getSelection(); + }//end if + Font font = parent.getFont(); + Composite composite = new Composite(parent, SWT.NULL); + composite.setLayout(new GridLayout(1, true)); + GridData grid = new GridData(GridData.FILL_BOTH); + grid.heightHint = HEIGHT_HINT; + composite.setLayoutData(grid); + composite.setFont(font); + + // create the treeview + fTree = new Tree(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK); + fProvider = new BreakpointsContentProvider(); + fView = ((BreakpointsView)DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().findView(IDebugUIConstants.ID_BREAKPOINT_VIEW)); + fTree.setLayoutData(new GridData(GridData.FILL_BOTH)); + fViewer = new BreakpointsViewer(fTree); + fViewer.setLabelProvider(new BreakpointsLabelProvider()); + fViewer.addCheckStateListener(fCheckListener); + fViewer.addTreeListener(new ITreeViewerListener() { + public void treeExpanded(TreeExpansionEvent event) { + fViewer.updateCheckedState(event.getElement()); + } + public void treeCollapsed(TreeExpansionEvent event) { + } + }); + IBreakpointOrganizer[] orgs = null; + if(fView != null) + orgs = fView.getBreakpointOrganizers(); + fViewer.setContentProvider(fProvider); + fViewer.setInput(input); + fProvider.setOrganizers(orgs); + Object[] items = fSelection.toArray(); + fViewer.setCheckedElements(items); + for(int i = 0; i < items.length; i++) { + updateCheckedState(items[i], true); + }//end for + } + + /** + * Returns the selection from the viewer with no duplicates + * @return the selection from the viewer with no duplicates + */ + public IStructuredSelection getCheckedElements() { + Object[] list = fViewer.getCheckedElements(); + Vector selected = new Vector(); + for(int i = 0; i < list.length; i++) { + if(!selected.contains(list[i])) { + selected.addElement(list[i]); + }//end if + }//end for + return new StructuredSelection(selected); + } + + /** + * Allows access to the viewer + * @return the viewer + */ + public BreakpointsViewer getViewer() { + return fViewer; + }//end getViewer + + /** + * Update the checked state of the given element and all of its children. + * + * @param obj the object that has been changed + * @param enable the checked status of the obj + */ + private void updateCheckedState(Object obj, boolean enable) { + //TreeItem item = (TreeItem)fViewer.searchItem(obj); + ArrayList list = findAllItemOccurances(obj); + TreeItem item = null; + for(int i = 0; i < list.size(); i++) { + item = (TreeItem)list.get(i); + if (obj instanceof IBreakpoint) { + item.setChecked(enable); + TreeItem parent = item.getParentItem(); + if(parent != null) { + if(otherChildrenChecked(parent.getItems())) { + if(allChildrenChecked(parent.getItems())) { + parent.setGrayed(false); + parent.setChecked(true); + } + else { + parent.setGrayed(true); + parent.setChecked(true); + }//end else + }//endif + else { + parent.setGrayed(false); + parent.setChecked(false); + }//end else + }//end if + }//end if + else if (obj instanceof BreakpointContainer) { + item.setGrayed(false); + item.setChecked(enable); + TreeItem[] children = item.getItems(); + for(int j = 0; j < children.length; j++) { + children[j].setChecked(enable); + }//end for + }//end if + }//end for + }//end updateCheckedState + + /** + * Finds all of the objects in the current tree view based on what is showing, not on findItem + * which only finds the first occurance of the object in the tree + * @param object the object to look for + * @return the list of objects or an empty list, never null + * + * @since 3.2 + */ + private ArrayList findAllItemOccurances(Object object) { + ArrayList results = new ArrayList(); + fTree.selectAll(); + TreeItem[] items = fTree.getSelection(); + fTree.deselectAll(); + for(int i = 0; i < items.length; i++) { + if(object.equals(items[i].getData())) { + results.add(items[i]); + }//end if + }//end for + return results; + } + + /** + * Checks to see if there is at least one other checked child from the list of children + * @param children the children treeitems to inspect + * @return true it at least oneo ther child is checked, false otherwise + */ + private boolean otherChildrenChecked(TreeItem[] children) { + for(int i = 0; i < children.length; i++) { + if(children[i].getChecked()) { + return true; + }//end if + }//end ofr + return false; + } + + /** + * Checks to see if all of the children under an given parent are checked or not + * @param children the children to check + * @return true if all children are checked, false otherwise + */ + private boolean allChildrenChecked(TreeItem[] children) { + boolean checked = true; + for(int i = 0; i < children.length; i++) { + checked = checked & children[i].getChecked(); + }//end for + return checked; + }//end allChildrenChecked + +}//end class diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpoints.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpoints.java new file mode 100644 index 000000000..9d9caa1bd --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpoints.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.debug.internal.ui.importexport.breakpoints; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IExportWizard; +import org.eclipse.ui.IWorkbench; + +/** + *+ * This class provides a wizard for exporting breakpoints. + * It serves dual purpose, in that it is used by the platform import/export wizard, + * but it can also be used as a standalone wizard. + *
+ *+ * Example: + *
+ *+ * IWizard wiz = new WizardExportBreakpoints(); + * wiz.init(workbench, selection); + * WizardDialog wizdialog = new WizardDialog(shell, wiz); + * wizdialog.open(); + *+ * + * This class uses
WizardExportBreakpointsPage
+ *
+ * @since 3.2
+ *
+ */
+public class WizardExportBreakpoints extends Wizard implements IExportWizard {
+
+ /*
+ * The main page
+ */
+ private WizardExportBreakpointsPage fMainPage = null;
+
+ /**
+ * The existing selection
+ */
+ private IStructuredSelection fSelection = null;
+
+ /**
+ * This is the default constructor
+ */
+ public WizardExportBreakpoints() {
+ super();
+ }//end constructor
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#addPages()
+ */
+ public void addPages() {
+ super.addPages();
+ fMainPage = new WizardExportBreakpointsPage(ImportExportMessages.WizardExportBreakpoints_0, fSelection);
+ addPage(fMainPage);
+ }//end addPages
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ fMainPage = null;
+ fSelection = null;
+ }//end dispose
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#performFinish()
+ */
+ public boolean performFinish() {
+ return fMainPage.finish();
+ }//end performFinish
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ fSelection = selection;
+ setWindowTitle(ImportExportMessages.WizardExportBreakpoints_0);
+ setNeedsProgressMonitor(true);
+ }//end init
+}//end class
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java
new file mode 100644
index 000000000..d85e59b9a
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java
@@ -0,0 +1,314 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.importexport.breakpoints;
+
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.ui.SWTUtil;
+import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsViewer;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * + * This class provides an internal implementation of a WizardPage, which is used + * in the Export Breakpoints wizard. + *
+ *+ * The implementation presents the breakpoints to the user as they are shown in + * their current breakpoint view. + *
+ *+ * Possible extensions would include: + *
WizardExportBreakpoints
+ *
+ * @since 3.2
+ */
+public class WizardExportBreakpointsPage extends WizardPage implements Listener {
+
+ // widgets
+ private Button fOverwriteExistingFilesCheckbox = null;
+ private Text fDestinationNameField = null;
+ private Button fDestinationBrowseButton = null;
+ private IPath fPath = null;
+ private TransientBreakpointsViewer fTView = null;
+ private IStructuredSelection fSelection = null;
+ private Button fSelectAll = null;
+ private Button fDeselectAll = null;
+
+ /**
+ * This is the default constructor. It accepts the name for the tab as a
+ * parameter and an existing selection
+ *
+ * @param pageName the name of the page
+ */
+ public WizardExportBreakpointsPage(String pageName, IStructuredSelection selection) {
+ super(pageName, ImportExportMessages.WizardExportBreakpoints_0, null);
+ fSelection = selection;
+ }// end constructor
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ public void handleEvent(Event event) {
+ Widget source = event.widget;
+ if (source == fDestinationBrowseButton) {
+ handleDestinationBrowseButtonPressed();
+ }// end if
+ else if (source == fDestinationNameField) {
+ handlePathTextModifiedEvent();
+ }// end if
+ else if(source == fSelectAll) {
+ handleSelectAllPressed();
+ }//end if
+ else if(source == fDeselectAll) {
+ handleDeselectAllPressed();
+ }//end if
+ }// end handleEvent
+
+ /**
+ * Handles the select all button pressed
+ *
+ */
+ private void handleSelectAllPressed() {
+ BreakpointsViewer viewer = fTView.getViewer();
+ viewer.getTree().selectAll();
+ viewer.setCheckedElements(((IStructuredSelection)viewer.getSelection()).toArray());
+ viewer.setGrayedElements(new Object[] {});
+ viewer.getTree().deselectAll();
+ setPageComplete(detectPageComplete());
+ }//end handleSelectAllPressed
+
+ /**
+ * Handles the deselect all button pressed
+ *
+ */
+ private void handleDeselectAllPressed() {
+ BreakpointsViewer viewer = fTView.getViewer();
+ viewer.setCheckedElements(new Object[] {});
+ viewer.setGrayedElements(new Object[] {});
+ setPageComplete(detectPageComplete());
+ }//end handleDeselectAllPressed
+
+ /**
+ * This method handles the modified event fomr the path combobox.
+ */
+ protected void handlePathTextModifiedEvent() {
+ setPageComplete(detectPageComplete());
+ }// end handlePathComboModifiedEvent
+
+ /**
+ * Open the SaveAsDialog so the user can save the listing of selected breakpoints
+ */
+ protected void handleDestinationBrowseButtonPressed() {
+ FileDialog dialog = new FileDialog(getContainer().getShell(), SWT.SAVE);
+ dialog.setFilterExtensions(new String[]{"*."+IImportExportConstants.EXTENSION}); //$NON-NLS-1$
+ dialog.setText(ImportExportMessages.WizardExportBreakpoints_0);
+ String file = dialog.open();
+ if(file != null) {
+ fPath = new Path(file);
+ if (fPath != null) {
+ setErrorMessage(null);
+ if(fPath.getFileExtension() == null) {
+ fPath = fPath.addFileExtension(IImportExportConstants.EXTENSION);
+ }//end if
+ else if(!fPath.getFileExtension().equals(IImportExportConstants.EXTENSION)) {
+ fPath = fPath.addFileExtension(IImportExportConstants.EXTENSION);
+ }//end elseif
+ fDestinationNameField.setText(fPath.toString());
+ }// end if
+ }//end if
+ }// end handleDestinationBrowseButtonPressed
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Font font = parent.getFont();
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+ composite.setFont(font);
+ fTView = new TransientBreakpointsViewer(composite, DebugPlugin.getDefault().getBreakpointManager(), fSelection);
+ fTView.getViewer().addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ setPageComplete(detectPageComplete());
+ }
+ });
+ createButtonsGroup(composite);
+ createDestinationGroup(composite);
+ createOptionsGroup(composite);
+ setControl(composite);
+ setPageComplete(detectPageComplete());
+ }// end createControl
+
+ /**
+ * Creates the buttons for selecting all or none of the elements.
+ *
+ * @param parent the parent control
+ */
+ private void createButtonsGroup(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = true;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+ fSelectAll = SWTUtil.createPushButton(composite, ImportExportMessages.WizardBreakpointsPage_1, null);
+ fSelectAll.addListener(SWT.Selection, this);
+ fDeselectAll = SWTUtil.createPushButton(composite, ImportExportMessages.WizardBreakpointsPage_2, null);
+ fDeselectAll.addListener(SWT.Selection, this);
+ }
+
+ /**
+ * This method is used to determine if the page can be "finished".
+ *
+ * To be determined "finishable" there must be a save path and there must be
+ * a selection in the tree.
+ *
+ * @return if the prerequesites of the wizard are met to allow the wizard to complete.
+ */
+ private boolean detectPageComplete() {
+ boolean emptyFile = fDestinationNameField.getText().trim().equals(""); //$NON-NLS-1$
+ if (emptyFile) {
+ setMessage(ImportExportMessages.WizardExportBreakpointsPage_0, IMessageProvider.NONE);
+ return false;
+ }
+ int size = fTView.getCheckedElements().size();
+ if (size == 0) {
+ setMessage(ImportExportMessages.WizardExportBreakpointsPage_1, IMessageProvider.ERROR);
+ return false;
+ }
+ setMessage(ImportExportMessages.WizardBreakpointsPage_4);
+ return true;
+ }//end detectPageComplete
+
+ /**
+ * Create the Options specification widgets.
+ *
+ * @param parent the parent to add this
+ */
+ protected void createOptionsGroup(Composite parent) {
+ Font font = parent.getFont();
+ // Options group
+ Group OptionsGroup = new Group(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ OptionsGroup.setLayout(layout);
+ OptionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
+ OptionsGroup.setText(ImportExportMessages.WizardBreakpointsPage_5);
+ OptionsGroup.setFont(parent.getFont());
+ fOverwriteExistingFilesCheckbox = new Button(OptionsGroup, SWT.CHECK | SWT.LEFT);
+ fOverwriteExistingFilesCheckbox.setText(ImportExportMessages.WizardBreakpointsPage_6);
+ fOverwriteExistingFilesCheckbox.setFont(font);
+ }// end createOptionsGroup
+
+ /**
+ * Create the export destination specification widgets
+ *
+ * @param parent org.eclipse.swt.widgets.Composite
+ */
+ protected void createDestinationGroup(Composite parent) {
+ Font font = parent.getFont();
+ // destination specification group
+ Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ destinationSelectionGroup.setLayout(layout);
+ destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ destinationSelectionGroup.setFont(font);
+ Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
+ destinationLabel.setText(ImportExportMessages.WizardBreakpointsPage_7);
+ destinationLabel.setFont(font);
+ fDestinationNameField = new Text(destinationSelectionGroup, SWT.BORDER);
+ fDestinationNameField.addListener(SWT.Modify, this);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ fDestinationNameField.setLayoutData(data);
+ fDestinationNameField.setFont(font);
+ fDestinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
+ fDestinationBrowseButton.setText(ImportExportMessages.WizardBreakpointsPage_8);
+ fDestinationBrowseButton.addListener(SWT.Selection, this);
+ fDestinationBrowseButton.setFont(font);
+ setButtonLayoutData(fDestinationBrowseButton);
+ }// end createDestinationGroup
+
+ /**
+ * The Finish button is clicked on the main wizard
+ * dialog to export the breakpoints, we write them out with all persistnat
+ * information to a simple XML file via the use of XMLMemento.
+ *
+ * @return if the save operation was successful or not
+ */
+ public boolean finish() {
+ try {
+ //name typed in without using selection box
+ if(fPath == null) {
+ fPath = new Path(fDestinationNameField.getText().trim());
+ if(fPath.getFileExtension() == null) {
+ fPath = fPath.addFileExtension(IImportExportConstants.EXTENSION);
+ }//end if
+ else if(!fPath.getFileExtension().equals(IImportExportConstants.EXTENSION)) {
+ fPath = fPath.addFileExtension(IImportExportConstants.EXTENSION);
+ }//end elseif
+ }//end if
+ if(fPath.toFile().exists()) {
+ if(fOverwriteExistingFilesCheckbox.getSelection()) {
+ getContainer().run(true, true, new ExportOperation(fTView.getCheckedElements().toArray(), fPath, true));
+ }//end if
+ else {
+ if(MessageDialog.openQuestion(null, ImportExportMessages.WizardBreakpointsPage_12, MessageFormat.format(ImportExportMessages.ImportExportOperations_0, new String[] {fPath.toPortableString()}))) {
+ getContainer().run(true, true, new ExportOperation(fTView.getCheckedElements().toArray(), fPath, true));
+ }//end if
+ }//end else
+ }//end if
+ else {
+ getContainer().run(true, true, new ExportOperation(fTView.getCheckedElements().toArray(), fPath, false));
+ }//end else
+ }// end try
+ catch (InterruptedException e) {
+ DebugPlugin.log(e);
+ return false;
+ }// end catch
+ catch (InvocationTargetException e) {
+ DebugPlugin.log(e);
+ return false;
+ }//end catch
+ return true;
+ }// end finish
+}// end class
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
new file mode 100644
index 000000000..02feb39df
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpoints.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.importexport.breakpoints;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * + * Wizard for Importing breakpoints. + * It serves a dual purpose, in that it is used by the platform import/export wizard, + * but it can also be used as a standalone wizard. + *
+ *+ * Example: + *
+ *+ * IWizard wiz = new WizardImportBreakpoints(); + * wiz.init(workbench, selection); + * WizardDialog wizdialog = new WizardDialog(shell, wiz); + * wizdialog.open(); + *+ * + * This class uses
WizardImportBreakpointsPage
+ *
+ * @since 3.2
+ *
+ */
+public class WizardImportBreakpoints extends Wizard implements IImportWizard {
+
+ /*
+ * The main page
+ */
+ private WizardImportBreakpointsPage fMainPage = null;
+
+ /**
+ * This is the default constructor
+ */
+ public WizardImportBreakpoints() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#addPages()
+ */
+ public void addPages() {
+ super.addPages();
+ fMainPage = new WizardImportBreakpointsPage(ImportExportMessages.WizardImportBreakpoints_0);
+ addPage(fMainPage);
+ }//end addPages
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ fMainPage = null;
+ }//end dispose
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#performFinish()
+ */
+ public boolean performFinish() {
+ return fMainPage.finish();
+ }//end performFinish
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ setWindowTitle(ImportExportMessages.WizardImportBreakpoints_0);
+ setNeedsProgressMonitor(true);
+ }//end init
+}//end class
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
new file mode 100644
index 000000000..757687f86
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.importexport.breakpoints;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.ui.SWTUtil;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * The import breakpoints wizard page.
+ *
+ * This class is used in WizardImportBreakpoints
.
+ *
+ * @since 3.2
+ */
+public class WizardImportBreakpointsPage extends WizardPage implements Listener {
+
+ //widgets
+ private Button fAutoRemoveDuplicates = null;
+ private Button fAutoCreateWorkingSets = null;
+ private Text fFileNameField = null;
+ private Button fBrowseForFileButton = null;
+ private File fImportFile = null;
+
+ /**
+ * This is the default constructor. It accepts the name for the tab as a
+ * parameter
+ *
+ * @param pageName the name of the page
+ */
+ public WizardImportBreakpointsPage(String pageName) {
+ super(pageName, ImportExportMessages.WizardImportBreakpointsPage_0, null);
+ }// end constructor
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ public void handleEvent(Event event) {
+ Widget source = event.widget;
+ if(source == fBrowseForFileButton) {
+ handleBrowseForFileButtonPressed();
+ }//end if
+ setPageComplete(detectPageComplete());
+ }// end handleEvent
+
+ /**
+ * This method handles the fBrowseForFileButton being pressed.
+ */
+ protected void handleBrowseForFileButtonPressed() {
+ FileDialog dialog = new FileDialog(getContainer().getShell(), SWT.OPEN);
+ dialog.setFilterExtensions(new String[]{"*."+IImportExportConstants.EXTENSION}); //$NON-NLS-1$
+ String file = dialog.open();
+ if(file != null) {
+ fImportFile = new File(file);
+ if (fImportFile == null) {
+ setMessage(ImportExportMessages.WizardImportBreakpointsPage_1, ERROR);
+ }//end if
+ else {
+ fFileNameField.setText(fImportFile.toString());
+ setPageComplete(true);
+ }//end else
+ }// end if
+ }//end handleBrowseForFileButtonPressed
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+ composite.setFont(parent.getFont());
+ createDestinationGroup(composite);
+ createOptionsGroup(composite);
+ setPageComplete(detectPageComplete());
+ setControl(composite);
+ }// end createControl
+
+ /**
+ * This method is used to determine if the page can be "finished".
+ * To be determined "finishable" there must be an import path.
+ *
+ * @return if the prerequesites of the wizard are met to allow the wizard to complete.
+ */
+ private boolean detectPageComplete() {
+ if (fFileNameField.getText().trim().equals("")) {//$NON-NLS-1$
+ setMessage(ImportExportMessages.WizardImportBreakpointsPage_6);
+ return false;
+ }
+ setMessage(ImportExportMessages.WizardImportBreakpointsPage_2);
+ return true;
+ }//end detectPageComplete
+
+ /**
+ * Create the options specification widgets.
+ *
+ * @param parent the parent composite to add this one to
+ */
+ protected void createOptionsGroup(Composite parent) {
+ Font font = parent.getFont();
+ // options group
+ Group optionsGroup = new Group(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ optionsGroup.setLayout(layout);
+ optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
+ optionsGroup.setText(ImportExportMessages.WizardBreakpointsPage_5);
+ optionsGroup.setFont(parent.getFont());
+ fAutoRemoveDuplicates = new Button(optionsGroup, SWT.CHECK | SWT.LEFT);
+ fAutoRemoveDuplicates.setText(ImportExportMessages.WizardImportBreakpointsPage_3);
+ fAutoRemoveDuplicates.setFont(font);
+ fAutoCreateWorkingSets = new Button(optionsGroup, SWT.CHECK | SWT.LEFT);
+ fAutoCreateWorkingSets.setText(ImportExportMessages.WizardImportBreakpointsPage_5);
+ fAutoCreateWorkingSets.setFont(font);
+ }// end createOptionsGroup
+
+ /**
+ * Create the export destination specification widgets
+ *
+ * @param parent the parent composite to add this one to
+ */
+ protected void createDestinationGroup(Composite parent) {
+ Font font = parent.getFont();
+ Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ destinationSelectionGroup.setLayout(layout);
+ destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ destinationSelectionGroup.setFont(font);
+ Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
+ destinationLabel.setText(ImportExportMessages.WizardImportBreakpointsPage_4);
+ destinationLabel.setFont(font);
+
+ // file name entry field
+ fFileNameField = new Text(destinationSelectionGroup, SWT.BORDER);
+ fFileNameField.addListener(SWT.Modify, this);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ fFileNameField.setLayoutData(data);
+ fFileNameField.setFont(font);
+
+ // destination browse button
+ fBrowseForFileButton = SWTUtil.createPushButton(destinationSelectionGroup, ImportExportMessages.WizardBreakpointsPage_8, null);
+ fBrowseForFileButton.addListener(SWT.Selection, this);
+ }// end createDestinationGroup
+
+ /**
+ * + * This method is called when the Finish button is click on the main wizard + * dialog To import the breakpoints, we read then from the tree + * and add them into the BreakpointManager + *
+ * @return if the import operation was successful or not + */ + public boolean finish() { + try { + getContainer().run(true, true, new ImportOperation(fImportFile, fAutoRemoveDuplicates.getSelection(), fAutoCreateWorkingSets.getSelection())); + }// end try + catch (InterruptedException e) { + DebugPlugin.log(e); + return false; + }// end catch + catch (InvocationTargetException e) { + DebugPlugin.log(e); + return false; + }//end catch + return true; + }// end finish + +}//end class diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java index 640ac7241..524301f4f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java @@ -13,7 +13,9 @@ package org.eclipse.debug.internal.ui.views.breakpoints; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarkerDelta; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IBreakpointManager; @@ -21,6 +23,7 @@ import org.eclipse.debug.core.IBreakpointsListener; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.importexport.breakpoints.IImportExportConstants; import org.eclipse.debug.ui.AbstractBreakpointOrganizerDelegate; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; @@ -35,237 +38,335 @@ import org.eclipse.ui.PlatformUI; * @since 3.1 */ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate implements IPropertyChangeListener, IBreakpointsListener { - - IWorkingSetManager fWorkingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); - /** - * Constructs a working set breakpoint organizer. Listens for changes in - * working sets and fires property change notification. - */ - public BreakpointSetOrganizer() { - fWorkingSetManager.addPropertyChangeListener(this); - DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); - DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); - } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#getCategories(org.eclipse.debug.core.model.IBreakpoint) - */ - public IAdaptable[] getCategories(IBreakpoint breakpoint) { - List result = new ArrayList(); - IWorkingSet[] workingSets = fWorkingSetManager.getWorkingSets(); - for (int i = 0; i < workingSets.length; i++) { - IWorkingSet set = workingSets[i]; - if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) { - IAdaptable[] elements = set.getElements(); - for (int j = 0; j < elements.length; j++) { - IAdaptable adaptable = elements[j]; - if (adaptable.equals(breakpoint)) { - result.add(new WorkingSetCategory(set)); - break; - } - } - } - } - return (IAdaptable[]) result.toArray(new IAdaptable[result.size()]); - } + private IWorkingSetManager fWorkingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); + + /** + * A cache for mapping markers to the working set they belong to + * @since 3.2 + */ + private BreakpointWorkingSetCache fCache = null; + + + /** + * Constructs a working set breakpoint organizer. Listens for changes in + * working sets and fires property change notification. + */ + public BreakpointSetOrganizer() { + fWorkingSetManager.addPropertyChangeListener(this); + fCache = new BreakpointWorkingSetCache(); + DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); + DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); + } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#dispose() - */ - public void dispose() { - fWorkingSetManager.removePropertyChangeListener(this); - fWorkingSetManager = null; - DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); - DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); - super.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - IWorkingSet set = null; - if (event.getNewValue() instanceof IWorkingSet) { - set = (IWorkingSet) event.getNewValue(); - } else if (event.getOldValue() instanceof IWorkingSet) { - set = (IWorkingSet) event.getOldValue(); - } - if (set != null && IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) { - fireCategoryChanged(new WorkingSetCategory(set)); - } - if (event.getProperty().equals(IInternalDebugUIConstants.MEMENTO_BREAKPOINT_WORKING_SET_NAME)) { - IWorkingSet defaultWorkingSet = getDefaultWorkingSet(); - if (defaultWorkingSet != null) { - fireCategoryChanged(new WorkingSetCategory(defaultWorkingSet)); - } else { - fireCategoryChanged(null); - } - } - } + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#getCategories(org.eclipse.debug.core.model.IBreakpoint) + */ + public IAdaptable[] getCategories(IBreakpoint breakpoint) { + List result = new ArrayList(); + IWorkingSet[] workingSets = fWorkingSetManager.getWorkingSets(); + for (int i = 0; i < workingSets.length; i++) { + IWorkingSet set = workingSets[i]; + if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) { + IAdaptable[] elements = set.getElements(); + for (int j = 0; j < elements.length; j++) { + IAdaptable adaptable = elements[j]; + if (adaptable.equals(breakpoint)) { + result.add(new WorkingSetCategory(set)); + break; + } + } + } + } + return (IAdaptable[]) result.toArray(new IAdaptable[result.size()]); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[]) - */ - public void breakpointsAdded(IBreakpoint[] breakpoints) { - IWorkingSet set = getDefaultWorkingSet(); - if (set != null) { - IAdaptable[] elements = set.getElements(); - IAdaptable[] newElements = new IAdaptable[elements.length + breakpoints.length]; - System.arraycopy(elements, 0, newElements, 0, elements.length); - System.arraycopy(breakpoints, 0, newElements, elements.length, breakpoints.length); - set.setElements(newElements); - } - } + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#dispose() + */ + public void dispose() { + fWorkingSetManager.removePropertyChangeListener(this); + fWorkingSetManager = null; + DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); + DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); + super.dispose(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[]) - */ - public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { - IWorkingSet[] workingSets = fWorkingSetManager.getWorkingSets(); - for (int i = 0; i < workingSets.length; i++) { - IWorkingSet set = workingSets[i]; - if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) { - clean(set); - } - } - } - - /** - * Removes deleted breakpoints from the given working set. - * - * @param workingSet breakpoint working set - */ - private void clean(IWorkingSet workingSet) { - IAdaptable[] elements = workingSet.getElements(); - IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); - boolean update = false; - for (int i = 0; i < elements.length; i++) { - IAdaptable adaptable = elements[i]; - if (adaptable instanceof IBreakpoint) { - IBreakpoint breakpoint = (IBreakpoint) adaptable; - if (!manager.isRegistered(breakpoint)) { - update = true; - elements[i] = null; - } - } - } - if (update) { - List newElements = new ArrayList(elements.length); - for (int i = 0; i < elements.length; i++) { - IAdaptable adaptable = elements[i]; - if (adaptable != null) { - newElements.add(adaptable); - } - } - workingSet.setElements((IAdaptable[]) newElements.toArray(new IAdaptable[newElements.size()])); - } - } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + IWorkingSet set = null; + if (event.getNewValue() instanceof IWorkingSet) { + set = (IWorkingSet) event.getNewValue(); + }//end if + else if (event.getOldValue() instanceof IWorkingSet) { + set = (IWorkingSet) event.getOldValue(); + }//end else if + //fix for bug 103731 + if(event.getProperty().equals(IWorkingSetManager.CHANGE_WORKING_SET_ADD)) { //$NON-NLS-1$ + IAdaptable[] breakpoints = set.getElements(); + for (int i = 0; i < breakpoints.length; i++) { + if (breakpoints[i] instanceof IBreakpoint) { + IMarker marker = ((IBreakpoint)breakpoints[i]).getMarker(); + fCache.addEntry(marker, set.getName()); + fCache.flushMarkerCache(marker); + }// end if + }//end for + }//end if + if (set != null && IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) { + fireCategoryChanged(new WorkingSetCategory(set)); + } + if (event.getProperty().equals(IInternalDebugUIConstants.MEMENTO_BREAKPOINT_WORKING_SET_NAME)) { + IWorkingSet defaultWorkingSet = getDefaultWorkingSet(); + if (defaultWorkingSet != null) { + fireCategoryChanged(new WorkingSetCategory(defaultWorkingSet)); + } else { + fireCategoryChanged(null); + } + } + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[]) - */ - public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { - } - - /** - * Returns the active default breakpoint working set, ornull
- * if none.
- *
- * @return the active default breakpoint working set, or null
- */
- public static IWorkingSet getDefaultWorkingSet() {
- IPreferenceStore preferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
- String name = preferenceStore.getString(IInternalDebugUIConstants.MEMENTO_BREAKPOINT_WORKING_SET_NAME);
- if (name != null) {
- return PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
- }
- return null;
- }
-
- /**
- * Sets the active default breakpoint working set, or null
- * if none.
- *
- * @param set default working set or null
- */
- public static void setDefaultWorkingSet(IWorkingSet set) {
- String name = ""; //$NON-NLS-1$
- if (set != null) {
- // only consider breakpoint working sets
- if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) {
- name = set.getName();
- }
- }
- DebugUIPlugin.getDefault().getPluginPreferences().setValue(IInternalDebugUIConstants.MEMENTO_BREAKPOINT_WORKING_SET_NAME, name);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#canRemove(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
- */
- public boolean canRemove(IBreakpoint breakpoint, IAdaptable category) {
- if (category instanceof WorkingSetCategory) {
- WorkingSetCategory wsc = (WorkingSetCategory) category;
- return IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(wsc.getWorkingSet().getId());
- }
- return super.canRemove(breakpoint, category);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#canAdd(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
- */
- public boolean canAdd(IBreakpoint breakpoint, IAdaptable category) {
- if (category instanceof WorkingSetCategory) {
- WorkingSetCategory wsc = (WorkingSetCategory) category;
- return IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(wsc.getWorkingSet().getId());
- }
- return super.canAdd(breakpoint, category);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#addBreakpoint(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
- */
- public void addBreakpoint(IBreakpoint breakpoint, IAdaptable category) {
- if (category instanceof WorkingSetCategory) {
- IWorkingSet workingSet = ((WorkingSetCategory) category).getWorkingSet();
- IAdaptable[] elements = workingSet.getElements();
- IAdaptable[] newElements = new IAdaptable[elements.length + 1];
- System.arraycopy(elements, 0, newElements, 0, elements.length);
- newElements[elements.length] = breakpoint;
- workingSet.setElements(newElements);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#removeBreakpoint(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
- */
- public void removeBreakpoint(IBreakpoint breakpoint, IAdaptable category) {
- if (category instanceof WorkingSetCategory) {
- IWorkingSet workingSet = ((WorkingSetCategory) category).getWorkingSet();
- IAdaptable[] elements = workingSet.getElements();
- List list = new ArrayList();
- for (int i = 0; i < elements.length; i++) {
- IAdaptable adaptable = elements[i];
- if (!adaptable.equals(breakpoint)) {
- list.add(adaptable);
- }
- }
- workingSet.setElements((IAdaptable[]) list.toArray(new IAdaptable[list.size()]));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#getCategories()
- */
- public IAdaptable[] getCategories() {
- IWorkingSet[] workingSets = fWorkingSetManager.getWorkingSets();
- List all = new ArrayList();
- for (int i = 0; i < workingSets.length; i++) {
- IWorkingSet set = workingSets[i];
- if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) {
- all.add(new WorkingSetCategory(set));
- }
- }
- return (IAdaptable[]) all.toArray(new IAdaptable[all.size()]);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
+ */
+ public void breakpointsAdded(IBreakpoint[] breakpoints) {
+ IWorkingSet set = null;
+ for (int i = 0; i < breakpoints.length; i++) {
+ IMarker marker = breakpoints[i].getMarker();
+ String[] names = getWorkingsetAttributeFromMarker(marker, IInternalDebugUIConstants.WORKING_SET_NAME);
+ //add it to the default set if the listing is empty
+ for (int j = 1; j < names.length; j++) {
+ set = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(names[j]);
+ // if we cannot find the one we want, try to get the default
+ if (set == null) {
+ set = getDefaultWorkingSet();
+ }// end if
+ if (set != null) {
+ fCache.addEntry(marker, set.getName()); // fix for bug 103731
+ fCache.flushMarkerCache(marker);
+ addBreakpointToSet(breakpoints[i], set);
+ }// end if
+ }// end for
+ }// end for
+ }
+
+ /**
+ * Adds a breakpoint to a workingset
+ * @param breakpoint the breakpoint to add
+ * @param set the set to add it to
+ *
+ * @since 3.2
+ */
+ private void addBreakpointToSet(IBreakpoint breakpoint, IWorkingSet set) {
+ IAdaptable[] elements = set.getElements();
+ IAdaptable[] newElements = new IAdaptable[elements.length + 1];
+ newElements[newElements.length-1] = breakpoint;
+ System.arraycopy(elements, 0, newElements, 0, elements.length);
+ set.setElements(newElements);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[],
+ * org.eclipse.core.resources.IMarkerDelta[])
+ */
+ public void breakpointsRemoved(IBreakpoint[] breakpoints,
+ IMarkerDelta[] deltas) {
+ IWorkingSet[] workingSets = fWorkingSetManager.getWorkingSets();
+ IWorkingSet set = null;
+ for (int i = 0; i < workingSets.length; i++) {
+ set = workingSets[i];
+ if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) {
+ clean(set);
+ }// end if
+ }// end for
+ }//end breakpointsRemoved
+
+ /**
+ * Removes deleted breakpoints from the given working set.
+ *
+ * @param workingSet
+ * breakpoint working set
+ */
+ private void clean(IWorkingSet workingSet) {
+ IAdaptable[] elements = workingSet.getElements();
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ boolean update = false;
+ for (int i = 0; i < elements.length; i++) {
+ IAdaptable adaptable = elements[i];
+ if (adaptable instanceof IBreakpoint) {
+ IBreakpoint breakpoint = (IBreakpoint) adaptable;
+ if (!manager.isRegistered(breakpoint)) {
+ update = true;
+ elements[i] = null;
+ }
+ }
+ }
+ if (update) {
+ List newElements = new ArrayList(elements.length);
+ for (int i = 0; i < elements.length; i++) {
+ IAdaptable adaptable = elements[i];
+ if (adaptable != null) {
+ newElements.add(adaptable);
+ }
+ }
+ workingSet.setElements((IAdaptable[]) newElements.toArray(new IAdaptable[newElements.size()]));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[],
+ * org.eclipse.core.resources.IMarkerDelta[])
+ */
+ public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
+ }
+
+ /**
+ * Returns the active default breakpoint working set, or null
+ * if none.
+ *
+ * @return the active default breakpoint working set, or null
+ */
+ public static IWorkingSet getDefaultWorkingSet() {
+ IPreferenceStore preferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
+ String name = preferenceStore.getString(IInternalDebugUIConstants.MEMENTO_BREAKPOINT_WORKING_SET_NAME);
+ if (name != null) {
+ return PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
+ }
+ return null;
+ }
+
+ /**
+ * Sets the active default breakpoint working set, or null
if
+ * none.
+ *
+ * @param set
+ * default working set or null
+ */
+ public static void setDefaultWorkingSet(IWorkingSet set) {
+ String name = ""; //$NON-NLS-1$
+ if (set != null) {
+ // only consider breakpoint working sets
+ if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) {
+ name = set.getName();
+ }
+ }
+ DebugUIPlugin.getDefault().getPluginPreferences().setValue(IInternalDebugUIConstants.MEMENTO_BREAKPOINT_WORKING_SET_NAME, name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#canRemove(org.eclipse.debug.core.model.IBreakpoint,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ public boolean canRemove(IBreakpoint breakpoint, IAdaptable category) {
+ if (category instanceof WorkingSetCategory) {
+ WorkingSetCategory wsc = (WorkingSetCategory) category;
+ return IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(wsc.getWorkingSet().getId());
+ }
+ return super.canRemove(breakpoint, category);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#canAdd(org.eclipse.debug.core.model.IBreakpoint,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ public boolean canAdd(IBreakpoint breakpoint, IAdaptable category) {
+ if (category instanceof WorkingSetCategory) {
+ WorkingSetCategory wsc = (WorkingSetCategory) category;
+ return IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(wsc.getWorkingSet().getId());
+ }
+ return super.canAdd(breakpoint, category);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#addBreakpoint(org.eclipse.debug.core.model.IBreakpoint,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ public void addBreakpoint(IBreakpoint breakpoint, IAdaptable category) {
+ if (category instanceof WorkingSetCategory) {
+ IWorkingSet set = ((WorkingSetCategory) category).getWorkingSet();
+ fCache.addEntry(breakpoint.getMarker(), set.getName()); //fix for bug 103731
+ fCache.flushMarkerCache(breakpoint.getMarker());
+ addBreakpointToSet(breakpoint, set);
+ }//end if
+ }
+
+ /**
+ * Gets the workingset names from the marker
+ *
+ * @param marker
+ * them arker to get the names from
+ * @return the listing of markers or an empty String array, never null
+ *
+ * @since 3.2
+ */
+ private String[] getWorkingsetAttributeFromMarker(IMarker marker, String type) {
+ try {
+ String name = (String) marker.getAttribute(type);
+ if (name != null) {
+ return name.split("\\" + IImportExportConstants.DELIMITER); //$NON-NLS-1$
+ }// end if
+ }// end try
+ catch (CoreException e) {DebugPlugin.log(e);}
+ return new String[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#removeBreakpoint(org.eclipse.debug.core.model.IBreakpoint,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ public void removeBreakpoint(IBreakpoint breakpoint, IAdaptable category) {
+ if (category instanceof WorkingSetCategory) {
+ IWorkingSet set = ((WorkingSetCategory) category).getWorkingSet();
+ IAdaptable[] elements = set.getElements();
+ List list = new ArrayList();
+ for (int i = 0; i < elements.length; i++) {
+ IAdaptable adaptable = elements[i];
+ if (!adaptable.equals(breakpoint)) {
+ list.add(adaptable);
+ }//end if
+ }//end for
+ fCache.removeMappedEntry(breakpoint.getMarker(), set.getName());
+ fCache.flushMarkerCache(breakpoint.getMarker());
+ set.setElements((IAdaptable[]) list.toArray(new IAdaptable[list.size()]));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#getCategories()
+ */
+ public IAdaptable[] getCategories() {
+ IWorkingSet[] workingSets = fWorkingSetManager.getWorkingSets();
+ List all = new ArrayList();
+ for (int i = 0; i < workingSets.length; i++) {
+ IWorkingSet set = workingSets[i];
+ if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set
+ .getId())) {
+ all.add(new WorkingSetCategory(set));
+ }
+ }
+ return (IAdaptable[]) all.toArray(new IAdaptable[all.size()]);
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java
new file mode 100644
index 000000000..d1f62c7f3
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.views.breakpoints;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.importexport.breakpoints.IImportExportConstants;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Class to cache the breakpoint to workingset information in its underlying
+ * marker as breakpoints are moved between breakpoint working sets.
+ * It resolves the need for constant attribute lookup and parsing to
+ * fix bug 103731
+ *
+ * @since 3.2
+ */
+public class BreakpointWorkingSetCache {
+
+ /**
+ * the entire cache
+ * key: marker
+ * value: vector of workingsets the marker belongs to
+ */
+ HashMap fCache = null;
+
+ /**
+ * Default constructor
+ * @param organizer the oprganizer that owns this cache
+ */
+ public BreakpointWorkingSetCache() {
+ fCache = new HashMap(15);
+ }//end constructor
+
+ /**
+ * Adds an entry into the cache
+ * @param marker the marker to add the workingset information about
+ * @param entry the entry to add to the cache
+ */
+ public void addEntry(IMarker marker, Object entry) {
+ Vector list = (Vector)fCache.get(marker);
+ if (list == null) {
+ list = new Vector();
+ list.addElement(entry);
+ fCache.put(marker, list);
+ }//end if
+ else {
+ if(!list.contains(entry)) {
+ list.addElement(entry);
+ }//end if
+ }//end else
+ }//end addEntry
+
+ /**
+ * Removes an item from the list contained under the marker key, not the marker entry
+ * @param marker the marker key to remove the item from
+ * @param entry the entry to remove
+ */
+ public void removeMappedEntry(IMarker marker, Object entry) {
+ Vector list = (Vector)fCache.get(marker);
+ if(list != null) {
+ list.remove(entry);
+ }//end if
+ }//end removeMappedEntry
+
+ /**
+ * Flushes the cache of only the sepcified marker
+ * @param marker the marker whose cache is to be flushed
+ */
+ public void flushMarkerCache(IMarker marker) {
+ IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
+ Vector list = (Vector)fCache.get(marker);
+ if(list != null) {
+ String names = IImportExportConstants.DELIMITER;
+ String ids = IImportExportConstants.DELIMITER;
+ for(int i = 0; i < list.size(); i++) {
+ String name = (String)list.elementAt(i);
+ IWorkingSet ws = manager.getWorkingSet(name);
+ if(ws != null) {
+ names += name+IImportExportConstants.DELIMITER;
+ ids += ws.getId()+IImportExportConstants.DELIMITER;
+ }//end if
+ }//end for
+ try {
+ marker.setAttribute(IInternalDebugUIConstants.WORKING_SET_NAME, names);
+ marker.setAttribute(IInternalDebugUIConstants.WORKING_SET_ID, ids);
+ }//end try
+ catch(CoreException e) {DebugPlugin.log(e);}
+ }//end if
+ }
+
+}//end class
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java
index 908b17324..55ad360a8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java
@@ -11,31 +11,21 @@
package org.eclipse.debug.internal.ui.views.breakpoints;
import java.util.ArrayList;
-import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.SWTUtil;
+import org.eclipse.debug.internal.ui.importexport.breakpoints.TransientBreakpointsViewer;
import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
-import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
@@ -46,8 +36,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
@@ -65,53 +54,7 @@ public class BreakpointWorkingSetPage extends WizardPage implements IWorkingSetP
final private static String PAGE_ID= "breakpointWorkingSetPage"; //$NON-NLS-1$
private Text fWorkingSetName;
- private CheckboxTreeViewer fTree;
- private ITreeContentProvider fTreeContentProvider;
-
- class ContentProvider implements ITreeContentProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parentElement) {
- return DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- return element instanceof IBreakpointManager;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @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) {
- }
-
- }
-
+ private TransientBreakpointsViewer fTViewer;
private boolean fFirstCheck;
private IWorkingSet fWorkingSet;
@@ -129,17 +72,14 @@ public class BreakpointWorkingSetPage extends WizardPage implements IWorkingSetP
*/
public void createControl(Composite parent) {
initializeDialogUnits(parent);
-
Composite composite= new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
setControl(composite);
-
Label label= new Label(composite, SWT.WRAP);
label.setText(DebugUIViewsMessages.BreakpointWorkingSetPage_2);
GridData gd= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
label.setLayoutData(gd);
-
fWorkingSetName= new Text(composite, SWT.SINGLE | SWT.BORDER);
fWorkingSetName.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
fWorkingSetName.addModifyListener(
@@ -150,58 +90,40 @@ public class BreakpointWorkingSetPage extends WizardPage implements IWorkingSetP
}
);
fWorkingSetName.setFocus();
-
label= new Label(composite, SWT.WRAP);
label.setText(DebugUIViewsMessages.BreakpointWorkingSetPage_3);
- gd= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
label.setLayoutData(gd);
-
- fTree= new CheckboxTreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- gd= new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
- gd.heightHint= convertHeightInCharsToPixels(15);
- fTree.getControl().setLayoutData(gd);
-
- fTreeContentProvider= new ContentProvider();
- fTree.setContentProvider(fTreeContentProvider);
-
- fTree.setLabelProvider(DebugUITools.newDebugModelPresentation());
- fTree.setSorter(new BreakpointsSorter());
- fTree.setUseHashlookup(true);
- fTree.setInput(DebugPlugin.getDefault().getBreakpointManager());
- fTree.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- validateInput();
- }
- });
-
+ IViewPart fViewpart = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().findView(IDebugUIConstants.ID_BREAKPOINT_VIEW);
+ fTViewer = new TransientBreakpointsViewer(composite, DebugPlugin.getDefault().getBreakpointManager(), (IStructuredSelection)fViewpart.getViewSite().getSelectionProvider().getSelection());
// Add select / deselect all buttons for bug 46669
Composite buttonComposite = new Composite(composite, SWT.NONE);
buttonComposite.setLayout(new GridLayout(2, false));
buttonComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
Button selectAllButton = SWTUtil.createPushButton(buttonComposite, DebugUIViewsMessages.BreakpointWorkingSetPage_selectAll_label, null);
selectAllButton.setToolTipText(DebugUIViewsMessages.BreakpointWorkingSetPage_selectAll_toolTip);
selectAllButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent selectionEvent) {
- fTree.setCheckedElements(fTreeContentProvider.getElements(fTree.getInput()));
+ BreakpointsViewer viewer = fTViewer.getViewer();
+ viewer.getTree().selectAll();
+ viewer.setCheckedElements(((IStructuredSelection)viewer.getSelection()).toArray());
+ viewer.setGrayedElements(new Object[] {});
+ viewer.getTree().deselectAll();
validateInput();
}
});
-
Button deselectAllButton = SWTUtil.createPushButton(buttonComposite, DebugUIViewsMessages.BreakpointWorkingSetPage_deselectAll_label, null);
deselectAllButton.setToolTipText(DebugUIViewsMessages.BreakpointWorkingSetPage_deselectAll_toolTip);
deselectAllButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent selectionEvent) {
- fTree.setCheckedElements(new Object[0]);
+ BreakpointsViewer viewer = fTViewer.getViewer();
+ viewer.setCheckedElements(new Object[] {});
validateInput();
}
});
-
if (fWorkingSet != null)
fWorkingSetName.setText(fWorkingSet.getName());
- initializeCheckedState();
validateInput();
-
Dialog.applyDialogFont(composite);
}
@@ -221,7 +143,6 @@ public class BreakpointWorkingSetPage extends WizardPage implements IWorkingSetP
if (getContainer() != null && getShell() != null && fWorkingSetName != null) {
fFirstCheck= false;
fWorkingSetName.setText(fWorkingSet.getName());
- initializeCheckedState();
validateInput();
}
}
@@ -230,18 +151,27 @@ public class BreakpointWorkingSetPage extends WizardPage implements IWorkingSetP
* Implements method from IWorkingSetPage
*/
public void finish() {
- String workingSetName= fWorkingSetName.getText();
- ArrayList elements= new ArrayList(10);
- findCheckedElements(elements, fTree.getInput());
+ String workingSetName = fWorkingSetName.getText();
+ Object[] adaptable = fTViewer.getCheckedElements().toArray();
+ ArrayList elements = new ArrayList();
+ //weed out non-breakpoint elements since 3.2
+ for(int i = 0; i < adaptable.length; i++) {
+ if(adaptable[i] instanceof IBreakpoint) {
+ elements.add(adaptable[i]);
+ }//end if
+ }//end for
if (fWorkingSet == null) {
IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager();
- fWorkingSet= workingSetManager.createWorkingSet(workingSetName, (IAdaptable[])elements.toArray(new IAdaptable[elements.size()]));
+ fWorkingSet = workingSetManager.createWorkingSet(workingSetName, (IAdaptable[])elements.toArray(new IAdaptable[elements.size()]));
} else {
fWorkingSet.setName(workingSetName);
- fWorkingSet.setElements((IAdaptable[]) elements.toArray(new IAdaptable[elements.size()]));
+ fWorkingSet.setElements((IAdaptable[])elements.toArray(new IAdaptable[elements.size()]));
}
}
+ /**
+ * validates the current input of the page to determine if the finish button can be enabled
+ */
private void validateInput() {
String errorMessage= null;
String newText= fWorkingSetName.getText();
@@ -256,9 +186,7 @@ public class BreakpointWorkingSetPage extends WizardPage implements IWorkingSetP
}
errorMessage= DebugUIViewsMessages.BreakpointWorkingSetPage_5;
}
-
fFirstCheck= false;
-
if (errorMessage == null && (fWorkingSet == null || newText.equals(fWorkingSet.getName()) == false)) {
IWorkingSet[] workingSets= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets();
for (int i= 0; i < workingSets.length; i++) {
@@ -267,62 +195,8 @@ public class BreakpointWorkingSetPage extends WizardPage implements IWorkingSetP
}
}
}
-
setErrorMessage(errorMessage);
setPageComplete(errorMessage == null);
}
-
- private void findCheckedElements(List checkedResources, Object parent) {
- Object[] children= fTreeContentProvider.getChildren(parent);
- for (int i= 0; i < children.length; i++) {
- if (fTree.getGrayed(children[i]))
- findCheckedElements(checkedResources, children[i]);
- else if (fTree.getChecked(children[i]))
- checkedResources.add(children[i]);
- }
- }
-
- private void initializeCheckedState() {
-
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- Object[] elements = new Object[0];
- if (fWorkingSet == null) {
- // Use current part's selection for initialization
- IWorkbenchPage page= DebugUIPlugin.getActiveWorkbenchWindow().getActivePage();
- if (page == null) {
- return;
- }
-
- IWorkbenchPart part= page.getActivePart();
- if (part == null) {
- return;
- }
-
- ISelectionProvider provider = part.getSite().getSelectionProvider();
- if (provider == null) {
- return;
- }
-
- ISelection selection = provider.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection) selection;
- List list = new ArrayList();
- Object[] objects = ss.toArray();
- for (int i= 0; i < objects.length; i++) {
- if (objects[i] instanceof IBreakpoint) {
- list.add(objects[i]);
- }
- }
- elements = list.toArray();
- }
- } else {
- elements= fWorkingSet.getElements();
- }
-
- fTree.setCheckedElements(elements);
- }
- });
- }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsContentProvider.java
index 1f52ab22f..827add9f4 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsContentProvider.java
@@ -94,7 +94,7 @@ public class BreakpointsContentProvider implements ITreeContentProvider, IProper
* @param organizers the nested order of breakpoint organizers, or null
* if none
*/
- void setOrganizers(IBreakpointOrganizer[] organizers) {
+ public void setOrganizers(IBreakpointOrganizer[] organizers) {
if (organizers != null && organizers.length == 0) {
organizers = null;
}
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 9b0e9dbf7..4f3c40a34 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
@@ -1022,4 +1022,11 @@ public interface IDebugUIConstants {
* @since 3.2
*/
public static final String PREF_MAX_DETAIL_LENGTH = PLUGIN_ID + ".max_detail_length"; //$NON-NLS-1$
+
+ /**
+ * Identifier for breakpoint working set type.
+ *
+ * @since 3.2
+ */
+ public static final String BREAKPOINT_WORKINGSET_ID = "org.eclipse.debug.ui.breakpointWorkingSet"; //$NON-NLS-1$
}
--
cgit v1.2.3