From 09d747ca8ce0a65bccde4b1adf2fb881e3f06e27 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 13 Mar 2009 12:23:01 +0000 Subject: [PATCH] Bug 265498: LaunchUIPlugin handleDebugEvents(...) launches multiple Project refreshes on launch terminate. --- .../org.eclipse.cdt.launch/plugin.properties | 3 +- launch/org.eclipse.cdt.launch/plugin.xml | 28 ++++++++++- .../launch/internal/ui/LaunchUIPlugin.java | 48 +++++++++---------- ...ocalAttachLaunchConfigurationTabGroup.java | 2 + .../LocalRunLaunchConfigurationTabGroup.java | 5 +- 5 files changed, 56 insertions(+), 30 deletions(-) diff --git a/launch/org.eclipse.cdt.launch/plugin.properties b/launch/org.eclipse.cdt.launch/plugin.properties index 109d6740c12..513ed307fc3 100644 --- a/launch/org.eclipse.cdt.launch/plugin.properties +++ b/launch/org.eclipse.cdt.launch/plugin.properties @@ -24,4 +24,5 @@ EnvironmentLaunchTab.name=Environment DebuggerLaunchTab.name=Debugger SourceLookupLaunchTab.name=Source CommonLaunchTab.name=Common -CoreFileLaunchTab.name=Debugger \ No newline at end of file +CoreFileLaunchTab.name=Debugger +RefreshLaunchTab.name=Refresh diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index 717eeb61205..b7ece1f0b4c 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -78,13 +78,25 @@ + + + + + + - + @@ -111,13 +123,25 @@ + + + + + + - + diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java index e4503e910fa..4c58cb81a4f 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java @@ -10,11 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.launch.internal.ui; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.ICDebugConstants; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -25,6 +21,7 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IDebugEventSetListener; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.ui.RefreshTab; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; @@ -213,29 +210,30 @@ public class LaunchUIPlugin extends AbstractUIPlugin implements IDebugEventSetLi if (events[i].getKind() == DebugEvent.TERMINATE) { Object o = events[i].getSource(); if (o instanceof IProcess) { - IProcess proc = (IProcess)o; - ICProject cproject = null; + IProcess process = (IProcess)o; + final ILaunchConfiguration config = process.getLaunch().getLaunchConfiguration(); try { - ILaunchConfiguration launchConfig = proc.getLaunch().getLaunchConfiguration(); - if (launchConfig != null) { - cproject = CDebugUtils.getCProject(launchConfig); - } - } catch (CoreException e) { - } - if (cproject != null) { - final IProject project = cproject.getProject(); - Job projectRefreshJob = new Job("Refresh"){ + if (RefreshTab.getRefreshScope(config) != null) { + Job refreshJob = new Job("Refresh"){ - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - project.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } catch (CoreException e) { - return new Status(Status.CANCEL, PLUGIN_ID, 1, e.getLocalizedMessage(), e); - } - return Status.OK_STATUS; - }}; - projectRefreshJob.schedule(); + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + RefreshTab.refreshResources(config, monitor); + } catch (CoreException e) { + return new Status(IStatus.ERROR, PLUGIN_ID, 1, e.getLocalizedMessage(), e); + } + return Status.OK_STATUS; + }}; + refreshJob.setSystem(true); + refreshJob.schedule(); + } + } + catch(CoreException e) { + LaunchUIPlugin.log( e.getStatus() ); } } } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java index 62e945e2bf0..1ea0596aef3 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java @@ -16,6 +16,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; import org.eclipse.debug.ui.CommonTab; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.debug.ui.RefreshTab; import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; public class LocalAttachLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { @@ -28,6 +29,7 @@ public class LocalAttachLaunchConfigurationTabGroup extends AbstractLaunchConfig new CMainAttachTab(), new CDebuggerTab(true), new SourceLookupTab(), + new RefreshTab(), new CommonTab() }; setTabs(tabs); diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java index 523f91fce66..ce9b4e7d6f9 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java @@ -18,6 +18,7 @@ import org.eclipse.debug.ui.CommonTab; import org.eclipse.debug.ui.EnvironmentTab; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.debug.ui.RefreshTab; import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; public class LocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { @@ -32,9 +33,9 @@ public class LocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfigura new EnvironmentTab(), new CDebuggerTab(false), new SourceLookupTab(), - new CommonTab() + new RefreshTab(), + new CommonTab(), }; setTabs(tabs); } - }