Only react if the select change is new. Don't refresh the exe list if ImportExecutables doesn't do anything.
authorryall
Fri, 05 Jun 2009 14:27:40 -0500
changeset 19 89d3c8eb71dd
parent 18 fad952f32a04
child 21 414098b7d47d
Only react if the select change is new. Don't refresh the exe list if ImportExecutables doesn't do anything.
cdt/cdt_5_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java
cdt/cdt_5_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java	Fri Jun 05 10:43:19 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java	Fri Jun 05 14:27:40 2009 -0500
@@ -261,6 +261,7 @@
 	 */
 	public void importExecutables(final String[] fileNames, IProgressMonitor monitor) {
 
+		boolean handled = false;
 		monitor.beginTask("Import Executables", executableImporters.size());
 		synchronized (executableImporters) {
 			Collections.sort(executableImporters, new Comparator<IExecutableImporter>() {
@@ -276,14 +277,15 @@
 				}});
 
 			for (IExecutableImporter importer : executableImporters) {
-				boolean handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
+				handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
 				if (handled || monitor.isCanceled()) {
 					break;
 				}
 			}
 		}
 		
-		scheduleRefresh();
+		if (handled)
+			scheduleRefresh();
 	}
 
 	/**
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java	Fri Jun 05 10:43:19 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java	Fri Jun 05 14:27:40 2009 -0500
@@ -225,6 +225,8 @@
 	private Action configureColumnsAction;
 
 	private IMemento memento;
+	
+	private IStructuredSelection oldSelection;
 
 	/**
 	 * Create contents of the Executables View
@@ -272,33 +274,38 @@
 				ISelection newSelection = event.getSelection();
 				if (newSelection instanceof IStructuredSelection) {
 					
-					// update the remove action
-					removeAction.setEnabled(!newSelection.isEmpty());
-					
-					final Object firstElement = ((IStructuredSelection) newSelection).getFirstElement();
-					
-					Job setectExeJob = new Job(Messages.ExecutablesView_Select_Executable) {
+					if (oldSelection == null || !oldSelection.equals(newSelection))
+					{
+						// update the remove action
+						removeAction.setEnabled(!newSelection.isEmpty());
+						
+						final Object firstElement = ((IStructuredSelection) newSelection).getFirstElement();
+						
+						Job setectExeJob = new Job(Messages.ExecutablesView_Select_Executable) {
 
-						@Override
-						protected IStatus run(IProgressMonitor monitor) {
-							if (firstElement instanceof Executable) {
-								Executable executable = (Executable)firstElement;
-								this.setName(Messages.ExecutablesView_Finding_Sources_Job_Name + executable.getName());
-								executable.getSourceFiles(monitor);
-							}
-							// selection could be empty, so do this no matter what to update the source
-							// files viewer
-							UIJob selectExeUIJob = new UIJob(Messages.ExecutablesView_Select_Executable){
-								@Override
-								public IStatus runInUIThread(IProgressMonitor monitor) {
-									sourceFilesViewer.setInput(firstElement);
-									sourceFilesViewer.packColumns();
-									return Status.OK_STATUS;
-								}};
-							selectExeUIJob.schedule();								
-							return Status.OK_STATUS;
-						}};
-					setectExeJob.schedule();
+							@Override
+							protected IStatus run(IProgressMonitor monitor) {
+								if (firstElement instanceof Executable) {
+									Executable executable = (Executable)firstElement;
+									this.setName(Messages.ExecutablesView_Finding_Sources_Job_Name + executable.getName());
+									executable.getSourceFiles(monitor);
+								}
+								// selection could be empty, so do this no matter what to update the source
+								// files viewer
+								UIJob selectExeUIJob = new UIJob(Messages.ExecutablesView_Select_Executable){
+									@Override
+									public IStatus runInUIThread(IProgressMonitor monitor) {
+										sourceFilesViewer.setInput(firstElement);
+										sourceFilesViewer.packColumns();
+										return Status.OK_STATUS;
+									}};
+								selectExeUIJob.schedule();								
+								return Status.OK_STATUS;
+							}};
+						setectExeJob.schedule();
+						oldSelection = (IStructuredSelection) newSelection;
+					}
+					
 				}
 			}
 		});