Source:
public void setVisible(boolean visible) { if (isEmpty() && visible) { IWorkbenchPage page = EclipseUIUtil.getActivePage(); if (page != null && page.getActivePart() instanceof DDiagramEditor) { final DDiagramEditor editor = (DDiagramEditor) page.getActivePart(); DDiagram editorDiagram = (DDiagram) editor.getRepresentation(); boolean visibilityModeActive = VisibilityModeSwitchingAction.diagramAllowsVisibilityMode(editorDiagram); boolean layoutingModeActive = LayoutingModeSwitchingAction.diagramAllowsLayoutingMode(editorDiagram); if (!visibilityModeActive && !visibilityModeActive) { super.setVisible(false); } else { standardModeAction = new StandardModeAction(page, editor, editorDiagram, this); add(standardModeAction); if (visibilityModeActive) { visibilityModeSwitchingAction = new VisibilityModeSwitchingAction(page, editor, editorDiagram, this); add(visibilityModeSwitchingAction); } if (layoutingModeActive) { layoutingModeSwitchingAction = new LayoutingModeSwitchingAction(page, editor, editorDiagram, this); add(layoutingModeSwitchingAction); } if (editorDiagram != null && editorDiagram.isIsInLayoutingMode() && layoutingModeSwitchingAction != null) { setDefaultAction(ActionIds.SWITCH_LAYOUTING_MODE); layoutingModeSwitchingAction.setChecked(true); } else if (editorDiagram != null && editorDiagram.isIsInShowingMode()) { setDefaultAction(ActionIds.SWITCH_SHOWING_MODE); visibilityModeSwitchingAction.setChecked(true); } else { setDefaultAction(ActionIds.DEFAULT_MODE); standardModeAction.setChecked(true); } } } } else if (!isEmpty() && !visible) { remove(ActionIds.SWITCH_LAYOUTING_MODE); remove(ActionIds.SWITCH_SHOWING_MODE); remove(ActionIds.DEFAULT_MODE); standardModeAction = null; layoutingModeSwitchingAction = null; visibilityModeSwitchingAction = null; } }

Target:
public void setVisible(boolean visible) { if (isEmpty() && visible) { IWorkbenchPage page = EclipseUIUtil.getActivePage(); if (page != null && page.getActivePart() instanceof DDiagramEditor) { final DDiagramEditor editor = (DDiagramEditor) page.getActivePart(); DDiagram editorDiagram = (DDiagram) editor.getRepresentation(); boolean visibilityModeActive = VisibilityModeSwitchingAction.diagramAllowsVisibilityMode(editorDiagram); boolean layoutingModeActive = LayoutingModeSwitchingAction.diagramAllowsLayoutingMode(editorDiagram); if (!visibilityModeActive && !layoutingModeActive) { super.setVisible(false); } else { standardModeAction = new StandardModeAction(page, editor, editorDiagram, this); add(standardModeAction); if (visibilityModeActive) { visibilityModeSwitchingAction = new VisibilityModeSwitchingAction(page, editor, editorDiagram, this); add(visibilityModeSwitchingAction); } if (layoutingModeActive) { layoutingModeSwitchingAction = new LayoutingModeSwitchingAction(page, editor, editorDiagram, this); add(layoutingModeSwitchingAction); } if (editorDiagram != null && editorDiagram.isIsInLayoutingMode() && layoutingModeSwitchingAction != null) { setDefaultAction(ActionIds.SWITCH_LAYOUTING_MODE); layoutingModeSwitchingAction.setChecked(true); } else if (editorDiagram != null && editorDiagram.isIsInShowingMode()) { setDefaultAction(ActionIds.SWITCH_SHOWING_MODE); visibilityModeSwitchingAction.setChecked(true); } else { setDefaultAction(ActionIds.DEFAULT_MODE); standardModeAction.setChecked(true); } } } } else if (!isEmpty() && !visible) { remove(ActionIds.SWITCH_LAYOUTING_MODE); remove(ActionIds.SWITCH_SHOWING_MODE); remove(ActionIds.DEFAULT_MODE); standardModeAction = null; layoutingModeSwitchingAction = null; visibilityModeSwitchingAction = null; } }