Beispiel #1
0
  public Config() {
    this.models = new DefaultListModel[7];
    for (int x = 0; x < 7; x++) {
      this.models[x] = new DefaultListModel<String>();
    }
    this.locale = Main.getLocale();
    this.dfs = DateFormatSymbols.getInstance(Main.getLocale());
    initDyn();

    initComponents();
  }
Beispiel #2
0
  /**
   * Used to edit days.
   *
   * @param days
   */
  @SuppressWarnings("unchecked")
  public Config(ArrayList<Day> days, Locale locale) {
    this.models = new DefaultListModel[7];
    for (int x = 0; x < 7; x++) {
      this.models[x] = new DefaultListModel<String>();
    }
    this.locale = locale;
    this.dfs = DateFormatSymbols.getInstance(Main.getLocale());
    initDyn();
    initComponents();

    // SWAP, 1 TEAM: 03
    //
    // QUALITY CHANGES
    //
    // Removed the if statement inside of the loop because it all did the
    // same stuff except for the do click
    // which i moved to a new method called performClickForDay()
    // This overcame the duplicated code Bad code smell
    for (Day day : days) {
      int dayIndex = day.getIndexOfDay();

      performClickForDay(dayIndex);
      ArrayList<String> jobs = day.getJobs();

      for (String job : jobs) {
        this.models[dayIndex].addElement(job);
      }
    }
  }
Beispiel #3
0
 /** @param evt */
 private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {
   ArrayList<Day> days = new ArrayList<Day>();
   if (this.sundayCheck.isSelected()) {
     ArrayList<Object> sun = new ArrayList<Object>();
     List<Object> jobs = Arrays.asList(this.models[0].toArray());
     sun.addAll(jobs);
     days.add(new Day(dfs.getWeekdays()[1], sun));
   }
   if (this.mondayCheck.isSelected()) {
     ArrayList<Object> mon = new ArrayList<Object>();
     List<Object> jobs = Arrays.asList(this.models[1].toArray());
     mon.addAll(jobs);
     days.add(new Day(dfs.getWeekdays()[2], mon));
   }
   if (this.tuesdayCheck.isSelected()) {
     ArrayList<Object> tue = new ArrayList<Object>();
     List<Object> jobs = Arrays.asList(this.models[2].toArray());
     tue.addAll(jobs);
     days.add(new Day(dfs.getWeekdays()[3], tue));
   }
   if (this.wednesdayCheck.isSelected()) {
     ArrayList<Object> wed = new ArrayList<Object>();
     List<Object> jobs = Arrays.asList(this.models[3].toArray());
     wed.addAll(jobs);
     days.add(new Day(dfs.getWeekdays()[4], wed));
   }
   if (this.thursdayCheck.isSelected()) {
     ArrayList<Object> thu = new ArrayList<Object>();
     List<Object> jobs = Arrays.asList(this.models[4].toArray());
     thu.addAll(jobs);
     days.add(new Day(dfs.getWeekdays()[5], thu));
   }
   if (this.fridayCheck.isSelected()) {
     ArrayList<Object> fri = new ArrayList<Object>();
     List<Object> jobs = Arrays.asList(this.models[5].toArray());
     fri.addAll(jobs);
     days.add(new Day(dfs.getWeekdays()[6], fri));
   }
   if (this.saturdayCheck.isSelected()) {
     ArrayList<Object> sat = new ArrayList<Object>();
     List<Object> jobs = Arrays.asList(this.models[6].toArray());
     sat.addAll(jobs);
     days.add(new Day(dfs.getWeekdays()[7], sat));
   }
   if (days.size() > 0) {
     boolean hasJobs = true;
     int i = 0;
     while (hasJobs && i < days.size()) {
       if (days.get(i).getJobs().size() == 0) {
         hasJobs = false;
       }
       i++;
     }
     if (hasJobs) {
       Main.setDays(days);
       Main.wSet = new WorkerSetup(Main.getLocale());
       Main.toggleWorkerSetup();
       Main.config = this;
       Main.toggleConfig();
     } else {
       JOptionPane.showMessageDialog(this, "You must have at least one job each day.");
     }
   } else {
     JOptionPane.showMessageDialog(this, "You have not added any days.");
   }
 }