Source:
<code>public Object execute(ExecutionEvent event) throws ExecutionException { IProject project = null; IEditorPart editorPart = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor(); if (editorPart != null) { IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput(); IFile file = input.getFile(); project = file.getProject(); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window != null) { IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection(); if (selection instanceof TreeSelection) { TreeSelection treeSelection = (TreeSelection) selection; TreePath path = treeSelection.getPaths()[0]; Object first = path.getFirstSegment(); if (first instanceof IAdaptable) { project = ((IAdaptable) first).getAdapter(IProject.class); } } else { Object firstElement = selection.getFirstElement(); if (firstElement instanceof IAdaptable) { project = ((IAdaptable) firstElement).getAdapter(IProject.class); } } } } if (project != null) { IFile file = project.getFile("/gulpfile.js"); if (file.exists()) { <START> StructuredSelection fileSelection = new StructuredSelection(file); <END> GulpLaunch launch = new GulpLaunch(); launch.launch(fileSelection, null); } } return null; }</code><technical_language>"ITask" selection is processed now. Also, great amend commit message - "EBZ#492124 " changed "Bug 492124" - this link gerrit change bugzilla automatically easier track</technical_language>

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { IContainer container = null; IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IWorkbenchPart part = page.getActivePart(); if (part != null) { IFile activeEditorFile = getEditorFile(part); if (activeEditorFile != null) { if (GULP_FILE_NAME.equals(activeEditorFile.getName())) { new GulpLaunch().launch(new StructuredSelection(activeEditorFile), GULP_TASK_RUN); return null; } else { container = activeEditorFile.getProject(); } } } if (container == null) { IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection(); if (selection instanceof TreeSelection) { TreeSelection treeSelection = (TreeSelection) selection; Object element = treeSelection.getFirstElement(); if (element != null) { element.toString(); if (element instanceof IFile && GULP_FILE_NAME.equals(((IFile) element).getName())) { new GulpLaunch().launch(treeSelection, GULP_TASK_RUN); return null; } else if (element instanceof ITask) { new GulpLaunch().launch(selection, GULP_TASK_RUN); return null; } } TreePath path = treeSelection.getPaths()[0]; Object first = path.getFirstSegment(); if (first instanceof IAdaptable) { container = ((IAdaptable) first).getAdapter(IContainer.class); } } else { Object firstElement = selection.getFirstElement(); if (firstElement instanceof IAdaptable) { container = ((IAdaptable) firstElement).getAdapter(IContainer.class); } } } } } if (container != null) { IFile file = container.getFile(new Path(GULP_FILE_NAME)); if (file.exists()) { StructuredSelection fileSelection = new StructuredSelection(file); new GulpLaunch().launch(fileSelection, GULP_TASK_RUN); } } return null; }