Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/actions/LaunchVerifAction.java

Go to the documentation of this file.
00001 
00020 package m2m.frontend.actions;
00021 
00022 import java.lang.reflect.InvocationTargetException;
00023 
00024 import org.eclipse.core.runtime.IProgressMonitor;
00025 import org.eclipse.jface.dialogs.MessageDialog;
00026 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
00027 import org.eclipse.jface.operation.IRunnableWithProgress;
00028 import org.eclipse.swt.widgets.Shell;
00029 import org.eclipse.ui.IWorkbench;
00030 import org.eclipse.ui.IWorkbenchWindow;
00031 import org.eclipse.ui.PlatformUI;
00032 
00033 import m2m.backend.processing.Errors;
00034 import m2m.backend.processing.ExternalRuns;
00035 import m2m.backend.processing.ProgressMonitoring;
00036 import m2m.frontend.ErrorProcessing;
00037 import m2m.frontend.GraphicalProgressMonitoring;
00038 import m2m.frontend.actions.M2MAction;
00039 import m2m.frontend.threads.QuestaThread;
00040 
00041 
00042 public class LaunchVerifAction extends M2MAction 
00043 {
00044         
00045         public LaunchVerifAction(IWorkbenchWindow window, String label) 
00046         {
00047                 super(window,label);
00048                 setImageDescriptor(m2m.frontend.Activator.getImageDescriptor("/icons/verif.gif"));
00049                 
00050         // The id is used to refer to the action in a menu or toolbar
00051                 setId(ICommandIds.CMD_VERIF);
00052                 
00053         // Associate the action with a pre-defined command, to allow key bindings.
00054                 setActionDefinitionId(ICommandIds.CMD_VERIF);
00055         }
00056 
00057         
00058         
00059         
00060         
00061 
00062         public void execute(IProgressMonitor monitor)
00063         {
00064                 
00065 
00066                 Errors.clearError();
00067 
00068                 monitor.beginTask("Running Simulation",editor.getM2MProject().getSimulationProperties().getNumberOfSamples());
00069                 GraphicalProgressMonitoring mon=new GraphicalProgressMonitoring();
00070                 mon.setIProgressMonitor(monitor);
00071                 editor.getM2MProject().monitoring=mon;          
00072                 if (ExternalRuns.runQuesta(editor.getM2MProject()))
00073                 {
00074                         if (ExternalRuns.getNbSimErrors()!=0) {
00075 //                              ErrorProcessing.displayError(editor.getShell().getDisplay(),"Simulation contains "+ExternalRuns.getNbSimErrors()+" errors!");
00076                         //      return;
00077                         }
00078                         
00079                 }
00080                 ErrorProcessing.processLastError(editor.getShell().getDisplay());
00081                 
00082                 
00083                 editor.getM2MProject().monitoring=new ProgressMonitoring();
00084                                 
00085         }
00089         public void run() 
00090         {       
00091 
00092                 if (!getEditor("Error","Select the tab with the code you want to transform in VHDL"))
00093                         return;
00094 
00095                 boolean octaveOK=editor.getM2MProject().isOctaveUpToDate();
00096                 boolean vhdlOK=editor.getM2MProject().isVHDLUpToDate();
00097                 if (!(octaveOK && vhdlOK)) {
00098                         MessageDialog.openError(window.getShell(), "Error", "Please generate VHDL and octave files before launch verification");
00099                         return;
00100                 }
00101                 if (!vhdlOK) {
00102                         MessageDialog.openError(window.getShell(), "Error", "Please generate VHDL files before launch verification");
00103                         return;
00104                 }
00105                 if (!octaveOK) {
00106                         MessageDialog.openError(window.getShell(), "Error", "Please generate Octave files before launch verification");
00107                         return;
00108                 }
00109                 activateConsole();
00110 
00111 
00112                 IRunnableWithProgress op = new IRunnableWithProgress() {
00113                         public void run(IProgressMonitor monitor) {
00114                                 execute(monitor);
00115                         }
00116                 };
00117                 IWorkbench wb = PlatformUI.getWorkbench();
00118                 IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
00119                 Shell shell = win != null ? win.getShell() : null;
00120                 try {
00121                         new ProgressMonitorDialog(shell).run(true, false, op);
00122                 } catch (InvocationTargetException e) {
00123                         // TODO Auto-generated catch block
00124                         e.printStackTrace();
00125                 } catch (InterruptedException e) {
00126                         // TODO Auto-generated catch block
00127                         e.printStackTrace();
00128                 }
00129 
00130 
00131                 /*
00132                         Shell shell=new Shell();
00133 
00134 
00135                     // Create a smooth progress bar
00136                     ProgressBar pb1 = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH);
00137                     pb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00138                     pb1.setMinimum(0);
00139                     pb1.setMaximum(30);
00140                     pb1.setSelection(10);
00141                     shell.open();
00142                  */
00143 
00144                 /* Launch the octaveThread */
00145                 //              RunAllThread runAllThread = new RunAllThread(editor,editor.getM2MProject());
00146                 //              runAllThread.start();   
00147         } 
00148         
00149         
00150         
00154 /*      public synchronized void run() 
00155         {       
00156                         
00157                 /* Launch the questaThread 
00158                 QuestaThread questaThread = new QuestaThread(editor);
00159                 questaThread.start();       
00160         }*/
00161 }
 All Classes Namespaces Files Functions Variables Enumerations