<commit_before>package lt.markmerkk.ui.week;

import java.net.URL;
import java.time.LocalDateTime;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TableRow;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Popup;
import javafx.util.Callback;
import javax.inject.Inject;
import jfxtras.internal.scene.control.skin.agenda.AgendaWeekSkin;
import jfxtras.scene.control.agenda.Agenda;
import jfxtras.util.NodeUtil;
import lt.markmerkk.storage2.BasicLogStorage;
import lt.markmerkk.storage2.IDataListener;
import lt.markmerkk.storage2.SimpleLog;
import lt.markmerkk.ui.interfaces.UpdateListener;
import org.joda.time.DateTime;

/**
 * Created by mariusmerkevicius on 12/5/15.
 * Represents the presenter to display the log list
 */
public class WeekPresenter implements Initializable {
  @Inject BasicLogStorage storage;

  @FXML VBox mainContainer;
  Agenda agenda;

  UpdateListener updateListener;

  @Override public void initialize(URL location, ResourceBundle resources) {
    storage.register(new IDataListener<SimpleLog>() {
      @Override
      public void onDataChange(ObservableList<SimpleLog> data) {
        update();
      }
    });
    agenda = new Agenda();
    agenda.setLocale(new java.util.Locale("de"));
		agenda.setSkin(new AgendaWeekSkin(agenda));
//		agenda.setSkin(new AgendaDaySkin(agenda));
		agenda.setAllowDragging(false);
		agenda.setAllowResize(false);
    agenda.editAppointmentCallbackProperty().set(new Callback<Agenda.Appointment, Void>() {
      @Override
      public Void call(final Agenda.Appointment appointment) {
        if (updateListener == null) return null;
        if (!(appointment instanceof AppointmentSimpleLog)) return null;
        updateListener.onUpdate(((AppointmentSimpleLog) appointment).getSimpleLog());
        return null;
      }
    });


    mainContainer.getChildren().add(agenda);
    update();
  }

  private void update() {
    agenda.appointments().clear();
    for (final SimpleLog simpleLog : storage.getData()) {
      DateTime startTime = new DateTime(simpleLog.getStart());
      DateTime endTime = new DateTime(simpleLog.getEnd());
      agenda.appointments().add(
          new AppointmentSimpleLog(simpleLog)
              .withStartLocalDateTime(
                  LocalDateTime.of(
                      startTime.getYear(),
                      startTime.getMonthOfYear(),
                      startTime.getDayOfMonth(),
                      startTime.getHourOfDay(),
                      startTime.getMinuteOfHour()))
              .withEndLocalDateTime(
                  LocalDateTime.of(
                      endTime.getYear(),
                      endTime.getMonthOfYear(),
                      endTime.getDayOfMonth(),
                      endTime.getHourOfDay(),
                      endTime.getMinuteOfHour()))
              .withSummary(simpleLog.getComment())
      );
    }
  }

  public void setUpdateListener(UpdateListener updateListener) {
    this.updateListener = updateListener;
  }
}<commit_msg>Integrated different color groups for different log states.<commit_after>package lt.markmerkk.ui.week;

import java.net.URL;
import java.time.LocalDateTime;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TableRow;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Popup;
import javafx.util.Callback;
import javax.inject.Inject;
import jfxtras.internal.scene.control.skin.agenda.AgendaWeekSkin;
import jfxtras.scene.control.agenda.Agenda;
import jfxtras.util.NodeUtil;
import lt.markmerkk.storage2.BasicLogStorage;
import lt.markmerkk.storage2.IDataListener;
import lt.markmerkk.storage2.SimpleLog;
import lt.markmerkk.ui.interfaces.UpdateListener;
import org.joda.time.DateTime;

/**
 * Created by mariusmerkevicius on 12/5/15.
 * Represents the presenter to display the log list
 */
public class WeekPresenter implements Initializable {
  @Inject BasicLogStorage storage;

  @FXML VBox mainContainer;
  Agenda agenda;

  UpdateListener updateListener;

  @Override public void initialize(URL location, ResourceBundle resources) {
    storage.register(new IDataListener<SimpleLog>() {
      @Override
      public void onDataChange(ObservableList<SimpleLog> data) {
        update();
      }
    });
    agenda = new Agenda();
    agenda.setLocale(new java.util.Locale("de"));
		agenda.setSkin(new AgendaWeekSkin(agenda));
//		agenda.setSkin(new AgendaDaySkin(agenda));
		agenda.setAllowDragging(false);
		agenda.setAllowResize(false);
    agenda.editAppointmentCallbackProperty().set(new Callback<Agenda.Appointment, Void>() {
      @Override
      public Void call(final Agenda.Appointment appointment) {
        if (updateListener == null) return null;
        if (!(appointment instanceof AppointmentSimpleLog)) return null;
        updateListener.onUpdate(((AppointmentSimpleLog) appointment).getSimpleLog());
        return null;
      }
    });


    mainContainer.getChildren().add(agenda);
    update();
  }

  private void update() {
    agenda.appointments().clear();
    for (final SimpleLog simpleLog : storage.getData()) {
      DateTime startTime = new DateTime(simpleLog.getStart());
      DateTime endTime = new DateTime(simpleLog.getEnd());
      Agenda.AppointmentGroup group = null;
      switch (simpleLog.getStateImageUrl()) {
        case "/red.png":
          group = agenda.appointmentGroups().get(0);
          break;
        case "/yellow.png":
          group = agenda.appointmentGroups().get(10);
          break;
        case "/green.png":
          group = agenda.appointmentGroups().get(13);
          break;
      }
      agenda.appointments().add(
          new AppointmentSimpleLog(simpleLog)
              .withStartLocalDateTime(
                  LocalDateTime.of(
                      startTime.getYear(),
                      startTime.getMonthOfYear(),
                      startTime.getDayOfMonth(),
                      startTime.getHourOfDay(),
                      startTime.getMinuteOfHour()))
              .withEndLocalDateTime(
                  LocalDateTime.of(
                      endTime.getYear(),
                      endTime.getMonthOfYear(),
                      endTime.getDayOfMonth(),
                      endTime.getHourOfDay(),
                      endTime.getMinuteOfHour()))
              .withAppointmentGroup(group)
              .withSummary(simpleLog.getComment())
      );
    }
  }

  public void setUpdateListener(UpdateListener updateListener) {
    this.updateListener = updateListener;
  }
}
{'fraction_non_alphanumeric': 0.10295545996947413, 'fraction_numerical': 0.0029138337727209656, 'mean_word_length': 2.9889319313779747, 'pattern_counts': {'":': 3, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5524123', 'n_tokens_mistral': 2084, 'n_tokens_neox': 2041, 'n_words': 378}