KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > edit > tree > TreePartFactory


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 12.11.2004 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.edit.tree;
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 import com.nightlabs.editor2d.filter.FilterManager;
21
22
23 public class TreePartFactory
24 implements EditPartFactory
25 {
26     public TreePartFactory(FilterManager filterMan)
27     {
28         if (filterMan == null)
29             throw new IllegalArgumentException JavaDoc("Param filterMan must not be null!");
30         
31         this.filterMan = filterMan;
32     }
33     protected FilterManager filterMan;
34     
35   public EditPart createEditPart(EditPart context, Object JavaDoc model)
36   {
37     if (model instanceof MultiLayerDrawComponent)
38         return new MultiLayerDrawComponentTreeEditPart((MultiLayerDrawComponent)model, filterMan);
39
40     else if (model instanceof Layer)
41         return new LayerTreeEditPart((Layer)model);
42         
43     else if (model instanceof EllipseDrawComponent)
44         return new EllipseTreeEditPart((EllipseDrawComponent)model);
45
46     else if (model instanceof RectangleDrawComponent)
47         return new RectangleTreeEditPart((RectangleDrawComponent)model);
48
49     else if (model instanceof LineDrawComponent)
50         return new LineTreeEditPart((LineDrawComponent)model);
51
52     else if (model instanceof TextDrawComponent)
53       return new TextTreeEditPart((TextDrawComponent)model);
54     
55     else if (model instanceof ImageDrawComponent)
56       return new ImageTreeEditPart((ImageDrawComponent)model);
57     
58     return null;
59   }
60
61 }
62
Popular Tags