コード例 #1
0
  public ActivityTaskProgressModel(ActivityTask activity) {
    d_task = activity;
    Set<Task> states = activity.getModel().getStates();

    if (!d_task.isFinished()) {
      for (Task state : states) {
        d_progress.put(state, 0.0);
        state.addTaskListener(d_listener);
      }
    }
    d_task.addTaskListener(
        new TaskListener() {
          public void taskEvent(TaskEvent e) {
            synchronized (d_lock) {
              if (e instanceof PhaseEvent) {
                Task phase = ((PhaseEvent) e).getPhase();
                if (e.getType().equals(TaskEvent.EventType.PHASE_STARTED)) {
                  d_runningTasks.add(phase);
                } else if (e.getType().equals(TaskEvent.EventType.PHASE_FINISHED)) {
                  d_runningTasks.remove(phase);
                }
                setDeterminate(calcDeterminate());
                setProgress(calcProgress());
              }
            }
          }
        });
    d_iterables.addAll(findIterables(states));
  }
コード例 #2
0
 protected List<String> getPhaseStrings() {
   List<String> phaseStrings = new ArrayList<String>();
   synchronized (d_lock) {
     for (Task p : d_runningTasks) {
       phaseStrings.add(
           p.toString()
               + ((p instanceof IterativeTask) ? ": " + formatProgress(d_progress.get(p)) : ""));
     }
   }
   return phaseStrings;
 }