1 11 package org.eclipse.ui.operations; 12 13 import org.eclipse.core.commands.ExecutionException; 14 import org.eclipse.core.commands.operations.IUndoContext; 15 import org.eclipse.core.commands.operations.IUndoableOperation; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.ui.ISharedImages; 19 import org.eclipse.ui.IWorkbenchPartSite; 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.internal.WorkbenchMessages; 22 23 24 33 public final class UndoActionHandler extends OperationHistoryActionHandler { 34 35 44 public UndoActionHandler(IWorkbenchPartSite site, IUndoContext context) { 45 super(site, context); 46 setImageDescriptor(PlatformUI.getWorkbench().getSharedImages() 47 .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO)); 48 setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages() 49 .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED)); 50 } 51 52 void flush() { 53 getHistory().dispose(getUndoContext(), true, false, false); 54 } 55 56 String getCommandString() { 57 return WorkbenchMessages.Operations_undoCommand; 58 } 59 60 String getTooltipString() { 61 return WorkbenchMessages.Operations_undoTooltipCommand; 62 } 63 64 String getSimpleCommandString() { 65 return WorkbenchMessages.Workbench_undo; 66 } 67 68 String getSimpleTooltipString() { 69 return WorkbenchMessages.Workbench_undoToolTip; 70 } 71 72 IUndoableOperation getOperation() { 73 return getHistory().getUndoOperation(getUndoContext()); 74 75 } 76 77 IStatus runCommand(IProgressMonitor pm) throws ExecutionException { 78 return getHistory().undo(getUndoContext(), pm, this); 79 } 80 81 boolean shouldBeEnabled() { 82 return getHistory().canUndo(getUndoContext()); 83 } 84 } 85 | Popular Tags |