package edu.pdx.cs410J.grader.poa.ui;

import com.google.inject.Singleton;
import edu.pdx.cs410J.grader.poa.POAGradeView;

import javax.swing.*;
import java.awt.*;

@Singleton
public class POAGradeWidgets implements POAGradeView {
  private final JCheckBox isLateCheckbox;
  private final JLabel totalPointsLabel;

  public POAGradeWidgets() {
    isLateCheckbox = new JCheckBox("Late");
    totalPointsLabel = new JLabel("out of");
  }

  public JCheckBox getIsLateCheckbox() {
    return isLateCheckbox;
  }

  @Override
  public void setIsEnabled(boolean isEnabled) {
    this.isLateCheckbox.setEnabled(isEnabled);
  }

  @Override
  public void setIsLate(boolean isLate) {
    this.isLateCheckbox.setSelected(isLate);
  }

  @Override
  public void addIsLateHandler(IsLateHandler handler) {
    this.isLateCheckbox.addItemListener(e -> handler.setIsLate(isLateCheckbox.isSelected()));
  }

  @Override
  public void setTotalPoints(String totalPoints) {
    this.totalPointsLabel.setText("out of " + totalPoints);
  }

  @Override
  public void addScoreValueHandler(ScoreValueHandler handler) {
    throw new UnsupportedOperationException("This method is not implemented yet");
  }

  @Override
  public void setErrorInScore(boolean errorInScore) {
    throw new UnsupportedOperationException("This method is not implemented yet");
  }

  public JComponent getGradeWidget() {
    JPanel panel = new JPanel(new FlowLayout());
    panel.add(this.totalPointsLabel);
    return panel;
  }
}

@@ -156,16 +156,87 @@
 a.awt.*;
+%0Aimport java.awt.event.FocusEvent;%0Aimport java.awt.event.FocusListener;
 %0A%0A@Singl
@@ -377,16 +377,50 @@
 tsLabel;
+%0A  private final JTextField score;
 %0A%0A  publ
@@ -527,24 +527,55 @@
 (%22out of%22);%0A
+    score = new JTextField(4);%0A
   %7D%0A%0A  publi
@@ -747,16 +747,54 @@
 abled);%0A
+    this.score.setEnabled(isEnabled);%0A
   %7D%0A%0A  @
@@ -1275,238 +1275,471 @@
   th
-row new UnsupportedOperationException(%22This method is not implemented yet%22);%0A  %7D%0A%0A  @Override%0A  public void setErrorInScore(boolean errorInScore) %7B%0A    throw new UnsupportedOperationException(%22This method is not implemented yet%22);
+is.score.addFocusListener(new FocusListener() %7B%0A      @Override%0A      public void focusGained(FocusEvent e) %7B%0A%0A      %7D%0A%0A      @Override%0A      public void focusLost(FocusEvent e) %7B%0A        handler.scoreValue(score.getText());%0A      %7D%0A    %7D);%0A  %7D%0A%0A  @Override%0A  public void setErrorInScore(boolean errorInScore) %7B%0A    if (errorInScore) %7B%0A      this.score.setBorder(BorderFactory.createLineBorder(Color.RED, 2));%0A%0A    %7D else %7B%0A      this.score.setBorder(null);%0A    %7D
 %0A  %7D
@@ -1824,24 +1824,88 @@
 wLayout());%0A
+    panel.add(new JLabel(%22Grade:%22));%0A    panel.add(this.score);%0A
     panel.ad

Add UI widgets for the POA submission's score.