question: public final void deleteSelectedObjects ( ) { Component [ ] components = getComponents ( ) ; List < DisplayNode > graphNodes = new ArrayList < > ( ) ; List < IDisplayEdge > graphEdges = new ArrayList < > ( ) ; for ( Component comp : components ) { if ( comp instanceof DisplayNode ) { if ( ! isDeleteVariablesAllowed ( ) ) { continue ; } DisplayNode node = ( DisplayNode ) comp ; if ( node . isSelected ( ) ) { graphNodes . add ( node ) ; } } else if ( comp instanceof IDisplayEdge ) { IDisplayEdge edge = ( IDisplayEdge ) comp ; if ( edge . isSelected ( ) ) { graphEdges . add ( edge ) ; } } } for ( DisplayNode graphNode : graphNodes ) { removeNode ( graphNode ) ; } for ( IDisplayEdge displayEdge : graphEdges ) { try { removeEdge ( displayEdge ) ; resetEdgeOffsets ( displayEdge ) ; } catch ( Exception e ) { if ( isNodeEdgeErrorsReported ( ) ) { JOptionPane . showMessageDialog ( JOptionUtils . centeringComp ( ) , e . getMessage ( ) ) ; } } } }
target:  Deletes all selected nodes in the workbench plus any edges that have had one of their nodes deleted in the process.