Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » How can I select an element in the canvas?
How can I select an element in the canvas? [message #119680] Mon, 16 April 2007 10:31 Go to next message
Eclipse UserFriend
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 #119692 is a reply to message #119680] Mon, 16 April 2007 10:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kalin.nakov.gmail.com

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 #119820 is a reply to message #119692] Mon, 16 April 2007 14:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kalin.nakov.gmail.com

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 #119833 is a reply to message #119820] Tue, 17 April 2007 02:25 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:GMF(Callisto) 1.0.3: org.eclipse.emf.validation.ocl requires "org.eclipse.ocl.ecore" ????
Next Topic:Problem creating Editor: Invocation Target Exception
Goto Forum:
  


Current Time: Mon Jul 07 19:07:44 EDT 2025

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

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

Back to the top