Search in sources :

Example 1 with ICanvasModelBlock

use of com.archimatetool.canvas.model.ICanvasModelBlock in project archi by archimatetool.

the class CanvasModelFactoryTests method testGetNewObjectCanvasBlock.

@Test
public void testGetNewObjectCanvasBlock() {
    ICreationFactory factory = new CanvasModelFactory(ICanvasPackage.eINSTANCE.getCanvasModelBlock());
    ICanvasModelBlock block = (ICanvasModelBlock) factory.getNewObject();
    assertEquals("#000000", block.getBorderColor());
}
Also used : ICreationFactory(com.archimatetool.editor.diagram.ICreationFactory) ICanvasModelBlock(com.archimatetool.canvas.model.ICanvasModelBlock) Test(org.junit.Test)

Example 2 with ICanvasModelBlock

use of com.archimatetool.canvas.model.ICanvasModelBlock in project archi by archimatetool.

the class CanvasModelEditPartFactoryTests method testCanvasBlockActorEditPart.

@Test
public void testCanvasBlockActorEditPart() {
    ICanvasModelBlock block = ICanvasFactory.eINSTANCE.createCanvasModelBlock();
    EditPart editPart = editPartFactory.createEditPart(null, block);
    assertTrue(editPart instanceof CanvasBlockEditPart);
    assertEquals(block, 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) ICanvasModelBlock(com.archimatetool.canvas.model.ICanvasModelBlock) Test(org.junit.Test)

Example 3 with ICanvasModelBlock

use of com.archimatetool.canvas.model.ICanvasModelBlock in project archi by archimatetool.

the class CanvasModelFactory method getNewObject.

public Object getNewObject() {
    // Create the instance from the registered factory in case of extensions
    Object object = fTemplate.getEPackage().getEFactoryInstance().create(fTemplate);
    // Sticky
    if (object instanceof ICanvasModelSticky) {
        ICanvasModelSticky sticky = (ICanvasModelSticky) object;
        sticky.setTextPosition(ITextPosition.TEXT_POSITION_CENTRE);
        sticky.setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_CENTER);
        if (fParam instanceof Color) {
            String color = ColorFactory.convertColorToString((Color) fParam);
            sticky.setFillColor(color);
        }
        // $NON-NLS-1$
        sticky.setBorderColor("#C0C0C0");
    } else // Block
    if (object instanceof ICanvasModelBlock) {
        ICanvasModelBlock block = (ICanvasModelBlock) object;
        block.setTextPosition(ITextPosition.TEXT_POSITION_TOP);
        block.setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
        // $NON-NLS-1$
        block.setBorderColor("#000000");
    } else // Image
    if (object instanceof ICanvasModelImage) {
        ICanvasModelImage image = (ICanvasModelImage) object;
        // $NON-NLS-1$
        image.setBorderColor("#000000");
    } else // Canvas Connection
    if (object instanceof ICanvasModelConnection) {
        ICanvasModelConnection connection = (ICanvasModelConnection) object;
        if (fParam instanceof Integer) {
            connection.setType((Integer) fParam);
        }
    }
    return object;
}
Also used : ICanvasModelSticky(com.archimatetool.canvas.model.ICanvasModelSticky) ICanvasModelConnection(com.archimatetool.canvas.model.ICanvasModelConnection) Color(org.eclipse.swt.graphics.Color) ICanvasModelBlock(com.archimatetool.canvas.model.ICanvasModelBlock) ICanvasModelImage(com.archimatetool.canvas.model.ICanvasModelImage)

Example 4 with ICanvasModelBlock

use of com.archimatetool.canvas.model.ICanvasModelBlock in project archi by archimatetool.

the class CanvasModelBlock method getCopy.

@Override
public EObject getCopy() {
    ICanvasModelBlock newObject = (ICanvasModelBlock) super.getCopy();
    // need to do this!
    newObject.getChildren().clear();
    return newObject;
}
Also used : ICanvasModelBlock(com.archimatetool.canvas.model.ICanvasModelBlock)

Aggregations

ICanvasModelBlock (com.archimatetool.canvas.model.ICanvasModelBlock)4 Test (org.junit.Test)2 ICanvasModelConnection (com.archimatetool.canvas.model.ICanvasModelConnection)1 ICanvasModelImage (com.archimatetool.canvas.model.ICanvasModelImage)1 ICanvasModelSticky (com.archimatetool.canvas.model.ICanvasModelSticky)1 ICreationFactory (com.archimatetool.editor.diagram.ICreationFactory)1 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 EditPart (org.eclipse.gef.EditPart)1 Color (org.eclipse.swt.graphics.Color)1