Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-02-17 12:21:15 -0500
committerPawel Piech2012-02-17 12:21:15 -0500
commitaa357e78b41e87b7d414d1a7d0b8b7db0dfce011 (patch)
tree24839c72d830282ae7a9b36518081a4e4bc59cbb /org.eclipse.debug.ui/ui/org/eclipse/debug/ui
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
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/ui')
-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.java30
-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
7 files changed, 201 insertions, 36 deletions
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/ui/actions/IToggleBreakpointsTargetManagerListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManagerListener.java
new file mode 100644
index 000000000..4538c4dc1
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetManagerListener.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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;
+
+
+/**
+ * Listener for changes in the preferred toggle targets in the toggle
+ * breakpoints target manager. This interface allows toggle breakpoint
+ * actions to update their enablement when the user changes the preferred
+ * toggle target settings.
+ *
+ * @see IToggleBreakpointsTargetManager
+ * @see IToggleBreakpointsTargetFactory
+ * @since 3.8
+ */
+public interface IToggleBreakpointsTargetManagerListener {
+
+ /**
+ * Called when the preferred toggle targets have changed.
+ */
+ public void preferredTargetsChanged();
+}
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