/* * V1.0 Edited by Omair and Jing * - Fixed problem with spaces in path name * Bug: CDModeler will not open when there's a space in the path name * Fix: Quotes added in exec() */ package CDBuilder.buttons; import java.io.File; 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; /** * @author Ali Monadi * * This class will open up the cd++ Modeler as a separate process. */ public class BubbleEditorAction extends Action implements IWorkbenchWindowActionDelegate{ public void run(IAction action) { try { //gets the active page IWorkspaceRoot root =(IWorkspaceRoot)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getInput(); System.out.println("root.getLocaition: " + root.getLocation()); // gets the path where the program is IPath bubblePath = root.getLocation().removeLastSegments(1); System.out.println("bubblepath " + bubblePath); bubblePath = bubblePath.append("/plugins/CD++Builder_1.1.0/cdmodelerFull/"); System.out.println(bubblePath); //start cd modeler process System.out.println("java -classpath \"" +bubblePath+"jhall.jar\";\"" + bubblePath + "CDModeler.jar\";\"" +bubblePath+ "CDModelerResources.jar\" gui.MainDEVS"); Process bubbleProcess = Runtime.getRuntime().exec("java -classpath \"" +bubblePath+"jhall.jar\";\"" + bubblePath + "CDModeler.jar\";\"" +bubblePath+ "CDModelerResources.jar\" gui.MainDEVS",null,new File(bubblePath.toString())); } catch (Exception e) { e.printStackTrace(); MessageBox mb = new MessageBox(new Shell(),SWT.RETRY | SWT.ICON_ERROR | SWT.APPLICATION_MODAL); mb.setText("CD++ Modeler Program Not Found"); mb.setMessage("CD++ Modeler must be placed in CD++Builder_1.1.0 plugin folder"); mb.open(); try { mb.wait(); } catch (InterruptedException e1) { } } } public void dispose() { } public void init(IWorkbenchWindow window) { } public void selectionChanged(IAction action, ISelection selection) { } }