Skip to main content



      Home
Home » Modeling » Graphiti » how can I install EditPolicy to the shape
how can I install EditPolicy to the shape [message #906960] Sun, 02 September 2012 23:03 Go to next message
Eclipse UserFriend
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 04:32 Go to previous messageGo to next message
Eclipse UserFriend
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 04:53 Go to previous messageGo to next message
Eclipse UserFriend
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 04:54] by Moderator

Re: how can I install EditPolicy to the shape [message #907091 is a reply to message #907073] Mon, 03 September 2012 05:16 Go to previous messageGo to next message
Eclipse UserFriend
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 11:37 Go to previous messageGo to next message
Eclipse UserFriend
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 11:40] by Moderator

Re: how can I install EditPolicy to the shape [message #1595151 is a reply to message #932940] Sat, 31 January 2015 15:28 Go to previous messageGo to next message
Eclipse UserFriend
How can I remove the decorators when the Node/ Shape is deselected, does the Diagram has any feature to remove the decorators.
Re: how can I install EditPolicy to the shape [message #1599366 is a reply to message #1595151] Tue, 03 February 2015 10:33 Go to previous message
Eclipse UserFriend
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 Jul 22 11:07:21 EDT 2025

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

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

Back to the top