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 public class PartialFlowDataEditPart 34 extends AbstractGraphicalEditPart 35 implements PropertyChangeListener { 36 37 38 41 public void propertyChange(PropertyChangeEvent evt) { 42 if (evt.getPropertyName().equals(CFGElement.PART_FLOW_CHILDREN)){ 43 refreshChildren(); 44 refreshVisuals(); 45 } 46 } 47 48 49 protected void refreshVisuals(){ 50 Iterator it = getChildren().iterator(); 51 while (it.hasNext()){ 52 Object next = it.next(); 53 if (next instanceof FlowInfoEditPart){ 54 ((CFGPartialFlowFigure)getFigure()).add(((FlowInfoEditPart)next).getFigure()); 55 } 56 57 } 58 } 59 60 61 public void updateSize(int width){ 62 int w = ((CFGPartialFlowFigure)getFigure()).getBounds().width; 63 64 w += width; 65 66 ((FlowDataEditPart)getParent()).updateSize(w+10); 67 ((CFGPartialFlowFigure)getFigure()).setSize(w+10, getFigure().getBounds().height); 68 69 } 70 71 public void resetChildColors(){ 72 Iterator it = getChildren().iterator(); 73 while (it.hasNext()){ 74 Object next = it.next(); 75 if (next instanceof FlowInfoEditPart){ 76 ((FlowInfoEditPart)next).resetColors(); 77 } 78 } 79 } 80 81 84 protected IFigure createFigure() { 85 return new CFGPartialFlowFigure(); 86 } 87 88 91 protected void createEditPolicies() { 92 93 } 94 95 public List getModelChildren(){ 96 return getPartialFlowData().getChildren(); 97 } 98 99 public void activate(){ 100 super.activate(); 101 getPartialFlowData().addPropertyChangeListener(this); 102 } 103 104 public void deactivate(){ 105 super.deactivate(); 106 getPartialFlowData().removePropertyChangeListener(this); 107 } 108 111 public CFGPartialFlowData getPartialFlowData() { 112 return (CFGPartialFlowData)getModel(); 113 } 114 115 116 public void handleClickEvent(Object evt){ 117 System.out.println(getParent().getClass()); 118 ((FlowDataEditPart)getParent()).handleClickEvent(evt); 119 } 120 } 121 | Popular Tags |