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] Sun, 02 September 2012 23:03 Go to next message
Jason Lin is currently offline Jason Lin
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 04:32 Go to previous messageGo to next message
Jeeeyul Lee is currently offline Jeeeyul Lee
Messages: 108
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 04:53 Go to previous messageGo to next message
Jason Lin is currently offline Jason Lin
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 04: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 05:16 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1574
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 11:37 Go to previous message
Rui Domingues is currently offline Rui Domingues
Messages: 186
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 11:40]

Report message to a moderator

Previous Topic:Gradiently render/fill Rectangles/Rounded Rectangles/ Polygons
Next Topic:Remove align and match width buttons from coolbar
Goto Forum:
  


Current Time: Fri Jul 25 19:08:39 EDT 2014

Powered by FUDForum. Page generated in 0.01851 seconds