Skip to content

Commit

Permalink
Merge pull request #129 from shawnlsj97/master
Browse files Browse the repository at this point in the history
Fix information display sizing and complete calendar feature
  • Loading branch information
shawnlsj97 authored Oct 30, 2019
2 parents 7d5d692 + ecfe41e commit e807339
Show file tree
Hide file tree
Showing 26 changed files with 247 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public CommandResult execute(Model model) throws CommandException {
switch (date.getType()) {
case 1:
String resultMsg =
MESSAGE_SUCCESS_1 + date.getDay() + " " + date.getMth() + " " + date.getYear();
MESSAGE_SUCCESS_1 + date.toString();
return new CommandResult(resultMsg, date, model);
case 2:
String resultMsg2 = MESSAGE_SUCCESS_2 + date.getMth() + " " + date.getYear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public CommandResult execute(Model model) throws CommandException {

Training training = new Training(super.getDate(), trainingAttendance);
model.addTraining(training);
return new CommandResult(TRAINING_ADD_SUCCESS);
AthletickDate date = super.getDate();
date.setType(2);
return new CommandResult(TRAINING_ADD_SUCCESS, date, model);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public CommandResult execute(Model model) throws CommandException {

Training training = new Training(super.getDate(), trainingAttendance);
model.addTraining(training);
return new CommandResult(TRAINING_ADD_SUCCESS);
AthletickDate date = super.getDate();
date.setType(2);
return new CommandResult(TRAINING_ADD_SUCCESS, date, model);
}
}
35 changes: 35 additions & 0 deletions src/main/java/seedu/address/ui/AttendanceTableContent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package seedu.address.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Region;

/**
* The UI component that displays a training record for a person. A training record includes a name
* and an tick or cross indicating attendance.
*/
public class AttendanceTableContent extends UiPart<Region> {

private static final String FXML = "AttendanceTableContent.fxml";
private Image tickIcon = new Image(this.getClass().getResourceAsStream("/images/tick.png"));
private Image crossIcon = new Image(this.getClass().getResourceAsStream("/images/cross.png"));

@FXML
private Label name;

@FXML
private ImageView indicator;

public AttendanceTableContent(String personName, boolean isPresent) {
super(FXML);
name.setText(personName);
if (isPresent) {
indicator.setImage(tickIcon);
} else {
indicator.setImage(crossIcon);
}
}
}

16 changes: 16 additions & 0 deletions src/main/java/seedu/address/ui/AttendanceTableHeader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package seedu.address.ui;

import javafx.scene.layout.Region;

/**
* The UI component that displays the title of a training record.
*/

public class AttendanceTableHeader extends UiPart<Region> {

private static final String FXML = "AttendanceTableHeader.fxml";

public AttendanceTableHeader() {
super(FXML);
}
}
57 changes: 36 additions & 21 deletions src/main/java/seedu/address/ui/CalendarDetailPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,49 @@ public CalendarDetailPanel(AthletickDate date, Model model) {
* name and attendance in the same row.
*/
private void initialiseAttendanceData() {
HashMap<Person, Boolean> attendanceData = model.getTrainingAttendanceOnDate(date);
attendanceData.forEach((person, attendance) -> {
String name = person.getName().toString();
boolean isPresent = attendance.booleanValue();
});
if (model.hasTraining(date)) {
attendanceBox.getChildren().add(new AttendanceTableHeader().getRoot());
HashMap<Person, Boolean> attendanceData = model.getTrainingAttendanceOnDate(date);
attendanceData.forEach((person, attendance) -> {
String name = person.getName().toString();
boolean isPresent = attendance;
AttendanceTableContent content = new AttendanceTableContent(name, isPresent);
attendanceBox.getChildren().add(content.getRoot());
});
} else {
String errorMsg = "No Training Record on " + date.toString();
ErrorMessageLabel error = new ErrorMessageLabel(errorMsg);
attendanceBox.getChildren().add(error.getRoot());
}
}

/**
* Retrieves performance data from model. Creates a header for each event and lists records for
* the event taken on the particular date.
*/
private void initialisePerformanceData() {
HashMap<Event, List<CalendarCompatibleRecord>> performanceData =
model.getCalendarCompatiblePerformance(date);
performanceData.forEach((event, recordList) -> {
int numRecords = recordList.size();
if (numRecords > 0) {
PerformanceTableHeader header = new PerformanceTableHeader(event.getName());
performanceBox.getChildren().add(header.getRoot());
for (int i = 0; i < numRecords; i++) {
CalendarCompatibleRecord record = recordList.get(i);
Person athlete = record.getAthlete();
String name = athlete.getName().toString();
String timing = record.getTiming();
PerformanceTableContent content = new PerformanceTableContent(name, timing);
performanceBox.getChildren().add(content.getRoot());
if (model.hasPerformanceOn(date)) {
HashMap<Event, List<CalendarCompatibleRecord>> performanceData =
model.getCalendarCompatiblePerformance(date);
performanceData.forEach((event, recordList) -> {
int numRecords = recordList.size();
if (numRecords > 0) {
PerformanceTableHeader header = new PerformanceTableHeader(event.getName());
performanceBox.getChildren().add(header.getRoot());
for (int i = 0; i < numRecords; i++) {
CalendarCompatibleRecord record = recordList.get(i);
Person athlete = record.getAthlete();
String name = athlete.getName().toString();
String timing = record.getTiming();
PerformanceTableContent content = new PerformanceTableContent(name, timing);
performanceBox.getChildren().add(content.getRoot());
}
}
}
});
});
} else {
String errorMsg = "No Performance Record on " + date.toString();
ErrorMessageLabel error = new ErrorMessageLabel(errorMsg);
performanceBox.getChildren().add(error.getRoot());
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/ui/CalendarPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ private void fillUpGrid(int numBefore, int numCurr, String[] days) {
for (int col = 0; col < 7; col++) {
String day = days[counter];
Label l = createLabel(day);
boolean havePerformanceEntry = false;
boolean haveTrainingEntry = false;
boolean havePerformanceEntry;
boolean haveTrainingEntry;
boolean setColour = false;
if (beforeCount > 0) {
l.setTextFill(Paint.valueOf("#999999"));
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/seedu/address/ui/ErrorMessageLabel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package seedu.address.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.Region;

/**
* The UI component that displays an error message when no training or performance record is
* found on a particular date.
*/
public class ErrorMessageLabel extends UiPart<Region> {

private static final String FXML = "ErrorMessage.fxml";

@FXML
private Label message;

public ErrorMessageLabel(String text) {
super(FXML);
message.setText(text);
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/ui/InformationDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public InformationDisplay(Person selectedPerson, String attendance) {
* Resize the image when window size changes
*/
public void resizeImage() {
photo.fitHeightProperty().bind(imageHolder.heightProperty().subtract(100));
photo.fitWidthProperty().bind(imageHolder.widthProperty().subtract(100));
photo.fitHeightProperty().bind(imageHolder.heightProperty().subtract(40));
photo.fitWidthProperty().bind(imageHolder.widthProperty());
}
}
1 change: 1 addition & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ private CommandResult executeCommand(String commandText) throws CommandException
break;
}
}

if (!(commandResult.getPerson() == null)) {
InformationDisplay informationDisplay = new InformationDisplay(logic.getPerson(),
logic.getPersonAttendance());
Expand Down
Binary file removed src/main/resources/images/alice.png
Binary file not shown.
Binary file removed src/main/resources/images/amy.png
Binary file not shown.
Binary file removed src/main/resources/images/bob.png
Binary file not shown.
Binary file removed src/main/resources/images/carl.png
Binary file not shown.
Binary file added src/main/resources/images/cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/main/resources/images/daniel.png
Binary file not shown.
Binary file removed src/main/resources/images/default.png
Binary file not shown.
Binary file removed src/main/resources/images/dummy.png
Binary file not shown.
Binary file added src/main/resources/images/tick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/main/resources/view/AttendanceTableContent.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>


<VBox maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane maxWidth="1.7976931348623157E308">
<columnConstraints>
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label fx:id="name" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Name" wrapText="true">
<font>
<Font size="13.0" />
</font>
</Label>
<ImageView fx:id="indicator" fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" />
</children>
</GridPane>
</children>
</VBox>
42 changes: 42 additions & 0 deletions src/main/resources/view/AttendanceTableHeader.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>


<VBox maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane maxWidth="1.7976931348623157E308">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-background-color: #95AFC0;" text="Name" textFill="WHITE">
<font>
<Font name="System Bold" size="16.0" />
</font>
<padding>
<Insets left="16.0" right="16.0" />
</padding>
</Label>
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-background-color: #95AFC0;" text="Attendance" textFill="WHITE" GridPane.columnIndex="1">
<font>
<Font name="System Bold" size="16.0" />
</font>
<padding>
<Insets left="16.0" right="16.0" />
</padding>
</Label>
</children>
</GridPane>
</children>
</VBox>
6 changes: 3 additions & 3 deletions src/main/resources/view/CalendarDetailPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-background-color: #ffffff;" styleClass="edge-to-edge" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-background-color: #ffffff;" styleClass="edge-to-edge" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<content>
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-background-color: #ffffff;">
<children>
Expand All @@ -21,7 +21,7 @@
<Insets />
</VBox.margin>
</Label>
<VBox fx:id="attendanceBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="50.0" style="-fx-background-color: #ffffff;">
<VBox fx:id="attendanceBox" alignment="TOP_CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="50.0" style="-fx-background-color: #ffffff;">
<padding>
<Insets bottom="16.0" left="32.0" right="32.0" top="16.0" />
</padding>
Expand All @@ -34,7 +34,7 @@
<Insets bottom="4.0" left="32.0" top="4.0" />
</padding>
</Label>
<VBox fx:id="performanceBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="50.0" style="-fx-background-color: #ffffff;">
<VBox fx:id="performanceBox" alignment="TOP_CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="50.0" style="-fx-background-color: #ffffff;">
<padding>
<Insets bottom="16.0" left="32.0" right="32.0" top="16.0" />
</padding>
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/view/ErrorMessage.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox maxWidth="1.7976931348623157E308" style="-fx-background-color: #ffffff;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="message" alignment="CENTER" maxWidth="1.7976931348623157E308" text="Attendance Not Found" wrapText="true">
<padding>
<Insets left="8.0" right="8.0" />
</padding>
<font>
<Font size="16.0" />
</font>
</Label>
</children>
</VBox>
Loading

0 comments on commit e807339

Please sign in to comment.