How can I select an element in the canvas? [message #119680] |
Mon, 16 April 2007 10:31  |
Eclipse User |
|
|
|
Originally posted by: kalin.nakov.gmail.com
Hi,
I want to select an element in the canvas by means of Java code. I
googled out the method SelectInDiagramHelper.selectElement(someView).
But unfortunately I have only a org.eclipse.gmf.runtime.notation.Node
class instance which points to the correct diagram node. The difficult
question is how can I convert that Node object to a
org.eclipse.gmf.runtime.notation.View object so that I can finally
select it?
Thanks in advance,
Kalin
|
|
|
|
|
Re: How can I select an element in the canvas? [message #119833 is a reply to message #119820] |
Tue, 17 April 2007 02:25   |
Eclipse User |
|
|
|
Originally posted by: kalin.nakov.gmail.com
I have more information on the GMF bug. Here it is:
XXXDiagramEditorUtil.openDiagram(r);
IEditorPart editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
diagramEditor = (DiagramEditor) editorPart;
The openDiagram() method opens the diagram, I see that in the editor,
but unfortunately the getActivePage() method returns the page which was
active before opening the diagram. I tried to check the number of pages
in the active workbench window, but it was not affected by the
openDiagram method. I find it impossible to retrieve the new active page
after opening a diagram, it seems that some internal structures in GMF
are not refreshed.
Kalin Nakov wrote:
> That should be simple, I just want to open a diagram and select an
> element in it. The obvious sequence XXXDiagramEditorUtil.openDiagram()
> -> SelectInDiagramHelper.selectElement() does not work - diagram is
> visually open, but is not set as the current active digram. What is the
> correct sequence to use?
>
> Kalin Nakov wrote:
>> Sorry for the stupid question, it appears that Node extends View so
>> that I can directly select the node. Unfortunately now that assertion
>> in SelectInDiagramHelper.selectElement() fails:
>>
>> Assert.isTrue(diagramEditor.getDiagram().equals(view.getDiag ram()));
>>
>> It appears that the selected element's diagram is different from the
>> current diagram. That is strange, because on the previous line I have
>> explicitly called
>>
>> EditUIUtil.openEditor((EObject) diagram.getContents().get(0));
>>
>> It appears that the editor is fooled out and no matter that the newly
>> open diagram is visible and active, it seems that the GMF framework
>> still thinks the old diagram is active instead of the new one.
>>
>> How can I force the framework to refresh it's state so that the newly
>> open diagram will become active?
>>
>> Thanks,
>> Kalin
>>
>> Kalin Nakov wrote:
>>> Hi,
>>>
>>> I want to select an element in the canvas by means of Java code. I
>>> googled out the method SelectInDiagramHelper.selectElement(someView).
>>> But unfortunately I have only a org.eclipse.gmf.runtime.notation.Node
>>> class instance which points to the correct diagram node. The
>>> difficult question is how can I convert that Node object to a
>>> org.eclipse.gmf.runtime.notation.View object so that I can finally
>>> select it?
>>>
>>> Thanks in advance,
>>> Kalin
|
|
|
Re: How can I select an element in the canvas? [message #119912 is a reply to message #119833] |
Tue, 17 April 2007 06:12  |
Eclipse User |
|
|
|
Hello Kalin,
> openDiagram method. I find it impossible to retrieve the new active
> page after opening a diagram, it seems that some internal structures
> in GMF are not refreshed.
You can easily track the result of open editor operation: EditUIUtil.openEditor
contains following line: return editorPart != null;
So, result of ???DiagramEditorUtil.openDiagram() will be "true" if editor
was successfully openned and available form eclipse API (IWorkbenchPage.getEditorReferences())
-----------------
Alex Shatalin
|
|
|
Powered by
FUDForum. Page generated in 0.04142 seconds