Skip to content

Commit

Permalink
Merge 1113b68 into 105f070
Browse files Browse the repository at this point in the history
  • Loading branch information
cchj1995 committed Apr 4, 2019
2 parents 105f070 + 1113b68 commit 2f8c550
Show file tree
Hide file tree
Showing 24 changed files with 645 additions and 34 deletions.
9 changes: 9 additions & 0 deletions bash.exe.stackdump
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Stack trace:
Frame Function Args
000FFFFA1E8 0018006021E (00180252DED, 001802340A6, 000FFFFA1E8, 000FFFF90E0)
000FFFFA1E8 00180048859 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFA1E8 00180048892 (00180252EA9, 000FFFFA098, 000FFFFA1E8, 00000000000)
000FFFFA1E8 001800AF0D8 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFA1E8 001800AF25D (000FFFFA200, 00000000000, 00000000000, 00000000000)
000FFFFA470 001800B0673 (000FFFFA200, 00000000000, 00000000000, 00000000000)
End of stack trace
20 changes: 11 additions & 9 deletions src/main/java/seedu/address/commons/util/DrawTeethUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;

import seedu.address.MainApp;

/**
* A container for teeth specific utility functions.
*/
Expand All @@ -21,19 +23,19 @@ public static BufferedImage drawTeeth(int[] teeth) throws IOException {
String type;
String basepath = System.getProperty("user.dir");
try {
File imgFile = new File(basepath + "/src/main/resources/images/teeth/BaseLayer.png");
BufferedImage main = ImageIO.read(imgFile);
InputStream imageFile = MainApp.class.getClassLoader()
.getResourceAsStream("images/teeth/BaseLayer.png");
BufferedImage main = ImageIO.read(imageFile);
for (int i = 0; i < teeth.length; i++) {
if (teeth[i] > 0) {
if (teeth[i] == 1) {
type = "P";
type = "P_";
} else {
type = "A";
type = "A_";
}
String filepath = "/src/main/resources/images/teeth/" + type + "_" + (i + 1) + ".png";
String path = basepath + filepath;
File imgFile2 = new File(path);
BufferedImage layer = ImageIO.read(imgFile2);
InputStream layerFile = MainApp.class.getClassLoader()
.getResourceAsStream("images/teeth/" + type + (i + 1) + ".png");
BufferedImage layer = ImageIO.read(layerFile);
Graphics g = main.getGraphics();
g.drawImage(layer, 0, 0, null);
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ public interface Logic {
*/
void setGuiSettings(GuiSettings guiSettings);

/**
* Selected record in the filtered record list.
* null if no record is selected.
*
* @see seedu.address.model.Model#selectedRecordProperty()
*/
ReadOnlyProperty<Record> selectedRecordProperty();

/**
* Sets the selected record in the filtered record list.
*
* @see seedu.address.model.Model#setSelectedRecord(Record)
*/
void setSelectedRecord(Record record);

/**
* Selected person in the filtered person list.
* null if no person is selected.
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ public void setGuiSettings(GuiSettings guiSettings) {
model.setGuiSettings(guiSettings);
}

@Override
public ReadOnlyProperty<Record> selectedRecordProperty() {
return model.selectedRecordProperty();
}

@Override
public void setSelectedRecord(Record record) {
model.setSelectedRecord(record);
}

@Override
public ReadOnlyProperty<Person> selectedPersonProperty() {
return model.selectedPersonProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
alert.getDialogPane().getStylesheets().add("view/DarkTheme.css");
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
model.setSelectedRecord(null);
return new CommandResult(MESSAGE_BACK_ACKNOWLEDGEMENT, false, false, true);
} else {
return new CommandResult(Messages.MESSAGE_NOTHING_DONE);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.layout.Region;
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.CommandHistory;
Expand Down Expand Up @@ -68,6 +69,7 @@ private void checkLinkedTasks(Model model, Person deletedPerson) {
+ "Choosing NO or closing this box will set the tasks to have no linked patient.",
ButtonType.YES, ButtonType.NO);
alert.setHeaderText("Tasks linked to patient detect!");
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().getStylesheets().add("view/DarkTheme.css");
alert.showAndWait();
for (Task task : linkedTasks) {
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/seedu/address/logic/commands/TaskAddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import static seedu.address.commons.core.Messages.MESSAGE_TIME_CLASH;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ENDDATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ENDTIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LINKEDPATIENT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PRIORITY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STARTDATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STARTTIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TITLE;
Expand Down Expand Up @@ -34,15 +36,19 @@ public class TaskAddCommand extends Command {
+ PREFIX_TITLE + "TITLE "
+ PREFIX_STARTDATE + "START DATE "
+ PREFIX_ENDDATE + "END DATE "
+ PREFIX_STARTTIME + "1100 "
+ PREFIX_ENDTIME + "1200\n"
+ "TITLE, START DATE, END DATE, START TIME and END TIME are mandatory fields and must be provided.\n"
+ PREFIX_STARTTIME + "START TIME "
+ PREFIX_ENDTIME + "END TIME "
+ PREFIX_PRIORITY + "PRIORITY "
+ PREFIX_LINKEDPATIENT + "PATIENT INDEX\n"
+ "TITLE, START DATE, START TIME and END TIME are mandatory fields and must be provided.\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_TITLE + "Teeth removal surgery "
+ PREFIX_STARTDATE + "10-11-2019 "
+ PREFIX_ENDDATE + "22-12-2019 "
+ PREFIX_STARTTIME + "1100 "
+ PREFIX_ENDTIME + "1200";
+ PREFIX_ENDTIME + "1200 "
+ PREFIX_PRIORITY + "high "
+ PREFIX_LINKEDPATIENT + "2\n";


public static final String MESSAGE_SUCCESS = "New task added: %1$s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
if (taskToComplete.getPriority() == Priority.COMPLETED) {
throw new CommandException("The task is already completed. ");
}
Task completedTask = new Task(taskToComplete, true);
Task completedTask = taskToComplete.isCopy() ? new Task(taskToComplete) : new Task(taskToComplete, true);
completedTask.setPriorityComplete();
model.setTask(taskToComplete, completedTask);
if (taskToComplete.getLinkedPatient() != null) {
Expand All @@ -64,7 +64,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
Patient replacement = found.get();
//TODO: Possibly switch Procedure and Description contents?
replacement.addRecord(new Record(new Procedure("Other-Completed Task"),
new Description(completedTask.getTitle().title)));
new Description(completedTask.getTitle().title)));
model.setPerson(found.get(), replacement);
patientRecordAddedMessage = String.format("\n Added Record to Patient: %s ( %s )",
found.get().getName().fullName, found.get().getNric().getNric());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_CANNOT_RUN_IN_GOTO;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.commons.core.Messages.MESSAGE_ONLY_GO_TO_MODE_COMMANDS;
import static seedu.address.commons.core.Messages.MESSAGE_ONLY_PATIENT_MODE_COMMANDS;
Expand Down Expand Up @@ -152,11 +151,7 @@ public Command parseCommand(String userInput) throws ParseException {

//Commands that runs ONLY in both Patient Mode OR Calendar Window
case TaskDoneCommand.COMMAND_WORD:
if (MainWindow.isGoToMode()) {
throw new ParseException(MESSAGE_CANNOT_RUN_IN_GOTO);
} else {
return new TaskDoneCommandParser().parse(arguments);
}
return new TaskDoneCommandParser().parse(arguments);
//Commands that should ONLY run in GoTo mode but not in Calendar Window
case GoToCommand.COMMAND_WORD:
checkSpecialCondition(!checkBothConditions);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ public static Title parseTitle(String title) throws ParseException {
public static DateCustom parseStartDate(String date) throws ParseException {
requireNonNull(date);
String trimmedDate = date.trim();
if (trimmedDate.equals("today")) {
return new DateCustom(DateCustom.getToday());
}
if (!DateCustom.isValidDate(date)) {
throw new ParseException(DateCustom.MESSAGE_CONSTRAINTS_START_DATE);
}
Expand All @@ -241,6 +244,9 @@ public static DateCustom parseStartDate(String date) throws ParseException {
public static DateCustom parseEndDate(String date) throws ParseException {
requireNonNull(date);
String trimmedDate = date.trim();
if (trimmedDate.equals("today")) {
return new DateCustom(DateCustom.getToday());
}
if (!DateCustom.isValidDate(date)) {
throw new ParseException(DateCustom.MESSAGE_CONSTRAINTS_END_DATE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.datetime.DateCustom;
import seedu.address.model.datetime.TimeCustom;
import seedu.address.model.task.LinkedPatient;
import seedu.address.model.task.Priority;
import seedu.address.model.task.Task;
import seedu.address.model.task.Title;
import seedu.address.ui.MainWindow;

/**
* Parses input arguments and creates a new AddCommand object
Expand All @@ -35,25 +37,29 @@ public TaskAddCommand parse(String args) throws ParseException {
ArgumentTokenizer.tokenize(args, PREFIX_TITLE, PREFIX_STARTDATE, PREFIX_ENDDATE,
PREFIX_STARTTIME, PREFIX_ENDTIME, PREFIX_PRIORITY, PREFIX_LINKEDPATIENT);

if (!arePrefixesPresent(argMultimap, PREFIX_TITLE, PREFIX_STARTDATE, PREFIX_ENDDATE, PREFIX_STARTTIME,
if (!arePrefixesPresent(argMultimap, PREFIX_TITLE, PREFIX_STARTDATE, PREFIX_STARTTIME,
PREFIX_ENDTIME) || !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, TaskAddCommand.MESSAGE_USAGE));
}

Title title = ParserUtil.parseTitle(argMultimap.getValue(PREFIX_TITLE).get());
DateCustom startDate = ParserUtil.parseStartDate(argMultimap.getValue(PREFIX_STARTDATE).get());
DateCustom endDate = ParserUtil.parseEndDate(argMultimap.getValue(PREFIX_ENDDATE).get());
DateCustom endDate = ParserUtil.parseEndDate(argMultimap.getValue(PREFIX_ENDDATE)
.orElse(argMultimap.getValue(PREFIX_STARTDATE).get()));
TimeCustom startTime = ParserUtil.parseStartTime(argMultimap.getValue(PREFIX_STARTTIME).get());
TimeCustom endTime = ParserUtil.parseEndTime(argMultimap.getValue(PREFIX_ENDTIME).get());
Priority priority = ParserUtil.parsePriority(argMultimap.getValue(PREFIX_PRIORITY).orElse("low"));
Index patientIndex;
if (argMultimap.getValue(PREFIX_LINKEDPATIENT).isPresent()) {
if (MainWindow.isGoToMode()) {
throw new ParseException(LinkedPatient.MESSAGE_ADDITIONAL_CONSTRAINT
+ LinkedPatient.MESSAGE_CONSTRAINTS);
}
patientIndex = ParserUtil.parseLinkedPatientIndex(argMultimap.getValue(PREFIX_LINKEDPATIENT).get());
} else {
patientIndex = null;
}


Task task = new Task(title, startDate, endDate, startTime, endTime, priority, null);
return new TaskAddCommand(task, patientIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import seedu.address.logic.commands.TaskEditCommand;
import seedu.address.logic.commands.TaskEditCommand.EditTaskDescriptor;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.task.LinkedPatient;
import seedu.address.ui.MainWindow;

/**
* Parses input arguments and creates a new TaskEditCommand object
Expand Down Expand Up @@ -69,6 +71,10 @@ public TaskEditCommand parse(String args) throws ParseException {
}

if (argMultimap.getValue(PREFIX_LINKEDPATIENT).isPresent()) {
if (MainWindow.isGoToMode()) {
throw new ParseException(LinkedPatient.MESSAGE_ADDITIONAL_CONSTRAINT
+ LinkedPatient.MESSAGE_CONSTRAINTS);
}
editTaskDescriptor.setPatientIndex(ParserUtil.parseLinkedPatientIndex(argMultimap
.getValue(PREFIX_LINKEDPATIENT).get()));
} else {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,32 @@ public interface Model {
*/
void deleteRecord(Record record);


/**
* Returns true if the model has previous address book states to restore.
* Selected record in the filtered record list.
* null if no record is selected.
*/
ReadOnlyProperty<Record> selectedRecordProperty();

/**
* Replaces the given record {@code target} with {@code editedRecord}.
* {@code target} must exist in the address book.
* The identity of {@code editedRecord} must not be the same as another existing record in the address book.
*/
void setRecord(Record target, Record editedRecord);

/**
* Returns the selected record in the filtered records list.
* null if no record is selected.
*/
Record getSelectedRecord();

/**
* Sets the selected record in the filtered record list.
*/
void setSelectedRecord(Record record);

//=========== Tags =================================================================================

/**
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import seedu.address.model.person.Person;
import seedu.address.model.person.exceptions.PersonNotFoundException;
import seedu.address.model.record.Record;
import seedu.address.model.record.exceptions.RecordNotFoundException;
import seedu.address.model.task.Task;
import seedu.address.ui.MainWindow;

Expand All @@ -34,6 +35,7 @@ public class ModelManager implements Model {
private final FilteredList<Person> filteredPersons;
private final FilteredList<Task> filteredTasks;
private final SimpleObjectProperty<Person> selectedPerson = new SimpleObjectProperty<>();
private final SimpleObjectProperty<Record> selectedRecord = new SimpleObjectProperty<>();
private final SimpleObjectProperty<Task> selectedTask = new SimpleObjectProperty<>();

private FilteredList<Record> filteredRecords;
Expand Down Expand Up @@ -206,6 +208,25 @@ public void setRecord(Record target, Record editedRecord) {
versionedAddressBook.setRecord(target, editedRecord);
}


@Override
public ReadOnlyProperty<Record> selectedRecordProperty() {
return selectedRecord;
}

@Override
public Record getSelectedRecord() {
return selectedRecord.getValue();
}

@Override
public void setSelectedRecord(Record record) {
if (record != null && !filteredRecords.contains(record)) {
throw new RecordNotFoundException();
}
selectedRecord.set(record);
}

/**
* Update tags based on teeth data.
*
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/model/datetime/DateCustom.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public boolean isToday() {
return !dateCompare(this.toString(), LocalDate.now().format(DATE_FORMATTER));
}

public static String getToday() {
return LocalDate.now().format(DATE_FORMATTER);
}

public LocalDate getDate() {
return LocalDate.parse(storedDate, DATE_FORMATTER);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/model/task/LinkedPatient.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class LinkedPatient {
+ "patient list\n"
+ "Example: pat/1 or pat/3";

public static final String MESSAGE_ADDITIONAL_CONSTRAINT = "To link a patient to a task, please ensure you are in "
+ "patient mode so that you can see the patient index. "
+ "To go to patient mode, use the back command.\n";

private Name fullname;
private Nric nric;

Expand Down
Loading

0 comments on commit 2f8c550

Please sign in to comment.