KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.beans.PropertyChangeEvent JavaDoc;
11 import java.util.List JavaDoc;
12
13 import org.eclipse.gef.EditPolicy;
14 import org.eclipse.gef.RootEditPart;
15 import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
16
17 import com.nightlabs.editor2d.DrawComponentContainer;
18 import com.nightlabs.editor2d.editpolicy.DrawComponentContainerEditPolicy;
19 import com.nightlabs.editor2d.editpolicy.tree.DrawComponentTreeContainerEditPolicy;
20
21 public abstract class DrawComponentContainerTreeEditPart
22 extends DrawComponentTreeEditPart
23 {
24   /**
25    * Constructor initializes this with the given model.
26    *
27    * @param model Model for this.
28    */

29 // public DrawComponentContainerTreeEditPart(DrawComponentContainer model, FilterManager filterMan) {
30
// super(model);
31
// this.filterMan = filterMan;
32
// }
33
public DrawComponentContainerTreeEditPart(DrawComponentContainer model) {
34     super(model);
35   }
36   
37 // protected FilterManager filterMan;
38
// public FilterManager getFilterMan() {
39
// return filterMan;
40
// }
41

42   /**
43    * Creates and installs pertinent EditPolicies.
44    */

45   protected void createEditPolicies()
46   {
47     super.createEditPolicies();
48     installEditPolicy(EditPolicy.CONTAINER_ROLE, new DrawComponentContainerEditPolicy());
49     installEditPolicy(EditPolicy.TREE_CONTAINER_ROLE, new DrawComponentTreeContainerEditPolicy());
50     //If this editpart is the contents of the viewer, then it is not deletable!
51
if (getParent() instanceof RootEditPart)
52         installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy());
53   }
54
55   /**
56    * Returns the model of this as a LogicDiagram.
57    *
58    * @return Model of this.
59    */

60   protected DrawComponentContainer getDrawComponentContainer() {
61     return (DrawComponentContainer)getModel();
62   }
63
64   /**
65    * Returns the children of this from the model,
66    * as this is capable enough of holding EditParts.
67    *
68    * @return List of children.
69    */

70   protected List JavaDoc getModelChildren()
71   {
72     return getDrawComponentContainer().getDrawComponents();
73   }
74   
75     protected void propertyChanged(PropertyChangeEvent JavaDoc evt)
76     {
77         super.propertyChanged(evt);
78         String JavaDoc propertyName = evt.getPropertyName();
79         if (propertyName.equals(DrawComponentContainer.CHILD_ADDED)) {
80             LOGGER.debug(propertyName);
81             refreshChildren();
82         }
83         else if (propertyName.equals(DrawComponentContainer.CHILD_REMOVED)) {
84             LOGGER.debug(propertyName);
85             refreshChildren();
86         }
87     }
88   
89 // /**
90
// * Returns the children of this from the model,
91
// * as this is capable enough of holding EditParts.
92
// *
93
// * @return List of children.
94
// */
95
// protected List getModelChildren()
96
// {
97
// if (!getFilterMan().isAllFilterSet()) {
98
// List filterChildren = new ArrayList();
99
// for (Iterator itFilter = getFilterMan().getFilters().iterator(); itFilter.hasNext(); ) {
100
// Class filter = (Class) itFilter.next();
101
// for (Iterator it = getDrawComponentContainer().getDrawComponents().iterator(); it.hasNext(); ) {
102
// DrawComponent dc = (DrawComponent) it.next();
103
// if (filter.isAssignableFrom(dc.getClass())) {
104
// filterChildren.add(dc);
105
// }
106
// }
107
// }
108
// return filterChildren;
109
// }
110
// else {
111
// return getDrawComponentContainer().getDrawComponents();
112
// }
113
// }
114

115 }
116
Popular Tags