Skip to content

Commit c9c3807

Browse files
authored
Merge pull request #171 from wyt-sonia/master
Main feature improve:
2 parents 7bbafdb + 6000a65 commit c9c3807

File tree

7 files changed

+273
-178
lines changed

7 files changed

+273
-178
lines changed

src/main/java/draganddrop/studybuddy/logic/parser/TimeParser.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.time.LocalDate;
44
import java.time.LocalDateTime;
5+
import java.time.format.DateTimeFormatter;
56
import java.time.format.DateTimeParseException;
67

78
import draganddrop.studybuddy.logic.parser.interactivecommandparser.exceptions.InteractiveCommandException;
@@ -12,6 +13,8 @@
1213
*/
1314
public class TimeParser {
1415

16+
public static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("dd/MM/yyyy");
17+
1518
/**
1619
* Parses valid dateTime string to LocalDateTime variable.
1720
*
@@ -29,6 +32,23 @@ public static LocalDateTime parseDateTime(String userInput) throws InteractiveCo
2932
return inputTime;
3033
}
3134

35+
/**
36+
* Parses valid date string to LocalDate variable.
37+
*
38+
* @param userInput
39+
* @return
40+
* @throws InteractiveCommandException
41+
*/
42+
public static LocalDate parseDate(String userInput) throws InteractiveCommandException {
43+
LocalDate inputDate = null;
44+
try {
45+
inputDate = LocalDate.parse(userInput.trim(), DATE_FORMAT);
46+
} catch (DateTimeParseException e) {
47+
throw new InteractiveCommandException("dataTimeFormatError");
48+
}
49+
return inputDate;
50+
}
51+
3252

3353
/**
3454
* Converts LocalDateTime variable to a String as HH:mm dd/MM/yyyy format.

src/main/java/draganddrop/studybuddy/model/util/SampleDataUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public static Module[] getSampleModule() {
5858
return new Module[]{emptyModule, cs2101};
5959
}
6060

61-
6261
public static ReadOnlyStudyBuddy getSampleStudyBuddy() {
6362
StudyBuddy sampleSb = new StudyBuddy();
6463
ArrayList<Task> sampleTasks = new ArrayList<>();

src/main/java/draganddrop/studybuddy/ui/MainWindow.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class MainWindow extends UiPart<Stage> {
9494
private Label dueListPanelTitle;
9595

9696
@FXML
97-
private Pane dueSoonTaskListPanelTitleHolder;
97+
private Pane dueListPanelTitleHolder;
9898

9999
@FXML
100100
private Label mainTitle;
@@ -103,7 +103,6 @@ public class MainWindow extends UiPart<Stage> {
103103
private Pane mainTitleHolder;
104104

105105

106-
107106
public MainWindow(Stage primaryStage, Logic logic) {
108107
super(FXML, primaryStage);
109108

@@ -166,7 +165,8 @@ void fillInnerParts() {
166165
taskListPanelPlaceholder.getChildren().add(taskListPanel.getRoot());
167166

168167
taskSummaryPanel = new TaskSummaryPanel(logic.getFilteredTaskList(),
169-
logic.getFilteredArchivedTaskList());
168+
logic.getFilteredArchivedTaskList(), logic.getFilteredModuleList(),
169+
dueSoonListPanelPlaceholder, dueListPanelTitle);
170170
taskSummaryHolder.getChildren().add(taskSummaryPanel.getRoot());
171171
taskSummaryHolder.setVisible(false);
172172
taskSummaryHolder.setManaged(false);
@@ -226,8 +226,11 @@ public void handleHelp() {
226226
public void handleShowTaskSummary() {
227227
toggleAllHoldersInvisible();
228228
toggleTaskSummaryHolderView(true);
229+
toggleTaskListHolderView(false, true);
230+
taskSummaryPanel.renderSelectedListPanel();
229231

230232
toggleAllTitle(false);
233+
toggleDueSoonTaskListPanelTitleView(true);
231234
toggleMainTitleView(true);
232235
setMainTitleText(TASK_SUMMARY);
233236
}
@@ -249,6 +252,7 @@ private void handleShowProfile() {
249252
toggleMainTitleView(true);
250253
setMainTitleText(PROFILE_PAGE);
251254
}
255+
252256
/**
253257
* Closes the application.
254258
*/
@@ -267,7 +271,7 @@ private void handleExit() {
267271
@FXML
268272
private void handleShowAllTasks() {
269273
toggleAllHoldersInvisible();
270-
toggleTaskListHolderView(true);
274+
toggleTaskListHolderView(true, true);
271275

272276
toggleAllTitle(true);
273277
setMainTitleText(TITLE);
@@ -283,11 +287,13 @@ private void handleShowAllTasks() {
283287
@FXML
284288
private void handleDueSoonTasks() {
285289
toggleAllHoldersInvisible();
286-
toggleTaskListHolderView(true);
290+
toggleTaskListHolderView(true, true);
287291

288292
toggleAllTitle(true);
289293
setMainTitleText(TITLE);
290294
dueListPanelTitle.setText(DUE_SOON_TASK);
295+
dueListPanelTitle.getStyleClass().clear();
296+
dueListPanelTitle.getStyleClass().add("sub_header");
291297
dueSoonListPanel = new DueSoonListPanel(logic.getFilteredDueSoonTaskList());
292298
dueSoonListPanelPlaceholder.getChildren().add(dueSoonListPanel.getRoot());
293299
}
@@ -298,7 +304,7 @@ private void handleDueSoonTasks() {
298304
@FXML
299305
private void handleShowArchivedTasks() {
300306
toggleAllHoldersInvisible();
301-
toggleTaskListHolderView(true);
307+
toggleTaskListHolderView(true, true);
302308

303309
toggleAllTitle(true);
304310
setMainTitleText(TITLE);
@@ -315,6 +321,7 @@ private void handleShowArchivedTasks() {
315321
private void handleShowModules() {
316322
toggleAllHoldersInvisible();
317323
toggleModTabView(true);
324+
toggleProfileHolderView(false);
318325

319326
toggleAllTitle(false);
320327
toggleMainTitleView(true);
@@ -328,14 +335,14 @@ private void handleShowModules() {
328335
@FXML
329336
private void handleShowCalendar() {
330337
toggleAllHoldersInvisible();
331-
toggleTaskListHolderView(true);
338+
toggleTaskListHolderView(true, true);
332339

333340
toggleAllTitle(true);
334341
toggleTaskListPanelTitleView(false);
335342
setMainTitleText(CALENDAR);
336343

337344
CalendarBox calendar = new CalendarBox(logic.getFilteredTaskList(), dueSoonListPanelPlaceholder,
338-
dueListPanelTitle);
345+
dueListPanelTitle);
339346
taskListPanelPlaceholder.getChildren().add(calendar.getRoot());
340347
}
341348

@@ -370,12 +377,13 @@ private CommandResult executeCommand(InteractivePrompt currentInteractivePrompt,
370377

371378
/**
372379
* Toggles list panels according to values assigned. Can add more if there are more windows required for display.
380+
*
373381
* @param val1 toggles TaskListHolder
374382
* @param val2 toggles TaskSummaryHolder
375383
* @param val3 toggles ModuleTabHolder
376384
*/
377385
private void customToggleHolders(boolean val1, boolean val2, boolean val3, boolean val4) {
378-
toggleTaskListHolderView(val1);
386+
toggleTaskListHolderView(val1, val1);
379387
toggleTaskSummaryHolderView(val2);
380388
toggleModTabView(val3);
381389
toggleProfileHolderView(val4);
@@ -384,6 +392,7 @@ private void customToggleHolders(boolean val1, boolean val2, boolean val3, boole
384392

385393
/**
386394
* Toggles title according to values assigned. Can add more if there are more windows required for display.
395+
*
387396
* @param val1 toggles MainTitle
388397
* @param val2 toggles TaskList(Left side)
389398
*/
@@ -407,8 +416,24 @@ private void toggleTaskSummaryHolderView(boolean val) {
407416
setPaneView(taskSummaryHolder, val);
408417
}
409418

410-
private void toggleTaskListHolderView(boolean val) {
411-
setPaneView(taskListHolder, val);
419+
/**
420+
* Toggles the visibility of taskListHolder.
421+
*
422+
* @param isAllTaskListShow
423+
* @param isDueSoonShow
424+
*/
425+
private void toggleTaskListHolderView(boolean isAllTaskListShow, boolean isDueSoonShow) {
426+
setPaneView(taskListPanelPlaceholder, isAllTaskListShow);
427+
setPaneView(taskListPanelTitleHolder, isAllTaskListShow);
428+
setPaneView(dueSoonListPanelPlaceholder, isDueSoonShow);
429+
setPaneView(dueListPanelTitleHolder, isDueSoonShow);
430+
if (isAllTaskListShow || isDueSoonShow) {
431+
taskListHolder.setManaged(true);
432+
taskListHolder.setVisible(true);
433+
} else {
434+
taskListHolder.setManaged(false);
435+
taskListHolder.setVisible(false);
436+
}
412437
}
413438

414439
private void toggleModTabView(boolean val) {
@@ -429,7 +454,7 @@ private void toggleTaskListPanelTitleView(boolean val) {
429454
}
430455

431456
private void toggleDueSoonTaskListPanelTitleView(boolean val) {
432-
setPaneView(dueSoonTaskListPanelTitleHolder, val);
457+
setPaneView(dueListPanelTitleHolder, val);
433458
}
434459

435460
private void setTaskListTitleText(String text) {

0 commit comments

Comments
 (0)