Skip to content

Commit

Permalink
Merge pull request #130 from wesho1107/ui-tabs
Browse files Browse the repository at this point in the history
Update UI with TabPane and features
  • Loading branch information
wesho1107 authored Nov 1, 2023
2 parents 2c71288 + 7025132 commit 0abb753
Show file tree
Hide file tree
Showing 70 changed files with 908 additions and 200 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Messages {
"Multiple values specified for the following single-valued field(s): ";
public static final String MESSAGE_ASSIGNMENT_GRADED = "The assignment has already been graded";
public static final String MESSAGE_ASSIGNMENT_UNGRADED = "The assignment has not been graded";
public static final String MESSAGE_INVALID_TAB_INDEX = "The inputted index is out of valid range";

/**
* Returns an error message indicating the duplicate prefixes.
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class AddCommand extends Command {

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
public static final CommandType COMMAND_TYPE = CommandType.ADD;

private final Person toAdd;

Expand All @@ -63,7 +64,12 @@ public CommandResult execute(Model model) throws CommandException {
}

model.addPerson(toAdd);
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd)));
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd)), COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class AddTaskCommand extends Command {

public static final String MESSAGE_DUPLICATE_TASK = "This task already exists in the task list.";

public static final CommandType COMMAND_TYPE = CommandType.ADD_TASK;

private final Task task;

/**
Expand All @@ -55,7 +57,12 @@ public CommandResult execute(Model model) throws CommandException {
}

model.addTask(task);
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(task)));
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(task)), COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class AddToConsultCommand extends Command {
public static final String MESSAGE_DUPLICATE_STUDENT = "The student(s) added are already in the consultation";
public static final String MESSAGE_PERSON_NOT_FOUND = "No student matching given name(s)";
public static final String MESSAGE_NOT_EDITED = "At least one student is to be added";

public static final CommandType COMMAND_TYPE = CommandType.ADD_TO_CONSULT;
private final Index index;
private final AddToConsultationDescriptor addToConsultationDescriptor;

Expand Down Expand Up @@ -81,7 +83,12 @@ public CommandResult execute(Model model) throws CommandException {

model.setConsultation(consultationToAddStudent, updatedConsultation);
model.updateFilteredConsultationList(PREDICATE_SHOW_ALL_CONSULTATIONS);
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(updatedConsultation)));
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(updatedConsultation)), COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/seedu/address/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ public class ClearCommand extends Command {
public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";

public static final CommandType COMMAND_TYPE = CommandType.CLEAR;


@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.setAddressBook(new AddressBook());
return new CommandResult(MESSAGE_SUCCESS);
return new CommandResult(MESSAGE_SUCCESS, COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}
}
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/logic/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ public abstract class Command {
*/
public abstract CommandResult execute(Model model) throws CommandException;

/**
* Returns the type of command it is.
*/
public abstract CommandType getCommandType();

}
71 changes: 31 additions & 40 deletions src/main/java/seedu/address/logic/commands/CommandResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.Objects;

import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.ToStringBuilder;

/**
Expand All @@ -13,56 +14,43 @@ public class CommandResult {

private final String feedbackToUser;

/** Help information should be shown to the user. */
private final boolean showHelp;
/** The command type producing the result, used for deciding application UI action **/
private final CommandType commandType;

/** The application should exit. */
private final boolean exit;

/** The application should show a person's assignments. */
private final boolean personAssignments;

/** The application should show assignment names. */
private final boolean assignmentNames;
/** The tab index to switch to **/
private final Index tabIndex;

/**
* Constructs a {@code CommandResult} with the specified fields.
*/
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit,
boolean personAssignments, boolean assignmentNames) {
public CommandResult(String feedbackToUser, CommandType commandType, Index index) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.showHelp = showHelp;
this.exit = exit;
this.personAssignments = personAssignments;
this.assignmentNames = assignmentNames;
this.commandType = commandType;
this.tabIndex = index;
}

/**
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser}
* and {@code commandType}, and index field set to their default value.
*/
public CommandResult(String feedbackToUser, CommandType commandType) {
this(feedbackToUser, commandType, null);
}

/**
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser},
* and other fields set to their default value.
*/
public CommandResult(String feedbackToUser) {
this(feedbackToUser, false, false, false, false);
this(feedbackToUser, null, null);
}

public String getFeedbackToUser() {
return feedbackToUser;
}

public boolean isShowHelp() {
return showHelp;
}

public boolean isExit() {
return exit;
}

public boolean isPersonAssignments() {
return personAssignments;
}

