@Override public IUndoableOperation getUndoOperation(IUndoContext context) { Assert.isNotNull(context); synchronized (undoRedoHistoryLock) { for (int i = undoList.size() - 1; i >= 0; i--) { IUndoableOperation operation = undoList.get(i); if (operation.hasContext(context)) { return operation; } } } return null; }
@Override public boolean canUndo() { if (triggeringOperation != null) { return triggeringOperation.canUndo(); } return false; }
/** * Check the undo limit before adding an operation. Return a boolean * indicating whether the undo should proceed. */ private boolean checkUndoLimit(IUndoableOperation operation) { IUndoContext[] contexts = operation.getContexts(); for (int i = 0; i < contexts.length; i++) { int limit = getLimit(contexts[i]); if (limit > 0) { forceUndoLimit(contexts[i], limit - 1); } else { // this context has a 0 limit operation.removeContext(contexts[i]); } } return operation.getContexts().length > 0; }
&& triggeringOperation.hasContext(original)) { if (triggeringOperation instanceof IContextReplacingOperation) { ((IContextReplacingOperation) triggeringOperation).replaceContext(original, replacement); } else { triggeringOperation.removeContext(original); triggeringOperation.addContext(replacement); if (child.hasContext(original)) { if (child instanceof IContextReplacingOperation) { ((IContextReplacingOperation) child).replaceContext( original, replacement); } else { child.removeContext(original); child.addContext(replacement);
/** * Construct a composite triggered operations using the specified undoable * operation as the trigger. Use the label of this trigger as the label of * the operation. * * @param operation * the operation that will trigger other operations. * @param history * the operation history containing the triggered operations. */ public TriggeredOperations(IUndoableOperation operation, IOperationHistory history) { super(operation.getLabel()); triggeringOperation = operation; recomputeContexts(); this.history = history; }
((IContextReplacingOperation)op).replaceContext(oldUndoContext, getUndoContext()); } else { op.addContext(getUndoContext()); op.removeContext(oldUndoContext);
/** * Add the specified context to the operation. Overridden in * TriggeredOperations to add the specified undo context to the triggering * operation. * * @param context * the context to be added * * @since 3.2 */ @Override public void addContext(IUndoContext context) { if (triggeringOperation != null) { triggeringOperation.addContext(context); recomputeContexts(); } }
private boolean requiresApproval(IUndoableOperation operation, IAdaptable uiInfo) { // no approval is required if the operation doesn't have our undo // context if (!(operation.hasContext(context))) { return false; } // no approval is required if the operation only has our context if (operation.getContexts().length == 1) { return false; } // no approval is required if we can ascertain that the operation did // not originate // in our context. if (uiInfo != null) { IUndoContext originatingContext = Adapters.adapt(uiInfo, IUndoContext.class); if (originatingContext != null && !(originatingContext.matches(context))) { return false; } } return true; }
if (!operation.canExecute()) { return IOperationHistory.OPERATION_INVALID_STATUS; status = operation.execute(monitor, info); } catch (OperationCanceledException e) { status = Status.CANCEL_STATUS; operation.dispose();
if (!command.canUndo() && !undoList.isEmpty() && ServerUIPlugin.getPreferences().getPromptBeforeIrreversibleChange()) { try { Display d = Display.getCurrent(); command.execute(new NullProgressMonitor(), null); } catch (ExecutionException ce) { return; return; if (command.canUndo()) addToUndoList(src); else {
@Override public boolean canRedo() { if (triggeringOperation != null) { return triggeringOperation.canRedo(); } return false; }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { status = undoableOperation.execute(monitor, null); if(status.getSeverity() == IStatus.ERROR){ throw new InvocationTargetException(status.getException()); } } catch (ExecutionException e) { throw new InvocationTargetException(e); } }
@Override public boolean canExecute() { if (triggeringOperation != null) { return triggeringOperation.canExecute(); } return false; }
&& triggeringOperation.hasContext(original)) { if (triggeringOperation instanceof IContextReplacingOperation) { ((IContextReplacingOperation) triggeringOperation).replaceContext(original, replacement); } else { triggeringOperation.removeContext(original); triggeringOperation.addContext(replacement); if (child.hasContext(original)) { if (child instanceof IContextReplacingOperation) { ((IContextReplacingOperation) child).replaceContext( original, replacement); } else { child.removeContext(original); child.addContext(replacement);
/** * Construct a composite triggered operations using the specified undoable * operation as the trigger. Use the label of this trigger as the label of * the operation. * * @param operation * the operation that will trigger other operations. * @param history * the operation history containing the triggered operations. */ public TriggeredOperations(IUndoableOperation operation, IOperationHistory history) { super(operation.getLabel()); triggeringOperation = operation; recomputeContexts(); this.history = history; }
((IContextReplacingOperation)op).replaceContext(oldUndoContext, getUndoContext()); } else { op.addContext(getUndoContext()); op.removeContext(oldUndoContext);
/** * Add the specified context to the operation. Overridden in * TriggeredOperations to add the specified undo context to the triggering * operation. * * @param context * the context to be added * * @since 3.2 */ @Override public void addContext(IUndoContext context) { if (triggeringOperation != null) { triggeringOperation.addContext(context); recomputeContexts(); } }
if (!operation.canExecute()) { return IOperationHistory.OPERATION_INVALID_STATUS; status = operation.execute(monitor, info); } catch (OperationCanceledException e) { status = Status.CANCEL_STATUS; operation.dispose();
@Override public boolean canRedo() { if (triggeringOperation != null) { return triggeringOperation.canRedo(); } return false; }