1 8 package com.nightlabs.editor2d.edit.tree; 9 10 import java.beans.PropertyChangeEvent ; 11 import java.util.List ; 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 29 public DrawComponentContainerTreeEditPart(DrawComponentContainer model) { 34 super(model); 35 } 36 37 42 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 (getParent() instanceof RootEditPart) 52 installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy()); 53 } 54 55 60 protected DrawComponentContainer getDrawComponentContainer() { 61 return (DrawComponentContainer)getModel(); 62 } 63 64 70 protected List getModelChildren() 71 { 72 return getDrawComponentContainer().getDrawComponents(); 73 } 74 75 protected void propertyChanged(PropertyChangeEvent evt) 76 { 77 super.propertyChanged(evt); 78 String 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 115 } 116 | Popular Tags |