| Getting wrong selection, sometimes [message #336568] | 
Tue, 23 June 2009 18:36  | 
 
Eclipse User  | 
 | 
 | 
   | 
 
I have simple view that consists of a TableViewer with the following  
double-click listener: 
 
  IHandlerService handlerService = (IHandlerService)  
    getSite().getService(IHandlerService.class); 
  handlerService.executeCommand(TestHandler.ID, null); 
 
The handler is registered in the plugin.xml and contains the following  
code: 
 
public Object execute(ExecutionEvent event) throws ExecutionException { 
  IWorkbenchPage page = HandlerUtil 
    .getActiveWorkbenchWindow(event).getActivePage(); 
  ISelection = page.getActivePart().getSite() 
    .getSelectionProvider().getSelection(); 
  ... 
} 
 
This works fine most of the time. But sometimes the ISelection ends up  
being a reference to the IEditorInput of an open editor, rather than the  
selection in the view! So it seems that double-clicking an element in a  
view does not make the view active immediately. Bug? Or is there a way  
right now to write this code without requiring the handlers to store the  
part ID of the view explicitly?
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.04706 seconds