Ejemplo n.º 1
0
 protected void runPostActions() throws DartModelException {
   while (actionsStart <= actionsEnd) {
     IPostAction postAction = actions[actionsStart++];
     if (POST_ACTION_VERBOSE) {
       System.out.println(
           "("
               + Thread.currentThread()
               + ") [DartModelOperation.runPostActions()] Running action "
               + postAction.getID()); // $NON-NLS-1$ //$NON-NLS-2$
     }
     postAction.run();
   }
 }
Ejemplo n.º 2
0
  /**
   * Register the given action to be run when the outer most Dart model operation has finished. The
   * insertion mode controls whether: - the action should discard all existing actions with the same
   * id, and be queued at the end (REMOVEALL_APPEND), - the action should be ignored if there is
   * already an action with the same id (KEEP_EXISTING), - the action should be queued at the end
   * without looking at existing actions (APPEND)
   */
  protected void postAction(IPostAction action, int insertionMode) {
    if (POST_ACTION_VERBOSE) {
      System.out.print(
          "("
              + Thread.currentThread()
              + ") [DartModelOperation.postAction(IPostAction, int)] Posting action "
              + action.getID()); // $NON-NLS-1$ //$NON-NLS-2$
      switch (insertionMode) {
        case REMOVEALL_APPEND:
          System.out.println(" (REMOVEALL_APPEND)"); // $NON-NLS-1$
          break;
        case KEEP_EXISTING:
          System.out.println(" (KEEP_EXISTING)"); // $NON-NLS-1$
          break;
        case APPEND:
          System.out.println(" (APPEND)"); // $NON-NLS-1$
          break;
      }
    }

    DartModelOperation topLevelOp = getCurrentOperationStack().get(0);
    IPostAction[] postActions = topLevelOp.actions;
    if (postActions == null) {
      topLevelOp.actions = postActions = new IPostAction[1];
      postActions[0] = action;
      topLevelOp.actionsEnd = 0;
    } else {
      String id = action.getID();
      switch (insertionMode) {
        case REMOVEALL_APPEND:
          int index = actionsStart - 1;
          while ((index = topLevelOp.firstActionWithID(id, index + 1)) >= 0) {
            // remove action[index]
            System.arraycopy(
                postActions, index + 1, postActions, index, topLevelOp.actionsEnd - index);
            postActions[topLevelOp.actionsEnd--] = null;
          }
          topLevelOp.addAction(action);
          break;
        case KEEP_EXISTING:
          if (topLevelOp.firstActionWithID(id, 0) < 0) {
            topLevelOp.addAction(action);
          }
          break;
        case APPEND:
          topLevelOp.addAction(action);
          break;
      }
    }
  }