Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 204475 | Differences between
and this patch

Collapse All | Expand All

(-)core/org/eclipse/debug/internal/core/LaunchConfiguration.java (-29 / +32 lines)
Lines 611-621 Link Here
611
     * @see org.eclipse.debug.core.ILaunchConfiguration#launch(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean, boolean)
611
     * @see org.eclipse.debug.core.ILaunchConfiguration#launch(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean, boolean)
612
     */
612
     */
613
    public ILaunch launch(String mode, IProgressMonitor monitor, boolean build, boolean register) throws CoreException {
613
    public ILaunch launch(String mode, IProgressMonitor monitor, boolean build, boolean register) throws CoreException {
614
    	IProgressMonitor launchmonitor = null;
614
    	if (monitor == null) {
615
    	if (monitor == null) {
615
			monitor = new NullProgressMonitor();
616
			launchmonitor = new NullProgressMonitor();
617
    	}
618
    	else {
619
    		//like other uses, the job manager for example, we cannot assume that the monitor has been started prior to being passed into this method
620
    		//therefore we must start it and end it in this scope
621
    		monitor.beginTask(IInternalDebugCoreConstants.EMPTY_STRING, 1);
622
    		launchmonitor = new SubProgressMonitor(monitor, 1);
616
    	}
623
    	}
617
    	/* Setup progress monitor
624
    	/* Setup progress monitor
618
    	 * - Prepare delegate (0)
625
    	 * - Prepare delegate (1)
619
    	 * - Pre-launch check (1)
626
    	 * - Pre-launch check (1)
620
    	 * - [Build before launch (7)]					if build
627
    	 * - [Build before launch (7)]					if build
621
    	 * - [Incremental build before launch (3)]		if build
628
    	 * - [Incremental build before launch (3)]		if build
Lines 623-634 Link Here
623
    	 * - Initialize source locator (1)
630
    	 * - Initialize source locator (1)
624
    	 * - Launch delegate (10) */
631
    	 * - Launch delegate (10) */
625
    	if (build) {
632
    	if (build) {
626
    		monitor.beginTask("", 23); //$NON-NLS-1$
633
    		launchmonitor.beginTask(IInternalDebugCoreConstants.EMPTY_STRING, 24);
627
    	}
634
    	}
628
    	else {
635
    	else {
629
    		monitor.beginTask("", 13); //$NON-NLS-1$
636
    		launchmonitor.beginTask(IInternalDebugCoreConstants.EMPTY_STRING, 14);
630
    	}
637
    	}
631
		monitor.subTask(DebugCoreMessages.LaunchConfiguration_9);
638
		launchmonitor.subTask(DebugCoreMessages.LaunchConfiguration_9);
632
    	try {
639
    	try {
633
			// bug 28245 - force the delegate to load in case it is interested in launch notifications
640
			// bug 28245 - force the delegate to load in case it is interested in launch notifications
634
	    	Set modes = getModes();
641
	    	Set modes = getModes();
Lines 638-644 Link Here
638
	    	if (delegates.length == 1) {
645
	    	if (delegates.length == 1) {
639
	    		delegate = delegates[0].getDelegate();
646
	    		delegate = delegates[0].getDelegate();
640
	    	} else if (delegates.length == 0) {
647
	    	} else if (delegates.length == 0) {
641
	    		monitor.setCanceled(true);
642
	    		IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus);
648
	    		IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus);
643
	    		if (handler != null) {
649
	    		if (handler != null) {
644
	    			handler.handleStatus(delegateNotAvailable, new Object[] {this, mode});
650
	    			handler.handleStatus(delegateNotAvailable, new Object[] {this, mode});
Lines 665-677 Link Here
665
							delegate = del.getDelegate();
671
							delegate = del.getDelegate();
666
						}
672
						}
667
						else {
673
						else {
668
							monitor.setCanceled(true);
669
							status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); 
674
							status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); 
670
				    		throw new CoreException(status);
675
				    		throw new CoreException(status);
671
						}
676
						}
672
					}
677
					}
673
					else {
678
					else {
674
						monitor.setCanceled(true);
675
						status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); 
679
						status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); 
676
			    		throw new CoreException(status);
