Every diagram has a diagram type and this type should be provided during diagram creation.
An example shows how to create and add a diagram to a parent element:
Project project = ...; Package parent = project.getPrimaryModel(); // create a new session SessionManager.getInstance().createSession(project, "Create a diagram"); try { //a class diagram is created and added to a parent model element Diagram diagram = ModelElementsManager.getInstance().createDiagram(DiagramTypeConstants.UML_CLASS_DIAGRAM, parent); //open a diagram project.getDiagram(diagram).open(); } catch (ReadOnlyElementException e) { } SessionManager.getInstance().closeSession(project);
Related pages