Edit Models and Presentations

In order to edit models or presentations using API, you need the transaction process. Also an exception will happen if:

  • The project is not registered in the project accessor or
  • target models/presentations you are trying to edit are non-editable

Transaction process

A transaction is a unit of update processing performed on a Astah project.

Use beginTransaction to start transaction.
Use endTransaction to commit the transaction.
This is one update process. undo / redo is done in this processing unit.

Use abortTransaction to cancel a transaction.
If you cancel a transaction, the project returns to the state it was in before the transaction started.
When any exception happened while working on the projects with API, you need to call abortTransaction method, then start again.

Edit model

Model Editor

The Model Editor is to used when you edit model with API.
If you edit a model that can have multiple presentations, you can create/edit from each Model Editor.

Editting Model Viewpoint

There are some models that are automatically created when you create presentations. For details, please refer to [Get Diagrams and Presentations].

Model Editors Model elements you can create in the Model Editor
BasicModelEditor Class, Artifact, Association, Association Class, Attribute, Component, Constraint, Copy, Dependency, DeriveReqt, Generalization, Interface, Model, Node, Operation, Package, Parameter, Port, Qualifier, Realization, Refine dependency, Requirement, Satisfy dependency, Subsystem, Tagged value, Template binding, Template parameter, TestCase, Trace dependency, Usage, Verify dependency
UseCaseModelEditor Actor, Usecase, Extension point, Include, Extend
CompositeStructureModelEditor Connector, Realization, Usage
ERModelEditor ER model, ER entity, Domain, ER attribute, Data type, Index of ERAttribute, Identifying relationship, Multi-to-multi relationship, Non-identifying relationship, Subtype

Create a Class under package

Create TaggedValues

Delete Models

Add Definition

This is an example to add Definition to a Class./

Add Stereotypes

Edit Presentations

Diagram Editor

You will use DiagramEditor to create, edit and delete presentations.

A diagram type needs to be set for DiagramEditor before you start editing.
When you create a diagram, the diagram type will be automatically set to DiagramEditor. But when you edit any existing diagrams, you need to call DiagramEditor#setDiagram(IDiagram diagram) and set the diagram type.

Editting Presentation Viewpoint

Diagram Editor Editable diagrams
ClassDiagramEditor Class Diagram
UseCaseDiagramEditor UseCase Diagram
StateMachineDiagramEditor StateMachine Diagram
ActivityDiagramEditor Activity Diagram, Flowchart
SequenceDiagramEditor Sequence Diagram
CompositeStructureDiagramEditor Composite Structure Diagram
RequirementDiagramEditor Requirement Diagram
ERDiagramEditor ER Diagram
MindmapEditor Mindmap

Create a Class diagram

Create a Class Presentation

Create an Action in Activity Diagram

Here’s an example to create an Action in Activity Diagram. When you create a presentation that requires a Model as 1:1, the model would be automatically created as you create a presentation.

Delete presentations

Change Property of presentation

To change the presentation such as background color etc…etc, use PresentationPropertyConstants or PresentationPropertyUtil.
For correspondence between model and presentation, please see Supported presentation list.

Presentation Interface

Change Color

Relocate