forked from nus-cs2103-AY1617S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/change-ui' into v0.2-release
- Loading branch information
Showing
29 changed files
with
815 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package seedu.agendum.ui; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.HBox; | ||
import seedu.agendum.model.task.ReadOnlyTask; | ||
|
||
public class CompletedTaskCard extends UiPart { | ||
|
||
private static final String FXML = "CompletedTaskCard.fxml"; | ||
|
||
@FXML | ||
private HBox cardPane; | ||
@FXML | ||
private Label name; | ||
@FXML | ||
private Label id; | ||
@FXML | ||
private Label tags; | ||
|
||
private ReadOnlyTask task; | ||
private int displayedIndex; | ||
|
||
public CompletedTaskCard(){ | ||
|
||
} | ||
|
||
public static CompletedTaskCard load(ReadOnlyTask task, int displayedIndex){ | ||
CompletedTaskCard card = new CompletedTaskCard(); | ||
card.task = task; | ||
card.displayedIndex = displayedIndex; | ||
return UiPartLoader.loadUiPart(card); | ||
} | ||
|
||
@FXML | ||
public void initialize() { | ||
name.setText(task.getName().fullName); | ||
id.setText(displayedIndex + ". "); | ||
tags.setText(task.tagsString()); | ||
} | ||
|
||
public HBox getLayout() { | ||
return cardPane; | ||
} | ||
|
||
@Override | ||
public void setNode(Node node) { | ||
cardPane = (HBox)node; | ||
} | ||
|
||
@Override | ||
public String getFxmlPath() { | ||
return FXML; | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
src/main/java/seedu/agendum/ui/CompletedTasksPanel.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,106 @@ | ||
package seedu.agendum.ui; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import javafx.application.Platform; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.ListCell; | ||
import javafx.scene.control.ListView; | ||
import javafx.scene.control.SplitPane; | ||
import javafx.scene.layout.AnchorPane; | ||
import javafx.stage.Stage; | ||
import seedu.agendum.commons.events.ui.TaskPanelSelectionChangedEvent; | ||
import seedu.agendum.model.task.ReadOnlyTask; | ||
import seedu.agendum.commons.core.LogsCenter; | ||
|
||
/** | ||
* Panel contains the list of completed tasks | ||
*/ | ||
public class CompletedTasksPanel extends UiPart { | ||
private final Logger logger = LogsCenter.getLogger(CompletedTasksPanel.class); | ||
private static final String FXML = "CompletedTasksPanel.fxml"; | ||
private AnchorPane panel; | ||
private AnchorPane placeHolderPane; | ||
|
||
@FXML | ||
private ListView<ReadOnlyTask> completedTasksListView; | ||
|
||
public CompletedTasksPanel() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void setNode(Node node) { | ||
panel = (AnchorPane) node; | ||
} | ||
|
||
@Override | ||
public String getFxmlPath() { | ||
return FXML; | ||
} | ||
|
||
@Override | ||
public void setPlaceholder(AnchorPane pane) { | ||
this.placeHolderPane = pane; | ||
} | ||
|
||
public static CompletedTasksPanel load(Stage primaryStage, AnchorPane CompletedTasksPlaceholder, | ||
ObservableList<ReadOnlyTask> taskList) { | ||
CompletedTasksPanel completedTasksPanel = UiPartLoader.loadUiPart(primaryStage, CompletedTasksPlaceholder, new CompletedTasksPanel()); | ||
completedTasksPanel.configure(taskList); | ||
return completedTasksPanel; | ||
} | ||
|
||
private void configure(ObservableList<ReadOnlyTask> completedTasks) { | ||
setConnections(completedTasks); | ||
addToPlaceholder(); | ||
} | ||
|
||
private void setConnections(ObservableList<ReadOnlyTask> completedTasks) { | ||
completedTasksListView.setItems(completedTasks); | ||
completedTasksListView.setCellFactory(listView -> new completedTasksListViewCell()); | ||
setEventHandlerForSelectionChangeEvent(); | ||
} | ||
|
||
private void addToPlaceholder() { | ||
SplitPane.setResizableWithParent(placeHolderPane, false); | ||
placeHolderPane.getChildren().add(panel); | ||
} | ||
|
||
private void setEventHandlerForSelectionChangeEvent() { | ||
completedTasksListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { | ||
if (newValue != null) { | ||
logger.fine("Selection in task list panel changed to : '" + newValue + "'"); | ||
raise(new TaskPanelSelectionChangedEvent(newValue)); | ||
} | ||
}); | ||
} | ||
|
||
public void scrollTo(int index) { | ||
Platform.runLater(() -> { | ||
completedTasksListView.scrollTo(index); | ||
completedTasksListView.getSelectionModel().clearAndSelect(index); | ||
}); | ||
} | ||
|
||
class completedTasksListViewCell extends ListCell<ReadOnlyTask> { | ||
|
||
public completedTasksListViewCell() { | ||
} | ||
|
||
@Override | ||
protected void updateItem(ReadOnlyTask task, boolean empty) { | ||
super.updateItem(task, empty); | ||
|
||
if (empty || task == null) { | ||
setGraphic(null); | ||
setText(null); | ||
} else { | ||
setGraphic(CompletedTaskCard.load(task, getIndex() + 1).getLayout()); | ||
} | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.