1 11 12 package org.eclipse.ui.views.tasklist; 13 14 import org.eclipse.core.commands.ExecutionException; 15 import org.eclipse.core.commands.operations.IUndoableOperation; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IAdaptable; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.jface.action.Action; 20 import org.eclipse.jface.dialogs.ErrorDialog; 21 import org.eclipse.jface.dialogs.IDialogSettings; 22 import org.eclipse.swt.widgets.Shell; 23 import org.eclipse.ui.PlatformUI; 24 import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; 25 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 26 27 30 abstract class TaskAction extends Action { 31 32 private TaskList taskList; 33 34 37 protected TaskAction(TaskList tasklist, String id) { 38 super(); 39 this.taskList = tasklist; 40 setId(id); 41 } 42 43 46 protected Shell getShell() { 47 return taskList.getSite().getShell(); 48 } 49 50 53 protected TaskList getTaskList() { 54 return taskList; 55 } 56 57 61 protected void storeValue() { 62 IDialogSettings workbenchSettings = TaskList.getPlugin() 63 .getDialogSettings(); 64 IDialogSettings settings = workbenchSettings.getSection("TaskAction"); if (settings == null) { 66 settings = workbenchSettings.addNewSection("TaskAction"); } 68 settings.put(getId(), isChecked()); 69 } 70 71 74 void execute(IUndoableOperation operation, String title, 75 IProgressMonitor monitor, IAdaptable uiInfo) { 76 try { 77 PlatformUI.getWorkbench().getOperationSupport() 78 .getOperationHistory().execute(operation, monitor, uiInfo); 79 } catch (ExecutionException e) { 80 if (e.getCause() instanceof CoreException) { 81 ErrorDialog 82 .openError(WorkspaceUndoUtil.getShell(uiInfo), title, 83 null, ((CoreException) e.getCause()) 84 .getStatus()); 85 } else { 86 IDEWorkbenchPlugin.log(title, e); 87 } 88 } 89 } 90 91 } 92 | Popular Tags |