Eclipse Platform
Release 3.0

org.eclipse.debug.core.model
Class LaunchConfigurationDelegate

java.lang.Object
  extended byorg.eclipse.debug.core.model.LaunchConfigurationDelegate
All Implemented Interfaces:
ILaunchConfigurationDelegate, ILaunchConfigurationDelegate2

public abstract class LaunchConfigurationDelegate
extends Object
implements ILaunchConfigurationDelegate2

Default implementation of a launch configuration delegate. Provides convenience methods for computing the build order of projects, building projects, and searching for errors in the workspace. The default pre-launch check prompts the user to launch in debug mode if breakpoints are present in the workspace.

Clients implementing launch configration delegates should subclass this class.

Since:
3.0

Field Summary
protected static IStatus complileErrorPromptStatus
          Status code for which a prompter is registered to ask the user if the want to continue launch despite existing compile errors
protected static IStatus promptStatus
          Status code for which a UI prompter is registered.
protected static IStatus switchToDebugPromptStatus
          Status code for which a prompter is registered to ask the user if they want to launch in debug mode when breakpoints are present.
 
Constructor Summary
LaunchConfigurationDelegate()
           
 
Method Summary
protected  void addReferencedProjects(IProject project, Set references)
          Adds all projects referenced by project to the given set.
 boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)
          Optionally performs any required building before launching the given configuration in the specified mode, and returns whether the debug platform should perform an incremental workspace build before the launch continues.
protected  void buildProjects(IProject[] projects, IProgressMonitor monitor)
          Performs an incremental build on each of the given projects.
protected  IProject[] computeBuildOrder(IProject[] projects)
          Returns a list of projects in their suggested build order from the given unordered list of projects.
protected  IProject[] computeReferencedBuildOrder(IProject[] baseProjects)
          Returns an array of projects in their suggested build order containing all of the projects specified by baseProjects and all of their referenced projects.
protected  boolean existsProblems(IProject proj)
          Returns whether the given project contains any problem markers of the specified severity.
 boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)
          Returns whether a launch should proceed.
protected  IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode)
          Returns the projects to build before launching the given launch configuration or null if the entire workspace should be built incrementally.
 ILaunch getLaunch(ILaunchConfiguration configuration, String mode)
          Returns a launch object to use when launching the given launch configuration in the given mode, or null if a new default launch object should be created by the debug platform.
protected  IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode)
          Returns the set of projects to use when searching for errors or null if no search is to be done.
protected  boolean isLaunchProblem(IMarker problemMarker)
          Returns whether the given problem should potentially abort the launch.
 boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)
          Returns whether a launch should proceed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.debug.core.model.ILaunchConfigurationDelegate
launch
 

Field Detail

promptStatus

protected static final IStatus promptStatus
Status code for which a UI prompter is registered.


switchToDebugPromptStatus

protected static final IStatus switchToDebugPromptStatus
Status code for which a prompter is registered to ask the user if they want to launch in debug mode when breakpoints are present.


complileErrorPromptStatus

protected static final IStatus complileErrorPromptStatus
Status code for which a prompter is registered to ask the user if the want to continue launch despite existing compile errors

Constructor Detail

LaunchConfigurationDelegate

public LaunchConfigurationDelegate()
Method Detail

getLaunch

public ILaunch getLaunch(ILaunchConfiguration configuration,
                         String mode)
                  throws CoreException
Description copied from interface: ILaunchConfigurationDelegate2
Returns a launch object to use when launching the given launch configuration in the given mode, or null if a new default launch object should be created by the debug platform. If a launch object is returned, its launch mode must match that of the mode specified in this method call.

Specified by:
getLaunch in interface ILaunchConfigurationDelegate2
Parameters:
configuration - the configuration being launched
mode - the mode the configuration is being launched in
Returns:
a launch object or null
Throws:
CoreException - if unable to launch

buildForLaunch

public boolean buildForLaunch(ILaunchConfiguration configuration,
                              String mode,
                              IProgressMonitor monitor)
                       throws CoreException
Description copied from interface: ILaunchConfigurationDelegate2
Optionally performs any required building before launching the given configuration in the specified mode, and returns whether the debug platform should perform an incremental workspace build before the launch continues. If false is returned the launch will proceed without further building, and if true is returned an incremental build will be performed on the workspace before launching.

This method is only called if the launch is invoked with flag indicating building should take place before the launch. This is done via the method ILaunchConfiguration.launch(String mode, IProgressMonitor monitor, boolean build).

