use of com.archimatetool.model.IDiagramModelGroup in project archi by archimatetool.
the class SketchEditPartFactory method createEditPart.
public EditPart createEditPart(EditPart context, Object model) {
if (model == null) {
return null;
}
EditPart child = null;
IObjectUIProvider provider = null;
// Exceptions to the rule...
if (model instanceof IDiagramModelReference) {
child = new SketchDiagramModelReferenceEditPart();
} else if (model instanceof IDiagramModelGroup) {
child = new SketchGroupEditPart();
} else if (model instanceof EObject) {
provider = ObjectUIFactory.INSTANCE.getProviderForClass(((EObject) model).eClass());
if (provider != null) {
child = provider.createEditPart();
}
}
/*
* It's better to return an Empty Edit Part in case of a corrupt model.
* Returning null is disastrous and means the Diagram View won't open.
*/
if (child == null) {
// $NON-NLS-1$
Logger.logError("Could not create EditPart for: " + model);
child = new EmptyEditPart();
}
// Set the Model in the Edit part
child.setModel(model);
return child;
}
use of com.archimatetool.model.IDiagramModelGroup 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;
}
use of com.archimatetool.model.IDiagramModelGroup in project archi by archimatetool.
the class SketchModelFactoryTests method testGetNewObjectGroup.
@Test
public void testGetNewObjectGroup() {
ICreationFactory factory = new SketchModelFactory(IArchimatePackage.eINSTANCE.getDiagramModelGroup());
IDiagramModelGroup group = (IDiagramModelGroup) factory.getNewObject();
assertEquals("Group", group.getName());
}
use of com.archimatetool.model.IDiagramModelGroup in project archi by archimatetool.
the class ArchimateDiagramModelFactoryTests method testGetNewObjectGroup.
@Test
public void testGetNewObjectGroup() {
ICreationFactory factory = new ArchimateDiagramModelFactory(IArchimatePackage.eINSTANCE.getDiagramModelGroup());
IDiagramModelGroup group = (IDiagramModelGroup) factory.getNewObject();
assertEquals("Group", group.getName());
}
use of com.archimatetool.model.IDiagramModelGroup in project archi by archimatetool.
the class ArchimateDiagramEditPartFactoryTests method testGroupEditPart.
@Test
public void testGroupEditPart() {
IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
EditPart editPart = editPartFactory.createEditPart(null, group);
assertTrue(editPart instanceof GroupEditPart);
assertEquals(group, editPart.getModel());
}
Aggregations