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);
}
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());
}
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;
}
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);
}
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());
}
Aggregations