1 17 package org.apache.forrest.eclipse.popup.actions; 18 19 import org.apache.forrest.eclipse.ForrestPlugin; 20 import org.apache.forrest.eclipse.job.ForrestManager; 21 import org.apache.forrest.eclipse.preference.ForrestPreferences; 22 import org.eclipse.core.resources.IProject; 23 import org.eclipse.core.resources.IResource; 24 import org.eclipse.core.runtime.IPath; 25 import org.eclipse.core.runtime.jobs.Job; 26 import org.eclipse.jdt.core.JavaCore; 27 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 28 import org.eclipse.jface.action.IAction; 29 import org.eclipse.jface.viewers.ISelection; 30 import org.eclipse.jface.viewers.IStructuredSelection; 31 import org.eclipse.swt.SWT; 32 import org.eclipse.swt.widgets.Label; 33 import org.eclipse.swt.widgets.Shell; 34 import org.eclipse.ui.IActionDelegate; 35 import org.eclipse.ui.IObjectActionDelegate; 36 import org.eclipse.ui.IWorkbenchPart; 37 38 public class StartForrest 39 implements IObjectActionDelegate, IJavaLaunchConfigurationConstants { 40 41 private IProject activeProject; 42 43 46 public StartForrest() { 47 super(); 48 } 49 50 53 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 54 } 55 56 59 public void run(IAction action) { 60 Shell messageDialog; 61 Label statusMsg; 62 if (activeProject == null) { 63 return; 64 } 65 66 Shell shell = new Shell(); 67 IPath path = JavaCore.getClasspathVariable("ECLIPSE_HOME"); 68 messageDialog = new Shell(shell); 70 71 String fhome = ForrestPlugin.getDefault().getPluginPreferences() 72 .getString(ForrestPreferences.FORREST_HOME); 73 74 IPath workingDirectory = activeProject.getLocation(); 75 76 if (fhome.equals("")) { 77 messageDialog.setText("Configure Forrest"); 78 messageDialog.setSize(400, 100); 79 statusMsg = new Label(messageDialog, SWT.NONE); 80 statusMsg 81 .setText("Please configure Forrest by providing values for the required preferences"); 82 statusMsg.setLocation(30, 25); 83 statusMsg.pack(); 84 messageDialog.open(); 86 return; 88 } 89 90 Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(), ForrestManager.COMMAND_START); 91 forrest.setUser(true); 92 forrest.schedule(); 93 } 94 95 98 public void selectionChanged(IAction action, ISelection selection) { 99 if (selection instanceof IStructuredSelection) { 100 Object first = ((IStructuredSelection)selection).getFirstElement(); 101 IResource resource = (IResource)first; 102 if (resource instanceof IProject) { 103 activeProject = (IProject)resource; 104 } 105 } 106 } 107 108 } | Popular Tags |