forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
15 changed files
with
287 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/seedu/address/ui/IncompleteTaskListPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package seedu.address.ui; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.ListCell; | ||
import javafx.scene.control.ListView; | ||
import javafx.scene.layout.Region; | ||
import seedu.address.commons.core.LogsCenter; | ||
import seedu.address.model.task.Task; | ||
|
||
/** | ||
* Panel containing the list of persons. | ||
*/ | ||
public class IncompleteTaskListPanel extends UiPart<Region> { | ||
private static final String FXML = "IncompleteTaskListPanel.fxml"; | ||
private final Logger logger = LogsCenter.getLogger(IncompleteTaskListPanel.class); | ||
|
||
@FXML | ||
private ListView<Task> incompleteTaskListView; | ||
|
||
public IncompleteTaskListPanel(ObservableList<Task> incompleteTaskList) { | ||
super(FXML); | ||
incompleteTaskListView.setItems(incompleteTaskList); | ||
incompleteTaskListView.setCellFactory(listView -> new IncompleteTaskListPanel.IncompleteTaskListViewCell()); | ||
} | ||
|
||
/** | ||
* Custom {@code ListCell} that displays the graphics of a {@code Task} using a {@code TaskCard}. | ||
*/ | ||
class IncompleteTaskListViewCell extends ListCell<Task> { | ||
@Override | ||
protected void updateItem(Task task, boolean empty) { | ||
super.updateItem(task, empty); | ||
|
||
if (empty || task == null) { | ||
setGraphic(null); | ||
setText(null); | ||
} else { | ||
setGraphic(new TaskCard(task, getIndex() + 1).getRoot()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package seedu.address.ui; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.stage.Stage; | ||
import seedu.address.commons.core.LogsCenter; | ||
import seedu.address.logic.Logic; | ||
import seedu.address.logic.commands.FreeCommand; | ||
import seedu.address.model.person.Driver; | ||
import seedu.address.model.task.Task; | ||
|
||
/** | ||
* Controller for a help page | ||
*/ | ||
public class NotificationWindow extends UiPart<Stage> { | ||
|
||
private static final Logger logger = LogsCenter.getLogger(NotificationWindow.class); | ||
private static final String FXML = "NotificationWindow.fxml"; | ||
|
||
private Logic logic; | ||
|
||
private IncompleteTaskListPanel incompleteTaskListPanel; | ||
|
||
@FXML | ||
private StackPane incompleteTaskListPanelPlaceholder; | ||
|
||
@FXML | ||
private Button okayButton; | ||
|
||
@FXML | ||
private StackPane okayButtonPlaceholder; | ||
|
||
/** | ||
* Creates a new HelpWindow. | ||
* | ||
* @param root Stage to use as the root of the HelpWindow. | ||
*/ | ||
public NotificationWindow(Stage root, Logic logic) { | ||
super(FXML, root); | ||
this.logic = logic; | ||
|
||
incompleteTaskListPanel = new IncompleteTaskListPanel(this.logic.getIncompleteTaskList()); | ||
incompleteTaskListPanelPlaceholder.getChildren().add(incompleteTaskListPanel.getRoot()); | ||
} | ||
|
||
/** | ||
* Creates a new HelpWindow. | ||
*/ | ||
public NotificationWindow(Logic logic) { | ||
this(new Stage(), logic); | ||
} | ||
|
||
/** | ||
* Shows the notification window. | ||
* @throws IllegalStateException | ||
* <ul> | ||
* <li> | ||
* if this method is called on a thread other than the JavaFX Application Thread. | ||
* </li> | ||
* <li> | ||
* if this method is called during animation or layout processing. | ||
* </li> | ||
* <li> | ||
* if this method is called on the primary stage. | ||
* </li> | ||
* <li> | ||
* if {@code dialogStage} is already showing. | ||
* </li> | ||
* </ul> | ||
*/ | ||
public void show() { | ||
logger.fine("Showing page about the incomplete task from the previous day."); | ||
getRoot().show(); | ||
getRoot().centerOnScreen(); | ||
} | ||
|
||
/** | ||
* Returns true if the help window is currently being shown. | ||
*/ | ||
public boolean isShowing() { | ||
return getRoot().isShowing(); | ||
} | ||
|
||
/** | ||
* Hides the help window. | ||
*/ | ||
public void hide() { | ||
getRoot().hide(); | ||
} | ||
|
||
/** | ||
* Focuses on the help window. | ||
*/ | ||
public void focus() { | ||
getRoot().requestFocus(); | ||
} | ||
|
||
/** | ||
* Frees driver's schedule from tasks in the past | ||
*/ | ||
@FXML | ||
private void freeDriver() { | ||
ObservableList<Task> tasksToBeCleared = logic.getIncompleteTaskList(); | ||
for (Task task: tasksToBeCleared) { | ||
Driver driver = task.getDriver().orElseThrow(); | ||
FreeCommand.freeDriverFromTask(driver, task); | ||
} | ||
this.hide(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.ListView?> | ||
<?import javafx.scene.control.ToolBar?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
<VBox xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"> | ||
<ToolBar prefHeight="36.0" prefWidth="248.0"> | ||
<items> | ||
<Label text="Uncompleted Delivery Tasks from Previous Days" /> | ||
</items> | ||
</ToolBar> | ||
<ListView fx:id="incompleteTaskListView" VBox.vgrow="ALWAYS" /> | ||
</VBox> |
Oops, something went wrong.