Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-02-17 17:21:15 +0000
committerPawel Piech2012-02-17 17:21:15 +0000
commitaa357e78b41e87b7d414d1a7d0b8b7db0dfce011 (patch)
tree24839c72d830282ae7a9b36518081a4e4bc59cbb
parentd8f49676d0842da03089b2ab50c237f16c66f1e4 (diff)
downloadeclipse.platform.debug-aa357e78b41e87b7d414d1a7d0b8b7db0dfce011.tar.gz
eclipse.platform.debug-aa357e78b41e87b7d414d1a7d0b8b7db0dfce011.tar.xz
eclipse.platform.debug-aa357e78b41e87b7d414d1a7d0b8b7db0dfce011.zip
Bug 369856 - [bp] Allows clients to create and extend toggle breakpoint actionsv20120217-1721
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java133
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/BreakpointTypesContribution.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetBreakpointAction.java21
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java88
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetFactory.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManager.java103
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManagerListener.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTargetManagerListener.java)7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java8
11 files changed, 259 insertions, 121 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java
index 163c6ef7a..c8239d198 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Wind River Systems and others.
+ * Copyright (c) 2008, 2012 Wind River Systems 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
@@ -29,6 +29,7 @@ import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionConverter;
import org.eclipse.core.expressions.ExpressionTagNames;
import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
@@ -38,36 +39,40 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.core.IConfigurationElementConstants;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
-import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManagerListener;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
/**
- * Organizes the toggle breakpoints target factories contributed through the
- * extension point and keeps track of the toggle breakpoints target that
- * the factories produce. The manager is accessed as a singleton through
- * the <code>getDefault()</code> method.
- * <p>
- * The adapter mechanism for obtaining a toggle breakpoints target is
- * still supported through a specialized toggle target factory. Targets
- * contributed through this mechanism are labeled as "Default" in the UI.
- * </p>
+ * The concrete implementation of the toggle breakpoints target manager
+ * interface.
*
- * @see IToggleBreakpointsTargetFactory
- * @see IToggleBreakpointsTarget
- * @see IToggleBreakpointsTargetExtension
* @since 3.5
*/
-public class ToggleBreakpointsTargetManager {
+public class ToggleBreakpointsTargetManager implements IToggleBreakpointsTargetManager {
/**
* Toggle breakpoints target ID which refers to a target contributed
@@ -82,7 +87,7 @@ public class ToggleBreakpointsTargetManager {
/**
* Acts as a proxy between the toggle breakpoints target manager and the factories
- * contributed to the extension point. Only loads information from the plug-in xml
+ * contributed to the extension point. Only loads information from the plug-in XML
* and only instantiates the specified factory if required (lazy loading).
*/
private static class ToggleTargetFactory implements IToggleBreakpointsTargetFactory {
@@ -516,40 +521,16 @@ public class ToggleBreakpointsTargetManager {
return idsForSelection;
}
- /**
- * Returns the set of <code>String</code> IDs of toggle breakpoint targets,
- * which are enabled for the given active part and selection. The IDs can be used
- * to create the {@link IToggleBreakpointsTarget} instance.
- * @param part active part
- * @param selection active selection in part
- * @return Set of toggle target IDs or an empty set
- */
public Set getEnabledToggleBreakpointsTargetIDs(IWorkbenchPart part, ISelection selection) {
return getEnabledTargetIDs(getEnabledFactories(part, selection), part, selection);
}
- /**
- * Returns the ID of the calculated preferred toggle breakpoints target for the
- * given active part and selection. The returned ID is chosen based on factory
- * enablement, whether the target is a default one, and on user choice.
- * @param part active part
- * @param selection active selection in part
- * @return The toggle target IDs or null if none.
- */
public String getPreferredToggleBreakpointsTargetID(IWorkbenchPart part, ISelection selection) {
Set factories = getEnabledFactories(part, selection);
Set possibleIDs = getEnabledTargetIDs(factories, part, selection);
return chooseToggleTargetIDInSet(possibleIDs, part, selection);
}
- /**
- * Given the ID of toggle breakpoint target, this method will try to find the factory
- * that creates it and return an instance of it.
- *
- * @param part The workbench part in which toggle target is to be used
- * @param selection The active selection to use with toggle target
- * @return The instantiated target or null
- */
public IToggleBreakpointsTarget getToggleBreakpointsTarget(IWorkbenchPart part, ISelection selection) {
String id = getPreferredToggleBreakpointsTargetID(part, selection);
IToggleBreakpointsTargetFactory factory = (IToggleBreakpointsTargetFactory)fFactoriesByTargetID.get(id);
@@ -563,13 +544,6 @@ public class ToggleBreakpointsTargetManager {
return null;
}
- /**
- * Given the ID of a toggle breakpoints target, this method will try
- * to find the factory that creates it and ask it for the name of it.
- *
- * @param id The ID of the requested toggle breakpoint target.
- * @return The name of the target.
- */
public String getToggleBreakpointsTargetName(String id) {
IToggleBreakpointsTargetFactory factory = (IToggleBreakpointsTargetFactory)fFactoriesByTargetID.get(id);
if (factory != null) {
@@ -578,13 +552,6 @@ public class ToggleBreakpointsTargetManager {
return null;
}
- /**
- * Given the ID of a toggle breakpoints target, this method will try
- * to find the factory that creates it and ask it for the description of it.
- *
- * @param id The ID of the requested toggle breakpoint target.
- * @return The description of the target or null.
- */
public String getToggleBreakpointsTargetDescription(String id) {
IToggleBreakpointsTargetFactory factory = (IToggleBreakpointsTargetFactory)fFactoriesByTargetID.get(id);
if (factory != null) {
@@ -593,20 +560,10 @@ public class ToggleBreakpointsTargetManager {
return null;
}
- /**
- * Adds the given listener to the list of listeners notified when the preferred
- * toggle breakpoints targets change.
- * @param listener The listener to add.
- */
public void addChangedListener(IToggleBreakpointsTargetManagerListener listener) {
fChangedListners.add(listener);
}
- /**
- * Removes the given listener from the list of listeners notified when the preferred
- * toggle breakpoints targets change.
- * @param listener The listener to add.
- */
public void removeChangedListener(IToggleBreakpointsTargetManagerListener listener) {
fChangedListners.remove(listener);
}
@@ -635,7 +592,10 @@ public class ToggleBreakpointsTargetManager {
buffer.append(entry.getValue());
buffer.append('|');
}
- DebugUIPlugin.getDefault().getPluginPreferences().setValue(PREF_TARGETS, buffer.toString());
+ IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(DebugUIPlugin.getUniqueIdentifier());
+ if(prefs != null) {
+ prefs.put(PREF_TARGETS, buffer.toString());
+ }
}
/**
@@ -645,7 +605,14 @@ public class ToggleBreakpointsTargetManager {
*/
private void loadPreferredTargets() {
fPreferredTargets = new HashMap();
- String preferenceValue = DebugUIPlugin.getDefault().getPluginPreferences().getString(PREF_TARGETS);
+ String preferenceValue = Platform.getPreferencesService().getString(
+ DebugUIPlugin.getUniqueIdentifier(),
+ PREF_TARGETS,
+ null,
+ null);
+ if(preferenceValue == null) {
+ return;
+ }
StringTokenizer entryTokenizer = new StringTokenizer(preferenceValue,"|"); //$NON-NLS-1$
while (entryTokenizer.hasMoreTokens()){
String token = entryTokenizer.nextToken();
@@ -744,4 +711,38 @@ public class ToggleBreakpointsTargetManager {
}
}
+ public IBreakpoint getBeakpointFromEditor(ITextEditor editor, IVerticalRulerInfo info) {
+ IDocumentProvider provider = editor.getDocumentProvider();
+ if(provider == null) {
+ return null;
+ }
+ IEditorInput input = editor.getEditorInput();
+ IAnnotationModel annotationModel = provider.getAnnotationModel(input);
+ if (annotationModel != null) {
+ IDocument document = provider.getDocument(input);
+ Iterator iterator = annotationModel.getAnnotationIterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof SimpleMarkerAnnotation) {
+ SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object;
+ IMarker marker = markerAnnotation.getMarker();
+ try {
+ if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
+ Position position = annotationModel.getPosition(markerAnnotation);
+ int line = document.getLineOfOffset(position.getOffset());
+ if (line == info.getLineOfLastMouseButtonActivity()) {
+ IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker);
+ if (breakpoint != null) {
+ return breakpoint;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ } catch (BadLocationException e) {
+ }
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/BreakpointTypesContribution.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/BreakpointTypesContribution.java
index 4fa2d566a..f7cc32c4b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/BreakpointTypesContribution.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/BreakpointTypesContribution.java
@@ -16,6 +16,8 @@ import java.util.List;
import java.util.Set;
import org.eclipse.debug.internal.ui.actions.ToggleBreakpointsTargetManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.ContributionItem;
@@ -50,6 +52,8 @@ public class BreakpointTypesContribution extends CompoundContributionItem implem
public void run() {
if (isChecked()) {
+ // Note: setPreferredTarget is not declared on the
+ // IToggleBreakpontsTargetManager interface.
ToggleBreakpointsTargetManager.getDefault().setPreferredTarget(fPossibleIDs, fID);
}
}
@@ -91,7 +95,7 @@ public class BreakpointTypesContribution extends CompoundContributionItem implem
}
// Get breakpoint toggle target IDs.
- ToggleBreakpointsTargetManager manager = ToggleBreakpointsTargetManager.getDefault();
+ IToggleBreakpointsTargetManager manager = DebugUITools.getToggleBreakpointsTargetManager();
Set enabledIDs = manager.getEnabledToggleBreakpointsTargetIDs(part, selection);
String preferredId = manager.getPreferredToggleBreakpointsTargetID(part, selection);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetBreakpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetBreakpointAction.java
index 9bd0a0e5a..99650fd36 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetBreakpointAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetBreakpointAction.java
@@ -12,20 +12,17 @@
package org.eclipse.debug.internal.ui.actions.breakpoints;
import org.eclipse.core.runtime.IAdaptable;
-
+import org.eclipse.debug.internal.ui.actions.RetargetAction;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManagerListener;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
-
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.debug.internal.ui.actions.IToggleBreakpointsTargetManagerListener;
-import org.eclipse.debug.internal.ui.actions.RetargetAction;
-import org.eclipse.debug.internal.ui.actions.ToggleBreakpointsTargetManager;
-
-import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
-
/**
* Retargettable breakpoint action.
@@ -44,7 +41,7 @@ public abstract class RetargetBreakpointAction extends RetargetAction implements
}
protected Object getAdapter(IAdaptable adaptable) {
- ToggleBreakpointsTargetManager manager = ToggleBreakpointsTargetManager.getDefault();
+ IToggleBreakpointsTargetManager manager = DebugUITools.getToggleBreakpointsTargetManager();
IWorkbenchPart activePart = getActivePart();
if (activePart != null) {
return manager.getToggleBreakpointsTarget(activePart, getTargetSelection());
@@ -54,16 +51,16 @@ public abstract class RetargetBreakpointAction extends RetargetAction implements
public void init(IWorkbenchWindow window) {
super.init(window);
- ToggleBreakpointsTargetManager.getDefault().addChangedListener(this);
+ DebugUITools.getToggleBreakpointsTargetManager().addChangedListener(this);
}
public void init(IAction action) {
super.init(action);
- ToggleBreakpointsTargetManager.getDefault().addChangedListener(this);
+ DebugUITools.getToggleBreakpointsTargetManager().addChangedListener(this);
}
public void dispose() {
- ToggleBreakpointsTargetManager.getDefault().removeChangedListener(this);
+ DebugUITools.getToggleBreakpointsTargetManager().removeChangedListener(this);
super.dispose();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java
index e3362890a..5d1f09b84 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java
@@ -13,7 +13,7 @@ package org.eclipse.debug.internal.ui.actions.breakpoints;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.internal.ui.actions.ToggleBreakpointsTargetManager;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
@@ -47,7 +47,7 @@ public abstract class ToggleBreakpointObjectActionDelegate implements IObjectAct
*/
public void run(IAction action) {
IToggleBreakpointsTarget target =
- ToggleBreakpointsTargetManager.getDefault().getToggleBreakpointsTarget(fPart, fSelection);
+ DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection);
if (target != null) {
try {
performAction(target, fPart, fSelection);
@@ -79,7 +79,7 @@ public abstract class ToggleBreakpointObjectActionDelegate implements IObjectAct
// Guard here against that possibility.
if (fPart != null) {
IToggleBreakpointsTarget target =
- ToggleBreakpointsTargetManager.getDefault().getToggleBreakpointsTarget(fPart, fSelection);
+ DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection);
enabled = target != null;
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
index bc9702123..59b3fb548 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
@@ -13,18 +13,14 @@ package org.eclipse.debug.ui;
import java.util.Set;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.commands.operations.ObjectUndoContext;
-
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -33,26 +29,6 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.ide.undo.DeleteMarkersOperation;
-import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
-
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -70,6 +46,7 @@ import org.eclipse.debug.internal.ui.DefaultLabelProvider;
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
import org.eclipse.debug.internal.ui.LazyModelPresentation;
import org.eclipse.debug.internal.ui.actions.ActionMessages;
+import org.eclipse.debug.internal.ui.actions.ToggleBreakpointsTargetManager;
import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationDialog;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
@@ -80,13 +57,32 @@ import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager;
import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility;
import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIUtils;
import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
-
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextManager;
import org.eclipse.debug.ui.contexts.IDebugContextService;
import org.eclipse.debug.ui.memory.IMemoryRenderingManager;
import org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser;
import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.ide.undo.DeleteMarkersOperation;
+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
/**
@@ -215,7 +211,7 @@ public class DebugUITools {
}
/**
- * Returns the element of the currently selected context in the
+ * Returns the element of the currently selected context in the
* active workbench window. Returns <code>null</code> if there is no
* current debug context.
* <p>
@@ -234,6 +230,31 @@ public class DebugUITools {
return null;
}
+ /**
+ * Returns the currently selected context in the given part or part's
+ * workbench window. Returns <code>null</code> if there is no current
+ * debug context.
+ * @param part workbench part where the active context is to be evaluated
+ * @return the currently selected debug context in the given workbench part,
+ * or <code>null</code>
+ * @since 3.8
+ * @see IDebugContextService#getActiveContext(String)
+ * @see IDebugContextService#getActiveContext(String, String)
+ */
+ public static ISelection getDebugContextForPart(IWorkbenchPart part) {
+ IWorkbenchPartSite site = part.getSite();
+ IWorkbenchWindow partWindow = site.getWorkbenchWindow();
+ if (partWindow != null) {
+ IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(partWindow);
+ if (site instanceof IViewSite) {
+ return contextService.getActiveContext(site.getId(), ((IViewSite)site).getSecondaryId());
+ } else {
+ return contextService.getActiveContext(site.getId());
+ }
+ }
+ return null;
+ }
+
/**
* Return the undo context that should be used for operations involving breakpoints.
*
@@ -1073,4 +1094,15 @@ public class DebugUITools {
return (ISelection) o;
}
+ /**
+ * Returns the global instance of toggle breakpoints target manager.
+ *
+ * @return toggle breakpoints target manager
+ *
+ * @since 3.8
+ */
+ public static IToggleBreakpointsTargetManager getToggleBreakpointsTargetManager() {
+ return ToggleBreakpointsTargetManager.getDefault();
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetFactory.java
index cb644d3e0..9913661ae 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetFactory.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetFactory.java
@@ -59,7 +59,7 @@ import org.eclipse.ui.IWorkbenchPart;
*
* @see IToggleBreakpointsTarget
* @see IToggleBreakpointsTargetExtension
- * @see org.eclipse.debug.internal.ui.actions.ToggleBreakpointsTargetManager
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager
* @since 3.5
*/
public interface IToggleBreakpointsTargetFactory {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManager.java
new file mode 100644
index 000000000..fb8e69af6
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManager.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.actions;
+
+import java.util.Set;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Organizes the toggle breakpoints target factories contributed through the
+ * extension point and keeps track of the toggle breakpoints target that
+ * the factories produce. The manager is accessed as a singleton through
+ * the <code>getDefault()</code> method.
+ * <p>
+ * The adapter mechanism for obtaining a toggle breakpoints target is
+ * still supported through a specialized toggle target factory. Targets
+ * contributed through this mechanism are labeled as "Default" in the UI.
+ * </p>
+ * <p>
+ * Clients should call {@link org.eclipse.debug.ui.DebugUITools#getToggleBreakpointsTargetManager()}
+ * for an instance of this instance.
+ * </p>
+ *
+ * @see IToggleBreakpointsTargetFactory
+ * @see IToggleBreakpointsTarget
+ * @see IToggleBreakpointsTargetExtension
+ *
+ * @since 3.8
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IToggleBreakpointsTargetManager {
+
+ /**
+ * Returns the set of <code>String</code> IDs of toggle breakpoint targets,
+ * which are enabled for the given active part and selection. The IDs can be used
+ * to create the {@link IToggleBreakpointsTarget} instance.
+ * @param part active part
+ * @param selection active selection in part
+ * @return Set of toggle target IDs or an empty set
+ */
+ public Set getEnabledToggleBreakpointsTargetIDs(IWorkbenchPart part, ISelection selection);
+
+ /**
+ * Returns the ID of the calculated preferred toggle breakpoints target for the
+ * given active part and selection. The returned ID is chosen based on factory
+ * enablement, whether the target is a default one, and on user choice.
+ * @param part active part
+ * @param selection active selection in part
+ * @return The toggle target IDs or null if none.
+ */
+ public String getPreferredToggleBreakpointsTargetID(IWorkbenchPart part, ISelection selection);
+
+ /**
+ * Given the ID of toggle breakpoint target, this method will try to find the factory
+ * that creates it and return an instance of it.
+ *
+ * @param part The workbench part in which toggle target is to be used
+ * @param selection The active selection to use with toggle target
+ * @return The instantiated target or null
+ */
+ public IToggleBreakpointsTarget getToggleBreakpointsTarget(IWorkbenchPart part, ISelection selection);
+
+ /**
+ * Given the ID of a toggle breakpoints target, this method will try
+ * to find the factory that creates it and ask it for the name of it.
+ *
+ * @param id The ID of the requested toggle breakpoint target.
+ * @return The name of the target.
+ */
+ public String getToggleBreakpointsTargetName(String id);
+
+ /**
+ * Given the ID of a toggle breakpoints target, this method will try
+ * to find the factory that creates it and ask it for the description of it.
+ *
+ * @param id The ID of the requested toggle breakpoint target.
+ * @return The description of the target or null.
+ */
+ public String getToggleBreakpointsTargetDescription(String id);
+
+ /**
+ * Adds the given listener to the list of listeners notified when the preferred
+ * toggle breakpoints targets change.
+ * @param listener The listener to add.
+ */
+ public void addChangedListener(IToggleBreakpointsTargetManagerListener listener);
+
+ /**
+ * Removes the given listener from the list of listeners notified when the preferred
+ * toggle breakpoints targets change.
+ * @param listener The listener to add.
+ */
+ public void removeChangedListener(IToggleBreakpointsTargetManagerListener listener);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTargetManagerListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManagerListener.java
index ba0ca5f40..4538c4dc1 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTargetManagerListener.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManagerListener.java
@@ -8,7 +8,8 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.ui.actions;
+
/**
* Listener for changes in the preferred toggle targets in the toggle
@@ -16,9 +17,9 @@ package org.eclipse.debug.internal.ui.actions;
* actions to update their enablement when the user changes the preferred
* toggle target settings.
*
- * @see ToggleBreakpointsTargetManager
+ * @see IToggleBreakpointsTargetManager
* @see IToggleBreakpointsTargetFactory
- * @since 3.5
+ * @since 3.8
*/
public interface IToggleBreakpointsTargetManagerListener {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java
index 62ab35d21..6612a9e8f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -56,7 +56,7 @@ public abstract class RulerBreakpointAction extends Action {
* @return breakpoint associated with activity in the ruler or <code>null</code>
*/
protected IBreakpoint getBreakpoint() {
- IAnnotationModel annotationModel = fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
+ IAnnotationModel annotationModel = fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
if (annotationModel != null) {
Iterator iterator = annotationModel.getAnnotationIterator();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java
index f3fa71d6a..ee4083dad 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java
@@ -68,7 +68,7 @@ import org.eclipse.ui.texteditor.ITextEditorExtension;
* Clients may refer to this class as an action delegate in plug-in XML. This class
* is not intended to be subclassed.
* </p>
- * @see ToggleBreakpointsTargetManager
+ * @see IToggleBreakpointsTargetManager
* @see IToggleBreakpointsTargetFactory
* @noextend This class is not intended to be subclassed by clients.
* @since 3.5
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java
index 4d850119f..30624bdf7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java
@@ -14,8 +14,8 @@ package org.eclipse.debug.ui.actions;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.actions.ActionMessages;
-import org.eclipse.debug.internal.ui.actions.IToggleBreakpointsTargetManagerListener;
import org.eclipse.debug.internal.ui.actions.ToggleBreakpointsTargetManager;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -70,7 +70,7 @@ public class ToggleBreakpointAction extends Action implements IUpdate {
fPart = part;
fDocument = document;
fRulerInfo = rulerInfo;
- ToggleBreakpointsTargetManager.getDefault().addChangedListener(fListener);
+ DebugUITools.getToggleBreakpointsTargetManager().addChangedListener(fListener);
}
/*
@@ -101,7 +101,7 @@ public class ToggleBreakpointAction extends Action implements IUpdate {
if(line > -1) {
try {
ITextSelection selection = getTextSelection(document, line);
- IToggleBreakpointsTarget target = ToggleBreakpointsTargetManager.getDefault().getToggleBreakpointsTarget(fPart, selection);
+ IToggleBreakpointsTarget target = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, selection);
if (target != null) {
if(target instanceof IToggleBreakpointsTargetExtension2) {
IToggleBreakpointsTargetExtension2 ext = (IToggleBreakpointsTargetExtension2) target;
@@ -153,7 +153,7 @@ public class ToggleBreakpointAction extends Action implements IUpdate {
fDocument = null;
fPart = null;
fRulerInfo = null;
- ToggleBreakpointsTargetManager.getDefault().removeChangedListener(fListener);
+ DebugUITools.getToggleBreakpointsTargetManager().removeChangedListener(fListener);
}
/**

Back to the top