/**
* Deletes the selected shapes
*/
public void deleteSelection(){
CompoundEdit ce = new CompoundEdit();
for(int i=0;i<_selectedElements.size();i++){
ElementSelection ss = (ElementSelection)_selectedElements.get(i);
Element as = ss.element;
as.processShapeRemoving();
ce.addEdit(new DeleteEdit((getElementContainer()), as));
if (ss.element instanceof GatedComponent){
GatedComponent gc = (GatedComponent)ss.element;
List gates = gc.getGates();
for(int k=0; k< gates.size(); k++){
Gate gate = ((Gate)gates.get(k));
List connections = gate.getConnections();
for(int j=0; j< connections.size(); j++){
Connection connection = (Connection)connections.get(j);
if (connection.isConnected(gate)){
ce.addEdit(new GateDisconnectEdit(connection, gate, connection.getFirstEndGate()!=null && connection.getFirstEndGate().equals(gate)));
connection.disconnect(gate);
}
}
}
}
if (ss.element instanceof Connection){
Connection gc = (Connection)ss.element;
if (gc.getFirstEndGate() != null){
ce.addEdit(new GateDisconnectEdit(gc, gc.getFirstEndGate(), true));
gc.disconnect(gc.getFirstEndGate());
}
if (gc.getLastEndGate() != null){
ce.addEdit(new GateDisconnectEdit(gc, gc.getLastEndGate(), false));
gc.disconnect(gc.getLastEndGate());
}
}
deleteShape(ss.element);
}
ce.end();
DiagramComponent dc = getElementContainer().getComponent();
dc.fireUndoableEditUpdate( new UndoableEditEvent(dc, ce));
unselect();