Skip to content

Commit 688c898

Browse files
authored
Merge pull request #49 from FeliciaTay/master
Create New and Refactor Old UI classes
2 parents e5a8338 + c49429e commit 688c898

File tree

87 files changed

+3509
-972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+3509
-972
lines changed

docs/DeveloperGuide.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ endif::[]
1616

1717
By: `CS2103T-F10-2`      Since: `Feb 2020`      Licence: `MIT`
1818

19+
== Introduction
20+
21+
(to be inserted)
22+
1923
== Setting up
2024

2125
Refer to the guide <<SettingUp#, here>>.

docs/diagrams/tracing/LogicSequenceDiagram.puml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ create ecp
1313
abp -> ecp
1414
abp -> ecp ++: parse(arguments)
1515
create ec
16-
ecp -> ec ++: index, editPersonDescriptor
16+
ecp -> ec ++: index, editInternshipDescriptor
1717
ec --> ecp --
1818
ecp --> abp --: command
1919
abp --> logic --: command

docs/tutorials/TracingCode.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ image::LogicSequenceDiagram.png[]
180180
public CommandResult execute(Model model) throws CommandException {
181181
...
182182
Person personToEdit = lastShownList.get(index.getZeroBased());
183-
Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor);
183+
Person editedPerson = createEditedPerson(personToEdit, editInternshipDescriptor);
184184
if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) {
185185
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
186186
}

