cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
changeset 54 89a4ce4b37f5
parent 51 49c226a8748e
child 62 c400a1d2216a
equal deleted inserted replaced
53:bf8d63f38814 54:89a4ce4b37f5
   134 	 * A list of prequisite projects ordered by their build order.
   134 	 * A list of prequisite projects ordered by their build order.
   135 	 */
   135 	 */
   136 	private List orderedProjects;
   136 	private List orderedProjects;
   137 	private String preLaunchBuildConfiguration;
   137 	private String preLaunchBuildConfiguration;
   138 
   138 
       
   139 	/**
       
   140 	 * Used in conjunction with build before launch settings in the main tab.
       
   141 	 */
       
   142 	private boolean buildForLaunchCalled;
   139 	abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
   143 	abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
   140 			throws CoreException;
   144 			throws CoreException;
   141 
   145 
   142 	/**
   146 	/**
   143 	 * Returns the working directory specified by the given launch
   147 	 * Returns the working directory specified by the given launch
   589 	 * @param monitor
   593 	 * @param monitor
   590 	 *            progress monitor
   594 	 *            progress monitor
   591 	 * @return whether the debug platform should perform an incremental
   595 	 * @return whether the debug platform should perform an incremental
   592 	 *         workspace build before the launch
   596 	 *         workspace build before the launch
   593 	 * @throws CoreException
   597 	 * @throws CoreException
   594 	 *             if an exception occurrs while building
   598 	 *             if an exception occurs while building
   595 	 */
   599 	 */
   596 	@Override
   600 	@Override
   597 	public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
   601 	public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
   598 		//This matches the old code, but I don't know that it is the right behaviour.
   602 
       
   603 		buildForLaunchCalled = true;
       
   604 		
       
   605 		// check the build before launch setting and honor it
       
   606 		int buildBeforeLaunchValue = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
       
   607 				ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING);
       
   608 
       
   609 		// we shouldn't be getting called if the workspace setting is disabled, so assume we need to
       
   610 		// build unless the user explicitly disabled it in the main tab of the launch.
       
   611 		if (buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED) {
       
   612 			return false;
       
   613 		}
       
   614 		
       
   615 		//This matches the old code, but I don't know that it is the right behavior.
   599 		//We should be building the local project as well, not just the ordered projects
   616 		//We should be building the local project as well, not just the ordered projects
   600 		if(orderedProjects == null) {		
   617 		if(orderedProjects == null) {		
   601 			return false;
   618 			return false;
   602 		}
   619 		}
   603 		
   620 		
   664 	 * @throws CoreException
   681 	 * @throws CoreException
   665 	 *             if an exception occurs while checking for compile errors.
   682 	 *             if an exception occurs while checking for compile errors.
   666 	 */
   683 	 */
   667 	@Override
   684 	@Override
   668 	public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
   685 	public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
       
   686 		
       
   687 		if (!buildForLaunchCalled) {
       
   688 			// buildForLaunch was not called which means that the workspace pref is disabled.  see if the user enabled the
       
   689 			// launch specific setting in the main tab.  if so, we do call buildBeforeLaunch here.
       
   690 			if (ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED == configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
       
   691 					ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING)) {
       
   692 				
       
   693 				IProgressMonitor buildMonitor = new SubProgressMonitor(monitor, 10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
       
   694 				buildMonitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.BuildBeforeLaunch"), 10); //$NON-NLS-1$	
       
   695 				buildMonitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.PerformingBuild")); //$NON-NLS-1$
       
   696 				if (buildForLaunch(configuration, mode, new SubProgressMonitor(buildMonitor, 7))) {
       
   697 					buildMonitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.PerformingIncrementalBuild")); //$NON-NLS-1$
       
   698 					ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(buildMonitor, 3));				
       
   699 				}
       
   700 				else {
       
   701 					buildMonitor.worked(3); /* No incremental build required */
       
   702 				}
       
   703 			}
       
   704 		}
       
   705 
   669 		boolean continueLaunch = true;
   706 		boolean continueLaunch = true;
   670 		if(orderedProjects == null) {
   707 		if(orderedProjects == null) {
   671 			return continueLaunch;
   708 			return continueLaunch;
   672 		}
   709 		}
   673 
   710 
   768 	public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
   805 	public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
   769 		if(monitor == null) {
   806 		if(monitor == null) {
   770 			monitor = new NullProgressMonitor();
   807 			monitor = new NullProgressMonitor();
   771 		}
   808 		}
   772 
   809 
       
   810 		buildForLaunchCalled = false;
       
   811 
   773 		int scale = 1000;
   812 		int scale = 1000;
   774 		int totalWork = 2 * scale;
   813 		int totalWork = 2 * scale;
   775 		
   814 		
   776 		try {
   815 		try {
   777 			monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.20"), totalWork); //$NON-NLS-1$
   816 			monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.20"), totalWork); //$NON-NLS-1$