1 11 12 package org.eclipse.ui.views.tasklist; 13 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.resources.IMarker; 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.jface.util.OpenStrategy; 18 import org.eclipse.jface.viewers.IStructuredSelection; 19 import org.eclipse.ui.IWorkbenchPage; 20 import org.eclipse.ui.PartInitException; 21 import org.eclipse.ui.PlatformUI; 22 import org.eclipse.ui.ide.IDE; 23 import org.eclipse.ui.internal.ide.DialogUtil; 24 import org.eclipse.ui.internal.views.tasklist.TaskListMessages; 25 26 31 class GotoTaskAction extends TaskAction { 32 33 39 public GotoTaskAction(TaskList tasklist, String id) { 40 super(tasklist, id); 41 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 42 ITaskListHelpContextIds.GOTO_TASK_ACTION); 43 } 44 45 48 public void run() { 49 IStructuredSelection selection = (IStructuredSelection) getTaskList() 50 .getSelection(); 51 Object o = selection.getFirstElement(); 52 if (!(o instanceof IMarker)) { 53 return; 54 } 55 IMarker marker = (IMarker) o; 56 IResource resource = marker.getResource(); 57 if (marker.exists() && resource instanceof IFile) { 58 IWorkbenchPage page = getTaskList().getSite().getPage(); 59 try { 60 IDE.openEditor(page, marker, OpenStrategy.activateOnOpen()); 61 } catch (PartInitException e) { 62 DialogUtil.openError(page.getWorkbenchWindow().getShell(), 63 TaskListMessages.GotoTask_errorMessage, 64 e.getMessage(), e); 65 } 66 } 67 } 68 } 69 | Popular Tags |