Customizing selection handles of GEF figures

Whenever a figure is selected in the GEF Editor, by default, you will see black,filled rectangle resize handles and a black border outlining the figure. Showing these handles is the job of container editpart of the selected figure’s editpart by defining resizable or non resizable editpolicy for it’s children. For this to happen, you need to install an edit policy which is subclass of ConstrainedLayoutEditPolicy (generally, XYLayoutEditPolicy ) in container figure’s editpart. By default, ‘createChildEditPolicy’ method of ConstrainedLayoutEditPolicy returns instance of ResizableEditPolicy. If you want your child figures not resizable you need to override this method and return instance of NonResizableEditPolicy. If you also want to display your own custom selection handles you need to subclass one of these resize editpolicies and override ‘createSelectionHandles’ method of SelectionHandlesEditPolicy .Both ResizableEditPolicy and NonResizableEditPolicy are sub classes of SelectionHandlesEditPolicy. Both override ‘createSelectionHandles’ in order to provide their own handles. Checkout the overridden method(createSelectionHandles) of these classes, it will give you good idea on how to add or remove handles. The MoveHandle is responsible for providing black line border. ResizeHandle and NonResizableHandle are responsible for black, filled squares. You can simply override these classes and customize for your need. Checkout the methods of these handle classes to get an idea.

4 thoughts on “Customizing selection handles of GEF figures

  1. cool ! I was really looking for the own custom handle for a long time. This gave me some idea where to look for. Do you have any samples for this. would be great if you can put it here Thanks.

  2. Thanks for this tip, it works well and was a real help. The GEF article vaguely hints that the XYLayoutPolicy should install a ResizableEditPolicy on its children, but never mentions this wrinkle.

    I have a follow-up question. Do you know an easy way for selection to show no border and no handles at all? I have some 9-pixel circle elements in my GEF editor that are obscured by the four selection corners. I change the color of the circle when it is selected, and it cannot be moved, so I really don’t need nor want the handles.

    Thanks in advance!

  3. Hi Chris, I am out of touch with GEF, let me try. Extend either NonResizableEditPolicy or ResizableEditPolicy, override ‘showSelection’ method with blank implementation. Let me know if it works.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s