1 11 package org.eclipse.core.commands.operations; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.core.runtime.Status; 16 17 26 public abstract class LinearUndoViolationDetector implements IOperationApprover { 27 28 31 public LinearUndoViolationDetector() { 32 super(); 33 } 34 35 61 62 protected abstract IStatus allowLinearRedoViolation( 63 IUndoableOperation operation, IUndoContext context, 64 IOperationHistory history, IAdaptable info); 65 66 92 protected abstract IStatus allowLinearUndoViolation( 93 IUndoableOperation operation, IUndoContext context, 94 IOperationHistory history, IAdaptable info); 95 96 103 public final IStatus proceedRedoing(IUndoableOperation operation, 104 IOperationHistory history, IAdaptable info) { 105 IUndoContext[] contexts = operation.getContexts(); 106 for (int i = 0; i < contexts.length; i++) { 107 IUndoContext context = contexts[i]; 108 if (history.getRedoOperation(context) != operation) { 109 IStatus status = allowLinearRedoViolation(operation, context, 110 history, info); 111 if (!status.isOK()) { 112 return status; 113 } 114 } 115 } 116 return Status.OK_STATUS; 117 } 118 119 126 127 public final IStatus proceedUndoing(IUndoableOperation operation, 128 IOperationHistory history, IAdaptable info) { 129 IUndoContext[] contexts = operation.getContexts(); 130 for (int i = 0; i < contexts.length; i++) { 131 IUndoContext context = contexts[i]; 132 if (history.getUndoOperation(context) != operation) { 133 IStatus status = allowLinearUndoViolation(operation, context, 134 history, info); 135 if (!status.isOK()) { 136 return status; 137 } 138 } 139 } 140 return Status.OK_STATUS; 141 } 142 } 143 | Popular Tags |