@Override
  public void run() {
    if (context == null) {
      return;
    }

    final Shell shell = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();

    Session session = SessionManager.INSTANCE.getSession(context);
    if (session == null) {
      return;
    }
    TransactionalEditingDomain editingDomain = session.getTransactionalEditingDomain();
    if (editingDomain == null) {
      return;
    }

    RecordingCommand cmd =
        new RecordingCommand(editingDomain, "Create Sequence diagram") {
          protected void doExecute() {
            // Get Session
            Session session = SessionManager.INSTANCE.getSession(context);

            if (session != null) {
              // Ask the user to provide a name for the diagram
              InputDialog dialog =
                  new InputDialog(
                      shell,
                      "New representation",
                      "New representation name",
                      "new Sequence diagram",
                      null);
              int buttonPressed = dialog.open();
              if (buttonPressed == InputDialog.OK) {
                String diagramName = dialog.getValue();

                // Create a new interaction instance
                Interaction interaction = InteractionFactory.eINSTANCE.createInteraction();
                interaction.setName(diagramName);
                context.getBehaviours().add(interaction);

                Collection<RepresentationDescription> descs =
                    DialectManager.INSTANCE.getAvailableRepresentationDescriptions(
                        session.getSelectedViewpoints(false), interaction);
                for (RepresentationDescription desc : descs) {
                  Viewpoint viewpoint = (Viewpoint) desc.eContainer();

                  if (InteractionAnalysisContextMenuActionProvider.isInteractionViewpoint(viewpoint)
                      && "Sequence Diagram".equals(desc.getName())) {
                    // Create the new diagram
                    if (DialectManager.INSTANCE.canCreate(interaction, desc)) {
                      DRepresentation sequenceDiagram =
                          DialectManager.INSTANCE.createRepresentation(
                              diagramName, interaction, desc, session, new NullProgressMonitor());
                      if (sequenceDiagram != null) {
                        DialectUIManager.INSTANCE.openEditor(
                            session, sequenceDiagram, new NullProgressMonitor());
                      }
                    }
                  }
                }
              }
            }
          }
        };
    editingDomain.getCommandStack().execute(cmd);
  }
 static {
   URL url = Activator.getDefault().getBundle().getEntry("images/createSequenceDiagram.gif");
   image = ImageDescriptor.createFromURL(url);
 }