forked from nus-cs2103-AY2223S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
162 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package seedu.waddle.ui; | ||
|
||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.Region; | ||
import javafx.scene.layout.StackPane; | ||
import seedu.waddle.model.item.Item; | ||
|
||
/** | ||
* An UI component that displays information of a {@code Itinerary}. | ||
*/ | ||
public class ItemGroupCard extends UiPart<Region> { | ||
|
||
private static final String FXML = "ItemGroupListCard.fxml"; | ||
|
||
/** | ||
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. | ||
* As a consequence, UI elements' variable names cannot be set to such keywords | ||
* or an exception will be thrown by JavaFX during runtime. | ||
* | ||
* @see <a href="https://github.com/se-edu/addressbook-level4/issues/336">The issue on AddressBook level 4</a> | ||
*/ | ||
|
||
public final ObservableList<Item> itemGroup; | ||
|
||
@FXML | ||
private Label id; | ||
@FXML | ||
private StackPane itemListPanelPlaceholder; | ||
|
||
|
||
/** | ||
* Creates a {@code ItineraryCode} with the given {@code Itinerary} and index to display. | ||
*/ | ||
public ItemGroupCard(ObservableList<Item> itemGroup, int displayedIndex) { | ||
super(FXML); | ||
this.itemGroup = itemGroup; | ||
if (displayedIndex == 0) { | ||
this.id.setText("Wishlist"); | ||
} else { | ||
this.id.setText("Day " + displayedIndex); | ||
} | ||
System.out.println("SET ITEM GROUP ID"); | ||
this.itemListPanelPlaceholder.getChildren().add(new ItemListPanel(itemGroup).getRoot()); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
// short circuit if same object | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof ItemGroupCard)) { | ||
return false; | ||
} | ||
|
||
// state check | ||
ItemGroupCard card = (ItemGroupCard) other; | ||
return id.getText().equals(card.id.getText()) | ||
&& itemGroup.equals(card.itemGroup); | ||
} | ||
} |
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,49 @@ | ||
package seedu.waddle.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 seedu.waddle.commons.core.LogsCenter; | ||
import seedu.waddle.model.item.Item; | ||
|
||
/** | ||
* Panel containing the list of Items. | ||
*/ | ||
public class ItemGroupListPanel extends ListPanel { | ||
private static final String FXML = "ItemGroupListPanel.fxml"; | ||
private final Logger logger = LogsCenter.getLogger(ItemGroupListPanel.class); | ||
|
||
@FXML | ||
private ListView<ObservableList<Item>> itemGroupListView; | ||
|
||
/** | ||
* Creates a {@code ItemListPanel} with the given {@code ObservableList}. | ||
*/ | ||
public ItemGroupListPanel(ObservableList<ObservableList<Item>> itemGroups) { | ||
super(FXML); | ||
itemGroupListView.setItems(itemGroups); | ||
itemGroupListView.setCellFactory(listView -> new ItemGroupListPanel.ItemGroupListViewCell()); | ||
System.out.println("DONE CREATING GROUP LIST PANEL"); | ||
} | ||
|
||
/** | ||
* Custom {@code ListCell} that displays the graphics of a {@code Item} using a {@code ItemCard}. | ||
*/ | ||
class ItemGroupListViewCell extends ListCell<ObservableList<Item>> { | ||
@Override | ||
protected void updateItem(ObservableList<Item> itemGroup, boolean empty) { | ||
super.updateItem(itemGroup, empty); | ||
|
||
if (empty || itemGroup == null) { | ||
setGraphic(null); | ||
setText(null); | ||
} else { | ||
setGraphic(new ItemGroupCard(itemGroup, getIndex()).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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.StackPane?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
<VBox VBox.vgrow="ALWAYS" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<children> | ||
<Label fx:id="id" prefHeight="60.0" text="Label" /> | ||
<StackPane fx:id="itemListPanelPlaceholder" prefHeight="100" VBox.vgrow="ALWAYS" /> | ||
</children> | ||
</VBox> |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.ListView?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<ListView fx:id="itemGroupListView" VBox.vgrow="ALWAYS" /> | ||
</VBox> |