Ejemplo n.º 1
0
  protected void addImplicitTransitions(Activity activity) {
    List activities = getActivities();
    int activityCount = activities.size();
    End end = getEnd();

    if (activityCount > 0) {
      Activity lastActivity = (Activity) activities.get(activityCount - 1);
      lastActivity.disconnect(end);
      lastActivity.connect(activity);
    } else getBegin().connect(activity);

    activity.connect(end);
  }
Ejemplo n.º 2
0
  public void reorderNode(int oldIndex, int newIndex) {
    // remove activity from its old position and disconnect it from other nodes
    List activities = getActivities();
    Activity reorderedActivity = (Activity) activities.remove(oldIndex);
    removeImplicitTransitions(reorderedActivity);

    // connect activity to its new predecessor and successor
    Activity predecessor = (newIndex == 0 ? getBegin() : (Activity) activities.get(newIndex - 1));
    Activity successor =
        newIndex == activities.size() ? getEnd() : (Activity) activities.get(newIndex);

    Transition leaving = predecessor.getDefaultLeavingTransition();
    successor.removeArrivingTransition(leaving);
    reorderedActivity.addArrivingTransition(leaving);
    reorderedActivity.connect(successor);

    activities.add(newIndex, reorderedActivity);
  }