src/main/java/seedu/address/MainApp.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
import seedu.address.commons.util.StringUtil;
1616
import seedu.address.logic.Logic;
1717
import seedu.address.logic.LogicManager;
18-
import seedu.address.model.AddressBook;
18+
import seedu.address.model.InternshipDiary;
1919
import seedu.address.model.Model;
2020
import seedu.address.model.ModelManager;
21-
import seedu.address.model.ReadOnlyAddressBook;
21+
import seedu.address.model.ReadOnlyInternshipDiary;
2222
import seedu.address.model.ReadOnlyUserPrefs;
2323
import seedu.address.model.UserPrefs;
2424
import seedu.address.model.util.SampleDataUtil;
25-
import seedu.address.storage.AddressBookStorage;
26-
import seedu.address.storage.JsonAddressBookStorage;
25+
import seedu.address.storage.InternshipDiaryStorage;
26+
import seedu.address.storage.JsonInternshipDiaryStorage;
2727
import seedu.address.storage.JsonUserPrefsStorage;
2828
import seedu.address.storage.Storage;
2929
import seedu.address.storage.StorageManager;
@@ -48,16 +48,17 @@ public class MainApp extends Application {
4848

4949
@Override
5050
public void init() throws Exception {
51-
logger.info("=============================[ Initializing AddressBook ]===========================");
51+
logger.info("=============================[ Initializing InternshipDiary ]===========================");
5252
super.init();
5353

5454
AppParameters appParameters = AppParameters.parse(getParameters());
5555
config = initConfig(appParameters.getConfigPath());
5656

5757
UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath());
5858
UserPrefs userPrefs = initPrefs(userPrefsStorage);
59-
AddressBookStorage addressBookStorage = new JsonAddressBookStorage(userPrefs.getAddressBookFilePath());
60-
storage = new StorageManager(addressBookStorage, userPrefsStorage);
59+
InternshipDiaryStorage internshipDiaryStorage =
60+
new JsonInternshipDiaryStorage(userPrefs.getInternshipDiaryFilePath());
61+
storage = new StorageManager(internshipDiaryStorage, userPrefsStorage);
6162

6263
initLogging(config);
6364

@@ -74,20 +75,20 @@ public void init() throws Exception {
7475
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book.
7576
*/
7677
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
77-
Optional<ReadOnlyAddressBook> addressBookOptional;
78-
ReadOnlyAddressBook initialData;
78+
Optional<ReadOnlyInternshipDiary> internshipDiaryOptional;
79+
ReadOnlyInternshipDiary initialData;
7980
try {
80-
addressBookOptional = storage.readAddressBook();
81-
if (!addressBookOptional.isPresent()) {
82-
logger.info("Data file not found. Will be starting with a sample AddressBook");
81+
internshipDiaryOptional = storage.readInternshipDiary();
82+
if (!internshipDiaryOptional.isPresent()) {
83+
logger.info("Data file not found. Will be starting with a sample InternshipDiary");
8384
}
84-
initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook);
85+
initialData = internshipDiaryOptional.orElseGet(SampleDataUtil::getSampleInternshipDiary);
8586
} catch (DataConversionException e) {
86-
logger.warning("Data file not in the correct format. Will be starting with an empty AddressBook");
87-
initialData = new AddressBook();
87+
logger.warning("Data file not in the correct format. Will be starting with an empty InternshipDiary");
88+
initialData = new InternshipDiary();
8889
} catch (IOException e) {
89-
logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook");
90-
initialData = new AddressBook();
90+
logger.warning("Problem while reading from the file. Will be starting with an empty InternshipDiary");
91+
initialData = new InternshipDiary();
9192
}
9293

9394
return new ModelManager(initialData, userPrefs);
@@ -151,7 +152,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {
151152
+ "Using default user prefs");
152153
initializedPrefs = new UserPrefs();
153154
} catch (IOException e) {
154-
logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook");
155+
logger.warning("Problem while reading from the file. Will be starting with an empty InternshipDiary");
155156
initializedPrefs = new UserPrefs();
156157
}
157158

@@ -167,13 +168,13 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {
167168

168169
@Override
169170
public void start(Stage primaryStage) {
170-
logger.info("Starting AddressBook " + MainApp.VERSION);
171+
logger.info("Starting InternshipDiary " + MainApp.VERSION);
171172
ui.start(primaryStage);
172173
}
173174

174175
@Override
175176
public void stop() {
176-
logger.info("============================ [ Stopping Address Book ] =============================");
177+
logger.info("============================ [ Stopping InternshipDiary ] =============================");
177178
try {
178179
storage.saveUserPrefs(model.getUserPrefs());
179180
} catch (IOException e) {

src/main/java/seedu/address/commons/core/Messages.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ public class Messages {
77

88
public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
99
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
10-
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
11-
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
10+
public static final String MESSAGE_INVALID_INTERNSHIP_DISPLAYED_INDEX =
11+
"The internship application index provided is invalid";
12+
public static final String MESSAGE_INTERNSHIP_LISTED_OVERVIEW = "%1$d internship application listed!";
1213

1314
}

src/main/java/seedu/address/logic/Logic.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import seedu.address.logic.commands.exceptions.CommandException;
99
import seedu.address.logic.parser.exceptions.ParseException;
1010
import seedu.address.model.ReadOnlyAddressBook;
11+
import seedu.address.model.ReadOnlyInternshipDiary;
12+
import seedu.address.model.internship.InternshipApplication;
1113
import seedu.address.model.person.Person;
1214

1315
/**
@@ -30,14 +32,30 @@ public interface Logic {
3032
*/
3133
ReadOnlyAddressBook getAddressBook();
3234

35+
/**
36+
* Returns the InternshipDiary.
37+
*
38+
* @see seedu.address.model.Model#getInternshipDiary()
39+
*/
40+
ReadOnlyInternshipDiary getInternshipDiary();
41+
42+
3343
/** Returns an unmodifiable view of the filtered list of persons */
3444
ObservableList<Person> getFilteredPersonList();
3545

46+
/** Returns an unmodifiable view of the filtered list of internship applications */
47+
ObservableList<InternshipApplication> getFilteredInternshipApplicationList();
48+
3649
/**
3750
* Returns the user prefs' address book file path.
3851
*/
3952
Path getAddressBookFilePath();
4053

54+
/**
55+
* Returns the user prefs' internship diary file path.
56+
*/
57+
Path getInternshipDiaryFilePath();
58+
4159
/**
4260
* Returns the user prefs' GUI settings.
4361
*/

src/main/java/seedu/address/logic/LogicManager.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
import seedu.address.logic.commands.Command;
1111
import seedu.address.logic.commands.CommandResult;
1212
import seedu.address.logic.commands.exceptions.CommandException;
13-
import seedu.address.logic.parser.AddressBookParser;
13+
import seedu.address.logic.parser.InternshipDiaryParser;
1414
import seedu.address.logic.parser.exceptions.ParseException;
1515
import seedu.address.model.Model;
1616
import seedu.address.model.ReadOnlyAddressBook;
17+
import seedu.address.model.ReadOnlyInternshipDiary;
18+
import seedu.address.model.internship.InternshipApplication;
1719
import seedu.address.model.person.Person;
1820
import seedu.address.storage.Storage;
1921

@@ -26,24 +28,25 @@ public class LogicManager implements Logic {
2628

2729
private final Model model;
2830
private final Storage storage;
29-
private final AddressBookParser addressBookParser;
31+
private final InternshipDiaryParser internshipDiaryParser;
3032

3133
public LogicManager(Model model, Storage storage) {
3234
this.model = model;
3335
this.storage = storage;
34-
addressBookParser = new AddressBookParser();
36+
internshipDiaryParser = new InternshipDiaryParser();
3537
}
3638

3739
@Override
3840
public CommandResult execute(String commandText) throws CommandException, ParseException {
3941
logger.info("----------------[USER COMMAND][" + commandText + "]");
4042

4143
CommandResult commandResult;
42-
Command command = addressBookParser.parseCommand(commandText);
44+
Command command = internshipDiaryParser.parseCommand(commandText);
4345
commandResult = command.execute(model);
4446

4547
try {
46-
storage.saveAddressBook(model.getAddressBook());
48+
//cf: Needs to be changed after storage is refactored.
49+
storage.saveInternshipDiary(model.getInternshipDiary());
4750
} catch (IOException ioe) {
4851
throw new CommandException(FILE_OPS_ERROR_MESSAGE + ioe, ioe);
4952
}
@@ -56,16 +59,31 @@ public ReadOnlyAddressBook getAddressBook() {
5659
return model.getAddressBook();
5760
}
5861

62+
@Override
63+
public ReadOnlyInternshipDiary getInternshipDiary() {
64+
return model.getInternshipDiary();
65+
}
66+
5967
@Override
6068
public ObservableList<Person> getFilteredPersonList() {
6169
return model.getFilteredPersonList();
6270
}
6371

72+
@Override
73+
public ObservableList<InternshipApplication> getFilteredInternshipApplicationList() {
74+
return model.getFilteredInternshipApplicationList();
75+
}
76+
6477
@Override
6578
public Path getAddressBookFilePath() {
6679
return model.getAddressBookFilePath();
6780
}
6881

82+
@Override
83+
public Path getInternshipDiaryFilePath() {
84+
return model.getInternshipDiaryFilePath();
85+
}
86+
6987
@Override
7088
public GuiSettings getGuiSettings() {
7189
return model.getGuiSettings();

src/main/java/seedu/address/logic/commands/AddCommand.java

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,69 @@
22

33
import static java.util.Objects.requireNonNull;
44
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
5+
import static seedu.address.logic.parser.CliSyntax.PREFIX_COMPANY;
6+
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE;
57
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
6-
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
78
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
8-
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
9+
import static seedu.address.logic.parser.CliSyntax.PREFIX_PRIORITY;
10+
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;
11+
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS;
912

1013
import seedu.address.logic.commands.exceptions.CommandException;
1114
import seedu.address.model.Model;
12-
import seedu.address.model.person.Person;
15+
import seedu.address.model.internship.InternshipApplication;
1316

1417
/**
15-
* Adds a person to the address book.
18+
* Adds a person to the internship diary.
1619
*/
1720
public class AddCommand extends Command {
1821

1922
public static final String COMMAND_WORD = "add";
2023

21-
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
24+
public static final String MESSAGE_USAGE = COMMAND_WORD
25+
+ ": Adds an internship application to the internship diary. "
2226
+ "Parameters: "
23-
+ PREFIX_NAME + "NAME "
27+
+ PREFIX_COMPANY + "COMPANY "
28+
+ PREFIX_ROLE + "ROLE "
29+
+ PREFIX_ADDRESS + "ADDRESS "
2430
+ PREFIX_PHONE + "PHONE "
2531
+ PREFIX_EMAIL + "EMAIL "
26-
+ PREFIX_ADDRESS + "ADDRESS "
27-
+ "[" + PREFIX_TAG + "TAG]...\n"
32+
+ PREFIX_DATE + "APPLICATION DATE "
33+
+ PREFIX_PRIORITY + "PRIORITY "
34+
+ PREFIX_STATUS + "STATUS "
2835
+ "Example: " + COMMAND_WORD + " "
29-
+ PREFIX_NAME + "John Doe "
30-
+ PREFIX_PHONE + "98765432 "
31-
+ PREFIX_EMAIL + "[email protected] "
32-
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
33-
+ PREFIX_TAG + "friends "
34-
+ PREFIX_TAG + "owesMoney";
36+
+ PREFIX_COMPANY + "Google "
37+
+ PREFIX_ROLE + "Software Engineer "
38+
+ PREFIX_ADDRESS + "123 Kent Ridge Road "
39+
+ PREFIX_PHONE + "67654321 "
40+
+ PREFIX_EMAIL + "[email protected] "
41+
+ PREFIX_DATE + "10 Feb 2020 "
42+
+ PREFIX_PRIORITY + "5 "
43+
+ PREFIX_STATUS + "Active ";
3544

36-
public static final String MESSAGE_SUCCESS = "New person added: %1$s";
37-
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
45+
public static final String MESSAGE_SUCCESS = "New internship application added: %1$s";
46+
public static final String MESSAGE_DUPLICATE_INTERNSHIP =
47+
"This internship application already exists in the internship diary";
3848

39-
private final Person toAdd;
49+
private final InternshipApplication toAdd;
4050

4151
/**
42-
* Creates an AddCommand to add the specified {@code Person}
52+
* Creates an AddCommand to add the specified {@code internshipApplication}
4353
*/
44-
public AddCommand(Person person) {
45-
requireNonNull(person);
46-
toAdd = person;
54+
public AddCommand(InternshipApplication internshipApplication) {
55+
requireNonNull(internshipApplication);
56+
toAdd = internshipApplication;
4757
}
4858

4959
@Override
5060
public CommandResult execute(Model model) throws CommandException {
5161
requireNonNull(model);
5262

53-
if (model.hasPerson(toAdd)) {
54-
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
63+
if (model.hasInternshipApplication(toAdd)) {
64+
throw new CommandException(MESSAGE_DUPLICATE_INTERNSHIP);
5565
}
5666

57-
model.addPerson(toAdd);
67+
model.addInternshipApplication(toAdd);
5868
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
5969
}
6070

src/main/java/seedu/address/logic/commands/ClearCommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
import static java.util.Objects.requireNonNull;
44

5-
import seedu.address.model.AddressBook;
5+
import seedu.address.model.InternshipDiary;
66
import seedu.address.model.Model;
77

88
/**
9-
* Clears the address book.
9+
* Clears the internship diary.
1010
*/
1111
public class ClearCommand extends Command {
1212

1313
public static final String COMMAND_WORD = "clear";
14-
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";
14+
public static final String MESSAGE_SUCCESS = "Internship diary has been cleared!";
1515

1616

1717
@Override
1818
public CommandResult execute(Model model) {
1919
requireNonNull(model);
20-
model.setAddressBook(new AddressBook());
20+
model.setInternshipDiary(new InternshipDiary());
2121
return new CommandResult(MESSAGE_SUCCESS);
2222
}
2323
}

0 commit comments

Comments
 (0)