680
			    		throw new CoreException(status);
677
					}
681
					}
Lines 680-686 Link Here
680
	    			delegate = del.getDelegate();
684
	    			delegate = del.getDelegate();
681
	    		}
685
	    		}
682
	    	}
686
	    	}
683
	    	
687
	    	launchmonitor.worked(1);
684
			ILaunchConfigurationDelegate2 delegate2 = null;
688
			ILaunchConfigurationDelegate2 delegate2 = null;
685
			if (delegate instanceof ILaunchConfigurationDelegate2) {
689
			if (delegate instanceof ILaunchConfigurationDelegate2) {
686
				delegate2 = (ILaunchConfigurationDelegate2) delegate;
690
				delegate2 = (ILaunchConfigurationDelegate2) delegate;
Lines 707-729 Link Here
707
			    launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, null);
711
			    launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, null);
708
			}
712
			}
709
			launch.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, getLaunchManager().getEncoding(this));
713
			launch.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, getLaunchManager().getEncoding(this));
710
			
714
			launchmonitor.worked(1);
715
711
		// perform initial pre-launch sanity checks
716
		// perform initial pre-launch sanity checks
712
			monitor.subTask(DebugCoreMessages.LaunchConfiguration_8);
717
			launchmonitor.subTask(DebugCoreMessages.LaunchConfiguration_8);
713
			
714
			if (delegate2 != null) {
718
			if (delegate2 != null) {
715
				if (!(delegate2.preLaunchCheck(this, mode, new SubProgressMonitor(monitor, 1)))) {
719
				if (!(delegate2.preLaunchCheck(this, mode, new SubProgressMonitor(launchmonitor, 1)))) {
716
					// canceled
717
					monitor.setCanceled(true);
718
					return launch;
720
					return launch;
719
				}
721
				}
720
			}
722
			}
721
			else {
723
			else {
722
				monitor.worked(1); /* No pre-launch-check */
724
				launchmonitor.worked(1); /* No pre-launch-check */
723
			}
725
			}
724
		// perform pre-launch build
726
		// perform pre-launch build
725
			if (build) {
727
			if (build) {
726
				IProgressMonitor buildMonitor = new SubProgressMonitor(monitor, 10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
728
				IProgressMonitor buildMonitor = new SubProgressMonitor(launchmonitor, 10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
727
				buildMonitor.beginTask(DebugCoreMessages.LaunchConfiguration_7, 10);			
729
				buildMonitor.beginTask(DebugCoreMessages.LaunchConfiguration_7, 10);			
728
				buildMonitor.subTask(DebugCoreMessages.LaunchConfiguration_6);
730
				buildMonitor.subTask(DebugCoreMessages.LaunchConfiguration_6);
729
				if (delegate2 != null) {
731
				if (delegate2 != null) {
Lines 738-753 Link Here
738
				}
740
				}
739
			}
741
			}
740
		// final validation
742
		// final validation
741
			monitor.subTask(DebugCoreMessages.LaunchConfiguration_4);
743
			launchmonitor.subTask(DebugCoreMessages.LaunchConfiguration_4);
742
			if (delegate2 != null) {
744
			if (delegate2 != null) {
743
				if (!(delegate2.finalLaunchCheck(this, mode, new SubProgressMonitor(monitor, 1)))) {
745
				if (!(delegate2.finalLaunchCheck(this, mode, new SubProgressMonitor(launchmonitor, 1)))) {
744
					// canceled
745
					monitor.setCanceled(true);
746
					return launch;
746
					return launch;
747
				}
747
				}
748
			}
748
			}
749
			else {
749
			else {
750
				monitor.worked(1); /* No validation */
750
				launchmonitor.worked(1); /* No validation */
751
			}
751
			}
752
			if (register) {
752
			if (register) {
753
			    getLaunchManager().addLaunch(launch);
753
			    getLaunchManager().addLaunch(launch);
Lines 755-782 Link Here
755
			
755
			
756
			try {
756
			try {
757
				//initialize the source locator
757
				//initialize the source locator
758
				monitor.subTask(DebugCoreMessages.LaunchConfiguration_3);
758
				launchmonitor.subTask(DebugCoreMessages.LaunchConfiguration_3);
759
				initializeSourceLocator(launch);
759
				initializeSourceLocator(launch);
760
				monitor.worked(1);
760
				launchmonitor.worked(1);
761
761
762
				/* Launch the delegate */
762
				/* Launch the delegate */
763
				monitor.subTask(DebugCoreMessages.LaunchConfiguration_2);
763
				launchmonitor.subTask(DebugCoreMessages.LaunchConfiguration_2);
764
				delegate.launch(this, mode,	launch,	new SubProgressMonitor(monitor, 10));
764
				delegate.launch(this, mode,	launch,	new SubProgressMonitor(launchmonitor, 10));
765
			} catch (CoreException e) {
765
			} catch (CoreException e) {
766
				// if there was an exception, and the launch is empty, remove it
766
				// if there was an exception, and the launch is empty, remove it
767
				if (!launch.hasChildren()) {
767
				if (!launch.hasChildren()) {
768
					getLaunchManager().removeLaunch(launch);
768
					getLaunchManager().removeLaunch(launch);
769
				}
769
				}
770
				monitor.setCanceled(true);
771
				throw e;
770
				throw e;
772
			}
771
			}
773
			if (monitor.isCanceled()) {
772
			if (launchmonitor.isCanceled()) {
774
				getLaunchManager().removeLaunch(launch);
773
				getLaunchManager().removeLaunch(launch);
775
			}
774
			}
776
			return launch;
775
			return launch;
777
    	}
776
    	}
778
    	finally {
777
    	finally {
779
   			monitor.done();
778
    		if(monitor != null) {
779
    			//if it is not null we have started it, so we have to end it
780
    			monitor.done();
781
    		}
782
   			launchmonitor.done();
780
    	}
783
    	}
781
    }
784
    }
