目前GEF的SelectAllAction在执行的时候忽略了了Connection Model,有时候需要Select All的时候将连线也选中,通过简单的修改即可实现这个效果
/**
* @author zhazha
*/
public class CaseSelectAllAction extends SelectAllAction {
private IWorkbenchPart part;
public CaseSelectAllAction(IWorkbenchPart part) {
super(part);
this.part = part;
}
@Override
public void run() {
GraphicalViewer viewer = (GraphicalViewer) part.getAdapter(GraphicalViewer.class);
if (viewer != null) {
Set<GraphicalEditPart> items = new HashSet<GraphicalEditPart>();
for (Object object : viewer.getContents().getChildren()) {
if (object instanceof GraphicalEditPart) {
GraphicalEditPart editPart = (GraphicalEditPart) object;
items.add(editPart);
//添加Connection的editpart
items.addAll(editPart.getSourceConnections());
items.addAll(editPart.getTargetConnections());
}
}
viewer.setSelection(new StructuredSelection(new ArrayList<GraphicalEditPart>(items)));
}
}
}