public void workspaceEventOccurred(WorkspaceEvent e) {
        // TODO Auto-generated method stub
        if (e.getEventType() == WorkspaceEvent.BLOCKS_CONNECTED) {
            BlockLink link = e.getSourceLink();
            if (link.getLastBlockID() != null && link.getLastBlockID() != Block.NULL
                    && BlockConnectorShape.isCommandConnector(link.getPlug()) && BlockConnectorShape.isCommandConnector(link.getSocket())) {
                Block top = workspace.getEnv().getBlock(link.getPlugBlockID());
                while (top.hasAfterConnector() && top.getAfterConnector().hasBlock()) {
                    top = workspace.getEnv().getBlock(top.getAfterBlockID());
                }
                Block bottom = workspace.getEnv().getBlock(link.getLastBlockID());

                // For safety: if either the top stack is terminated, or
                // the bottom stack is not a starter, don't try to force a link
                if (!top.hasAfterConnector() || !bottom.hasBeforeConnector()) {
                    return;
                }

                link = BlockLink.getBlockLink(workspace, top, bottom, top.getAfterConnector(), bottom.getBeforeConnector());
                link.connect();
            }
        }
    }