KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > commands > operations > IOperationApprover


1 /*******************************************************************************
2  * Copyright (c) 2005 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.core.commands.operations;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.core.runtime.IStatus;
15
16 /**
17  * <p>
18  * IOperationApprover defines an interface for approving the undo or redo of a
19  * particular operation within an operation history. Operations that are
20  * candidates for undo or redo have already been validated against their current
21  * state and according to the rules of the history.
22  * </p>
23  * <p>
24  * By the time an IOperationApprover is consulted, the undo has already been
25  * requested. Approvers should return an <code>IStatus</code> object with
26  * severity <code>OK</code> if the operation should proceed, and any other
27  * severity if it should not. When an operation is not approved, it is expected
28  * that the object not allowing the operation has already consulted the user if
29  * necessary or otherwise provided any necessary information to the user about
30  * the fact that the operation is not approved.
31  * </p>
32  * <p>
33  * Operation approvers must be prepared to receive the approval messages from a
34  * background thread. Any UI access occurring inside the implementation must be
35  * properly synchronized using the techniques specified by the client's widget
36  * library.
37  * </p>
38  *
39  * @since 3.1
40  */

41 public interface IOperationApprover {
42
43     /**
44      * Return a status indicating whether the specified operation should be
45      * redone. Any status that does not have severity <code>IStatus.OK</code>
46      * will not be approved. Implementers should not assume that the redo will
47      * be performed when the status is <code>OK</code>, since other operation
48      * approvers may veto the redo.
49      *
50      * @param operation
51      * the operation to be redone
52      * @param history
53      * the history redoing the operation
54      * @param info
55      * the IAdaptable (or <code>null</code>) provided by the
56      * caller in order to supply UI information for prompting the
57      * user if necessary. When this parameter is not
58      * <code>null</code>, it should minimally contain an adapter
59      * for the org.eclipse.swt.widgets.Shell.class. Even if UI
60      * information is provided, the implementation of this method
61      * must be prepared for being called from a background thread.
62      * Any UI access must be properly synchronized using the
63      * techniques specified by the client's widget library.
64      * @return the IStatus describing whether the operation is approved. The
65      * redo will not proceed if the status severity is not
66      * <code>OK</code>, and the caller requesting the redo will be
67      * returned the status that caused the rejection. Any other status
68      * severities will not be interpreted by the history.
69      */

70     IStatus proceedRedoing(IUndoableOperation operation,
71             IOperationHistory history, IAdaptable info);
72
73     /**
74      * Return a status indicating whether the specified operation should be
75      * undone. Any status that does not have severity <code>IStatus.OK</code>
76      * will not be approved. Implementers should not assume that the undo will
77      * be performed when the status is <code>OK</code>, since other operation
78      * approvers can veto the undo.
79      *
80      * @param operation
81      * the operation to be undone
82      * @param history
83      * the history undoing the operation
84      * @param info
85      * the IAdaptable (or <code>null</code>) provided by the
86      * caller in order to supply UI information for prompting the
87      * user if necessary. When this parameter is not
88      * <code>null</code>, it should minimally contain an adapter
89      * for the org.eclipse.swt.widgets.Shell.class. Even if UI
90      * information is provided, the implementation of this method
91      * must be prepared for being called from a background thread.
92      * Any UI access must be properly synchronized using the
93      * techniques specified by the client's widget library.
94      * @return the IStatus describing whether the operation is approved. The
95      * undo will not proceed if the status severity is not
96      * <code>OK</code>, and the caller requesting the undo will be
97      * returned the status that caused the rejection. Any other status
98      * severities will not be interpreted by the history.
99      */

100     IStatus proceedUndoing(IUndoableOperation operation,
101             IOperationHistory history, IAdaptable info);
102
103 }
104
Popular Tags