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;
}
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;
}
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);
}
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;
}
Aggregations