Math2mat

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

Go to the documentation of this file.
00001 
00017 package m2m.frontend.dynamicview.editPart;
00018 
00019 import java.beans.PropertyChangeListener;
00020 import java.util.List;
00021 
00022 import m2m.frontend.dynamicview.model.GraphicOperation;
00023 import m2m.frontend.dynamicview.model.Node;
00024 import m2m.frontend.dynamicview.model.Schema;
00025 
00026 import org.eclipse.draw2d.*;
00027 import org.eclipse.gef.*;
00028 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
00029 
00030 
00031 public abstract class AbstractEditPart extends AbstractGraphicalEditPart implements PropertyChangeListener, NodeEditPart, MouseMotionListener, MouseListener
00032 {       
00036     public void activate() 
00037     {
00038         super.activate();
00039         ((Node) getModel()).addPropertyChangeListener(this);
00040     }
00041 
00042     
00046     public void deactivate()
00047     {
00048         super.deactivate();
00049         ((Node) getModel()).removePropertyChangeListener(this);
00050     }
00051     
00052     
00057     @SuppressWarnings("rawtypes")
00058         protected List getModelSourceConnections() 
00059         {
00060                 return ((Node) getModel()).getSourceConnections();
00061         }
00062            
00063          
00068         @SuppressWarnings("rawtypes")
00069         protected List getModelTargetConnections() 
00070         {
00071             return ((Node) getModel()).getTargetConnections();
00072         }
00073            
00074         
00080         public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) 
00081         {
00082                 if (getModel() instanceof GraphicOperation)
00083                         return new EllipseAnchor(getFigure());
00084                 else
00085                         return new ChopboxAnchor(getFigure());
00086         }
00087           
00088         
00094         public ConnectionAnchor getSourceConnectionAnchor(Request request) 
00095         {
00096                 if (getModel() instanceof GraphicOperation)
00097                         return new EllipseAnchor(getFigure());
00098                 else
00099                         return new ChopboxAnchor(getFigure());
00100         }
00101         
00102         
00108         @Override
00109         public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) 
00110         {
00111                 if (getModel() instanceof GraphicOperation)
00112                         return new EllipseAnchor(getFigure());
00113                 else
00114                         return new ChopboxAnchor(getFigure());
00115         }
00116         
00117         
00123         @Override
00124         public ConnectionAnchor getTargetConnectionAnchor(Request request) 
00125         {
00126                 if (getModel() instanceof GraphicOperation)
00127                         return new EllipseAnchor(getFigure());
00128                 else
00129                         return new ChopboxAnchor(getFigure());
00130         }
00131         
00132         
00137         @Override
00138         public void mouseEntered(MouseEvent evt) 
00139         {
00140                 // Get the root editPart
00141                 Schema schema = (Schema)((SchemaPart)getRoot().getContents()).getModel();
00142                 
00143                 /* Change the selected node if the properties aren't lock */
00144             if(!schema.getPropertyLock())
00145                 schema.setSelectedNode((Node) getModel());                      
00146         }
00147 
00148 
00153         @Override
00154         public void mousePressed(MouseEvent evt) 
00155         {
00156                 // Get the node model
00157                 Node node = (Node) getModel();
00158                 
00159                 // Get the root editPart
00160                 Schema schema = (Schema)((SchemaPart)getRoot().getContents()).getModel();
00161                 
00162                 /* Lock/Unlock properties */
00163                 if(node instanceof Schema)
00164                         ((Schema)node).setPropertyLock(false);
00165                 else
00166                     schema.setPropertyLock(true);
00167                 
00168                 // Change the selected node
00169                 schema.setSelectedNode(node);   
00170         }
00171 
00172 
00173         @Override
00174         public void mouseReleased(MouseEvent arg0) {
00175                 // TODO Auto-generated method stub
00176         }
00177         
00178         
00179         @Override
00180         public void mouseExited(MouseEvent arg0) {
00181                 // TODO Auto-generated method stub
00182                 
00183         }
00184 
00185 
00186         @Override
00187         public void mouseHover(MouseEvent arg0) {
00188                 // TODO Auto-generated method stub
00189                 
00190         }
00191 
00192 
00193         @Override
00194         public void mouseMoved(MouseEvent arg0) {
00195                 // TODO Auto-generated method stub
00196                 
00197         }
00198         
00199         
00200         @Override
00201         public void mouseDragged(MouseEvent arg0) {
00202                 // TODO Auto-generated method stub
00203                 
00204         }
00205         
00206 
00207         @Override
00208         public void mouseDoubleClicked(MouseEvent arg0) {
00209                 // TODO Auto-generated method stub
00210         }
00211 }
 All Classes Namespaces Files Functions Variables Enumerations