Math2mat
|
00001 00018 package m2m.frontend.dynamicview.editPart; 00019 00020 import java.beans.PropertyChangeEvent; 00021 import java.util.Vector; 00022 00023 import m2m.frontend.dynamicview.editpolicies.EditLayoutPolicy; 00024 import m2m.frontend.dynamicview.figure.IfFigure; 00025 import m2m.frontend.dynamicview.model.GraphicIf; 00026 import m2m.frontend.dynamicview.model.Node; 00027 00028 import org.eclipse.draw2d.IFigure; 00029 import org.eclipse.gef.EditPolicy; 00030 00031 00032 public class IfPart extends AbstractEditPart 00033 { 00038 @Override 00039 protected IFigure createFigure() 00040 { 00041 IFigure figure = new IfFigure(); 00042 ((IfFigure) figure).addMouseMotionListener(this); 00043 ((IfFigure) figure).addMouseListener(this); 00044 return figure; 00045 } 00046 00047 00051 @Override 00052 protected void createEditPolicies() 00053 { 00054 installEditPolicy(EditPolicy.LAYOUT_ROLE, new EditLayoutPolicy()); 00055 } 00056 00057 00061 protected void refreshVisuals() 00062 { 00063 /* Get the figure and the model */ 00064 IfFigure figure = (IfFigure)getFigure(); 00065 GraphicIf model = (GraphicIf)getModel(); 00066 00067 /* Update the figure with the model */ 00068 figure.setLayout(model.getLayout()); 00069 figure.setVisible(model.getVisible()); 00070 } 00071 00072 00077 public Vector<Node> getModelChildren() 00078 { 00079 return ((GraphicIf)getModel()).getChildrenArray(); 00080 } 00081 00082 00087 @Override 00088 public void propertyChange(PropertyChangeEvent evt) 00089 { 00090 if (evt.getPropertyName().equals(Node.LAYOUT)) 00091 refreshVisuals(); 00092 else if(evt.getPropertyName().equals(Node.VISIBLE_COMPONENT)) 00093 refreshVisuals(); 00094 } 00095 }