cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java
changeset 60 3982fab6369e
parent 52 42077b7eab6e
equal deleted inserted replaced
59:a612e067382b 60:3982fab6369e
   223 	Action importAction;
   223 	Action importAction;
   224 	Action removeAction;
   224 	Action removeAction;
   225 	private Action configureColumnsAction;
   225 	private Action configureColumnsAction;
   226 
   226 
   227 	private IMemento memento;
   227 	private IMemento memento;
       
   228 	
       
   229 	private IStructuredSelection oldSelection;
   228 
   230 
   229 	/**
   231 	/**
   230 	 * Create contents of the Executables View
   232 	 * Create contents of the Executables View
   231 	 * 
   233 	 * 
   232 	 * @param parent
   234 	 * @param parent
   237 		container.setLayout(new FillLayout());
   239 		container.setLayout(new FillLayout());
   238 
   240 
   239 		final SashForm sashForm = new SashForm(container, SWT.NONE);
   241 		final SashForm sashForm = new SashForm(container, SWT.NONE);
   240 
   242 
   241 		// Create the two sub viewers.
   243 		// Create the two sub viewers.
   242 		executablesViewer = new ExecutablesViewer(this, sashForm, SWT.FULL_SELECTION + SWT.BORDER + SWT.MULTI);
   244 		executablesViewer = new ExecutablesViewer(this, sashForm, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);
   243 		ExecutablesManager.getExecutablesManager().addExecutablesChangeListener(executablesViewer);
   245 		ExecutablesManager.getExecutablesManager().addExecutablesChangeListener(executablesViewer);
   244 		sourceFilesViewer = new SourceFilesViewer(this, sashForm, SWT.BORDER);
   246 		sourceFilesViewer = new SourceFilesViewer(this, sashForm, SWT.BORDER | SWT.MULTI);
   245 
   247 
   246 		sashForm.setWeights(new int[] { 1, 1 });
   248 		sashForm.setWeights(new int[] { 1, 1 });
   247 
   249 
   248 		// Keep a combined list of all the columns so
   250 		// Keep a combined list of all the columns so
   249 		// we can easily operate on them all.
   251 		// we can easily operate on them all.
   266 
   268 
   267 		// When the selection changes in the executables list
   269 		// When the selection changes in the executables list
   268 		// update the source files viewer
   270 		// update the source files viewer
   269 		executablesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
   271 		executablesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
   270 
   272 
   271 					public void selectionChanged(SelectionChangedEvent event) {
   273 			public void selectionChanged(SelectionChangedEvent event) {
   272 						ISelection newSelection = event.getSelection();
   274 				ISelection newSelection = event.getSelection();
   273 						if (newSelection instanceof IStructuredSelection) {
   275 				if (newSelection instanceof IStructuredSelection) {
   274 
   276 					
   275 							// update the remove action
   277 					if (oldSelection == null || !oldSelection.equals(newSelection))
   276 							removeAction.setEnabled(!newSelection.isEmpty());
   278 					{
   277 
   279 						// update the remove action
   278 							final Object firstElement = ((IStructuredSelection) newSelection)
   280 						removeAction.setEnabled(!newSelection.isEmpty());
   279 									.getFirstElement();
   281 						
   280 
   282 						final Object firstElement = ((IStructuredSelection) newSelection).getFirstElement();
   281 							Job setectExeJob = new Job(
   283 						
   282 									Messages.ExecutablesView_Select_Executable) {
   284 						Job setectExeJob = new Job(Messages.ExecutablesView_Select_Executable) {
   283 
   285 
   284 								@Override
   286 							@Override
   285 								protected IStatus run(IProgressMonitor monitor) {
   287 							protected IStatus run(IProgressMonitor monitor) {
   286 									if (firstElement instanceof Executable) {
   288 								if (firstElement instanceof Executable) {
   287 										Executable executable = (Executable) firstElement;
   289 									Executable executable = (Executable)firstElement;
   288 										this
   290 									this.setName(Messages.ExecutablesView_Finding_Sources_Job_Name + executable.getName());
   289 												.setName(Messages.ExecutablesView_Finding_Sources_Job_Name
   291 									executable.getSourceFiles(monitor);
   290 														+ executable.getName());
       
   291 										executable.getSourceFiles(monitor);
       
   292 										UIJob selectExeUIJob = new UIJob(
       
   293 												Messages.ExecutablesView_Select_Executable) {
       
   294 											@Override
       
   295 											public IStatus runInUIThread(
       
   296 													IProgressMonitor monitor) {
       
   297 												sourceFilesViewer
       
   298 														.setInput(firstElement);
       
   299 												sourceFilesViewer.packColumns();
       
   300 												return Status.OK_STATUS;
       
   301 											}
       
   302 										};
       
   303 										selectExeUIJob.schedule();
       
   304 									}
       
   305 
       
   306 									return Status.OK_STATUS;
       
   307 								}
   292 								}
   308 							};
   293 								// selection could be empty, so do this no matter what to update the source
   309 							setectExeJob.schedule();
   294 								// files viewer
   310 						}
   295 								UIJob selectExeUIJob = new UIJob(Messages.ExecutablesView_Select_Executable){
       
   296 									@Override
       
   297 									public IStatus runInUIThread(IProgressMonitor monitor) {
       
   298 										sourceFilesViewer.setInput(firstElement);
       
   299 										sourceFilesViewer.packColumns();
       
   300 										return Status.OK_STATUS;
       
   301 									}};
       
   302 								selectExeUIJob.schedule();								
       
   303 								return Status.OK_STATUS;
       
   304 							}};
       
   305 						setectExeJob.schedule();
       
   306 						oldSelection = (IStructuredSelection) newSelection;
   311 					}
   307 					}
   312 				});
   308 					
       
   309 				}
       
   310 			}
       
   311 		});
   313 
   312 
   314 		executablesViewer.packColumns();
   313 		executablesViewer.packColumns();
   315 		sourceFilesViewer.packColumns();
   314 		sourceFilesViewer.packColumns();
   316 
   315 
   317 		PlatformUI.getWorkbench().getHelpSystem().setHelp(container, EXECUTABLES_VIEW_CONTEXT);
   316 		PlatformUI.getWorkbench().getHelpSystem().setHelp(container, EXECUTABLES_VIEW_CONTEXT);