|
Re: Programatically select Item in Editor in different window [message #904369 is a reply to message #904360] |
Tue, 28 August 2012 06:27   |
Eclipse User |
|
|
|
Markus,
Comments below.
On 28/08/2012 12:10 PM, Markus G wrote:
> Hi everyone,
>
> I'm afraid I need some help again. What I want to do is the following:
> I am keeping a relation URI from elements in my model to elements in a
> different resource. I want to add a functionality to trace down that
> other element, open it in another editor (might already be opened),
> extend the tree as far as needed to select that element in the other
> viewer.
>
> I have already gotten as far that I can check if that other file is
> already open by checking the titles of the editor's parts against a
> part of my URI. I can open the resource, iterate through it and look
> for my item that I can also find. I can focus the editor on my other
> model. Now I want to select the item I have found in the editor that
> already opened the resource I want.
I think you can just ask for the editor to be opened like what we do in
org.eclipse.emf.edit.ui.util.EditUIUtil.openEditor(EObject)
>
> My appreach was the follwing:
>
> List<Item> selectionList = new LinkedList<Item>();
> selectionList.add(findItem(itemURI));
> editor.setSelection(new StructuredSelection(selectionList));
>
>
> That doesn't seem to do the trick.
No, that sets what the editor normally updates itself based on
selections in the viewer.
>
> I have access to the editor, the IEditorPart , the resource and the
> item. So to me it seems I have all the ingredients together.. :)
You need to call the setSelectionToViewer method to actually update the
selection in the active view within the editor.
>
>
> Any help would be great!
> Thanks, Markus
|
|
|
|
|
|
Re: Programatically select Item in Editor in different window [message #904466 is a reply to message #904443] |
Tue, 28 August 2012 09:22   |
Eclipse User |
|
|
|
Markus,
Comments below.
On 28/08/2012 2:35 PM, Markus G wrote:
> Hi Ed,
>
> I'm pretty sure that searchedForElement is contained in a resource.
Yes, a resource, but if you look at what that utility does, it
determines the URI of the containing resource and opens an editor for
that URI. That editor will have its own copy of the resource and its
contained objects object, not the same instance you started with. You
need to get the instance in that editor.
> EditUIUtil.openEditor(searchedForElement)
>
> also opens the editor correctly, so that should already proves that
> the element is present and contained in a resource contained by that
> editor's resource set, right?
No.
>
> Doesn't that also mean that it's definitly in the tree? Otherwise the
> openEditor call would fail, no?
No. Unless you did something to locate the object actually created by
the editor, you won't have the right object. EcoreUtil.getURI will
create a URI for your object. ResourceSet.getEObject can resolve that
URI in the resource set of the editor you've opened.
>
>
> I did not explicitly add anything connected to wrappers in my
> ItemProviders. What exactly would that mean?
Given you've not really provided much detail, there's no point in me
explaining complex things that might not even apply.
>
> Thanks!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06849 seconds