1 11 12 package org.eclipse.ui.views.tasklist; 13 14 import org.eclipse.core.resources.IMarker; 15 import org.eclipse.jface.dialogs.MessageDialog; 16 import org.eclipse.jface.viewers.StructuredSelection; 17 import org.eclipse.jface.window.Window; 18 import org.eclipse.ui.PlatformUI; 19 import org.eclipse.ui.internal.views.tasklist.TaskListMessages; 20 21 37 class NewTaskAction extends TaskAction { 38 39 45 public NewTaskAction(TaskList tasklist, String id) { 46 super(tasklist, id); 47 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 48 ITaskListHelpContextIds.NEW_TASK_ACTION); 49 } 50 51 55 public void run() { 56 TaskPropertiesDialog dialog = new TaskPropertiesDialog(getShell()); 57 dialog.setResource(getTaskList().getResource()); 58 int result = dialog.open(); 59 if (result == Window.OK) { 60 showMarker(dialog.getMarker()); 61 } 62 } 63 64 67 private void showMarker(final IMarker marker) { 68 if (marker == null) { 69 return; 70 } 71 if (getTaskList().shouldShow(marker)) { 72 getShell().getDisplay().asyncExec(new Runnable () { 76 public void run() { 77 getTaskList().setSelection(new StructuredSelection(marker), 78 true); 79 } 80 }); 81 } else { 82 MessageDialog.openInformation(getShell(), TaskListMessages.NewTask_notShownTitle, 83 TaskListMessages.NewTask_notShownMsg); 84 } 85 } 86 } 87 | Popular Tags |