1 8 package com.nightlabs.editor2d.edit; 9 10 import org.eclipse.gef.EditPart; 11 import org.eclipse.gef.EditPartFactory; 12 13 import com.nightlabs.editor2d.EllipseDrawComponent; 14 import com.nightlabs.editor2d.ImageDrawComponent; 15 import com.nightlabs.editor2d.Layer; 16 import com.nightlabs.editor2d.LineDrawComponent; 17 import com.nightlabs.editor2d.MultiLayerDrawComponent; 18 import com.nightlabs.editor2d.RectangleDrawComponent; 19 import com.nightlabs.editor2d.TextDrawComponent; 20 21 public class GraphicalEditPartFactory 22 implements EditPartFactory 23 { 24 27 public GraphicalEditPartFactory() 28 { 29 super(); 30 } 31 32 35 public EditPart createEditPart(EditPart context, Object model) 36 { 37 if(model instanceof MultiLayerDrawComponent) 38 return new MultiLayerDrawComponentEditPart((MultiLayerDrawComponent)model); 39 40 else if (model instanceof Layer) 41 return new LayerEditPart((Layer)model, (MultiLayerDrawComponentEditPart)context); 42 43 else if (model instanceof EllipseDrawComponent) 44 return new EllipseEditPart((EllipseDrawComponent)model); 45 46 else if (model instanceof RectangleDrawComponent) 47 return new RectangleEditPart((RectangleDrawComponent)model); 48 49 else if (model instanceof LineDrawComponent) 50 return new LineEditPart((LineDrawComponent)model); 51 52 else if (model instanceof TextDrawComponent) 53 return new TextEditPart((TextDrawComponent)model); 54 55 else if (model instanceof ImageDrawComponent) 56 return new ImageEditPart((ImageDrawComponent)model); 57 58 return null; 59 } 60 61 } | Popular Tags |