1 17 package org.apache.forrest.eclipse.popup.actions; 18 19 import org.apache.forrest.eclipse.job.ForrestManager; 20 import org.eclipse.core.resources.IProject; 21 import org.eclipse.core.resources.IResource; 22 import org.eclipse.core.runtime.IPath; 23 import org.eclipse.core.runtime.jobs.Job; 24 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 25 import org.eclipse.jface.action.IAction; 26 import org.eclipse.jface.viewers.ISelection; 27 import org.eclipse.jface.viewers.IStructuredSelection; 28 import org.eclipse.ui.IActionDelegate; 29 import org.eclipse.ui.IObjectActionDelegate; 30 import org.eclipse.ui.IWorkbenchPart; 31 32 public class StopForrest 33 implements IObjectActionDelegate, IJavaLaunchConfigurationConstants { 34 35 private IProject activeProject; 36 37 40 public StopForrest() { 41 super(); 42 } 43 44 47 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 48 } 49 50 53 public void run(IAction action) { 54 IPath workingDirectory = activeProject.getLocation(); 55 Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(), ForrestManager.COMMAND_STOP); 56 forrest.setUser(true); 57 forrest.schedule(); 58 } 59 60 63 public void selectionChanged(IAction action, ISelection selection) { 64 if (selection instanceof IStructuredSelection) { 65 Object first = ((IStructuredSelection)selection).getFirstElement(); 66 IResource resource = (IResource)first; 67 if (resource instanceof IProject) { 68 activeProject = (IProject)resource; 69 } 70 } 71 } 72 73 } | Popular Tags |