Example #1
0
  /** Used when the context is switched. Installs the undoMa */
  public void update() {
    try {
      actualProjectDiagram = ModelerSession.getProjectService().getSelectedDiagram();
      actualUCDiagramModel = (UCDiagramModel) actualProjectDiagram.getDiagramModel();
      actualUCDiagramModel.installUndoActions(
          actions.get(UCNotationModel.UNDO_ACTION_KEY),
          actions.get(UCNotationModel.REDO_ACTION_KEY));

      actions
          .get(UCNotationModel.UNDO_ACTION_KEY)
          .setEnabled(actualUCDiagramModel.getUndoManager().canUndo());
      actions
          .get(UCNotationModel.REDO_ACTION_KEY)
          .setEnabled(actualUCDiagramModel.getUndoManager().canRedo());

      final ProjectDiagram projectDiagram = ModelerSession.getProjectService().getSelectedDiagram();
      projectDiagram.addChangeListener(this);
      actions.get(UCNotationModel.SAVE_ACTION_KEY).setEnabled(projectDiagram.isChanged());

    } catch (ClassCastException exception) {
      LOG.error("Unable to cast selected diagram model to UCDiagramModel class.", exception);
    } catch (Exception exception) {
      LOG.error("An error has occurred during context switch.", exception);
    }

    this.setTitleAt(0, actualProjectDiagram.getDisplayName());
    ((UCTabParent) this.getComponent(0)).update();
  }