forked from nus-cs2113-AY2021S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from QX-CHEN/display
Display
- Loading branch information
Showing
8 changed files
with
226 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,71 @@ | ||
package seedu.ui; | ||
|
||
import seedu.commons.Util; | ||
import seedu.data.TaskMap; | ||
import seedu.task.Task; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.TextStyle; | ||
import java.util.Locale; | ||
|
||
import static seedu.messages.Messages.LS; | ||
|
||
public class DayStructure extends DisplayDateStructure { | ||
|
||
public DayStructure(LocalDate date) { | ||
super(date); | ||
} | ||
|
||
@Override | ||
protected void generateScreen(TaskMap tasks) { | ||
protected void generateContent(TaskMap tasks) { | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
|
||
String headerFormat = " | %-10s | %-20s | %-15s | %-10s | %-10s | %-11s |" + LS; | ||
String contentFormat = " | %-10s | %-20s | %-15s | %-10s | %-10s | %-20s |" + LS; | ||
|
||
stringBuilder.append(LS) | ||
.append(currentDate.format(DateTimeFormatter.ofPattern("dd-MMM-yyyy"))) | ||
.append(" ") | ||
.append(currentDate.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.ENGLISH)) | ||
.append(":") | ||
.append(LS) | ||
.append(" ") | ||
.append(Util.generatePadStringWithCharAndLength('_', 93)) | ||
.append(LS) | ||
.append(String.format(headerFormat, "Index", "Description", "Date", "Start", "End", "Priority")) | ||
.append(" ").append(Util.generatePadStringWithCharAndLength('-', 93)) | ||
.append(LS); | ||
|
||
TaskMap filteredTasks = tasks.searchByDate(currentDate); | ||
if (filteredTasks.size() == 0) { | ||
stringBuilder.append(" |") | ||
.append(Util.generatePadStringWithCharAndLength(' ', 93)) | ||
.append("|") | ||
.append(LS); | ||
} else { | ||
for (Task task : filteredTasks.getValues()) { | ||
stringBuilder.append(String.format(contentFormat, | ||
"#" + task.getTaskID(), | ||
Util.limitStringWithDots(task.getDescription(), 20), | ||
task.getDate(), | ||
task.getStartTime() == null ? "" : task.getStartTime(), | ||
task.getEndTime() == null ? "" : task.getEndTime(), | ||
task.getPriority())); | ||
} | ||
} | ||
stringBuilder.append(" ") | ||
.append(Util.generatePadStringWithCharAndLength('-', 93)) | ||
.append(LS); | ||
|
||
content = stringBuilder.toString(); | ||
} | ||
|
||
public void increment() { | ||
setCurrentDate(currentDate.plusDays(1)); | ||
} | ||
|
||
public void decrement() { | ||
setCurrentDate(currentDate.minusDays(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
public enum DisplayMode { | ||
ALL, | ||
WEEK, | ||
MONTH; | ||
MONTH, | ||
DAY; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.