Specified by:
buildForLaunch in interface ILaunchConfigurationDelegate2
Parameters:
configuration - the configuration being launched
mode - the mode the configuration is being launched in
monitor - progress monitor
Returns:
whether the debug platform should perform an incremental workspace build before the launch
Throws:
CoreException - if an exception occurrs while building

getBuildOrder

protected IProject[] getBuildOrder(ILaunchConfiguration configuration,
                                   String mode)
                            throws CoreException
Returns the projects to build before launching the given launch configuration or null if the entire workspace should be built incrementally. Subclasses should override as required.

Parameters:
configuration - the configuration being launched
mode - launch mode
Returns:
projects to build, in build order, or null
Throws:
CoreException - if an exception occurrs

getProjectsForProblemSearch

protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration,
                                                 String mode)
                                          throws CoreException
Returns the set of projects to use when searching for errors or null if no search is to be done.

Parameters:
configuration - the configuration being launched
mode - launch mode
Returns:
a list of projects or null
Throws:
CoreException - if an exception occurrs

finalLaunchCheck

public boolean finalLaunchCheck(ILaunchConfiguration configuration,
                                String mode,
                                IProgressMonitor monitor)
                         throws CoreException
Description copied from interface: ILaunchConfigurationDelegate2
Returns whether a launch should proceed. This method is called after preLaunchCheck() and buildForLaunch() providing a final chance for this launch delegate to abort a launch if required. For example, a delegate could cancel a launch if it discovered compilation errors that would prevent the launch from succeeding.

Specified by:
finalLaunchCheck in interface ILaunchConfigurationDelegate2
Parameters:
configuration - the configuration being launched
mode - launch mode
monitor - progress monitor
Returns:
whether the launch should proceed
Throws:
CoreException - if an exception occurs during final checks

preLaunchCheck

public boolean preLaunchCheck(ILaunchConfiguration configuration,
                              String mode,
                              IProgressMonitor monitor)
                       throws CoreException
Description copied from interface: ILaunchConfigurationDelegate2
Returns whether a launch should proceed. This method is called first in the launch sequence providing an opportunity for this launch delegate to abort the launch.

Specified by:
preLaunchCheck in interface ILaunchConfigurationDelegate2
Parameters:
configuration - configuration being lanuched
mode - launch mode
monitor - progress monitor
Returns:
whether the launch should proceed
Throws:
CoreException - if an exception occurs while performing pre launch checks

computeReferencedBuildOrder

protected IProject[] computeReferencedBuildOrder(IProject[] baseProjects)
                                          throws CoreException
Returns an array of projects in their suggested build order containing all of the projects specified by baseProjects and all of their referenced projects.

Parameters:
baseProjects - a collection of projetcs
Returns:
an array of projects in their suggested build order containing all of the projects specified by baseProjects
Throws:
CoreException - if an error occurs while computing referenced projects

addReferencedProjects

protected void addReferencedProjects(IProject project,
                                     Set references)
                              throws CoreException
Adds all projects referenced by project to the given set.

Parameters:
project - project
references - set to which referenced projects are added
Throws:
CoreException - if an error occurs while computing referenced projects

computeBuildOrder

protected IProject[] computeBuildOrder(IProject[] projects)
Returns a list of projects in their suggested build order from the given unordered list of projects.

Parameters:
projects - the list of projects to sort into build order
Returns:
a new array containing all projects from projects sorted according to their build order.

existsProblems

protected boolean existsProblems(IProject proj)
                          throws CoreException
Returns whether the given project contains any problem markers of the specified severity.

Parameters:
proj - the project to search
Returns:
whether the given project contains any problems that should stop it from launching
Throws:
CoreException - if an error occurs while searching for problem markers

isLaunchProblem

protected boolean isLaunchProblem(IMarker problemMarker)
                           throws CoreException
Returns whether the given problem should potentially abort the launch. By default if the problem has an error severity, the problem is considered a potential launch problem. Subclasses may override to specialize error detection.

Parameters:
problemMarker - candidate problem
Returns:
whether the given problem should potentially abort the launch
Throws:
CoreException - if any exceptions occurr while accessing marker attributes

buildProjects

protected void buildProjects(IProject[] projects,
                             IProgressMonitor monitor)
                      throws CoreException
Performs an incremental build on each of the given projects.

Parameters:
projects - projects to build
monitor - progress monitor
Throws:
CoreException - if an exception occurrs while building

Eclipse Platform
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.