Example #1
0
  /**
   * Method to return a list of current jobs
   *
   * @return list of job id's
   */
  private List<String> getCurrentJobsList() {
    List<String> jobsList = new ArrayList<String>();
    for (MyJobsModel m : myJobsStore.getAll()) {
      jobsList.add(m.getJobid());
    }

    return jobsList;
  }
Example #2
0
  /**
   * Adds jobs to grid.
   *
   * @param jobs jobs to display
   * @param selectedJobId current job
   */
  private void setJobs(List<ProcessingInProgressData> jobs, String selectedJobId) {
    MyJobsModel itemToSelect = null;
    int itemToSelectIndex = 0;

    if (jobs != null) {
      int i = 0;

      for (int ii = 0; ii < myJobsStore.size(); ii++) {
        MyJobsModel model = myJobsStore.get(ii);
        boolean found = false;
        int j = 0;

        while ((j < jobs.size()) && (!found)) {
          if (jobs.get(j).getJobId().equals(model.getJobid())) {
            found = true;
            break;
          }

          j++;
        }

        if (!found) {
          myJobsStore.remove(ii);
        }
      }

      for (ProcessingInProgressData statusData : jobs) {
        MyJobsModel myJobsModel =
            new MyJobsModel(statusData.getJobId(), statusData.getStatus(), statusData.getInput());

        if ((selectedJobId != null) && (statusData.getJobId().equals(selectedJobId))) {
          itemToSelect = myJobsModel;
          itemToSelectIndex = i;
        }

        MyJobsModel existingModel = myJobsStore.findModel(myJobsModel);

        if (existingModel != null) {
          existingModel.setStatus(statusData.getStatus());
          existingModel.setInput(statusData.getInput());
          myJobsStore.update(existingModel);
        } else {
          myJobsStore.add(myJobsModel);
        }

        i++;
      }
    }

    myJobsStore.commitChanges();

    if ((selectedJobId != null) && (myJobsStore.size() > 0)) {
      myJobsGrid.getSelectionModel().select(itemToSelect, false);

      if (isJobsListFirstTimeLoaded) {
        myJobsGrid.getView().focusRow(itemToSelectIndex);
        isJobsListFirstTimeLoaded = false;
      }
      EventBusManager.EVENT_BUS.fireEvent(new ShowJobsPanelEvent());
    } else {
      EventBusManager.EVENT_BUS.fireEvent(new HideJobsPanelEvent());
    }
  }