Math2mat
|
00001 00016 package m2m.frontend.dynamicview.commands; 00017 00018 import m2m.frontend.dynamicview.ThreadRouteConnections; 00019 import m2m.frontend.dynamicview.model.GraphicIf; 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 IfChangeLayoutCommand extends AbstractLayoutCommand 00027 { 00031 private GraphicIf model; 00035 private Rectangle layoutOutPut = new Rectangle(); 00036 00037 00041 public void execute() 00042 { 00043 // Set the layout of the model 00044 model.setLayout(getLayout()); 00045 00046 /* Set the layout of the output connection point */ 00047 if(model.getOutputPointConnection() != null) 00048 model.getOutputPointConnection().setLayout(layoutOutPut); 00049 00050 // Route connections 00051 Display.getCurrent().asyncExec(new ThreadRouteConnections()); 00052 } 00053 00054 00059 public boolean canExecute() 00060 { 00061 /* Check if we can set the layout of the model */ 00062 if(model.CanSetLayout(getLayout())) 00063 { 00064 /* Check if we can set the layout of the output connection point */ 00065 if(model.getOutputPointConnection() == null) 00066 return true; 00067 layoutOutPut.x = getLayout().x - model.getLayout().x + model.getOutputPointConnection().getLayout().x; 00068 layoutOutPut.y = getLayout().y - model.getLayout().y + model.getOutputPointConnection().getLayout().y; 00069 layoutOutPut.height = 10; 00070 layoutOutPut.width = 10; 00071 return model.getOutputPointConnection().CanSetLayout(layoutOutPut); 00072 } 00073 00074 return false; 00075 } 00076 00077 00082 public void setModel(Node model) 00083 { 00084 this.model = (GraphicIf)model; 00085 } 00086 }