@Override public void historyNotification(OperationHistoryEvent event) { if (!enabled) return; /* * OPERATION_ADDED is triggered when Eclipse adds a new operation to * its history. We do the same on this event. */ if (event.getEventType() == OperationHistoryEvent.OPERATION_ADDED) { storeCurrentLocalOperation(); updateCurrentLocalAtomicOperation(null); } /* * OPERATION_CHANGED is triggered when Eclipse changes the operation * that is recently added to its history. For example: Eclipse adds * Insert(3,"A") to its operation and later on the user enters B at * position 4. If Eclipse decides not to add a new Undo step it * changes the most recent operation in history to Insert(3, "AB") */ if (event.getEventType() == OperationHistoryEvent.OPERATION_CHANGED) { updateCurrentLocalAtomicOperation(null); } }
static final void put(final StructuredContent content, final OperationHistoryEvent event) { content.put( key("type"), OperationHistoryEventType.valueOf(event.getEventType()).toString().toLowerCase()); content.put(key("status"), new StatusSerializer(TREE).serialize(event.getStatus())); content.put( key("operation"), new UndoableOperationSerializer(TREE).serialize(event.getOperation())); }
public void historyNotification(OperationHistoryEvent event) { // This method updates the enablement of all content operations // when the undo history changes. It could be localized to UNDO and REDO. IUndoContext context = getUndoContext(); if (context != null && event.getOperation().hasContext(context)) { Display.getDefault() .asyncExec( new Runnable() { public void run() { updateContentDependantActions(); } }); } }
@Override public void historyNotification(final OperationHistoryEvent event) { IWorkbenchWindow workbenchWindow = getWorkbenchWindow(); if (workbenchWindow == null) return; Display display = workbenchWindow.getWorkbench().getDisplay(); if (display == null) return; switch (event.getEventType()) { case OperationHistoryEvent.OPERATION_ADDED: case OperationHistoryEvent.OPERATION_REMOVED: case OperationHistoryEvent.UNDONE: case OperationHistoryEvent.REDONE: if (event.getOperation().hasContext(undoContext)) { display.asyncExec( new Runnable() { @Override public void run() { update(); } }); } break; case OperationHistoryEvent.OPERATION_NOT_OK: if (event.getOperation().hasContext(undoContext)) { display.asyncExec( new Runnable() { @Override public void run() { if (pruning) { IStatus status = event.getStatus(); /* * Prune the history unless we can determine * that this was a cancelled attempt. See * https://bugs.eclipse.org/bugs/show_bug.cgi?id=101215 */ if (status == null || status.getSeverity() != IStatus.CANCEL) { flush(); } // not all flushes will trigger an update so // force it here update(); } else { update(); } } }); } break; case OperationHistoryEvent.OPERATION_CHANGED: if (event.getOperation() == getOperation()) { display.asyncExec( new Runnable() { @Override public void run() { update(); } }); } break; } }