1 19 20 21 package ca.mcgill.sable.soot.cfg.editParts; 22 23 import java.beans.PropertyChangeEvent ; 24 import java.beans.PropertyChangeListener ; 25 26 import org.eclipse.draw2d.*; 27 import org.eclipse.gef.editparts.AbstractGraphicalEditPart; 28 import org.eclipse.gef.*; 29 import ca.mcgill.sable.soot.cfg.editpolicies.*; 30 import ca.mcgill.sable.soot.cfg.model.*; 31 import ca.mcgill.sable.soot.*; 32 import org.eclipse.swt.graphics.*; 33 import org.eclipse.swt.*; 34 35 public class FlowInfoEditPart 36 extends AbstractGraphicalEditPart 37 implements PropertyChangeListener { 38 39 Font f = new Font(null, "Arial", 8, SWT.NORMAL); 40 41 42 public FlowInfoEditPart() { 43 super(); 44 } 45 46 49 protected IFigure createFigure() { 50 return new Label(); 51 } 52 53 56 protected void createEditPolicies() { 57 installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,new FlowSelectPolicy()); 58 59 } 60 61 64 public void propertyChange(PropertyChangeEvent evt) { 65 if (evt.getPropertyName().equals(CFGElement.FLOW_INFO)){ 66 67 ((Label)getFigure()).setText(evt.getNewValue().toString()); 68 ((Label)getFigure()).setFont(f); 69 ((Label)getFigure()).setForegroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0,153,0))); 70 ((Label)getFigure()).setSize(evt.getNewValue().toString().length()*7, getFigure().getBounds().height); 71 ((PartialFlowDataEditPart)getParent()).updateSize(evt.getNewValue().toString().length()*7+10); 72 73 } 74 } 75 76 public void resetColors(){ 77 ((Label)getFigure()).setForegroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0, 0, 0))); 78 } 79 80 83 public CFGFlowInfo getFlowInfo() { 84 return (CFGFlowInfo)getModel(); 85 } 86 87 88 89 public void activate(){ 90 super.activate(); 91 getFlowInfo().addPropertyChangeListener(this); 92 } 93 94 public void deactivate(){ 95 super.deactivate(); 96 getFlowInfo().removePropertyChangeListener(this); 97 } 98 99 public void handleClickEvent(Object evt){ 100 System.out.println(getParent().getClass()); 101 ((PartialFlowDataEditPart)getParent()).handleClickEvent(evt); 102 } 103 } 104 | Popular Tags |