Search in sources :

Example 6 with IDiagramModelImage

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

the class CanvasModelEditPartFactoryTests method testDiagramImageEditPart.

@Test
public void testDiagramImageEditPart() {
    IDiagramModelImage image = IArchimateFactory.eINSTANCE.createDiagramModelImage();
    EditPart editPart = editPartFactory.createEditPart(null, image);
    assertTrue(editPart instanceof DiagramImageEditPart);
    assertEquals(image, editPart.getModel());
}
Also used : DiagramImageEditPart(com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart) DiagramConnectionEditPart(com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) DiagramImageEditPart(com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart) Test(org.junit.Test)

Example 7 with IDiagramModelImage

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

the class ArchiveManagerTests method testDispose.

@Test
public void testDispose() throws IOException {
    IDiagramModelImage dmImage = IArchimateFactory.eINSTANCE.createDiagramModelImage();
    dm.getChildren().add(dmImage);
    archiveManager.loadImagesFromModelFile(TestSupport.TEST_MODEL_FILE_ZIPPED);
    dmImage.setImagePath(archiveManager.getLoadedImagePaths().get(0));
    assertEquals(2, model.eAdapters().size());
    assertFalse(archiveManager.getLoadedImagePaths().isEmpty());
    archiveManager.dispose();
    assertEquals(1, model.eAdapters().size());
    assertTrue(archiveManager.getLoadedImagePaths().isEmpty());
}
Also used : IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) Test(org.junit.Test)

Example 8 with IDiagramModelImage

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

the class ArchiveManagerTests method testEContentAdapter.

@Test
public void testEContentAdapter() throws Exception {
    assertTrue(archiveManager.getImagePaths().isEmpty());
    IDiagramModelImage dmImage = IArchimateFactory.eINSTANCE.createDiagramModelImage();
    // Add IDiagramModelImageProvider without an image path set - should not register
    dm.getChildren().add(dmImage);
    assertTrue(archiveManager.getImagePaths().isEmpty());
    assertTrue(archiveManager.getLoadedImagePaths().isEmpty());
    dm.getChildren().remove(dmImage);
    // Add IDiagramModelImageProvider with an image path set - should register
    String imagePath = "/somePath/image.png";
    dmImage.setImagePath(imagePath);
    dm.getChildren().add(dmImage);
    assertEquals(1, archiveManager.getImagePaths().size());
    assertEquals(1, archiveManager.getLoadedImagePaths().size());
    assertEquals(imagePath, archiveManager.getImagePaths().get(0));
    // Set image path, should still only be one
    String imagePath2 = "/somePath/image2.png";
    dmImage.setImagePath(imagePath2);
    assertEquals(1, archiveManager.getImagePaths().size());
    // This should be increased
    assertEquals(2, archiveManager.getLoadedImagePaths().size());
    assertEquals(imagePath2, archiveManager.getImagePaths().get(0));
}
Also used : IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) Test(org.junit.Test)

Example 9 with IDiagramModelImage

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

the class ArchiveManagerTests method testHasImages.

@Test
public void testHasImages() {
    assertFalse(archiveManager.hasImages());
    IDiagramModelImage dmImage = IArchimateFactory.eINSTANCE.createDiagramModelImage();
    dmImage.setImagePath("somePath");
    dm.getChildren().add(dmImage);
    assertTrue(archiveManager.hasImages());
}
Also used : IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) Test(org.junit.Test)

Example 10 with IDiagramModelImage

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

the class ArchiveManagerTests method testAddImageFromFile.

@Test
public void testAddImageFromFile() throws Exception {
    IDiagramModelImage dmImage = IArchimateFactory.eINSTANCE.createDiagramModelImage();
    dm.getChildren().add(dmImage);
    // should be empty
    assertTrue(archiveManager.getLoadedImagePaths().isEmpty());
    File imgFile = new File(TestSupport.getTestDataFolder(), "/img/img1.png");
    String pathName = archiveManager.addImageFromFile(imgFile);
    assertNotNull(pathName);
    // should still be empty
    assertTrue(archiveManager.getLoadedImagePaths().isEmpty());
    dmImage.setImagePath(pathName);
    // This should now be increased
    assertEquals(pathName, archiveManager.getLoadedImagePaths().get(0));
    // This should be set
    assertEquals(pathName, archiveManager.getImagePaths().get(0));
}
Also used : IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) File(java.io.File) Test(org.junit.Test)

Aggregations

IDiagramModelImage (com.archimatetool.model.IDiagramModelImage)10 Test (org.junit.Test)9 File (java.io.File)3 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)1 DiagramImageEditPart (com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart)1 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)1 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)1 IBounds (com.archimatetool.model.IBounds)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 INameable (com.archimatetool.model.INameable)1 ISketchModel (com.archimatetool.model.ISketchModel)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 EObject (org.eclipse.emf.ecore.EObject)1 EditPart (org.eclipse.gef.EditPart)1 Image (org.eclipse.swt.graphics.Image)1