782
	
785
	
(-)ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java (-16 / +2 lines)
Lines 47-53 Link Here
47
import org.eclipse.debug.core.ILaunchListener;
47
import org.eclipse.debug.core.ILaunchListener;
48
import org.eclipse.debug.core.IStatusHandler;
48
import org.eclipse.debug.core.IStatusHandler;
49
import org.eclipse.debug.core.Launch;
49
import org.eclipse.debug.core.Launch;
50
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
51
import org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager;
50
import org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager;
52
import org.eclipse.debug.internal.ui.launchConfigurations.ClosedProjectFilter;
51
import org.eclipse.debug.internal.ui.launchConfigurations.ClosedProjectFilter;
53
import org.eclipse.debug.internal.ui.launchConfigurations.DeletedProjectFilter;
52
import org.eclipse.debug.internal.ui.launchConfigurations.DeletedProjectFilter;
Lines 818-837 Link Here
818
	 * @return resulting launch or <code>null</code> if user cancels
817
	 * @return resulting launch or <code>null</code> if user cancels
819
	 */
818
	 */
820
	public static ILaunch buildAndLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
819
	public static ILaunch buildAndLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
821
		boolean buildBeforeLaunch = getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH);
820
		return configuration.launch(mode, monitor, getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH));
822
		
823
		monitor.beginTask(IInternalDebugCoreConstants.EMPTY_STRING, 1);
824
		try
825
		{
826
			return configuration.launch(
827
					mode,
828
					new SubProgressMonitor(monitor, 1),
829
					buildBeforeLaunch);	
830
		}
831
		finally
832
		{
833
			monitor.done();
834
		}
835
	}
821
	}
836
	
822
	
837
	/**
823
	/**
Lines 909-915 Link Here
909
					 * - Build & launch (1) */
895
					 * - Build & launch (1) */
910
					monitor.beginTask(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, new Object[] {configuration.getName()}), 1);
896
					monitor.beginTask(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, new Object[] {configuration.getName()}), 1);
911
					try {
897
					try {
912
						buildAndLaunch(configuration, mode,	new SubProgressMonitor(monitor, 1));
898
						buildAndLaunch(configuration, mode,	new SubProgressMonitor(monitor, 98));
913
					} 
899
					} 
914
					catch (CoreException e) {
900
					catch (CoreException e) {
915
						throw new InvocationTargetException(e);
901
						throw new InvocationTargetException(e);

Return to bug 204475