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 BuildSite 39 implements IObjectActionDelegate, IJavaLaunchConfigurationConstants { 40 41 private IProject activeProject; 42 43 46 public BuildSite() { 47 super(); 48 } 49 50 53 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 54 } 55 56 59 public void run(IAction action) { 60 String cmdString = null; 61 IPath path = JavaCore.getClasspathVariable("ECLIPSE_HOME"); 62 63 String fhome = ForrestPlugin.getDefault().getPluginPreferences() 65 .getString(ForrestPreferences.FORREST_HOME); 66 67 if (fhome.equals("")) { 68 Shell dialog = new Shell(new Shell()); 69 dialog.setText("Configure Forrest"); 70 dialog.setSize(400, 100); 71 Label statusMsg = new Label(dialog, SWT.NONE); 72 statusMsg 73 .setText("Please configure Forrest by providing values for the required preferences"); 74 statusMsg.setLocation(30, 25); 75 statusMsg.pack(); 76 dialog.open(); 78 return; 80 } 81 82 IPath workingDirectory = activeProject.getLocation(); 83 84 Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(), ForrestManager.COMMAND_BUILD); 85 forrest.setUser(true); 86 forrest.schedule(); 87 } 88 89 92 public void selectionChanged(IAction action, ISelection selection) { 93 if (selection instanceof IStructuredSelection) { 94 Object first = ((IStructuredSelection)selection).getFirstElement(); 95 IResource resource = (IResource)first; 96 if (resource instanceof IProject) { 97 activeProject = (IProject)resource; 98 } 99 } 100 } 101 102 } | Popular Tags |