Search in sources :

Example 1 with PaintFormat

use of com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat in project archi by archimatetool.

the class FormatPainterInfoTests method testReset.

@Test
public void testReset() {
    PaintFormat pf = info.getPaintFormat();
    assertNull(pf);
    IDiagramModelArchimateObject sourceComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    info.updatePaintFormat(sourceComponent);
    pf = info.getPaintFormat();
    assertNotNull(pf);
    info.reset();
    pf = info.getPaintFormat();
    assertNull(pf);
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 2 with PaintFormat

use of com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat in project archi by archimatetool.

the class FormatPainterToolTests method testCreateCommandForDiagramModelArchimateObject.

// ---------------------------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------------------------
@Test
public void testCreateCommandForDiagramModelArchimateObject() throws Exception {
    // Source component
    IDiagramModelArchimateObject sourceComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    // Target component
    IDiagramModelArchimateObject targetComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    // Set FormatPainterInfo to Source component
    FormatPainterInfo.INSTANCE.updatePaintFormat(sourceComponent);
    PaintFormat pf = FormatPainterInfo.INSTANCE.getPaintFormat();
    // Execute command
    FormatPainterTool tool = new FormatPainterTool();
    CompoundCommand compoundCmd = tool.createCommand(pf, targetComponent);
    // Source and Target have same properties except for fill color so only one command
    assertEquals(1, compoundCmd.getCommands().size());
    // Fill Color should be set even if fill colour source is null (default)
    Command cmd = (Command) compoundCmd.getCommands().get(0);
    assertTrue(cmd instanceof FillColorCommand);
    Object newValue = TestUtils.getPrivateField(cmd, "fNewValue");
    assertEquals("#ffffb5", newValue);
    // Now change some properties on the source component
    sourceComponent.setFont("Consolas");
    sourceComponent.setFontColor("#eeeeee");
    sourceComponent.setLineColor("#eeeeee");
    sourceComponent.setLineWidth(3);
    sourceComponent.setTextAlignment(1);
    compoundCmd = tool.createCommand(pf, targetComponent);
    assertEquals(6, compoundCmd.getCommands().size());
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) FillColorCommand(com.archimatetool.editor.diagram.commands.FillColorCommand) Command(org.eclipse.gef.commands.Command) FillColorCommand(com.archimatetool.editor.diagram.commands.FillColorCommand) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Test(org.junit.Test)

Example 3 with PaintFormat

use of com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat in project archi by archimatetool.

the class FormatPainterTool method handleButtonUp.

@Override
protected boolean handleButtonUp(int button) {
    if (button == 1) {
        Point pt = getLocation();
        EditPart editpart = getCurrentViewer().findObjectAt(pt);
        if (editpart != null && editpart.getModel() != null) {
            Object object = editpart.getModel();
            if (isPaintableObject(object)) {
                PaintFormat pf = FormatPainterInfo.INSTANCE.getPaintFormat();
                if (pf == null) {
                    FormatPainterInfo.INSTANCE.updatePaintFormat((IDiagramModelComponent) object);
                } else if (!isObjectLocked(object)) {
                    Command cmd = createCommand(pf, (IDiagramModelComponent) object);
                    if (cmd.canExecute()) {
                        executeCommand(cmd);
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) FontStyleCommand(com.archimatetool.editor.diagram.commands.FontStyleCommand) DiagramModelObjectAlphaCommand(com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) BorderColorCommand(com.archimatetool.editor.diagram.commands.BorderColorCommand) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) FontColorCommand(com.archimatetool.editor.diagram.commands.FontColorCommand) TextAlignmentCommand(com.archimatetool.editor.diagram.commands.TextAlignmentCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) FillColorCommand(com.archimatetool.editor.diagram.commands.FillColorCommand) LineColorCommand(com.archimatetool.editor.diagram.commands.LineColorCommand) Command(org.eclipse.gef.commands.Command) EditPart(org.eclipse.gef.EditPart) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) ILineObject(com.archimatetool.model.ILineObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IBorderObject(com.archimatetool.model.IBorderObject) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with PaintFormat

use of com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat in project archi by archimatetool.

the class FormatPainterInfoTests method testGetPaintFormat.

// ---------------------------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------------------------
@Test
public void testGetPaintFormat() {
    // Should be null initially
    PaintFormat pf = info.getPaintFormat();
    assertNull(pf);
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) Test(org.junit.Test)

Example 5 with PaintFormat

use of com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat in project archi by archimatetool.

the class FormatPainterInfoTests method testUpdatePaintFormat.

@Test
public void testUpdatePaintFormat() {
    // Set FormatPainterInfo to Source component
    IDiagramModelArchimateObject sourceComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    info.updatePaintFormat(sourceComponent);
    PaintFormat pf = info.getPaintFormat();
    assertNotNull(pf);
    assertEquals(sourceComponent, pf.getSourceComponent());
    // Check cursor
    assertEquals(new RGB(255, 255, 181), pf.getCursorColor());
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) RGB(org.eclipse.swt.graphics.RGB) Test(org.junit.Test)

Aggregations

PaintFormat (com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat)6 Test (org.junit.Test)5 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)4 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 FillColorCommand (com.archimatetool.editor.diagram.commands.FillColorCommand)2 Command (org.eclipse.gef.commands.Command)2 BorderColorCommand (com.archimatetool.editor.diagram.commands.BorderColorCommand)1 ConnectionTextPositionCommand (com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)1 DiagramModelObjectAlphaCommand (com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand)1 FontColorCommand (com.archimatetool.editor.diagram.commands.FontColorCommand)1 FontStyleCommand (com.archimatetool.editor.diagram.commands.FontStyleCommand)1 LineColorCommand (com.archimatetool.editor.diagram.commands.LineColorCommand)1 LineWidthCommand (com.archimatetool.editor.diagram.commands.LineWidthCommand)1 TextAlignmentCommand (com.archimatetool.editor.diagram.commands.TextAlignmentCommand)1 TextPositionCommand (com.archimatetool.editor.diagram.commands.TextPositionCommand)1 IBorderObject (com.archimatetool.model.IBorderObject)1 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)1 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 ILineObject (com.archimatetool.model.ILineObject)1