gef connection 改变颜色
企业开发
2018-05-31 17:24:04
阅读次数: 0
[list=1]
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SelectionEditPolicy());
[/list]
public class SelectionEditPolicy extends SelectionEditPolicy {
protected void hideSelection() {
BlockEditpart editpart = (BlockEditpart)getHost();
setConnectionVisible(editpart.getSourceConnections(),false,null);
setConnectionVisible(editpart.getTargetConnections(),false,null);
}
protected void showPrimarySelection() {
BlockEditpart editpart = (BlockEditpart)getHost();
editpart.refreshConnections();
setConnectionVisible(editpart.getSourceConnections(),true,ColorConstants.red);
setConnectionVisible(editpart.getTargetConnections(),true,ColorConstants.red);
}
protected void showSelection() {
BlockEditpart editpart = (BlockEditpart)getHost();
setConnectionVisible(editpart.getSourceConnections(),true,ColorConstants.green);
setConnectionVisible(editpart.getTargetConnections(),true,ColorConstants.green);
}
private void setConnectionVisible(List> Connections, boolean b, Color fg) {
for(Object o : Connections) {
if(o instanceof ConnectionEditPart) {
ConnectionEditPart cep = (ConnectionEditPart)o;
cep.setVisible(b,fg);
}
}
}
}
http://www.imilo.cn/
转载自zhymin77.iteye.com/blog/910429