1 19 20 package ca.mcgill.sable.soot.cfg.editParts; 21 22 import org.eclipse.gef.editparts.AbstractGraphicalEditPart; 23 24 import java.beans.PropertyChangeEvent ; 25 import java.beans.PropertyChangeListener ; 26 27 import org.eclipse.draw2d.*; 28 import ca.mcgill.sable.soot.cfg.figures.*; 29 import ca.mcgill.sable.soot.cfg.model.*; 30 import java.util.*; 31 import org.eclipse.draw2d.geometry.*; 32 33 34 public class FlowDataEditPart 35 extends AbstractGraphicalEditPart 36 implements PropertyChangeListener { 37 38 39 42 public void propertyChange(PropertyChangeEvent evt) { 43 if (evt.getPropertyName().equals(CFGElement.FLOW_CHILDREN)){ 44 refreshChildren(); 45 refreshVisuals(); 46 } 47 } 48 49 50 protected void refreshVisuals(){ 51 Iterator it = getChildren().iterator(); 52 while (it.hasNext()){ 53 Object next = it.next(); 54 if (next instanceof PartialFlowDataEditPart){ 55 ((CFGFlowFigure)getFigure()).add(((PartialFlowDataEditPart)next).getFigure()); 56 } 57 58 } 59 } 60 61 public void updateSize(FlowInfoEditPart childEdit, IFigure child, Rectangle rect){ 62 this.setLayoutConstraint(childEdit, child, rect); 63 ((CFGNodeEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(getFigure().getBounds().x, getFigure().getBounds().y, getFigure().getBounds().width, getFigure().getBounds().height)); } 65 66 public void updateSize(int width){ 67 int w = ((CFGFlowFigure)getFigure()).getBounds().width; 68 69 if (width > w){ 70 w = width; 71 } 72 73 int height = getChildren().size() * 20; 74 75 ((CFGNodeEditPart)getParent()).updateSize(w+10, height); 76 ((CFGFlowFigure)getFigure()).setSize(w+10, height); 77 78 } 79 80 public void resetChildColors(){ 81 Iterator it = getChildren().iterator(); 82 while (it.hasNext()){ 83 Object next = it.next(); 84 if (next instanceof PartialFlowDataEditPart){ 85 ((PartialFlowDataEditPart)next).resetChildColors(); 86 } 87 } 88 } 89 90 93 protected IFigure createFigure() { 94 return new CFGFlowFigure(); 95 } 96 97 100 protected void createEditPolicies() { 101 } 102 103 public List getModelChildren(){ 104 return getFlowData().getChildren(); 105 } 106 107 public void activate(){ 108 super.activate(); 109 getFlowData().addPropertyChangeListener(this); 110 } 111 112 public void deactivate(){ 113 super.deactivate(); 114 getFlowData().removePropertyChangeListener(this); 115 } 116 119 public CFGFlowData getFlowData() { 120 return (CFGFlowData)getModel(); 121 } 122 123 124 public void handleClickEvent(Object evt){ 125 ((CFGNodeEditPart)getParent()).handleClickEvent(evt); 126 } 127 } 128 | Popular Tags |