Search in sources :

Example 11 with IDiagramModelGroup

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;
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) EObject(org.eclipse.emf.ecore.EObject) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IObjectUIProvider(com.archimatetool.editor.ui.factory.IObjectUIProvider)

Example 12 with IDiagramModelGroup

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;
}
Also used : ISketchModelActor(com.archimatetool.model.ISketchModelActor) Color(org.eclipse.swt.graphics.Color) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) ISketchModelSticky(com.archimatetool.model.ISketchModelSticky) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup)

Example 13 with IDiagramModelGroup

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());
}
Also used : ICreationFactory(com.archimatetool.editor.diagram.ICreationFactory) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) Test(org.junit.Test)

Example 14 with IDiagramModelGroup

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());
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) Test(org.junit.Test)

Example 15 with IDiagramModelGroup

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());
}
Also used : GroupEditPart(com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) GroupEditPart(com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart) Test(org.junit.Test)

Aggregations

IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)20 Test (org.junit.Test)14 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 IArchimateModel (com.archimatetool.model.IArchimateModel)4 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)4 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)3 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IDiagramModel (com.archimatetool.model.IDiagramModel)3 IDiagramModelNote (com.archimatetool.model.IDiagramModelNote)3 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)3 EditPart (org.eclipse.gef.EditPart)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)2 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2 ICreationFactory (com.archimatetool.editor.diagram.ICreationFactory)1 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)1 GroupEditPart (com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart)1 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)1 IObjectUIProvider (com.archimatetool.editor.ui.factory.IObjectUIProvider)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1