/* * Created on Jun 20, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package CDBuilder.buttons; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; 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.IPageLayout; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; import CDBuilder.console.ConsoleDocument; /** * @author ssim * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class SimuAction extends Action implements IWorkbenchWindowActionDelegate{ IContainer container; boolean isCellDev; public SimuAction() { super(); setText("Simulate"); setDescription("This is a Simulator"); } public void run() { boolean needCompile; isCellDev = true;// is true always unless a .cpp file is found try { //show console view PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("ConsoleView"); ConsoleDocument cdos = ConsoleDocument.getCDOS(); IWorkspaceRoot root = (IWorkspaceRoot)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getInput(); //get path IPath projectPath = root.getLocation(); String selectPath = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(IPageLayout.ID_RES_NAV).toString(); selectPath = selectPath.substring(selectPath.indexOf("/")+1, selectPath.lastIndexOf("/")); //concatenate the string to get rid of [] projectPath = projectPath.append(selectPath +"/"); System.out.println("Project Path:" + projectPath); IPath internalPath = root.getLocation().removeLastSegments(1); internalPath = internalPath.append("/plugins/CD++Builder_1.1.0/internal/"); System.out.println("Internal Path: " + internalPath); IContainer container = root.getContainerForLocation(projectPath); String projectPathForUnix = projectPath.toString().charAt(0) + projectPath.toString().substring(2); String internalPathForUnix = internalPath.toString().charAt(0) + internalPath.toString().substring(2); Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); File simuFileCheck = new File(projectPath + "simu.exe"); // cdos.clear(); container.refreshLocal(1, null); try { IResource[] projectFiles; projectFiles = root.getContainerForLocation(projectPath).members(); IFile maFile = null; for(int i=0;i