Astah API User Guide
  • Java Doc
  • Plug-ins
  • Script Editor
Astah - Software Design Tools for Agile teams with UML, ER Diagram, Flowchart, Mindmap and More | Astah.net
  • Introduction Open "Introduction"
    • About Astah API
    • Agreements
    • Requirements
    • Notes
    • Try Script Editor
    • Model and Presentation
  • Access project Open "Access project"
    • How to access a project
    • Get project models
  • Get Models and Presentations Open "Get Models and Presentations"
    • Get Models
      • Find models in a project
      • Get a model selected in the structure tree
      • Get a model selected on the diagram
      • Associations
      • Dependencies
      • Template Classes
      • Packages - recursively
      • Classes under Packages
      • Namespace of Class
      • Activity Diagram Models
      • Sequence Diagram Models
      • Statemachine Diagram Models
      • TaggedValues
      • Stereotypes
      • Alias
    • Get Diagrams and Presentations
      • Get Diagrams
      • Get all presentations in the diagram
      • Get presentation from model
      • Get presentation of selected model on the diagram
      • Alias from presentation
  • Edit Models and Presentations Open "Edit Models and Presentations"
    • Transaction process
    • Edit model
      • Model Editor
      • Create a Class under package
      • Create TaggedValues
      • Delete Models
      • Add Definition
      • Add Stereotypes
    • Edit Presentations
      • Diagram Editor
      • Create a Class diagram
      • Create a Class Presentation
      • Create an Action in Activity Diagram
      • Delete presentations
      • Change Property of presentation
        • Change Color
        • Relocate
  • Manage View Open "Manage View"
    • View Manager
    • Example
  • Supported model / Presentation list Open "Supported model / Presentation list"
    • Supported Models
      • Class Diagram
      • UseCase Diagram
      • Statemachine Diagram
      • Activity Diagram
      • Flowchart
      • Sequence Diagram
      • Communication Diagram
      • Composite Structure Diagram
      • ER Diagram
      • DFD
      • CRUD
      • Mind Map
      • Requirement Diagram
      • Requirement Table
      • Other
    • Presentation list
      • Common Diagram Elements
      • Class / Composite Structure Diagram
      • UseCase Diagram
      • Statemachine Diagram
      • Activity Diagram
      • Sequence / Communication Diagram
      • Flowchart
      • DFD
      • Requirement Diagram
      • ER Diagram
      • Mind Map
      • CRUD
  • Advanced use Open "Advanced use"
    • XML Input/Output
    • Reference Model Management
    • Easy Merge
    • Programming Language
      • Get language information
      • Set language
      • Find out language info1
      • Find out language info2
  • Sample Open "Sample"
    • Sample application
      • Sample composition
      • Compile and running
    • Samples on Blog
    • More sample code
      • Create a Class

Access project

To get or modify models using Astah API, you need to access the project first.

How to access a project

In order to access a project, you need to use ProjectAccessor.

You can access only one project at a time. So when you want to edit more than one project, make sure you open only one project at a time, and close before you move to another. Here’s a sample for how to use ProjectAccessor.

// Getting ProjectAccessor
ProjectAccessor projectAccessor = AstahAPI.getAstahAPI().getProjectAccessor();

try {

    // Register a project
    if (new File(PROJECT_PATH).exists()) {
        System.out.println("Opening Project : " + PROJECT_PATH);
        projectAccessor.open(PROJECT_PATH);
    } else {
        System.out.println("Creating Project : " + PROJECT_PATH);
        projectAccessor.create(PROJECT_PATH);
        projectAccessor.save();
    }

    // Reference process

    // Editing process

    // Save the project
    if (!projectAccessor.isProjectModified()) {
        return;
    }
    System.out.println("Save the project.");
    projectAccessor.save();

} finally {

    // Close a Project
    projectAccessor.close();
    System.out.println("Closed the project.");

}

Get project models

All the models and presentations exist in the Project Model which can be accessed by calling ProjectAccessor#getProject().

public IModel getProjectModel(ProjectAccessor projectAccessor) throws ProjectNotFoundException {
    return projectAccessor.getProject();
}
Copyright(C) 2010-2019 Change Vision, Inc. All rights reserved.
Copyright(C) 2010-2019 Change Vision, Inc. All rights reserved.