1 8 package com.nightlabs.editor2d.model; 9 10 import org.eclipse.gef.requests.CreationFactory; 11 12 import com.nightlabs.editor2d.DrawComponentContainer; 13 import com.nightlabs.editor2d.Editor2DFactory; 14 import com.nightlabs.editor2d.EditorGuide; 15 import com.nightlabs.editor2d.EditorRuler; 16 import com.nightlabs.editor2d.EllipseDrawComponent; 17 import com.nightlabs.editor2d.ImageDrawComponent; 18 import com.nightlabs.editor2d.Layer; 19 import com.nightlabs.editor2d.LineDrawComponent; 20 import com.nightlabs.editor2d.MultiLayerDrawComponent; 21 import com.nightlabs.editor2d.RectangleDrawComponent; 22 import com.nightlabs.editor2d.TextDrawComponent; 23 24 public class ModelCreationFactory 25 implements CreationFactory 26 { 27 protected Class targetClass; 28 29 public ModelCreationFactory( Class targetClass ) { 30 this.targetClass = targetClass; 31 } 32 33 36 public Object getNewObject() 37 { 38 44 Editor2DFactory factory = Editor2DFactory.eINSTANCE; 45 46 Object result = null; 47 48 if( targetClass.equals(RectangleDrawComponent.class)) { 49 result = factory.createRectangleDrawComponent(); 50 } 51 else if( targetClass.equals(Layer.class)) { 52 result = factory.createLayer(); 53 } 54 else if( targetClass.equals(EllipseDrawComponent.class)) { 55 result = factory.createEllipseDrawComponent(); 56 } 57 else if( targetClass.equals(MultiLayerDrawComponent.class)) { 58 result = factory.createMultiLayerDrawComponent(); 59 } 60 else if (targetClass.equals(DrawComponentContainer.class)) { 61 result = factory.createDrawComponentContainer(); 62 } 63 else if( targetClass.equals(EditorGuide.class)) { 64 result = factory.createEditorGuide(); 65 } 66 else if ( targetClass.equals(EditorRuler.class)) { 67 result = factory.createEditorRuler(); 68 } 69 else if ( targetClass.equals(LineDrawComponent.class)) { 70 result = factory.createLineDrawComponent(); 71 } 72 else if ( targetClass.equals(TextDrawComponent.class)) { 73 result = factory.createTextDrawComponent(); 74 } 75 else if ( targetClass.equals(ImageDrawComponent.class)) { 76 result = factory.createImageDrawComponent(); 77 } 78 79 return result; 80 } 81 82 85 public Object getObjectType() 86 { 87 return targetClass; 88 } 89 } 90 91 | Popular Tags |