public class DebugUITools extends Object
Images retrieved from this facility should not be disposed. The images will be disposed when this plug-in is shutdown.
Note: all methods in this class are expected to be called on the Display thread unless otherwise noted.
Constructor and Description |
---|
DebugUITools() |
Modifier and Type | Method and Description |
---|---|
static void |
addPartDebugContextListener(IWorkbenchPartSite site,
IDebugContextListener listener)
Adds the given debug context listener as a listener to the debug context changed events, in
the context of the given workbench part.
|
static ILaunch |
buildAndLaunch(ILaunchConfiguration configuration,
String mode,
IProgressMonitor monitor)
Builds the workspace according to current preference settings, and launches
the given configuration in the specified mode, returning the resulting launch
object.
|
static void |
deleteBreakpoints(IBreakpoint[] breakpoints,
Shell shell,
IProgressMonitor progressMonitor)
Deletes the given breakpoints using the operation history, which allows to undo the deletion.
|
static void |
displaySource(ISourceLookupResult result,
IWorkbenchPage page)
Displays the given source lookup result in an editor in the given workbench
page.
|
static IUndoContext |
getBreakpointsUndoContext()
Return the undo context that should be used for operations involving breakpoints.
|
static IConsole |
getConsole(IDebugElement element)
Returns the console associated with the given debug element, or
null if none. |
static IConsole |
getConsole(IProcess process)
Returns the console associated with the given process, or
null if none. |
static IProcess |
getCurrentProcess()
Returns the process associated with the current debug context.
|
static IAdaptable |
getDebugContext()
Returns the element of the currently selected context in the
active workbench window.
|
static ISelection |
getDebugContextForEvent(ExecutionEvent event)
Return the debug context for the given executionEvent or
null if none. |
static ISelection |
getDebugContextForEventChecked(ExecutionEvent event)
Return the debug context for the given executionEvent.
|
static ISelection |
getDebugContextForPart(IWorkbenchPart part)
Returns the currently selected context in the given part or part's
workbench window.
|
static IDebugContextManager |
getDebugContextManager()
Returns the debug context manager.
|
static ImageDescriptor |
getDefaultImageDescriptor(Object element)
Returns the default image descriptor for the given element.
|
static Image |
getImage(String key)
Returns the shared image managed under the given key, or
null
if none. |
static ImageDescriptor |
getImageDescriptor(String key)
Returns the shared image descriptor managed under the given key, or
null if none. |
static ILaunchConfiguration |
getLastLaunch(String groupId)
Returns the last configuration that was launched for specified launch group or
null , if there is not one. |
static ILaunchConfiguration |
getLaunchConfiguration(ILaunchConfigurationDialog dialog)
Returns the ILaunchConfiguration corresponding to
ILaunchConfigurationDialog
|
static ILaunchGroup |
getLaunchGroup(ILaunchConfiguration configuration,
String mode)
Returns the launch group that the given launch configuration belongs to, for the specified
mode, or
null if none. |
static ILaunchGroup[] |
getLaunchGroups()
Returns all registered launch group extensions.
|
static String |
getLaunchPerspective(ILaunchConfigurationType type,
ILaunchDelegate delegate,
Set<String> modes)
Returns the perspective id to switch to when a configuration of the given type launched with the specified delegate
is launched in the given mode set, or
null if no switch should occurr. |
static String |
getLaunchPerspective(ILaunchConfigurationType type,
String mode)
Returns the perspective to switch to when a configuration of the given type
is launched in the given mode, or
null if no switch should take
place. |
static IMemoryRenderingManager |
getMemoryRenderingManager()
Returns the memory rendering manager.
|
static IAdaptable |
getPartDebugContext(IWorkbenchPartSite site)
Returns the currently active context for the given workbench part.
|
static Color |
getPreferenceColor(String id)
Returns the color associated with the specified preference identifier or
null if none. |
static IPreferenceStore |
getPreferenceStore()
Returns the preference store for the debug UI plug-in.
|
static IResource |
getSelectedResource()
Returns the currently selected resource in the active workbench window,
or
null if none. |
static ISourceContainerBrowser |
getSourceContainerBrowser(String id)
Returns a new source container browser for the specified type of source container
or
null if a browser has not been registered. |
static Image |
getSourceContainerImage(String id)
Returns the image associated with the specified type of source container
or
null if none. |
static IToggleBreakpointsTargetManager |
getToggleBreakpointsTargetManager()
Returns the global instance of toggle breakpoints target manager.
|
static boolean |
isPrivate(ILaunchConfiguration configuration)
Returns whether the given launch configuration is private.
|
static boolean |
isUseStepFilters()
Returns whether step filters are applied to step commands.
|
static void |
launch(ILaunchConfiguration configuration,
String mode)
Saves and builds the workspace according to current preference settings,
and launches the given launch configuration in the specified mode.
|
static void |
launch(ILaunchConfiguration configuration,
String mode,
boolean isShift)
Saves and builds the workspace according to current preference settings,
and launches the given launch configuration in the specified mode.
|
static ISourceLookupResult |
lookupSource(Object artifact,
ISourceLocator locator)
Performs source lookup on the given artifact and returns the result.
|
static IDebugModelPresentation |
newDebugModelPresentation()
Returns a new debug model presentation that delegates to
appropriate debug models.
|
static IDebugModelPresentation |
newDebugModelPresentation(String identifier)
Returns a new debug model presentation for specified
debug model, or
null if a presentation does
not exist. |
static int |
openLaunchConfigurationDialog(Shell shell,
ILaunchConfiguration configuration,
String groupIdentifier,
IStatus status)
Open the launch configuration dialog on the specified launch
configuration.
|
static int |
openLaunchConfigurationDialog(Shell shell,
IStructuredSelection selection,
String mode)
Deprecated.
use openLaunchConfigurationDialogOnGroup(Shell, IStructuredSelection, String)
to specify the launch group that the dialog should be opened on. This method will open
on the launch group with the specified mode and a
null category |
static int |
openLaunchConfigurationDialogOnGroup(Shell shell,
IStructuredSelection selection,
String groupIdentifier)
Open the launch configuration dialog with the specified initial selection.
|
static int |
openLaunchConfigurationDialogOnGroup(Shell shell,
IStructuredSelection selection,
String groupIdentifier,
IStatus status)
Open the launch configuration dialog with the specified initial selection.
|
static int |
openLaunchConfigurationPropertiesDialog(Shell shell,
ILaunchConfiguration configuration,
String groupIdentifier)
Open the launch configuration properties dialog on the specified launch
configuration.
|
static int |
openLaunchConfigurationPropertiesDialog(Shell shell,
ILaunchConfiguration configuration,
String groupIdentifier,
IStatus status)
Open the launch configuration properties dialog on the specified launch
configuration.
|
static void |
reLaunch(ILaunchConfiguration configuration,
String mode)
Saves and builds the workspace according to current preference settings,
and launches the given launch configuration in the specified mode.
|
static void |
removeLaunchToggleTerminate(Object data)
Stores the toggle data for launch in a Map to be used while launching to
decide if previous launch for same configuration can be terminated.
|
static void |
removePartDebugContextListener(IWorkbenchPartSite site,
IDebugContextListener listener)
Removes the given debug context listener as a listener to the debug context changed events,
in the context of the given workbench part.
|
static boolean |
saveAndBuildBeforeLaunch()
Deprecated.
Saving has been moved to the launch delegate
LaunchConfigurationDelegate to allow for scoped saving
of resources that are only involved in the current launch, no longer the entire workspace |
static boolean |
saveBeforeLaunch()
Deprecated.
Saving has been moved to the launch delegate
LaunchConfigurationDelegate to allow for scoped saving
of resources that are only involved in the current launch, no longer the entire workspace |
static void |
setLaunchPerspective(ILaunchConfigurationType type,
ILaunchDelegate delegate,
Set<String> modes,
String perspectiveid)
Sets the perspective to switch to when a configuration of the specified type and launched using the
specified launch delegate is launched in the specified modeset.
|
static void |
setLaunchPerspective(ILaunchConfigurationType type,
String mode,
String perspective)
Sets the perspective to switch to when a configuration of the given type
is launched in the given mode.
|
static void |
setUseStepFilters(boolean useStepFilters)
Sets whether step filters should be applied to step commands.
|
static void |
storeLaunchToggleTerminate(Object data,
Object isShift)
Stores the toggle data for launch in a Map to be used while launching to
decide if previous launch for same configuration can be terminated.
|
public static Image getImage(String key)
null
if none.
Note that clients MUST NOT dispose the image returned by this method.
See IDebugUIConstants
for available images.
key
- the image keynull
if noneIDebugUIConstants
public static ImageDescriptor getImageDescriptor(String key)
null
if none.
See IDebugUIConstants
for available image descriptors.
key
- the image descriptor keynull
if noneIDebugUIConstants
public static ImageDescriptor getDefaultImageDescriptor(Object element)
element
- the elementnull
if nonepublic static IPreferenceStore getPreferenceStore()
public static IDebugModelPresentation newDebugModelPresentation()
It is the client's responsibility dispose the presentation.
IBaseLabelProvider.dispose()
public static IDebugModelPresentation newDebugModelPresentation(String identifier)
null
if a presentation does
not exist.
It is the client's responsibility dispose the presentation.
identifier
- debug model identifiernull
IBaseLabelProvider.dispose()
public static IAdaptable getDebugContext()
null
if there is no
current debug context.
This method used to return null
when called from a non-UI thread,
but since 3.1, this methods also works when called from a non-UI thread.
null
public static ISelection getDebugContextForPart(IWorkbenchPart part)
null
if there is no current
debug context.part
- workbench part where the active context is to be evaluatednull
IDebugContextService.getActiveContext(String)
,
IDebugContextService.getActiveContext(String, String)
public static IUndoContext getBreakpointsUndoContext()
public static void deleteBreakpoints(IBreakpoint[] breakpoints, Shell shell, IProgressMonitor progressMonitor) throws CoreException
breakpoints
- the breakpoints to deleteshell
- the shell used for potential user interactions, or null
if unknownprogressMonitor
- the progress monitorCoreException
- if the deletion failspublic static IAdaptable getPartDebugContext(IWorkbenchPartSite site)
null
if there is no current debug context.site
- the part's site where to look up the active contextnull
public static void addPartDebugContextListener(IWorkbenchPartSite site, IDebugContextListener listener)
This method is a utility method which ultimately calls
IDebugContextService.addDebugContextListener(IDebugContextListener, String, String)
using the part id parameters extracted from the given part parameter.
site
- the part's site to get the part ID and part secondary ID fromlistener
- Debug context listener to addIDebugContextService.addDebugContextListener(IDebugContextListener, String, String)
,
IDebugContextManager.addDebugContextListener(IDebugContextListener)
public static void removePartDebugContextListener(IWorkbenchPartSite site, IDebugContextListener listener)
This method is a utility method which ultimately calls
IDebugContextService.removeDebugContextListener(IDebugContextListener, String, String)
using the part id parameters extracted from the given part parameter.
site
- the part's site to get the part ID and part secondary ID fromlistener
- Debug context listener to removeIDebugContextService.removeDebugContextListener(IDebugContextListener, String, String)
,
IDebugContextManager.removeDebugContextListener(IDebugContextListener)
public static IResource getSelectedResource()
null
if none. If an editor is active, the resource adapter
associated with the editor is returned, if any.null
public static IProcess getCurrentProcess()
null
is returned.null
@Deprecated public static int openLaunchConfigurationDialog(Shell shell, IStructuredSelection selection, String mode)
null
categorynull
, or contain any mix of
ILaunchConfiguration
or ILaunchConfigurationType
elements.
Before opening a new dialog, this method checks if there is an existing open launch configuration dialog. If there is, this dialog is used with the specified selection. If there is no existing dialog, a new one is created.
Note that if an existing dialog is reused, the mode
argument is ignored
and the existing dialog keeps its original mode.
shell
- the parent shell for the launch configuration dialogselection
- the initial selection for the dialogmode
- the mode (run or debug) in which to open the launch configuration dialog.
This should be one of the constants defined in ILaunchManager
.Window.OK
or Window.CANCEL
. Window.CANCEL
is returned if an invalid launch group identifier is provided.ILaunchGroup
public static int openLaunchConfigurationDialogOnGroup(Shell shell, IStructuredSelection selection, String groupIdentifier)
null
, or contain any mix of
ILaunchConfiguration
or ILaunchConfigurationType
elements.
Before opening a new dialog, this method checks if there is an existing open launch configuration dialog. If there is, this dialog is used with the specified selection. If there is no existing dialog, a new one is created.
Note that if an existing dialog is reused, the mode
argument is ignored
and the existing dialog keeps its original mode.
shell
- the parent shell for the launch configuration dialogselection
- the initial selection for the dialoggroupIdentifier
- the identifier of the launch group to display (corresponds to
the identifier of a launch group extension)Window.OK
or Window.CANCEL
. Window.CANCEL
is returned if an invalid launch group identifier is provided.ILaunchGroup
public static int openLaunchConfigurationDialogOnGroup(Shell shell, IStructuredSelection selection, String groupIdentifier, IStatus status)
null
, or contain any mix of
ILaunchConfiguration
or ILaunchConfigurationType
elements.
Before opening a new dialog, this method checks if there is an existing open launch configuration dialog. If there is, this dialog is used with the specified selection. If there is no existing dialog, a new one is created.
Note that if an existing dialog is reused, the mode
argument is ignored
and the existing dialog keeps its original mode.
If a status is specified, a status handler is consulted to handle the status. The status handler is passed the instance of the launch configuration dialog that is opened. This gives the status handler an opportunity to perform error handling/initialization as required.
shell
- the parent shell for the launch configuration dialogselection
- the initial selection for the dialoggroupIdentifier
- the identifier of the launch group to display (corresponds to
the identifier of a launch group extension)status
- the status to display in the dialog, or null
if noneWindow.OK
or Window.CANCEL
. Window.CANCEL
is returned if an invalid launch group identifier is provided.IStatusHandler
,
ILaunchGroup
public static int openLaunchConfigurationPropertiesDialog(Shell shell, ILaunchConfiguration configuration, String groupIdentifier)
shell
- the parent shell for the launch configuration dialogconfiguration
- the configuration to displaygroupIdentifier
- group identifier of the launch group the launch configuration
belongs toWindow.OK
or Window.CANCEL
. Window.CANCEL
is returned if an invalid launch group identifier is provided.ILaunchGroup
public static int openLaunchConfigurationPropertiesDialog(Shell shell, ILaunchConfiguration configuration, String groupIdentifier, IStatus status)
shell
- the parent shell for the launch configuration dialogconfiguration
- the configuration to displaygroupIdentifier
- group identifier of the launch group the launch configuration
belongs tostatus
- the status to display, or null
if noneWindow.OK
or Window.CANCEL
. Window.CANCEL
is returned if an invalid launch group identifier is provided.ILaunchGroup
public static int openLaunchConfigurationDialog(Shell shell, ILaunchConfiguration configuration, String groupIdentifier, IStatus status)
If a status is specified, a status handler is consulted to handle the status. The status handler is passed the instance of the launch configuration dialog that is opened. This gives the status handler an opportunity to perform error handling/initialization as required.
shell
- the parent shell for the launch configuration dialogconfiguration
- the configuration to displaygroupIdentifier
- group identifier of the launch group the launch configuration
belongs tostatus
- the status to display, or null
if noneWindow.OK
or Window.CANCEL
. Window.CANCEL
is returned if an invalid launch group identifier is provided.ILaunchGroup
@Deprecated public static boolean saveAndBuildBeforeLaunch()
LaunchConfigurationDelegate
to allow for scoped saving
of resources that are only involved in the current launch, no longer the entire workspaceThe following preferences affect whether dirty editors are saved, and/or if the user is prompted to save dirty editors:
@Deprecated public static boolean saveBeforeLaunch()
LaunchConfigurationDelegate
to allow for scoped saving
of resources that are only involved in the current launch, no longer the entire workspaceThe following preferences affect whether dirty editors are saved, and/or if the user is prompted to save dirty editors:
public static void launch(ILaunchConfiguration configuration, String mode)
This method must be called in the UI thread.
configuration
- the configuration to launchmode
- launch mode - run or debugpublic static void storeLaunchToggleTerminate(Object data, Object isShift)
data
- the editor or selected tree nodeisShift
- is Shift pressed (use false
if no support for
Shift)public static void removeLaunchToggleTerminate(Object data)
data
- the editor or selected tree nodepublic static void reLaunch(ILaunchConfiguration configuration, String mode)
This method must be called in the UI thread.
configuration
- the configuration to launchmode
- launch mode - run or debugpublic static void launch(ILaunchConfiguration configuration, String mode, boolean isShift)
This method must be called in the UI thread.
configuration
- the configuration to launchmode
- launch mode - run or debugisShift
- is Shift pressed (use false
if no support for
Shift)public static ILaunch buildAndLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException
The following preference affects whether a build is performed before launching (if required):
configuration
- the configuration to launchmode
- the mode to launch inmonitor
- progress monitorCoreException
- if building or launching failspublic static String getLaunchPerspective(ILaunchConfigurationType type, String mode)
null
if no switch should take
place.
In 3.3 this method is equivalent to calling getLaunchPerspective(ILaunchConfigurationType type, Set modes, ILaunchDelegate delegate)
,
with the 'mode' parameter comprising a single element set and passing null
as the launch delegate.type
- launch configuration typemode
- launch mode identifiernull
public static String getLaunchPerspective(ILaunchConfigurationType type, ILaunchDelegate delegate, Set<String> modes)
null
if no switch should occurr.type
- the configuration typedelegate
- the launch delegatemodes
- the set of modesnull
if no switch should occurpublic static void setLaunchPerspective(ILaunchConfigurationType type, String mode, String perspective)
PERSPECTIVE_NONE
indicates no
perspective switch should take place. PERSPECTIVE_DEFAULT
indicates
a default perspective switch should take place, as defined by the associated
launch tab group extension.
In 3.3 this method is equivalent to calling setLaunchPerspective(ILaunchConfigurationType type, Set modes, ILaunchDelegate delegate, String perspectiveid)
,
with the parameter 'mode' used in the set modes, and null passed as the delegatetype
- launch configuration typemode
- launch mode identifierperspective
- identifier, PERSPECTIVE_NONE
, or
PERSPECTIVE_DEFAULT
public static void setLaunchPerspective(ILaunchConfigurationType type, ILaunchDelegate delegate, Set<String> modes, String perspectiveid)
PERSPECTIVE_NONE
indicates no
perspective switch should take place.
Passing null
for the launch delegate is quivalent to using the default perspective for the specified
type.type
- the configuration typedelegate
- the launch delegatemodes
- the set of modesperspectiveid
- identifier or PERSPECTIVE_NONE
public static boolean isPrivate(ILaunchConfiguration configuration)
IDebugUIConstants.ATTR_PRIVATE
attribute.configuration
- launch configurationpublic static void setUseStepFilters(boolean useStepFilters)
Since 3.3, this is equivalent to calling DebugPlugin.setUseStepFilters(boolean)
.
useStepFilters
- whether step filters should be applied to step
commandsIStepFilters
public static boolean isUseStepFilters()
Since 3.3, this is equivalent to calling DebugPlugin.isUseStepFilters()
.
IStepFilters
public static IConsole getConsole(IProcess process)
null
if none.process
- a processnull
if nonepublic static IConsole getConsole(IDebugElement element)
null
if none.element
- a debug model elementnull
if nonepublic static ILaunchGroup[] getLaunchGroups()
public static ILaunchConfiguration getLastLaunch(String groupId)
null
, if there is not one. This method does not provide any form of
filtering on the returned launch configurations.groupId
- the unique identifier of a launch groupnull
.getLaunchGroups()
public static ILaunchGroup getLaunchGroup(ILaunchConfiguration configuration, String mode)
null
if none.configuration
- the launch configurationmode
- the modenull
if nonepublic static ISourceLookupResult lookupSource(Object artifact, ISourceLocator locator)
artifact
- object for which source is to be resolvedlocator
- the source locator to use, or null
. When null
a source locator is determined from the artifact, if possible. If the artifact
is a debug element, the source locator from its associated launch is used.public static void displaySource(ISourceLookupResult result, IWorkbenchPage page)
Honors user preference for editors re-use.
result
- source lookup result to displaypage
- the page to display the result inpublic static IMemoryRenderingManager getMemoryRenderingManager()
public static Image getSourceContainerImage(String id)
null
if none.id
- unique identifier for a source container typenull
if noneISourceContainerType
public static ISourceContainerBrowser getSourceContainerBrowser(String id)
null
if a browser has not been registered.id
- unique identifier for a source container typenull
if noneISourceContainerBrowser
public static Color getPreferenceColor(String id)
null
if none.id
- preference identifier of the colornull
if noneIDebugUIConstants
public static IDebugContextManager getDebugContextManager()
public static ISelection getDebugContextForEvent(ExecutionEvent event)
null
if none.event
- The execution event that contains the application contextnull
.public static ISelection getDebugContextForEventChecked(ExecutionEvent event) throws ExecutionException
event
- The execution event that contains the application contextnull
.ExecutionException
- If the current selection variable is not found.public static IToggleBreakpointsTargetManager getToggleBreakpointsTargetManager()
public static ILaunchConfiguration getLaunchConfiguration(ILaunchConfigurationDialog dialog)
dialog
- The input launch configuration dialogILaunchConfiguration
Corresponding launch configuration
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.