1 /******************************************************************************* 2 * Copyright (c) 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.core.commands.operations; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.core.runtime.IStatus; 15 16 /** 17 * Extends {@link IOperationApprover} to approve the execution of a particular 18 * operation within an operation history. Operations that are candidates for 19 * execution have already been validated against their current state and 20 * according to the rules of the history. Prior to 3.2, an operation approver 21 * was only consulted for undo and redo of an operation, not its initial 22 * execution. 23 * <p> 24 * By the time an IOperationApprover2 is consulted, the execution has already 25 * been requested and it has been determined that the operation is valid. 26 * Approvers should return an <code>IStatus</code> object with severity 27 * <code>OK</code> if the operation should proceed, and any other severity if 28 * it should not. When an operation is not approved, it is expected that the 29 * object not allowing the operation has already consulted the user if necessary 30 * or otherwise provided any necessary information to the user about the fact 31 * that the operation is not approved. 32 * </p> 33 * <p> 34 * Like {@link IOperationApprover}, implementers of this extension must be 35 * prepared to receive the approval messages from a background thread. Any UI 36 * access occurring inside the implementation must be properly synchronized 37 * using the techniques specified by the client's widget library. 38 * </p> 39 * 40 * @since 3.2 41 */ 42 public interface IOperationApprover2 extends IOperationApprover { 43 /** 44 * Return a status indicating whether the specified operation should be 45 * executed. Any status that does not have severity <code>IStatus.OK</code> 46 * will not be approved. Implementers should not assume that the execution 47 * will be performed when the status is <code>OK</code>, since other 48 * operation approvers may veto the execution. 49 * 50 * @param operation 51 * the operation to be executed 52 * @param history 53 * the history performing the execution of 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 * execution will not proceed if the status severity is not 66 * <code>OK</code>, and the caller requesting the execution will 67 * be returned the status that caused the rejection. Any other 68 * status severities will not be interpreted by the history. 69 */ 70 IStatus proceedExecuting(IUndoableOperation operation, 71 IOperationHistory history, IAdaptable info); 72 }