Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to see the actual open and close time of tasks #73

Merged
merged 13 commits into from
Nov 3, 2016
Merged
19 changes: 18 additions & 1 deletion src/main/java/seedu/task/model/task/DateTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public class DateTime {

public static final String MESSAGE_DATETIME_CONSTRAINTS = "You have entered an invalid Date/Time format. For a complete list of all acceptable formats, please view our user guide.";

//@@author A0141052Y
private static final String DATE_TIME_DISPLAY_FORMAT = "%s (%s)";
//@@author

public final Optional<Instant> value;
private static PrettyTime p = new PrettyTime();

Expand Down Expand Up @@ -72,7 +76,7 @@ public String toString() {

if(value.isPresent()) {
DateTimeFormatter formatter =
DateTimeFormatter.ofLocalizedDateTime( FormatStyle.FULL )
DateTimeFormatter.ofLocalizedDateTime( FormatStyle.SHORT )
.withLocale( Locale.UK )
.withZone( ZoneId.systemDefault() );
return formatter.format( value.get() );
Expand All @@ -89,6 +93,19 @@ public String toPrettyString() {
}
}

//@@author A0141052Y
/**
* Gets a display friendly representation of the DateTime
*/
public String toDisplayString() {
if (this.toString().isEmpty()) {
return "";
} else {
return String.format(DATE_TIME_DISPLAY_FORMAT, this.toString(), this.toPrettyString());
}
}
//@@author

public Long getSaveableValue() {
if(value.isPresent()) {
return this.value.get().toEpochMilli();
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/task/ui/TaskCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class TaskCard extends UiPart{
@FXML
private Label closeTime;
//@@author

@FXML
private VBox cardDetails;

Expand Down Expand Up @@ -62,13 +63,14 @@ public void initialize() {
setVisualFlags();
showExtendedInformation();
}

//@@author A0144939R
private void setCardDetails() {
name.setText(task.getName().taskName);
id.setText(displayedIndex + ". ");

openTime.setText(task.getOpenTime().toPrettyString());
closeTime.setText(task.getCloseTime().toPrettyString());
openTime.setText(task.getOpenTime().toDisplayString());
closeTime.setText(task.getCloseTime().toDisplayString());

tagListPanel = TagListPanel.load(getPrimaryStage(), tagsListPlaceholder, task.getTags().getInternalList());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/view/TaskListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
<HBox spacing="5" alignment="CENTER_LEFT">
<children>
<Label styleClass="cell_big_label" text="Start: "></Label>
<Label fx:id="openTime" styleClass="cell_big_label" text="\$openTime" />
<Label fx:id="openTime" styleClass="cell_big_label" text="\$openTime" />
</children>
</HBox>
<HBox spacing="5" alignment="CENTER_LEFT">
<children>
<Label styleClass="cell_big_label" text="End: "></Label>
<Label fx:id="closeTime" styleClass="cell_big_label" text="\$closeTime" />
<Label fx:id="closeTime" styleClass="cell_big_label" text="\$closeTime" />
</children>
</HBox>
</children>
Expand Down
17 changes: 11 additions & 6 deletions src/test/java/guitests/ChangePathCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ public void changePath() throws InterruptedException {
//Try with unwritable file path
String unWriteableFilePath = TestUtil.getFilePathInSandboxFolder("unwritable.xml");
File unWriteableFolder = new File(unWriteableFilePath).getParentFile();
unWriteableFolder.setWritable(false);
Thread.sleep(300);
commandBox.runCommand("change-to " + unWriteableFilePath);
assertResultMessage(String.format(ChangePathCommand.MESSAGE_PATH_CHANGE_FAIL, unWriteableFilePath));
unWriteableFolder.setWritable(true);
Thread.sleep(300);

// check if test is run on Windows, as Windows has bad support for writeable flags
if (unWriteableFolder.setWritable(false)) {
Thread.sleep(300);
commandBox.runCommand("change-to " + unWriteableFilePath);
assertResultMessage(String.format(ChangePathCommand.MESSAGE_PATH_CHANGE_FAIL, unWriteableFilePath));
unWriteableFolder.setWritable(true);
Thread.sleep(300);
} else {
unWriteableFolder.setWritable(true);
}

//Try with empty String
String emptyPath = TestUtil.getFilePathInSandboxFolder("");
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/guitests/guihandles/TaskCardHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TaskCardHandle extends GuiHandle {
private static final String OPEN_TIME_FIELD_ID = "#openTime";
private static final String CLOSE_TIME_FIELD_ID = "#closeTime";
private static final String DETAILS_FIELD_ID = "#cardDetails";

private Node node;

public TaskCardHandle(GuiRobot guiRobot, Stage primaryStage, Node node){
Expand Down Expand Up @@ -48,8 +48,8 @@ public boolean isDetailsShown() {

public boolean isSameTask(ReadOnlyTask task){
return getTaskName().equals(task.getName().taskName)
&& getOpenTime().equals(task.getOpenTime().toPrettyString())
&& getCloseTime().equals(task.getCloseTime().toPrettyString());
&& getOpenTime().equals(task.getOpenTime().toDisplayString())
&& getCloseTime().equals(task.getCloseTime().toDisplayString());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/task/testutil/TypicalTestTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public TypicalTestTasks() {
laundry = new TaskBuilder().withName("Meier").withOpenTime("tomorrow")
.withCloseTime("day after tomorrow").withImportance(false).withTags("urgent", "important").build();
carl = new TaskBuilder().withName("Meet Carl").withOpenTime("5 days from now")
.withCloseTime("13 days from now").build();
.withCloseTime("14 days from now").build();
daniel = new TaskBuilder().withName("Have lunch with Meier").withOpenTime("6 hours from now")
.withCloseTime("8 hours from now").build();
elle = new TaskBuilder().withName("Take Ellie out on a date").withOpenTime("6 hours from now")
Expand Down