Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/dynamicview/commands/OperationChangeLayoutCommand.java

Go to the documentation of this file.
00001 
00016 package m2m.frontend.dynamicview.commands;
00017 
00018 import m2m.frontend.dynamicview.ThreadRouteConnections;
00019 import m2m.frontend.dynamicview.model.GraphicOperation;
00020 import m2m.frontend.dynamicview.model.Node;
00021 
00022 import org.eclipse.draw2d.geometry.Rectangle;
00023 import org.eclipse.swt.widgets.Display;
00024 
00025 
00026 public class OperationChangeLayoutCommand extends AbstractLayoutCommand 
00027 {
00031         private GraphicOperation model;
00035         private Rectangle layoutOutPut = new Rectangle();
00036 
00037   
00038         
00042         public void execute() 
00043         {
00044                 // Set the layout of the model
00045             model.setLayout(getLayout());
00046             
00047             /* Set the layout of the output connection point */
00048                 if(model.getOutputPointConnection() != null)
00049                         model.getOutputPointConnection().setLayout(layoutOutPut);       
00050                 
00051                 // Route connections
00052                 Display.getCurrent().asyncExec(new ThreadRouteConnections());
00053         }
00054         
00055         
00060         public boolean canExecute() 
00061         {
00062                 /* Check if we can set the layout of the model */
00063         if(model.CanSetLayout(getLayout()))
00064         {                       
00065                 /* Check i we can set the layout of the output connection point */
00066                 if(model.getOutputPointConnection() == null)
00067                         return true;
00068                 layoutOutPut.x = getLayout().x -  model.getLayout().x +  model.getOutputPointConnection().getLayout().x;
00069                 layoutOutPut.y = getLayout().y -  model.getLayout().y +  model.getOutputPointConnection().getLayout().y;
00070                 layoutOutPut.height = 10;
00071                 layoutOutPut.width = 10;
00072             return model.getOutputPointConnection().CanSetLayout(layoutOutPut);
00073         }
00074         
00075         return false;
00076         }  
00077                   
00078           
00083         public void setModel(Node model) 
00084         {
00085                 this.model = (GraphicOperation)model;
00086         }
00087 }
 All Classes Namespaces Files Functions Variables Enumerations