gef connection 改变颜色

    [list=1]
  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