Search in sources :

Example 1 with ISketchModelSticky

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

the class SketchModelStickyTests method testGetCopy.

@Override
@Test
public void testGetCopy() {
    super.testGetCopy();
    sticky.setContent("hello");
    sticky.getProperties().add(IArchimateFactory.eINSTANCE.createProperty());
    ISketchModelSticky copy = (ISketchModelSticky) sticky.getCopy();
    assertNotSame(sticky, copy);
    assertEquals(sticky.getContent(), copy.getContent());
    assertNotSame(sticky.getChildren(), copy.getChildren());
    assertTrue(copy.getChildren().isEmpty());
    assertNotSame(sticky.getProperties(), copy.getProperties());
    assertEquals(sticky.getProperties().size(), copy.getProperties().size());
}
Also used : ISketchModelSticky(com.archimatetool.model.ISketchModelSticky) Test(org.junit.Test)

Example 2 with ISketchModelSticky

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

the class SketchModelSticky method getCopy.

@Override
public EObject getCopy() {
    ISketchModelSticky newObject = (ISketchModelSticky) super.getCopy();
    // newObject.setContent(getContent());
    newObject.getChildren().clear();
    return newObject;
}
Also used : ISketchModelSticky(com.archimatetool.model.ISketchModelSticky)

Example 3 with ISketchModelSticky

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

the class SketchModelFactoryTests method testGetNewObjectSticky.

@Test
public void testGetNewObjectSticky() {
    ICreationFactory factory = new SketchModelFactory(IArchimatePackage.eINSTANCE.getSketchModelSticky(), ColorFactory.get(201, 231, 183));
    ISketchModelSticky sticky = (ISketchModelSticky) factory.getNewObject();
    assertEquals("Sticky", sticky.getName());
    assertEquals(ColorFactory.convertColorToString(ColorFactory.get(201, 231, 183)), sticky.getFillColor());
}
Also used : ICreationFactory(com.archimatetool.editor.diagram.ICreationFactory) ISketchModelSticky(com.archimatetool.model.ISketchModelSticky) Test(org.junit.Test)

Example 4 with ISketchModelSticky

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

the class SketchModelFactory method getNewObject.

public Object getNewObject() {
    Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
    // Actor
    if (object instanceof ISketchModelActor) {
        ((ISketchModelActor) object).setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
    } else // Sticky
    if (object instanceof ISketchModelSticky) {
        ISketchModelSticky sticky = (ISketchModelSticky) object;
        sticky.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        sticky.setTextPosition(ITextPosition.TEXT_POSITION_TOP);
        sticky.setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
        if (fParam instanceof Color) {
            String color = ColorFactory.convertColorToString((Color) fParam);
            sticky.setFillColor(color);
            Color lineColor = ColorFactory.getDefaultLineColor(sticky);
            if (lineColor != null) {
                sticky.setLineColor(ColorFactory.convertColorToString(lineColor));
            }
        }
    } else // Group
    if (object instanceof IDiagramModelGroup) {
        IDiagramModelGroup group = (IDiagramModelGroup) object;
        group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        ColorFactory.setDefaultColors(group);
    } else // Connection
    if (object instanceof IDiagramModelConnection) {
        IDiagramModelConnection connection = (IDiagramModelConnection) object;
        if (fParam instanceof Integer) {
            connection.setType((Integer) fParam);
        }
        ColorFactory.setDefaultColors(connection);
    }
    return object;
}
Also used : ISketchModelActor(com.archimatetool.model.ISketchModelActor) Color(org.eclipse.swt.graphics.Color) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) ISketchModelSticky(com.archimatetool.model.ISketchModelSticky) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup)

Example 5 with ISketchModelSticky

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

the class SketchEditPartFactoryTests method testSketchStickyEditPart.

@Test
public void testSketchStickyEditPart() {
    ISketchModelSticky sticky = IArchimateFactory.eINSTANCE.createSketchModelSticky();
    EditPart editPart = editPartFactory.createEditPart(null, sticky);
    assertTrue(editPart instanceof StickyEditPart);
    assertEquals(sticky, editPart.getModel());
}
Also used : DiagramConnectionEditPart(com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) ISketchModelSticky(com.archimatetool.model.ISketchModelSticky) Test(org.junit.Test)

Aggregations

ISketchModelSticky (com.archimatetool.model.ISketchModelSticky)5 Test (org.junit.Test)3 ICreationFactory (com.archimatetool.editor.diagram.ICreationFactory)1 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)1 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)1 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)1 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)1 ISketchModelActor (com.archimatetool.model.ISketchModelActor)1 EditPart (org.eclipse.gef.EditPart)1 Color (org.eclipse.swt.graphics.Color)1