Search in sources :

Example 11 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class EditorModelManagerTests method createNewModel_IsValid.

@Test
public void createNewModel_IsValid() {
    IArchimateModel model = editorModelManager.createNewModel();
    assertNotNull(model);
    // Has default folders
    assertFalse(model.getFolders().isEmpty());
    // Has One Default View
    // $NON-NLS-1$
    assertTrue(model.getFolder(FolderType.DIAGRAMS).getElements().get(0) instanceof IArchimateDiagramModel);
    // Has a Command Stack
    assertTrue(model.getAdapter(CommandStack.class) instanceof CommandStack);
    // Has an Archive Manager
    assertTrue(model.getAdapter(IArchiveManager.class) instanceof IArchiveManager);
    // Has an ECore Adapter
    assertTrue(hasECoreAdapter(model));
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IArchiveManager(com.archimatetool.editor.model.IArchiveManager) IArchimateModel(com.archimatetool.model.IArchimateModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 12 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class ArchiLabelProviderTests method testGetLabel.

@Test
public void testGetLabel() {
    // Null object
    assertEquals("", ArchiLabelProvider.INSTANCE.getLabel(null));
    // Any object
    assertEquals("", ArchiLabelProvider.INSTANCE.getLabel(""));
    // Nameable
    INameable nameable = IArchimateFactory.eINSTANCE.createBusinessActor();
    nameable.setName("Hello");
    assertEquals("Hello", ArchiLabelProvider.INSTANCE.getLabel(nameable));
    // View
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    assertEquals("View", ArchiLabelProvider.INSTANCE.getLabel(dm));
    // Sketch
    ISketchModel sm = IArchimateFactory.eINSTANCE.createSketchModel();
    assertEquals("Sketch", ArchiLabelProvider.INSTANCE.getLabel(sm));
    // Image
    IDiagramModelImage di = IArchimateFactory.eINSTANCE.createDiagramModelImage();
    assertEquals("Image", ArchiLabelProvider.INSTANCE.getLabel(di));
}
Also used : INameable(com.archimatetool.model.INameable) IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 13 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class CopySnapshotTests method testCanPasteToDiagram_DifferentModelDiagramReference.

@Test
public void testCanPasteToDiagram_DifferentModelDiagramReference() throws IOException {
    loadTestModel1();
    // Test can't paste IDiagramModelReference to another Archimate model
    // Source model
    IDiagramModelReference reference = IArchimateFactory.eINSTANCE.createDiagramModelReference();
    reference.setReferencedModel(model.getDiagramModels().get(0));
    sourceDiagramModel.getChildren().add(reference);
    // Target model
    IArchimateModel model2 = IArchimateFactory.eINSTANCE.createArchimateModel();
    IArchimateDiagramModel targetDiagramModel2 = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    model2.getDefaultFolderForObject(targetDiagramModel2).getElements().add(targetDiagramModel2);
    List<IDiagramModelComponent> selected = new ArrayList<IDiagramModelComponent>();
    selected.add(reference);
    CopySnapshot snapshot = new CopySnapshot(selected);
    assertFalse(snapshot.canPasteToDiagram(targetDiagramModel2));
    // Should be OK if other objects added
    selected.addAll(sourceDiagramModel.getChildren());
    snapshot = new CopySnapshot(selected);
    assertTrue(snapshot.canPasteToDiagram(targetDiagramModel2));
}
Also used : IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) ArrayList(java.util.ArrayList) IArchimateModel(com.archimatetool.model.IArchimateModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 14 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class EditorManager method openDiagramEditor.

/**
 * Open the Diagram Editor for a given DiagramModel Model
 * @param name
 */
public static IDiagramModelEditor openDiagramEditor(IDiagramModel model) {
    if (model == null || model.eContainer() == null || !PlatformUI.isWorkbenchRunning()) {
        return null;
    }
    String id = null;
    IEditorInput editorInput = null;
    if (model instanceof IArchimateDiagramModel) {
        id = IArchimateDiagramEditor.ID;
        editorInput = new DiagramEditorInput(model);
    } else if (model instanceof ISketchModel) {
        id = ISketchEditor.ID;
        editorInput = new DiagramEditorInput(model);
    } else {
        IDiagramEditorFactory factory = DiagramEditorFactoryExtensionHandler.INSTANCE.getFactory(model);
        if (factory != null) {
            id = factory.getEditorID();
            editorInput = factory.createEditorInput(model);
        }
    }
    if (id == null || editorInput == null) {
        // $NON-NLS-1$
        throw new RuntimeException("Unsupported model type");
    }
    IEditorPart part = openEditor(editorInput, id);
    // Check it actually is IDiagramModelEditor, it could be an org.eclipse.ui.internal.ErrorEditorPart if an error occurs
    return part instanceof IDiagramModelEditor ? (IDiagramModelEditor) part : null;
}
Also used : IDiagramEditorFactory(com.archimatetool.editor.diagram.IDiagramEditorFactory) DiagramEditorInput(com.archimatetool.editor.diagram.DiagramEditorInput) IEditorPart(org.eclipse.ui.IEditorPart) IDiagramModelEditor(com.archimatetool.editor.diagram.IDiagramModelEditor) IEditorInput(org.eclipse.ui.IEditorInput) ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 15 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class MagicConnectionCreationTool method isAllowedTargetTypeInViewpoint.

/**
 * @return True if type is an allowed target type for a given Viewpoint
 */
private boolean isAllowedTargetTypeInViewpoint(IDiagramModelArchimateComponent diagramComponent, EClass type) {
    if (!Preferences.STORE.getBoolean(IPreferenceConstants.VIEWPOINTS_HIDE_MAGIC_CONNECTOR_ELEMENTS)) {
        return true;
    }
    IArchimateDiagramModel dm = (IArchimateDiagramModel) diagramComponent.getDiagramModel();
    String id = dm.getViewpoint();
    IViewpoint viewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
    return viewpoint == null ? true : viewpoint.isAllowedConcept(type);
}
Also used : IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Aggregations

IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)29 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)8 IIssue (com.archimatetool.hammer.validation.issues.IIssue)6 IArchimateModel (com.archimatetool.model.IArchimateModel)6 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 IViewpoint (com.archimatetool.model.viewpoints.IViewpoint)5 EObject (org.eclipse.emf.ecore.EObject)5 AdviceType (com.archimatetool.hammer.validation.issues.AdviceType)4 ISketchModel (com.archimatetool.model.ISketchModel)4 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)3 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)3 IDiagramEditorFactory (com.archimatetool.editor.diagram.IDiagramEditorFactory)2 ArchimateDiagramEditPartFactory (com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory)2 IFolder (com.archimatetool.model.IFolder)2 FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)2 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2