コード例 #1
0
 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()));
 }
コード例 #2
0
 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();
               }
             });
   }
 }
コード例 #3
0
    @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;
      }
    }