private IStatus getRedoApproval(IUndoableOperation operation, IAdaptable info) { final Object[] approverArray = approvers.getListeners(); for (int i = 0; i < approverArray.length; i++) { IOperationApprover approver = (IOperationApprover) approverArray[i]; IStatus approval = approver.proceedRedoing(operation, this, info); if (!approval.isOK()) { if (DEBUG_OPERATION_HISTORY_APPROVAL) { Tracing.printTrace("OPERATIONHISTORY", //$NON-NLS-1$ "Redo not approved by " + approver //$NON-NLS-1$ + "for operation " + operation //$NON-NLS-1$ + " approved by " + approval); //$NON-NLS-1$ } return approval; } } return Status.OK_STATUS; }
private IStatus getUndoApproval(IUndoableOperation operation, IAdaptable info) { final Object[] approverArray = approvers.getListeners(); for (int i = 0; i < approverArray.length; i++) { IOperationApprover approver = (IOperationApprover) approverArray[i]; IStatus approval = approver.proceedUndoing(operation, this, info); if (!approval.isOK()) { if (DEBUG_OPERATION_HISTORY_APPROVAL) { Tracing.printTrace("OPERATIONHISTORY", //$NON-NLS-1$ "Undo not approved by " + approver //$NON-NLS-1$ + "for operation " + operation //$NON-NLS-1$ + " with status " + approval); //$NON-NLS-1$ } return approval; } } return Status.OK_STATUS; }
public static IOperationApprover getInstance() { if (instance == null) { synchronized (PlanReadOnlyOperationApprover.class) { if (instance == null) { try { instance = MissionExtender.construct(PlanReadOnlyOperationApprover.class); } catch (ConstructionException e) { instance = new PlanReadOnlyOperationApprover(); } } } } return instance; }
@Override public void removeOperationApprover(IOperationApprover approver) { approvers.remove(approver); }
@Override protected IOperationApprover getUndoRedoOperationApprover(IUndoContext undoContext) { // since IResource is a more general way to compare java elements, we // use this as the preferred class for comparing objects. return new NonLocalUndoUserApprover(undoContext, this, new Object [] { getInputJavaElement() }, IResource.class); }
/** * <p> * Add the specified approver to the list of operation approvers consulted * by the operation history before an undo or redo is allowed to proceed. * This method has no effect if the instance being added is already in the * list. * </p> * <p> * Operation approvers must be prepared to receive these the operation * approval messages from a background thread. Any UI access occurring * inside the implementation must be properly synchronized using the * techniques specified by the client's widget library. * </p> * * @param approver * the IOperationApprover to be added as an approver. * */ @Override public void addOperationApprover(IOperationApprover approver) { approvers.add(approver); }