Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/dynamicview/editPart/PropertyPart.java

Go to the documentation of this file.
00001 
00017 package m2m.frontend.dynamicview.editPart;
00018 
00019 import java.beans.PropertyChangeEvent;
00020 import java.beans.PropertyChangeListener;
00021 
00022 import m2m.frontend.dynamicview.figure.PropertyFigure;
00023 import m2m.frontend.dynamicview.model.GraphicIf;
00024 import m2m.frontend.dynamicview.model.GraphicLoopIterator;
00025 import m2m.frontend.dynamicview.model.Node;
00026 import m2m.frontend.dynamicview.model.Schema;
00027 
00028 import org.eclipse.draw2d.IFigure;
00029 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
00030 
00031 
00032 public class PropertyPart extends AbstractGraphicalEditPart implements PropertyChangeListener
00033 {
00037     public void activate() 
00038     {
00039         super.activate();
00040         ((Node) getModel()).addPropertyChangeListener(this);
00041     }
00042 
00043     
00047     public void deactivate()
00048     {
00049         super.deactivate();
00050         ((Node) getModel()).removePropertyChangeListener(this);
00051     }
00052     
00053     
00058         @Override
00059         protected IFigure createFigure() 
00060         {
00061         IFigure figure = new PropertyFigure((Schema)getModel());
00062         return figure;
00063         }
00064 
00065         
00069     protected void refreshVisuals()
00070     { 
00071         /* Get the figure and the model */
00072         PropertyFigure figure = (PropertyFigure)getFigure();
00073         Schema model = (Schema)getModel();
00074         
00075         /* Set the property of the selected node */
00076         if(model.getSelectedNode() != null)
00077                 figure.setProperty(model.getSelectedNode()); 
00078         /* Set the property of the selected connection */
00079         else if(model.getSelectedConnection() != null)
00080                 figure.setProperty(model.getSelectedConnection()); 
00081         
00082         /* Set the default color of conditions points selection of a GraphicIf */
00083         if(model.getLastIfSelected() != null)
00084         {
00085                 for(Node node : model.getLastIfSelected().getConditionNodes())
00086                         node.setColorConditionSelected(false);
00087                 model.setLastIfSelected(null);  
00088         }
00089         
00090         /* Change the color of conditions points selection if a GraphicIf is selected */
00091         if(model.getSelectedNode() instanceof GraphicIf)
00092         {
00093                 model.setLastIfSelected((GraphicIf)model.getSelectedNode());                    
00094                 for(Node node : ((GraphicIf)model.getSelectedNode()).getConditionNodes())
00095                         node.setColorConditionSelected(true);
00096         }
00097         
00098         /* Set the default color of conditions points selection of a GraphicLoopIterator */
00099         if(model.getLastloopIteratorSelected() != null)
00100         {
00101                 for(Node node : model.getLastloopIteratorSelected().getConditionNodes())
00102                         node.setColorConditionSelected(false);
00103                 model.setLastLoopIteratorSelected(null);        
00104         }
00105         
00106         /* Change the color of condition point selection if a GraphicLoopIterator is selected */
00107         if(model.getSelectedNode() instanceof GraphicLoopIterator)
00108         {
00109                 model.setLastLoopIteratorSelected((GraphicLoopIterator)model.getSelectedNode());                        
00110                 for(Node node : ((GraphicLoopIterator)model.getSelectedNode()).getConditionNodes())
00111                         node.setColorConditionSelected(true);
00112         }
00113     }
00114     
00115 
00120         @Override
00121         public void propertyChange(PropertyChangeEvent evt) 
00122         {
00123                  if (evt.getPropertyName().equals(Schema.PROPERTY)) 
00124                          refreshVisuals();
00125         }
00126         
00127         
00128         @Override
00129         protected void createEditPolicies() 
00130         {
00131                 // TODO Auto-generated method stub              
00132         }
00133 }
 All Classes Namespaces Files Functions Variables Enumerations