Search in sources :

Example 1 with EmptyEditPart

use of com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart in project archi by archimatetool.

the class ArchimateDiagramEditPartFactory method createEditPart.

public EditPart createEditPart(EditPart context, Object model) {
    if (model == null) {
        return null;
    }
    EditPart child = null;
    IObjectUIProvider provider = null;
    if (model instanceof EObject) {
        provider = ObjectUIFactory.INSTANCE.getProvider(((EObject) model));
    }
    // We have a provider
    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 : EObject(org.eclipse.emf.ecore.EObject) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IObjectUIProvider(com.archimatetool.editor.ui.factory.IObjectUIProvider)

Example 2 with EmptyEditPart

use of com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart 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 3 with EmptyEditPart

use of com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart in project archi by archimatetool.

the class ArchimateDiagramEditPartFactoryTests method testEmptyEditPart.

@Test
public void testEmptyEditPart() {
    Logger.enabled = false;
    assertTrue(editPartFactory.createEditPart(null, new Object()) instanceof EmptyEditPart);
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) Test(org.junit.Test)

Example 4 with EmptyEditPart

use of com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart in project archi by archimatetool.

the class CanvasModelEditPartFactory method createEditPart.

public EditPart createEditPart(EditPart context, Object model) {
    if (model == null) {
        return null;
    }
    EditPart child = null;
    IObjectUIProvider provider = null;
    // Diagram Model Reference is an exception to the rule
    if (model instanceof IDiagramModelReference) {
        child = new CanvasDiagramModelReferenceEditPart();
    } 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) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IObjectUIProvider(com.archimatetool.editor.ui.factory.IObjectUIProvider)

Aggregations

EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)4 IObjectUIProvider (com.archimatetool.editor.ui.factory.IObjectUIProvider)3 EObject (org.eclipse.emf.ecore.EObject)3 EditPart (org.eclipse.gef.EditPart)3 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)2 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)1 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)1 Test (org.junit.Test)1