public final class ShowStatisticsActionHandler extends SapphireActionHandler
{
@Override
protected Object run( final Presentation context )
{
final SapphireDiagramEditorPagePart page = (SapphireDiagramEditorPagePart) getPart();
ConnectionService connService = page.service(ConnectionService.class);
int nodes = 0;
int connections = 0;
int bendpoints = 0;
for( ISapphirePart selectedPart : page.getSelections() )
{
if( selectedPart instanceof DiagramNodePart )
{
nodes++;
}
else if( selectedPart instanceof DiagramConnectionPart )
{
connections++;
bendpoints += ( (DiagramConnectionPart) selectedPart ).getBendpoints().size();
}
else if( selectedPart instanceof SapphireDiagramEditorPagePart )
{
nodes = page.getNodes().size();
final List<DiagramConnectionPart> allConnections = connService.list();
connections = allConnections.size();