1 11 12 package org.eclipse.ui.internal.operations; 13 14 import org.eclipse.core.commands.operations.DefaultOperationHistory; 15 import org.eclipse.core.commands.operations.IOperationApprover; 16 import org.eclipse.core.commands.operations.IOperationHistory; 17 import org.eclipse.core.commands.operations.IUndoContext; 18 import org.eclipse.core.commands.operations.ObjectUndoContext; 19 import org.eclipse.core.commands.operations.OperationHistoryFactory; 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.internal.misc.Policy; 22 import org.eclipse.ui.operations.IWorkbenchOperationSupport; 23 24 33 public class WorkbenchOperationSupport implements IWorkbenchOperationSupport { 34 35 private ObjectUndoContext undoContext; 36 private IOperationApprover approver; 37 38 static { 40 DefaultOperationHistory.DEBUG_OPERATION_HISTORY_UNEXPECTED = Policy.DEBUG_OPERATIONS; 41 DefaultOperationHistory.DEBUG_OPERATION_HISTORY_OPENOPERATION = Policy.DEBUG_OPERATIONS; 42 DefaultOperationHistory.DEBUG_OPERATION_HISTORY_APPROVAL = Policy.DEBUG_OPERATIONS; 43 DefaultOperationHistory.DEBUG_OPERATION_HISTORY_NOTIFICATION = Policy.DEBUG_OPERATIONS && Policy.DEBUG_OPERATIONS_VERBOSE; 44 DefaultOperationHistory.DEBUG_OPERATION_HISTORY_DISPOSE = Policy.DEBUG_OPERATIONS && Policy.DEBUG_OPERATIONS_VERBOSE; 45 } 46 47 50 public void dispose() { 51 54 getOperationHistory().removeOperationApprover(approver); 55 58 getOperationHistory().dispose(getUndoContext(), true, true, true); 59 } 60 61 69 public IUndoContext getUndoContext() { 70 if (undoContext == null) { 71 undoContext = new ObjectUndoContext(PlatformUI.getWorkbench(), 72 "Workbench Context"); } 74 return undoContext; 75 } 76 77 83 public IOperationHistory getOperationHistory() { 84 IOperationHistory history = OperationHistoryFactory.getOperationHistory(); 85 88 if (approver == null) { 89 93 approver = new AdvancedValidationUserApprover(getUndoContext()); 94 history.addOperationApprover(approver); 95 98 history.setLimit(getUndoContext(), 25); 99 } 100 return history; 101 } 102 103 } 104 | Popular Tags |