Java 类org.eclipse.core.commands.operations.OperationHistoryEvent 实例源码

项目:OpenSPIFe    文件:OperationHistoryMonitor.java   
@Override
    public void historyNotification(OperationHistoryEvent event) {

        IUndoableOperation op = event.getOperation();
        String typeString = decodeEventType(event.getEventType());
//      System.out.println("type='"+typeString+"' operation='"+op+"' of type '"+op.getClass().getName()+"' e="+op.canExecute()+" u="+op.canUndo()+" r="+op.canRedo());
//      for(IUndoContext c : op.getContexts()) {
//          System.out.println("\t"+c.getLabel());
//      }

        switch(event.getEventType()) {
            case OperationHistoryEvent.OPERATION_ADDED:
            case OperationHistoryEvent.OPERATION_CHANGED:
            case OperationHistoryEvent.OPERATION_REMOVED:
            case OperationHistoryEvent.ABOUT_TO_EXECUTE:
            case OperationHistoryEvent.ABOUT_TO_REDO:
            case OperationHistoryEvent.ABOUT_TO_UNDO:
                break;
            default:
                EnsembleUsageLogger.logUsage(op.getLabel() + " - " + typeString + "\n" + op.toString());
        }

    }
项目:OpenSPIFe    文件:OperationHistoryMonitor.java   
private static String decodeEventType(int eventType) {
    String typeString = null;
    switch(eventType) {
        case OperationHistoryEvent.ABOUT_TO_EXECUTE:typeString="ABOUT_TO_EXECUTE";break;
        case OperationHistoryEvent.ABOUT_TO_REDO:typeString="ABOUT_TO_REDO";break;
        case OperationHistoryEvent.ABOUT_TO_UNDO:typeString="ABOUT_TO_UNDO";break;
        case OperationHistoryEvent.DONE:typeString="DONE";break;
        case OperationHistoryEvent.OPERATION_ADDED:typeString="OPERATION_ADDED";break;
        case OperationHistoryEvent.OPERATION_CHANGED:typeString="OPERATION_CHANGED";break;
        case OperationHistoryEvent.OPERATION_NOT_OK:typeString="OPERATION_NOT_OK";break;
        case OperationHistoryEvent.OPERATION_REMOVED:typeString="OPERATION_REMOVED";break;
        case OperationHistoryEvent.REDONE:typeString="REDONE";break;
        case OperationHistoryEvent.UNDONE:typeString="UNDONE";break;
    }
    return typeString;
}
项目:OpenSPIFe    文件:Timeline.java   
@Override
public void historyNotification(OperationHistoryEvent event) {
    switch (event.getEventType()) {
    case OperationHistoryEvent.ABOUT_TO_EXECUTE:
    case OperationHistoryEvent.ABOUT_TO_REDO:
    case OperationHistoryEvent.ABOUT_TO_UNDO:
        if (WidgetUtils.inDisplayThread()) {
            Animation.markBegin();
        }
        break;
    case OperationHistoryEvent.DONE:
    case OperationHistoryEvent.REDONE:
    case OperationHistoryEvent.UNDONE:
        if (WidgetUtils.inDisplayThread()) {
            Animation.run(150);
        }
        break;
    }
}
项目:OpenSPIFe    文件:AbstractUndoableOperationAction.java   
@Override
public void historyNotification(OperationHistoryEvent event) {
    int type = event.getEventType();
    if ((type == OperationHistoryEvent.DONE)
        || (type == OperationHistoryEvent.REDONE)
        || (type == OperationHistoryEvent.UNDONE)) {
        IUndoableOperation operation = event.getOperation();
        if ((undoContext == null) || operation.hasContext(undoContext) || operation.getContexts().length == 0) {
            Display display = WidgetUtils.getDisplay();
            display.asyncExec(new Runnable() {
                @Override
                public void run() {
                    updateEnablement();
                }
            });
        }
    }
}
项目:OpenSPIFe    文件:AbstractPlanEditorHandler.java   
@Override
public void historyNotification(OperationHistoryEvent event) {
    int eventType = event.getEventType();
    if (eventType == OperationHistoryEvent.DONE ||
            eventType == OperationHistoryEvent.UNDONE ||
            eventType == OperationHistoryEvent.REDONE) {
        IEditorPart activeEditor = getActiveEditor();
        if (activeEditor != null) {
            WidgetUtils.runInDisplayThread(activeEditor.getSite().getShell(), new Runnable() {
                @Override
                public void run() {
                    selectionChanged(activeSelectionProvider.getSelection());
                }
            });
        }
    }
}
项目:bts    文件:OperationHistoryListener.java   
public void historyNotification(OperationHistoryEvent event) {
    final int type = event.getEventType();
    switch (type) {
        case OperationHistoryEvent.UNDONE:
        case OperationHistoryEvent.REDONE:
        case OperationHistoryEvent.OPERATION_ADDED:
        case OperationHistoryEvent.OPERATION_REMOVED:
        case OperationHistoryEvent.OPERATION_NOT_OK:
            // if this is one of our operations
            if (event.getOperation().hasContext(this.context)) {
                this.update.update();
            }
    }
}
项目:che    文件:UndoManager2.java   
public void historyNotification(OperationHistoryEvent event) {
  IUndoableOperation op = event.getOperation();
  if (op instanceof TriggeredOperations) {
    op = ((TriggeredOperations) op).getTriggeringOperation();
  }
  UndoableOperation2ChangeAdapter changeOperation = null;
  if (op instanceof UndoableOperation2ChangeAdapter) {
    changeOperation = (UndoableOperation2ChangeAdapter) op;
  }
  if (changeOperation == null) return;
  Change change = changeOperation.getChange();
  switch (event.getEventType()) {
    case OperationHistoryEvent.ABOUT_TO_EXECUTE:
    case OperationHistoryEvent.ABOUT_TO_UNDO:
    case OperationHistoryEvent.ABOUT_TO_REDO:
      fireAboutToPerformChange(change);
      break;
    case OperationHistoryEvent.DONE:
    case OperationHistoryEvent.UNDONE:
    case OperationHistoryEvent.REDONE:
      fireChangePerformed(change);
      fireUndoStackChanged();
      fireRedoStackChanged();
      break;
    case OperationHistoryEvent.OPERATION_NOT_OK:
      fireChangePerformed(change);
      break;
    case OperationHistoryEvent.OPERATION_ADDED:
      // would be better to have different events for this
      fireUndoStackChanged();
      fireRedoStackChanged();
      break;
    case OperationHistoryEvent.OPERATION_REMOVED:
      // would be better to have different events for this
      fireUndoStackChanged();
      fireRedoStackChanged();
      break;
  }
}
项目:che    文件:UndoableOperation2ChangeAdapter.java   
public void aboutToNotify(OperationHistoryEvent event) {
  switch (event.getEventType()) {
    case OperationHistoryEvent.ABOUT_TO_EXECUTE:
    case OperationHistoryEvent.ABOUT_TO_UNDO:
    case OperationHistoryEvent.ABOUT_TO_REDO:
    case OperationHistoryEvent.DONE:
    case OperationHistoryEvent.UNDONE:
    case OperationHistoryEvent.REDONE:
    case OperationHistoryEvent.OPERATION_NOT_OK:
      ResourcesPlugin.getWorkspace().checkpoint(false);
      break;
  }
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyAboutToExecute(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "ABOUT_TO_EXECUTE " //$NON-NLS-1$ //$NON-NLS-2$
                + operation);
    }

    notifyListeners(new OperationHistoryEvent(
            OperationHistoryEvent.ABOUT_TO_EXECUTE, this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyAboutToRedo(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "ABOUT_TO_REDO " //$NON-NLS-1$ //$NON-NLS-2$
                + operation);
    }

    notifyListeners(new OperationHistoryEvent(
            OperationHistoryEvent.ABOUT_TO_REDO, this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyAboutToUndo(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "ABOUT_TO_UNDO " //$NON-NLS-1$ //$NON-NLS-2$
                + operation);
    }

    notifyListeners(new OperationHistoryEvent(
            OperationHistoryEvent.ABOUT_TO_UNDO, this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyAdd(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "OPERATION_ADDED " //$NON-NLS-1$ //$NON-NLS-2$
                + operation);
    }

    notifyListeners(new OperationHistoryEvent(
            OperationHistoryEvent.OPERATION_ADDED, this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyDone(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "DONE " + operation); //$NON-NLS-1$ //$NON-NLS-2$
    }

    notifyListeners(new OperationHistoryEvent(OperationHistoryEvent.DONE,
            this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyNotOK(IUndoableOperation operation, IStatus status) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "OPERATION_NOT_OK " //$NON-NLS-1$ //$NON-NLS-2$
                + operation);
    }

    notifyListeners(new OperationHistoryEvent(
            OperationHistoryEvent.OPERATION_NOT_OK, this, operation, status));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyRedone(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "REDONE " + operation); //$NON-NLS-1$ //$NON-NLS-2$
    }

    notifyListeners(new OperationHistoryEvent(OperationHistoryEvent.REDONE,
            this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyRemoved(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "OPERATION_REMOVED " //$NON-NLS-1$ //$NON-NLS-2$
                + operation);
    }

    notifyListeners(new OperationHistoryEvent(
            OperationHistoryEvent.OPERATION_REMOVED, this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyUndone(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "UNDONE " + operation); //$NON-NLS-1$ //$NON-NLS-2$
    }

    notifyListeners(new OperationHistoryEvent(OperationHistoryEvent.UNDONE,
            this, operation));
}
项目:OpenSPIFe    文件:DefaultOperationHistory.java   
private void notifyChanged(IUndoableOperation operation) {
    if (DEBUG_OPERATION_HISTORY_NOTIFICATION) {
        Tracing.printTrace("OPERATIONHISTORY", "OPERATION_CHANGED " //$NON-NLS-1$//$NON-NLS-2$
                + operation);
    }

    notifyListeners(new OperationHistoryEvent(
            OperationHistoryEvent.OPERATION_CHANGED, this, operation));
}
项目:OpenSPIFe    文件:TestOperationJob.java   
@Override
public void historyNotification(OperationHistoryEvent event) {
    IStatus status = event.getStatus();
    if ((status != null) && !status.isOK()) {
        testStatus = status;
    }
}
项目:cuina    文件:TerrainEditor.java   
@Override
public void historyNotification(OperationHistoryEvent event)
{
    if (event.getOperation() instanceof MapOperation)
    {
        System.out.println("Undo-History Event: " + event);
        panel.redraw();
    }
}
项目:che    文件:RefactoringHistoryService.java   
private void performHistoryNotification(final OperationHistoryEvent event) {
  RefactoringDescriptor descriptor = getRefactoringDescriptor(event.getOperation());
  if (descriptor != null) {
    RefactoringDescriptorProxyAdapter proxy = new RefactoringDescriptorProxyAdapter(descriptor);
    switch (event.getEventType()) {
      case OperationHistoryEvent.ABOUT_TO_EXECUTE:
        {
          if (checkDescriptor(descriptor, event.getOperation())) {
            fireRefactoringExecutionEvent(proxy, RefactoringExecutionEvent.ABOUT_TO_PERFORM);
          }
          break;
        }
      case OperationHistoryEvent.DONE:
        {
          if (!RefactoringDescriptor.ID_UNKNOWN.equals(descriptor.getID())) {
            long timeStamp =
                fOverrideTimeStamp >= 0 ? fOverrideTimeStamp : System.currentTimeMillis();
            descriptor.setTimeStamp(timeStamp);
          }

          fireRefactoringHistoryEvent(proxy, RefactoringHistoryEvent.PUSHED);
          fireRefactoringExecutionEvent(proxy, RefactoringExecutionEvent.PERFORMED);
          break;
        }
      case OperationHistoryEvent.ABOUT_TO_UNDO:
        {
          fireRefactoringExecutionEvent(proxy, RefactoringExecutionEvent.ABOUT_TO_UNDO);
          break;
        }
      case OperationHistoryEvent.UNDONE:
        {
          fireRefactoringHistoryEvent(proxy, RefactoringHistoryEvent.POPPED);
          fireRefactoringExecutionEvent(proxy, RefactoringExecutionEvent.UNDONE);
          break;
        }
      case OperationHistoryEvent.ABOUT_TO_REDO:
        {
          fireRefactoringExecutionEvent(proxy, RefactoringExecutionEvent.ABOUT_TO_REDO);
          break;
        }
      case OperationHistoryEvent.REDONE:
        {
          fireRefactoringHistoryEvent(proxy, RefactoringHistoryEvent.PUSHED);
          fireRefactoringExecutionEvent(proxy, RefactoringExecutionEvent.REDONE);
          break;
        }
    }
  }
}
项目:OpenSPIFe    文件:AbstractEnsembleEditorModel.java   
@Override
public void historyNotification(OperationHistoryEvent event) {
    IUndoableOperation eventOperation = event.getOperation();
    IUndoContext inputUndoContext = getUndoContext();
    IUndoContext[] operationContexts = eventOperation.getContexts();
    boolean matches = false;
    for (IUndoContext operationContext : operationContexts) {
        matches = operationContext.matches(inputUndoContext);
        if (matches) {
            break;
        }
    }
    if (!matches) {
        return;
    }
    switch (event.getEventType()) {
    case OperationHistoryEvent.REDONE: {
        if (eventOperation == cleanStateOperation) {
            dirty = false;
            fireDirtyStateChanged();
        } else if (!dirty) {
            dirty = true;
            fireDirtyStateChanged();
        }
        break;
    }
    case OperationHistoryEvent.DONE: {
        if (!dirty) {
            dirty = true;
            fireDirtyStateChanged();
        }
        break;
    }
    case OperationHistoryEvent.UNDONE: {
        IUndoableOperation undoOperation = event.getHistory().getUndoOperation(inputUndoContext);
        if (undoOperation == cleanStateOperation) {
            dirty = false;
            fireDirtyStateChanged();
        } else if (!dirty) {
            dirty = true;
            fireDirtyStateChanged();
        }
        break;
    }
    default:
        // nothing to do yet
        break;
    }
}
项目:NIEM-Modeling-Tool    文件:ClassifierNamePopupEditorConfiguration.java   
@Override
public void historyNotification(final OperationHistoryEvent event) {
    if (event.getOperation() == theEditLabelOperation) {
        if (event.getEventType() == OperationHistoryEvent.UNDONE) {
            async(new Runnable() {
                @Override
                public void run() {
                    final IUndoableOperation[] theUndoHistory = theCommandStack.getOperationHistory()
                            .getUndoHistory(theCommandStack.getDefaultUndoContext());
                    if (theUndoHistory.length > 0
                            && theUndoHistory[theUndoHistory.length - 1] == theCreateElementOperation) {
                        theCommandStack.undo();
                    } else {
                        Activator.INSTANCE
                        .log("Unable to cascade the undo after the element label change was undone. The Reference Library Subset may be in an illegal state.");
                        stopListening();
                    }
                }
            });
        } else if (event.getEventType() == OperationHistoryEvent.OPERATION_REMOVED) {
            stopListening();
        }
    }
    if (event.getOperation() == theCreateElementOperation) {
        if (event.getEventType() == OperationHistoryEvent.REDONE) {
            async(new Runnable() {
                @Override
                public void run() {
                    final IUndoableOperation[] theRedoHistory = theCommandStack.getOperationHistory()
                            .getRedoHistory(theCommandStack.getDefaultUndoContext());
                    if (theRedoHistory.length > 0
                            && theRedoHistory[theRedoHistory.length - 1] == theEditLabelOperation) {
                        theCommandStack.redo();
                    } else {
                        Activator.INSTANCE
                        .log("Unable to cascade the redo after the create element change was redone. The Reference Library Subset may be in an illegal state.");
                        stopListening();
                    }
                }
            });
        } else if (event.getEventType() == OperationHistoryEvent.OPERATION_REMOVED) {
            stopListening();
        }
    }
}
项目:OpenSPIFe    文件:OperationsHistoryMonitorTest.java   
@Test
public void simpleTest() {

    OperationHistoryMonitor monitor = new OperationHistoryMonitor();
    OperationHistoryEvent event = new OperationHistoryEvent(OperationHistoryEvent.REDONE, null, null);

    monitor.historyNotification(event);

    assertTrue(true);

}