KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > operations > RedoActionHandler


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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  * <p>
25  * RedoActionHandler provides common behavior for redoing an operation, as well
26  * as labelling and enabling the menu item. This class may be instantiated by
27  * clients.
28  * </p>
29  *
30  * @since 3.1
31  */

32 public final class RedoActionHandler extends OperationHistoryActionHandler {
33
34     /**
35      * Construct an action handler that handles the labelling and enabling of
36      * the redo action for the specified undo context.
37      *
38      * @param site
39      * the workbench part site that created the action.
40      * @param context
41      * the undo context to be used for redoing.
42      */

43     public RedoActionHandler(IWorkbenchPartSite site, IUndoContext context) {
44         super(site, context);
45         setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
46                 .getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
47         setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
48                 .getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED));
49     }
50
51     void flush() {
52         getHistory().dispose(getUndoContext(), false, true, false);
53     }
54
55     String JavaDoc getCommandString() {
56         return WorkbenchMessages.Operations_redoCommand;
57     }
58     
59     String JavaDoc getTooltipString() {
60         return WorkbenchMessages.Operations_redoTooltipCommand;
61     }
62     
63     String JavaDoc getSimpleCommandString() {
64         return WorkbenchMessages.Workbench_redo;
65     }
66     
67     String JavaDoc getSimpleTooltipString() {
68         return WorkbenchMessages.Workbench_redoToolTip;
69     }
70
71
72     IUndoableOperation getOperation() {
73         return getHistory().getRedoOperation(getUndoContext());
74     }
75
76     IStatus runCommand(IProgressMonitor pm) throws ExecutionException {
77         return getHistory().redo(getUndoContext(), pm, this);
78     }
79
80     boolean shouldBeEnabled() {
81         return getHistory().canRedo(getUndoContext());
82     }
83 }
84
Popular Tags