swt - Eclipse GEF - Select figures -


i using gef framework show network of connected nodes. have topeditpart diagram , 1 editpart each node , connections. diagram rendering properly. need select node , outgoing connections , connected nodes should change different color. started off @ editpolicies gef provides, have no clue edit policy use highlight figure ie., show selection feedback. in regard appreciated. have tried:

i created class extending xylayouteditpolicy , installed on rooteditpart

public class basicxylayouteditpolicy extends xylayouteditpolicy {     protected command createaddcommand(editpart child, object constraint) {         return null;     }      protected command createchangeconstraintcommand(editpart child, object constraint) {         return null;     }      protected command getcreatecommand(createrequest request) {         return null;     }      protected editpolicy createchildeditpolicy(editpart child) {         return new noderesizableeditpolicy();      }      protected command getdeletedependantcommand(request request) {         return null;     }      public editpart gettargeteditpart(request request) {         editpart targeteditpart = gethost(); // guessed that...         return targeteditpart;     } } 

installed on root editpart

protected void createeditpolicies() {     installeditpolicy(editpolicy.layout_role, new basicxylayouteditpolicy()); } 

now create new class nodeselectioneditpolicy extends selectioneditpolicy

public class nodeselectioneditpolicy extends selectioneditpolicy {      @override     protected void hideselection() {         gethostfigure().setbackgroundcolor(display.getdefault().getsystemcolor(swt.color_green));     }      @override     protected void showselection() {         gethostfigure().setbackgroundcolor(display.getdefault().getsystemcolor(swt.color_dark_red));     } } 

next installing policy onto node edit parts

protected void createeditpolicies() {     installeditpolicy(editpolicy.selection_feedback_role, new nodeselectioneditpolicy()); } 

when execute code, nothing seems happen ie., no visual selection feedback happens. missing ? need implement method of nodeselectioneditpolicy ?

extending selectioneditpolicy right way go , should working (in code change color of selected figure).

the problem figure not have background color therefore changing background color doesn't much. try changing foreground color.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -