Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Empty Selection after opened an editor
Empty Selection after opened an editor [message #1033482] Thu, 04 April 2013 09:19
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

Goodmorning everyone,
I've got a perspective with 2 views and I use SelectionService to get the selected object from one of these (doubleclick event).

If I use this selection to open an editor on selected object I've got this problem: once the editor is open the selection is empty and if I try to double-click on other objects I'll receive NullPointerException.

If I try to debug, selection is never empty and all goes fine (could be a synchronization problem?)

Here are some hot code parts:

        @Override
	public Object execute(final ExecutionEvent event) throws ExecutionException {
		
		final E objectToBeEditedEObject = getObjectToBeEdited();
		final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		
		
		try {
			final IEditorInput editorInput = retrieveEditorInput(page, objectToBeEditedEObject);
			page.openEditor(editorInput, getEditorId());
		} catch (final PartInitException e) {
			throw new RuntimeException(e);
		}
		
		return null;
		
	}


    @Override
    protected MyType getObjectToBeEdited() {
        return (MyType) getCurrentSelection();
    }


   protected Object getCurrentSelection() {
    	final StructuredSelection selection=(StructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
    	Object toReturn = selection.getFirstElement();
        return toReturn;
    }


Thanks for you help.
Previous Topic:Errors in Workspace
Next Topic:refresh properties view
Goto Forum:
  


Current Time: Tue Sep 24 20:03:11 GMT 2024

Powered by FUDForum. Page generated in 0.03357 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top