Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Sphinx » selecting element in Sphinx editor and focusing it(selecting element in Sphinx editor and focusing it)
selecting element in Sphinx editor and focusing it [message #1733834] Wed, 01 June 2016 10:50 Go to next message
Zakir Meer is currently offline Zakir MeerFriend
Messages: 28
Registered: February 2016
Junior Member
Hello Experts,

I am trying to select a model element in the sphinx editor and getting it in focus.

For this I did some ground work and understood that a model element can be selected in Sphinx editor with the following piece of code (below code is from
ModelSearchResultView.java of Sphinx editor plugin)


With the below code element is selected but it is not Focused. In a case where the model size is more --> it is really had to search which element is selected (when the element is not focused)

It will be of great help if someone can let me know how to get the selected element in Focus



	private void selectElement( EObject element){

		final URIEditorInput input = EcoreUIUtil.createURIEditorInput(element.eResource());
		if (null != input) {
			final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
			IEditorInput editorInput = null;
			 
				editorInput = EcoreUIUtil.createURIEditorInput(element.eResource());
		 
			IEditorPart part1;
			try {
				part1 = page.openEditor(editorInput, "org.itea2.amalthea.sphinx.ui.editor", true);
				if (part1 instanceof BasicTransactionalFormEditor) {
					((BasicTransactionalFormEditor) part1).setSelectionToViewer(Collections.singleton(element));
				}
			} catch (PartInitException e) {
				e.printStackTrace();
			}  
			
		}
	
	}
Re: selecting element in Sphinx editor and focusing it [message #1734018 is a reply to message #1733834] Fri, 03 June 2016 06:05 Go to previous message
Zakir Meer is currently offline Zakir MeerFriend
Messages: 28
Registered: February 2016
Junior Member
In the above code, I found that there is an error -> as editor is opened again and due to this reason focus is lost.

Solution for my above query is : instead of opening editor, get the active instance of editor from the workbench -> active page and set the selection of specific element in the viewer. using below code:
((BasicTransactionalFormEditor) part1).setSelectionToViewer(Collections.singleton(element));
Previous Topic:Resolve Sphinx Model
Next Topic:adding new action to submenu
Goto Forum:
  


Current Time: Mon Feb 19 15:42:42 GMT 2018

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

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