use of com.archimatetool.canvas.model.ICanvasModelConnection in project archi by archimatetool.
the class CanvasModelFactory method getNewObject.
@Override
public Object getNewObject() {
// Create the instance from the registered factory in case of extensions
EObject object = fTemplate.getEPackage().getEFactoryInstance().create(fTemplate);
// Sticky
if (object instanceof ICanvasModelSticky) {
ICanvasModelSticky sticky = (ICanvasModelSticky) object;
if (fParam instanceof RGB) {
String color = ColorFactory.convertRGBToString((RGB) fParam);
sticky.setFillColor(color);
}
// $NON-NLS-1$
sticky.setBorderColor("#C0C0C0");
} else // Block
if (object instanceof ICanvasModelBlock) {
ICanvasModelBlock block = (ICanvasModelBlock) object;
// $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);
}
}
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(object);
if (object instanceof ITextAlignment) {
((IDiagramModelObject) object).setTextAlignment(provider.getDefaultTextAlignment());
}
if (object instanceof ITextPosition) {
((ITextPosition) object).setTextPosition(provider.getDefaultTextPosition());
}
// Add new bounds with a default user size
if (object instanceof IDiagramModelObject) {
Dimension size = provider.getDefaultSize();
((IDiagramModelObject) object).setBounds(0, 0, size.width, size.height);
}
return object;
}
use of com.archimatetool.canvas.model.ICanvasModelConnection in project archi by archimatetool.
the class CanvasModelFactoryTests method testGetNewObjectConnection.
@Test
public void testGetNewObjectConnection() {
ICreationFactory factory = new CanvasModelFactory(ICanvasPackage.eINSTANCE.getCanvasModelConnection(), 2);
ICanvasModelConnection connection = (ICanvasModelConnection) factory.getNewObject();
assertEquals("", connection.getName());
assertEquals(2, connection.getType());
}
Aggregations