public boolean isAssignmentNames() {
return assignmentNames;
public CommandType getCommandType() {
return commandType;
}

@Override
Expand All @@ -78,25 +66,28 @@ public boolean equals(Object other) {

CommandResult otherCommandResult = (CommandResult) other;
return feedbackToUser.equals(otherCommandResult.feedbackToUser)
&& showHelp == otherCommandResult.showHelp
&& exit == otherCommandResult.exit
&& personAssignments == otherCommandResult.personAssignments
&& assignmentNames == otherCommandResult.assignmentNames;
&& commandType == otherCommandResult.commandType;
}

/**
* A method to return the target tab index.
*
* @return The zero based index of the target tab.
*/
public int getTabIndex() {
return this.tabIndex.getZeroBased();
}

@Override
public int hashCode() {
return Objects.hash(feedbackToUser, showHelp, exit, personAssignments, assignmentNames);
return Objects.hash(feedbackToUser, commandType);
}

@Override
public String toString() {
return new ToStringBuilder(this)
.add("feedbackToUser", feedbackToUser)
.add("showHelp", showHelp)
.add("exit", exit)
.add("personAssignments", personAssignments)
.add("assignmentNames", assignmentNames)
.add("commandType", commandType)
.toString();
}

Expand Down
38 changes: 38 additions & 0 deletions src/main/java/seedu/address/logic/commands/CommandType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package seedu.address.logic.commands;
/**
* Enum representing the type of commands.
*/
public enum CommandType {
/**
* Command type for graphical display
*/
ADD,
ADD_TASK,
ADD_TO_CONSULT,
CLEAR,
CREATE_CONSULT,
CREATE_SESSION,
DELETE,
DELETE_COMMENT,
DELETE_CONSULT,
DELETE_GRADE,
DELETE_SESSION,
DELETE_TASK,
EDIT,
EDIT_COMMENT,
EDIT_GRADE,
EDIT_GRADED_TEST,
EXIT,
FIND,
HELP,
LIST,
REMOVE_FROM_CONSULT,
TAB,
TAKE_ATTENDANCE,
UPDATE_SESSION_REMARK,
UPDATE_TASK_PROGRESS,
VIEW_ALL_ASSIGNMENTS,
VIEW_ASSIGNMENTS,
VIEW_ATTENDANCE,
VIEW_TASKS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class CreateConsultCommand extends Command {
+ PREFIX_NAME + "Foo Bar";
public static final String MESSAGE_SUCCESS = "New consultation added: %1$s";
public static final String MESSAGE_PERSON_NOT_FOUND = "No student matching given name(s)";

public static final CommandType COMMAND_TYPE = CommandType.CREATE_CONSULT;
private final LocalDate date;
private final LocalTime time;
private Set<Name> names;
Expand Down Expand Up @@ -67,7 +69,13 @@ public CommandResult execute(Model model) throws CommandException {

this.consultationToAdd = new Consultation(date, time, studentsToAdd);
model.addConsultation(this.consultationToAdd);
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(this.consultationToAdd)));
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(this.consultationToAdd)),
COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class CreateSessionCommand extends Command {
public static final String MESSAGE_PERSON_NOT_FOUND = "No student match given name(s)";
public static final String MESSAGE_DUPLICATE_SESSION = "Session list contains duplicate session(s).";

public static final CommandType COMMAND_TYPE = CommandType.CREATE_SESSION;

private SessionNumber sessionNumber;
private Set<Name> names;
private Session sessionToAdd;
Expand Down Expand Up @@ -99,7 +101,13 @@ public CommandResult execute(Model model) throws CommandException {
model.addSession(this.sessionToAdd);

// Return a success message
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(this.sessionToAdd)));
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(this.sessionToAdd)),
COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class DeleteCommand extends Command {

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";

public static final CommandType COMMAND_TYPE = CommandType.DELETE;

private final Index targetIndex;

public DeleteCommand(Index targetIndex) {
Expand All @@ -42,7 +44,13 @@ public CommandResult execute(Model model) throws CommandException {

Person personToDelete = lastShownList.get(targetIndex.getZeroBased());
model.deletePerson(personToDelete);
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)));
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)),
COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class DeleteCommentCommand extends Command {

public static final String MESSAGE_CONSTRAINT = "Cannot delete the comment from an assignment with no comment";

public static final CommandType COMMAND_TYPE = CommandType.DELETE_COMMENT;

private final AssignmentName assignmentName;
private final Index index;

Expand Down Expand Up @@ -76,7 +78,12 @@ public CommandResult execute(Model model) throws CommandException {

model.setPerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
return new CommandResult(String.format(MESSAGE_SUCCESS, this.assignmentName));
return new CommandResult(String.format(MESSAGE_SUCCESS, this.assignmentName), COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class DeleteConsultationCommand extends Command {

public static final String MESSAGE_DELETE_CONSULTATION_SUCCESS = "Deleted Consultation: %1$s";

public static final CommandType COMMAND_TYPE = CommandType.DELETE_CONSULT;

private final Index targetIndex;

public DeleteConsultationCommand(Index targetIndex) {
Expand All @@ -42,7 +44,12 @@ public CommandResult execute(Model model) throws CommandException {
Consultation consultationToDelete = lastShownConsultation.get(targetIndex.getZeroBased());
model.deleteConsultation(consultationToDelete);
return new CommandResult(String.format(MESSAGE_DELETE_CONSULTATION_SUCCESS,
Messages.format(consultationToDelete)));
Messages.format(consultationToDelete)), COMMAND_TYPE);
}

@Override
public CommandType getCommandType() {
return COMMAND_TYPE;
}

@Override
Expand Down
Loading

0 comments on commit 0abb753

Please sign in to comment.