/** * Removes any listeners that were installed by the document. */ private void removeListeners() { listenToTextChanges(false); fHistory.removeOperationHistoryListener(fHistoryListener); fHistoryListener= null; }
@Override public void flush() { if (fActiveOperation != null) { if (fIsOpen) { fOperationHistory.closeOperation(false, false, IOperationHistory.EXECUTE); } /* the triggering operation is invalid, but we must ensure that any * other operations executed while it was open remain in the undo * history. We accomplish this by adding the invalid operation, * since disposing the context later will cause it to be broken up into * its atomic parts. */ fOperationHistory.add(fActiveOperation); } fActiveOperation= null; fIsOpen= false; fOperationHistory.dispose(RefactoringCorePlugin.getUndoContext(), true, true, false); }
@Override public boolean redoable() { return fHistory.canRedo(fUndoContext); }
@Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (triggeringOperation != null) { history.openOperation(this, IOperationHistory.EXECUTE); try { IStatus status = triggeringOperation.execute(monitor, info); history.closeOperation(status.isOK(), false, IOperationHistory.EXECUTE); return status; } catch (ExecutionException e) { history.closeOperation(false, false, IOperationHistory.EXECUTE); throw e; } catch (RuntimeException e) { history.closeOperation(false, false, IOperationHistory.EXECUTE); throw e; } } return IOperationHistory.OPERATION_INVALID_STATUS; }
@Override public String peekUndoName() { IUndoableOperation op= fOperationHistory.getUndoOperation(RefactoringCorePlugin.getUndoContext()); if (op == null) return null; return op.getLabel(); }
/** * Adds any listeners needed to track the document and the operations * history. */ private void addListeners() { fHistoryListener= new HistoryListener(); fHistory.addOperationHistoryListener(fHistoryListener); listenToTextChanges(true); }
public void performUndo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException { IUndoableOperation undo= fOperationHistroy.getUndoOperation(RefactoringCorePlugin.getUndoContext()); UndoableOperation2ChangeAdapter changeOperation= getUnwrappedOperation(undo); if (changeOperation == null) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoManager2_no_change, null)); if (query == null) query= new NullQuery(); try { fOperationHistroy.undoOperation(undo, pm, new QueryAdapter(query)); } catch (ExecutionException e) { handleException(e); } }
/** * Initializes the command stack. * * @since 3.1 */ private void initializeCommandStack() { if (fHistory != null && fUndoContext != null) fHistory.dispose(fUndoContext, true, true, false); }
while (operation != history.getRedoOperation(context)) { try { IStatus status = history.redo(context, null, uiInfo); if (!status.isOK()) { history.dispose(context, false, true, false); return Status.CANCEL_STATUS; history.dispose(context, false, true, false); return Status.CANCEL_STATUS;
@Override public void setMaximalUndoLevel(int undoLimit) { fHistory.setLimit(fUndoContext, undoLimit); }
@Override public boolean undoable() { return fHistory.canUndo(fUndoContext); }
public String peekRedoName() { IUndoableOperation op= fOperationHistroy.getRedoOperation(RefactoringCorePlugin.getUndoContext()); if (op == null) return null; return op.getLabel(); }
/** * Adds the given command to the operation history if it is not part of * a compound change. * * @param command the command to be added * @since 3.1 */ private void addToCommandStack(TextCommand command){ if (!fFoldingIntoCompoundChange || command instanceof CompoundTextCommand) { fHistory.add(command); fLastAddedCommand= command; } }
/** * Disposes of anything created by the operation support. */ public void dispose() { /* * uninstall the operation approver that we added to the operation history */ getOperationHistory().removeOperationApprover(approver); /* * dispose of all operations using our context */ getOperationHistory().dispose(getUndoContext(), true, true, true); }
@Override public void performRedo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException { IUndoableOperation redo= fOperationHistory.getRedoOperation(RefactoringCorePlugin.getUndoContext()); UndoableOperation2ChangeAdapter changeOperation= getUnwrappedOperation(redo); if (changeOperation == null) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoManager2_no_change, null)); if (query == null) query= new NullQuery(); try { fOperationHistory.redoOperation(redo, pm, new QueryAdapter(query)); } catch (ExecutionException e) { handleException(e); } }
/** * Returns the workbench operation history. * * @return the operation history for workbench operations. * @since 3.1 */ @Override public IOperationHistory getOperationHistory() { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); /* * Set up the history if we have not done so before. */ if (approver == null) { /* * install an operation approver that prevents linear undo violations * in any context */ approver = new AdvancedValidationUserApprover(getUndoContext()); history.addOperationApprover(approver); /* * set a limit for the workbench undo context */ history.setLimit(getUndoContext(), 25); } return history; }
@Override public void changePerformed(Change change, boolean successful) { if (fIsOpen && fActiveOperation != null) { fOperationHistory.closeOperation(successful, false, IOperationHistory.EXECUTE); fIsOpen= false; } }
@Override public String peekUndoName() { IUndoableOperation op= fOperationHistory.getUndoOperation(RefactoringCorePlugin.getUndoContext()); if (op == null) return null; return op.getLabel(); }
/** * Adds any listeners needed to track the document and the operations * history. */ private void addListeners() { fHistoryListener= new HistoryListener(); fHistory.addOperationHistoryListener(fHistoryListener); listenToTextChanges(true); }
@Override public void performUndo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException { IUndoableOperation undo= fOperationHistory.getUndoOperation(RefactoringCorePlugin.getUndoContext()); UndoableOperation2ChangeAdapter changeOperation= getUnwrappedOperation(undo); if (changeOperation == null) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoManager2_no_change, null)); if (query == null) query= new NullQuery(); try { fOperationHistory.undoOperation(undo, pm, new QueryAdapter(query)); } catch (ExecutionException e) { handleException(e); } }