Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » PolylineConnection color when focused(GMF , PolylineConnection, color)
PolylineConnection color when focused [message #1059230] Fri, 17 May 2013 08:13 Go to next message
Eclipse UserFriend
Hi all,

I have a GMF diagram created with a graphical element of type PolylineConnectionEx ( this would be the baseclass). My figure element is properly displayed but I would like to change its color at selection time, meaning the color of the line dash to become green or something.

Do you have any hints for this? In the EditPart for this figure I see no handling for it. I have handleFocusedGain from IFigure but the note says not to overwrite it. Doing the opposite does not execute this code.
Any other clues?

Re: PolylineConnection color when focused [message #1059426 is a reply to message #1059230] Sat, 18 May 2013 05:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you can install a selection edit policy into you edit part which handles this for you. More information can be found in the gef section of the Eclipse Online Help.

Ralph
Re: PolylineConnection color when focused [message #1059536 is a reply to message #1059426] Mon, 20 May 2013 07:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ralph,

Thank you for the hint. I have now the following:
- created the editPolicy with the key SELECTION_FEEDBACK_ROLE
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
new MyFigureItemSemanticEditPolicy());

- in the xxxItemSemanticEditPolicy I override the getHost -> had no other idea to get the figure
public EditPart getHost() {
IFigure figure=null;

if(super.getHost() instanceof MyFigureEditPart)
{
((MyFigureEditPart)super.getHost()).getFigure().setForegroundColor(new Color(null, 153, 204, 255));
}

return super.getHost();
}


So now I have it colored. Moving to another figure of same type, will color the newly selected as well but the previous is still colored. How should I clear the color from the previous figure?
Thanks
Re: PolylineConnection color when focused [message #1060256 is a reply to message #1059536] Thu, 23 May 2013 13:15 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dan,

the SemanticEditPolicy is probably not the right place to begin.

Please check:
org.eclipse.gef.editpolicies.SelectionEditPolicy

You will find the implementations to activate/deactivate the editpolicy that you can use to color/uncolor your figure.
Make sure to install the modified editpolicy with the correct editpolicyrole to prevent policies to overlap each other. Each editpolicy can only be registered once with the corresponding role.

Regards
Thomas
Re: PolylineConnection color when focused [message #1060652 is a reply to message #1060256] Mon, 27 May 2013 09:32 Go to previous message
Eclipse UserFriend
Hi Thomas,

Thanks for help. I followed your idea and used to override the method
protected void setSelectedState(int type).
Type can be 0 for deselect and 2 for select, so I added my coloring for these two values.

All the best.
Previous Topic:Link Constraints and shared tool element
Next Topic:GMF Outline dont show my model hierarchy
Goto Forum:
  


Current Time: Tue Jul 08 01:50:24 EDT 2025

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

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

Back to the top