Skip to main content



      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 05:19
Eclipse UserFriend
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: Mon Mar 17 23:14:06 EDT 2025

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

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

Back to the top