001package edu.pdx.cs410J.grader.poa.ui;
002
003import com.google.inject.Inject;
004import com.google.inject.Singleton;
005
006import javax.swing.*;
007import java.awt.*;
008
009@Singleton
010public class POASubmissionInformationPanel extends JPanel {
011
012  @Inject
013  public POASubmissionInformationPanel(POASubmissionInformationWidgets submissionWidgets,
014                                       GradeBookWidget gradeBookWidget,
015                                       StudentsWidget studentsWidget,
016                                       POAAssignmentsWidget assignmentsWidget,
017                                       POAGradeWidgets gradeWidgets) {
018    this.setLayout(new BorderLayout());
019
020    JPanel information = new JPanel(new GridBagLayout());
021
022    addComponentOnGrid(submissionWidgets.getSubmitterWidget(), information, 0, 0);
023    addComponentOnGrid(studentsWidget, information, 0, 1);
024
025    addComponentOnGrid(submissionWidgets.getSubjectWidget(), information, 1, 0);
026    addComponentOnGrid(assignmentsWidget, information, 1, 1);
027
028    addComponentOnGrid(submissionWidgets.getSubmissionTimeWidget(), information, 2, 0);
029
030    addComponentOnGrid(gradeBookWidget, information, 3, 0);
031    addComponentOnGrid(gradeWidgets.getGradeWidget(), information, 3, 1);
032
033    this.add(information, BorderLayout.NORTH);
034    this.add(submissionWidgets.getSubmissionContentWidget(), BorderLayout.CENTER);
035  }
036
037  private void addComponentOnGrid(JComponent component, JPanel container, int row, int column) {
038    GridBagConstraints constraints = new GridBagConstraints();
039    constraints.fill = GridBagConstraints.HORIZONTAL;
040    constraints.anchor = GridBagConstraints.LINE_START;
041    constraints.gridx = column;
042    constraints.gridy = row;
043
044    container.add(component, constraints);
045  }
046
047}