Search in sources :

Example 1 with IObjectUIProvider

use of com.archimatetool.editor.ui.factory.IObjectUIProvider 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 IObjectUIProvider

use of com.archimatetool.editor.ui.factory.IObjectUIProvider 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 IObjectUIProvider

use of com.archimatetool.editor.ui.factory.IObjectUIProvider in project archi by archimatetool.

the class FigureImagePreviewFactoryTests method testGetFigurePreviewImageForClass.

@Test
public void testGetFigurePreviewImageForClass() {
    for (IObjectUIProvider provider : ObjectUIFactory.INSTANCE.getProviders()) {
        if (provider instanceof IArchimateElementUIProvider) {
            Image image = FigureImagePreviewFactory.getFigurePreviewImageForClass(provider.providerFor());
            assertNotNull(image);
        }
    }
}
Also used : IArchimateElementUIProvider(com.archimatetool.editor.ui.factory.IArchimateElementUIProvider) Image(org.eclipse.swt.graphics.Image) IObjectUIProvider(com.archimatetool.editor.ui.factory.IObjectUIProvider) Test(org.junit.Test)

Example 4 with IObjectUIProvider

use of com.archimatetool.editor.ui.factory.IObjectUIProvider 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

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