Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » PolylineConnection color when focused(GMF , PolylineConnection, color)
PolylineConnection color when focused [message #1059230] Fri, 17 May 2013 12:13 Go to next message
Dan Tololoi is currently offline Dan TololoiFriend
Messages: 33
Registered: September 2012
Location: Iasi, Romania
Member

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 09:01 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
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 11:24 Go to previous messageGo to next message
Dan Tololoi is currently offline Dan TololoiFriend
Messages: 33
Registered: September 2012
Location: Iasi, Romania
Member

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 17:15 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas BeyerFriend
Messages: 55
Registered: February 2013
Member
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 13:32 Go to previous message
Dan Tololoi is currently offline Dan TololoiFriend
Messages: 33
Registered: September 2012
Location: Iasi, Romania
Member

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: Thu Dec 18 13:33:00 GMT 2014

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

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