private UndoableOperation2ChangeAdapter getUnwrappedOperation(IUndoableOperation operation) { IUndoableOperation result= operation; if (result instanceof TriggeredOperations) { result= ((TriggeredOperations)result).getTriggeringOperation(); } if (result instanceof UndoableOperation2ChangeAdapter) { return (UndoableOperation2ChangeAdapter)result; } return null; }
@Override public void add(IUndoableOperation operation) { children.add(operation); recomputeContexts(); }
@Override public void aboutToPerformChange(Change change) { IUndoableOperation operation= new UndoableOperation2ChangeAdapter(change); operation.addContext(RefactoringCorePlugin.getUndoContext()); fActiveOperation= new TriggeredOperations(operation, fOperationHistory); fActiveOperation.addContext(RefactoringCorePlugin.getUndoContext()); fOperationHistory.openOperation(fActiveOperation, IOperationHistory.EXECUTE); fIsOpen= true; }
&& triggeringOperation.hasContext(context)) { if (triggeringOperation.getContexts().length == 1) { remove(triggeringOperation); return; remove(toBeRemoved.get(i)); recomputeContexts();
@Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (triggeringOperation != null) { history.openOperation(this, IOperationHistory.UNDO); List<IUndoableOperation> childrenToRestore = new ArrayList<>(children); try { removeAllChildren(); IStatus status = triggeringOperation.undo(monitor, info); if (!status.isOK()) { children = childrenToRestore; } history.closeOperation(status.isOK(), false, IOperationHistory.UNDO); return status; } catch (ExecutionException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.UNDO); throw e; } catch (RuntimeException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.UNDO); throw e; } } return IOperationHistory.OPERATION_INVALID_STATUS; }
for (IUndoContext context : this.getContexts()) { if (context != null) { undoHistory.addAll(Arrays.asList(history.getUndoHistory(context))); recomputeContexts(); operation.dispose(); children.remove(operation); operation.dispose(); recomputeContexts();
@Override public void aboutToPerformChange(Change change) { IUndoableOperation operation= new UndoableOperation2ChangeAdapter(change); operation.addContext(RefactoringCorePlugin.getUndoContext()); fActiveOperation= new TriggeredOperations(operation, fOperationHistory); fActiveOperation.addContext(RefactoringCorePlugin.getUndoContext()); fOperationHistory.openOperation(fActiveOperation, IOperationHistory.EXECUTE); fIsOpen= true; }
&& triggeringOperation.hasContext(context)) { if (triggeringOperation.getContexts().length == 1) { remove(triggeringOperation); return; remove(toBeRemoved.get(i)); recomputeContexts();
@Override public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (triggeringOperation != null) { history.openOperation(this, IOperationHistory.REDO); List<IUndoableOperation> childrenToRestore = new ArrayList<>(children); try { removeAllChildren(); IStatus status = triggeringOperation.redo(monitor, info); if (!status.isOK()) { children = childrenToRestore; } history.closeOperation(status.isOK(), false, IOperationHistory.REDO); return status; } catch (ExecutionException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.REDO); throw e; } catch (RuntimeException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.REDO); throw e; } } return IOperationHistory.OPERATION_INVALID_STATUS; }
private UndoableOperation2ChangeAdapter getUnwrappedOperation(IUndoableOperation operation) { IUndoableOperation result= operation; if (result instanceof TriggeredOperations) { result= ((TriggeredOperations)result).getTriggeringOperation(); } if (result instanceof UndoableOperation2ChangeAdapter) { return (UndoableOperation2ChangeAdapter)result; } return null; }
@Override public void add(IUndoableOperation operation) { children.add(operation); recomputeContexts(); }
public void aboutToPerformChange(Change change) { IUndoableOperation operation= new UndoableOperation2ChangeAdapter(change); operation.addContext(RefactoringCorePlugin.getUndoContext()); fActiveOperation= new TriggeredOperations(operation, fOperationHistroy); fActiveOperation.addContext(RefactoringCorePlugin.getUndoContext()); fOperationHistroy.openOperation(fActiveOperation, IOperationHistory.EXECUTE); fIsOpen= true; }
&& triggeringOperation.hasContext(context)) { if (triggeringOperation.getContexts().length == 1) { remove(triggeringOperation); return; remove(toBeRemoved.get(i)); recomputeContexts();
@Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (triggeringOperation != null) { history.openOperation(this, IOperationHistory.UNDO); List<IUndoableOperation> childrenToRestore = new ArrayList<>(children); try { removeAllChildren(); IStatus status = triggeringOperation.undo(monitor, info); if (!status.isOK()) { children = childrenToRestore; } history.closeOperation(status.isOK(), false, IOperationHistory.UNDO); return status; } catch (ExecutionException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.UNDO); throw e; } catch (RuntimeException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.UNDO); throw e; } } return IOperationHistory.OPERATION_INVALID_STATUS; }
private UndoableOperation2ChangeAdapter getUnwrappedOperation(IUndoableOperation operation) { IUndoableOperation result= operation; if (result instanceof TriggeredOperations) { result= ((TriggeredOperations)result).getTriggeringOperation(); } if (result instanceof UndoableOperation2ChangeAdapter) { return (UndoableOperation2ChangeAdapter)result; } return null; }
@Override public void add(IUndoableOperation operation) { children.add(operation); recomputeContexts(); }
@Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (triggeringOperation != null) { history.openOperation(this, IOperationHistory.UNDO); List<IUndoableOperation> childrenToRestore = new ArrayList<>(children); try { removeAllChildren(); IStatus status = triggeringOperation.undo(monitor, info); if (!status.isOK()) { children = childrenToRestore; } history.closeOperation(status.isOK(), false, IOperationHistory.UNDO); return status; } catch (ExecutionException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.UNDO); throw e; } catch (RuntimeException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.UNDO); throw e; } } return IOperationHistory.OPERATION_INVALID_STATUS; }
private RefactoringDescriptor getRefactoringDescriptor(IUndoableOperation operation) { if (operation instanceof TriggeredOperations) { operation= ((TriggeredOperations) operation).getTriggeringOperation(); } if (operation instanceof UndoableOperation2ChangeAdapter) { ChangeDescriptor changeDescriptor= ((UndoableOperation2ChangeAdapter) operation).getChangeDescriptor(); if (changeDescriptor instanceof RefactoringChangeDescriptor) { return ((RefactoringChangeDescriptor) changeDescriptor).getRefactoringDescriptor(); } } return null; }
/** * 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(); } }
@Override public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (triggeringOperation != null) { history.openOperation(this, IOperationHistory.REDO); List<IUndoableOperation> childrenToRestore = new ArrayList<>(children); try { removeAllChildren(); IStatus status = triggeringOperation.redo(monitor, info); if (!status.isOK()) { children = childrenToRestore; } history.closeOperation(status.isOK(), false, IOperationHistory.REDO); return status; } catch (ExecutionException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.REDO); throw e; } catch (RuntimeException e) { children = childrenToRestore; history.closeOperation(false, false, IOperationHistory.REDO); throw e; } } return IOperationHistory.OPERATION_INVALID_STATUS; }