Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » how can I install EditPolicy to the shape
how can I install EditPolicy to the shape [message #906960] Mon, 03 September 2012 03:03 Go to next message
Jason Lin is currently offline Jason LinFriend
Messages: 12
Registered: July 2012
Junior Member
I want the shape to change its icon/Image when it is selected.
I found that there is createEditPolicies() method in ShapeEditPart.
And it has installed an highlight plicy.
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, getConfigurationProvider().getEditPolicyFactory().createShapeHighlightEditPolicy());

I know how to create a new edit policy. But the question is:
How can I install this new edit policy to the graphiti internal EditPart?

Best Regards,
Jason, Lin
Re: how can I install EditPolicy to the shape [message #907063 is a reply to message #906960] Mon, 03 September 2012 08:32 Go to previous messageGo to next message
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

As far as I know, ShapeEditPart is not an API since Graphiti completely hide underlying Technologies(GEF, Draw2d...) with IContext mechanism.
So you can't.

If you want to use GEF API, you have to branch Graphiti and modify Graphiti itself.

Remember that Graphiti plan(Even I think it is very hard to accomplish) contains supporting other platforms.
Re: how can I install EditPolicy to the shape [message #907073 is a reply to message #907063] Mon, 03 September 2012 08:53 Go to previous messageGo to next message
Jason Lin is currently offline Jason LinFriend
Messages: 12
Registered: July 2012
Junior Member
Thank.
I saw a reply from michael:"there's a hook method in the tool behavior provider that allows to change the appearance of a shape when it is selected (getSelectionInfoForShape)".
But it can only change color and lineStyle... Crying or Very Sad

Best Regards,
Jason

[Updated on: Mon, 03 September 2012 08:54]

Report message to a moderator

Re: how can I install EditPolicy to the shape [message #907091 is a reply to message #907073] Mon, 03 September 2012 09:16 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Maybe you could try to use ImageDecorators. Usually they show markers on top
of a shape, but that sounds as if it would work as well in this case. See
IToolBehaviorProvider.getDecorators.

Michael
Re: how can I install EditPolicy to the shape [message #932940 is a reply to message #907073] Thu, 04 October 2012 15:37 Go to previous messageGo to next message
Rui Domingues is currently offline Rui DominguesFriend
Messages: 194
Registered: October 2010
Senior Member
Hi. I was successful to install policies in my ediparts, but this is kind a workaround.

I install my policies in the exact moment the object is created. First I have a selecction listener like this
IWorkbenchPage page = getSite().getPage();
ISelectionListener selListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection sel) {
...
}


once, after creation the object remains selected for, at least, a fraction of a moment, I do something like this:
unknownSelectedObject=((IStructuredSelection) getSite().getPage().getSelection()).getFirstElement();
if (unknownSelectedObject instanceof ContainerShapeEditPart) { 
  ((ContainerShapeEditPart)unknownSelectedObject).installPolicy
}

I check if it is a containershapeeditpart (or a shapeeditpart...) and I can check also if it corresponds to some Business object I want, and then I install the policy.
Here it is working like a charm.

I wanted to contribute this (kinda ugly) workaround. For me it was useful.

P.S. Probably you must import gef jar into buid path Sad

[Updated on: Thu, 04 October 2012 15:40]

Report message to a moderator

Re: how can I install EditPolicy to the shape [message #1595151 is a reply to message #932940] Sat, 31 January 2015 20:28 Go to previous messageGo to next message
Abhishek Chakraborty is currently offline Abhishek ChakrabortyFriend
Messages: 82
Registered: July 2009
Location: Cologne, Germany
Member

How can I remove the decorators when the Node/ Shape is deselected, does the Diagram has any feature to remove the decorators.

Regards,
Abhishek Chakraborty
Re: how can I install EditPolicy to the shape [message #1599366 is a reply to message #1595151] Tue, 03 February 2015 15:33 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Abhishek,

for that I guess you would need to trigger a refresh of the decorators via
refreshRenderingDecorators on the DiagramBehavior instance of your editor.
While providing the decorators for a shape you need to check if the shape is
selected before adding decorators.

Michael
Previous Topic:Vertical Scrollbar Query
Next Topic:[Spray] Error: PackageImpl cannot be cast to org.eclipse.emf.codegen.ecore.genmodel.GenModel
Goto Forum:
  


Current Time: Tue Mar 19 06:50:49 GMT 2024

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

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

Back to the top