package CDBuilder.buttons; import org.eclipse.jface.action.*; import org.eclipse.jface.preference.IPreferenceStore; 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.*; import CDBuilder.CDBuilderPlugin; public class BlenderLaunchAction extends Action implements IWorkbenchWindowActionDelegate{ public BlenderLaunchAction() { super(); } public void dispose() { } public void init(IWorkbenchWindow arg0) { } public void run(IAction arg0) { IPreferenceStore store = CDBuilderPlugin.getDefault().getPreferenceStore(); String blenderPath = store.getString("blenderPath"); if(blenderPath.length() == 0) { MessageBox npGui = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK); npGui.setMessage("In order to lanch the visualization tool, you need to have Blender installed and the path to the .exe file correctly defined in the CD++Builder Preference Page in Window -> Preferences."); npGui.setText("Blender"); npGui.open(); } else { try { Runtime r = Runtime.getRuntime(); // If this application must wait the end of the process //Process p = r.exec(cmd); //p.waitFor(); // Else r.exec(blenderPath); }catch(Exception e) { MessageBox npGui = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK); npGui.setMessage("Eclipse can't run the program set in the preferences (or no program is set). Please check the CD++Builder Preference Page in Window -> Preferences."); npGui.setText("Blender"); npGui.open(); } } } public void selectionChanged(IAction arg0, ISelection arg1) { } }