@SuppressWarnings({ "rawtypes", "unchecked" })
protected void performSelection() {
if (hasSelectionOccurred())
return;
setFlag(FLAG_SELECTION_PERFORMED, true);
EditPartViewer viewer = getCurrentViewer();
List<EditPart> selectedObjects = viewer.getSelectedEditParts();
if (getCurrentInput().isModKeyDown(SWT.MOD1)) {
EditPart deselectPart = getDeselectPart(selectedObjects, getSourceEditPart());
if (deselectPart != null) {
viewer.deselect(deselectPart);
} else {
if (!isParentSelected(getSourceEditPart())) {
viewer.appendSelection(getSourceEditPart());
removeChildrenDuplicates(getSourceEditPart());
}
}
viewer.setProperty(LAST_EDIT_PART, getSourceEditPart());
} else if (getCurrentInput().isShiftKeyDown()) {
EditPart fromEditPart = (EditPart)viewer.getProperty(LAST_EDIT_PART);
if (sameNodeModel(fromEditPart, getSourceEditPart())) {
viewer.deselectAll();
EditPart toEditPart = getSourceEditPart();
Rectangle fromRect = getRectangle(fromEditPart);
Rectangle toRect = getRectangle(toEditPart);
Rectangle rect = fromRect.getUnion(toRect);
Collection editPartsToProcess = new HashSet();
editPartsToProcess.addAll(EditPartUtilities.getAllChildren(getNodeEditPart(fromEditPart)));
List<EditPart> selectedEditParts = new ArrayList<EditPart>();
for (Iterator iterator = editPartsToProcess.iterator(); iterator.hasNext();) {
GraphicalEditPart editPart = (GraphicalEditPart) iterator.next();
if (editPart.isSelectable() && FigureUtilities.isNotFullyClipped(editPart.getFigure()) && isEditPartInRect(editPart, rect)) {
selectedEditParts.add(editPart);
}
}
filterEditParts(selectedEditParts, fromEditPart, getSourceEditPart());
for (EditPart editPart : selectedEditParts) {
viewer.appendSelection(editPart);
}
} else {
viewer.appendSelection(getSourceEditPart());
viewer.setProperty(LAST_EDIT_PART, getSourceEditPart());
}
}
else {
viewer.select(getSourceEditPart());
viewer.setProperty(LAST_EDIT_PART, getSourceEditPart());
}
}