/* * Created on Jun 20, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package RegressionTest.buttons; import java.io.File; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; import CDBuilder.console.ConsoleDocument; /** * @author A.Monadi * * This class will run models with two versions of cd++.exe and compair output and logfiles * */ public class TestDevsAction extends Action implements IWorkbenchWindowActionDelegate{ IPath internalPath; public TestDevsAction() { super(); setText("Simulate"); setDescription("This is a Simulator"); } public void run() { boolean needCompile; Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); try { //show console view PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("ConsoleView"); ConsoleDocument cdos = ConsoleDocument.getCDOS(); IWorkspaceRoot root = (IWorkspaceRoot)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getInput(); internalPath = root.getLocation().removeLastSegments(1).append("/plugins/CD++Builder_1.1.0/internal/"); //this is where the test models are located IPath DevsRegression = root.getLocation().removeLastSegments(1).append("/plugins/CD++Builder_1.1.0/DevsRegression");; IPath projectPath = root.getLocation().append("DevsRegression/Models/"); ResetFolders.deleteProject(root,"DevsRegression"); if ( !ResetFolders.setupTestfolders(root,DevsRegression.toString()) ){ MessageBox box = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK); box.setMessage("Error occured during setup. Make sure projects are copied to: \n" +projectPath); box.setText("ERROR"); box.open(); return; } File DevsProjects = new File(projectPath.toString()); File [] projects = DevsProjects.listFiles(); if (projects != null){ for (int i= 0; i< projects.length; i++){ ResetFolders.doCheck(root, projects[i].toString()); } } /* try{ System.out.println(root.getProject("a")); System.out.println(root.getLocation()); root.getProject("a").open(null); }catch(Exception e){ e.printStackTrace(); }*/ IContainer container = root.getContainerForLocation(root.getLocation()); container.refreshLocal(1,null); String projectPathForUnix = projectPath.toString().charAt(0) + projectPath.toString().substring(2); String internalPathForUnix = internalPath.toString().charAt(0) + projectPath.toString().substring(2); cdos.clear(); TestDevsGUI dialog = new TestDevsGUI(parent, projectPath); dialog.create(); dialog.open(); dialog.close(); }catch (Exception np) { np.printStackTrace(); MessageBox npGui = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK); npGui.setMessage("Error occured during simulation. Aborting"); npGui.setText("ERROR"); npGui.open(); } } public void run(IAction action) { run(); } public void dispose() { // do nothing. } public void init(IWorkbenchWindow window) { // do nothing. } public void selectionChanged(IAction action, ISelection selection) { } }