Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Set selection programmatically
Set selection programmatically [message #667239] Wed, 27 April 2011 15:10 Go to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 169
Registered: July 2009
Senior Member
Hello,

How do I programmatically set the selection of a Graphiti-based editor? (Scenario: The user double-clicks on an entry in the Problems view, that entry contains information about the business object and I would like to select the diagram element(s) that correspond to this BO.) I would have expected the editor to map between business objects or pictogram elements and the low-level GEF element, but that might have been a bit naive since all I'm getting is a CCE:

java.lang.ClassCastException: org.eclipse.graphiti.mm.pictograms.impl.ContainerShapeImpl cannot be cast to org.eclipse.gef.EditPart
 at org.eclipse.gef.SelectionManager.setSelection(SelectionManager.java:253)
 at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setSelection(AbstractEditPartViewer.java:751)
 at org.eclipse.graphiti.ui.internal.editor.GraphitiScrollingGraphicalViewer.setSelection(GraphitiScrollingGraphicalViewer.java:62)
  ...


Thanks
Volker
Re: Set selection programmatically [message #667331 is a reply to message #667239] Thu, 28 April 2011 07:36 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1635
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Volker,

you can call the method selectPictogramElements in the DiagramEditor, that
will do it. Before you might have to get the pictogram element for your BO
using the LinkService.

HTH,
Michael

"Volker Wegert" wrote in message news:ip9b5j$ofb$1@news.eclipse.org...

Hello,

How do I programmatically set the selection of a Graphiti-based editor?
(Scenario: The user double-clicks on an entry in the Problems view, that
entry contains information about the business object and I would like to
select the diagram element(s) that correspond to this BO.) I would have
expected the editor to map between business objects or pictogram elements
and the low-level GEF element, but that might have been a bit naive since
all I'm getting is a CCE:

java.lang.ClassCastException:
org.eclipse.graphiti.mm.pictograms.impl.ContainerShapeImpl cannot be cast to
org.eclipse.gef.EditPart
at org.eclipse.gef.SelectionManager.setSelection(SelectionManag er.java:253)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setSelection (AbstractEditPartViewer.java:751)
at
org.eclipse.graphiti.ui.internal.editor.GraphitiScrollingGra phicalViewer.setSelection(GraphitiScrollingGraphicalViewer.j ava:62)
...

Thanks
Volker
Re: Set selection programmatically [message #667372 is a reply to message #667331] Thu, 28 April 2011 12:10 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 169
Registered: July 2009
Senior Member
Michael,

thanks for the information.

Michael Wenz wrote on Thu, 28 April 2011 03:36

you can call the method selectPictogramElements in the DiagramEditor, that will do it. Before you might have to get the pictogram element for your BO using the LinkService.



First of all, I get a warning when doing this:
Discouraged access: The type DiagramEditorInternal is not accessible due to restriction on required project org.eclipse.graphiti.ui

And this feels strange - I've got a framework that is supposed to handle the entire business object vs. graphical representation thingy, and I still have to fiddle with this outside of the editor. I think that the editor should be able to do this mapping by itself - or does that collide with some design principle I overlooked?

Volker
Re: Set selection programmatically [message #667378 is a reply to message #667372] Thu, 28 April 2011 12:16 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1635
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Right, the editor API is something we still need to clean up. See
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336488

Michael


"Volker Wegert" wrote in message news:ipbl15$87h$1@news.eclipse.org...

Michael,

thanks for the information.

Michael Wenz wrote on Thu, 28 April 2011 03:36
> you can call the method selectPictogramElements in the DiagramEditor, that
> will do it. Before you might have to get the pictogram element for your BO
> using the LinkService.


First of all, I get a warning when doing this:
Discouraged access: The type DiagramEditorInternal is not accessible due to
restriction on required project org.eclipse.graphiti.ui

And this feels strange - I've got a framework that is supposed to handle the
entire business object vs. graphical representation thingy, and I still have
to fiddle with this outside of the editor. I think that the editor should be
able to do this mapping by itself - or does that collide with some design
principle I overlooked?

Volker
Previous Topic:2 Resources in 1 Domain leads to a Problem during Save/Refresh
Next Topic:How to change line dash patterns?
Goto Forum:
  


Current Time: Sun Nov 23 18:54:11 GMT 2014

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

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