package tool.commands.run;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import tool.builder.FScript;
public class RunHandler extends AbstractHandler{
FScript fscript;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
ISelectionService selectionService = window.getSelectionService();
ISelection selection = selectionService.getSelection();
if (selection instanceof ITreeSelection && (((ITreeSelection) selection).getFirstElement() instanceof IFolder)){
ITreeSelection treeSelection = (ITreeSelection)selection;
IFolder planFolder = (IFolder) treeSelection.getFirstElement();
RunJob runner = new RunJob(planFolder);
runner.setPriority(Job.INTERACTIVE);
runner.schedule();
}
return null;
}
}