-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from IronBiscuit/master
List Inventory
- Loading branch information
Showing
20 changed files
with
302 additions
and
23 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
27 changes: 27 additions & 0 deletions
27
src/main/java/nustorage/logic/commands/ListInventoryCommand.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,27 @@ | ||
package nustorage.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static nustorage.model.Model.PREDICATE_SHOW_ALL_INVENTORY; | ||
|
||
import javafx.collections.ObservableList; | ||
import nustorage.model.Model; | ||
import nustorage.model.record.InventoryRecord; | ||
|
||
/** | ||
* Lists all persons in the address book to the user. | ||
*/ | ||
public class ListInventoryCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "list_inventory"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Listed all inventory items!"; | ||
|
||
|
||
@Override | ||
public CommandResult execute(Model model) { | ||
requireNonNull(model); | ||
model.updateFilteredInventoryList(PREDICATE_SHOW_ALL_INVENTORY); | ||
ObservableList<InventoryRecord> inventory = model.getFilteredInventory(); | ||
return new CommandResult(MESSAGE_SUCCESS); | ||
} | ||
} |
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,16 @@ | ||
package nustorage.model.item; | ||
|
||
import javafx.collections.ObservableList; | ||
import nustorage.model.record.InventoryRecord; | ||
|
||
/** | ||
* Unmodifiable view of an address book | ||
*/ | ||
public interface ReadOnlyInventory { | ||
|
||
/** | ||
* Returns an unmodifiable view of the persons list. | ||
* This list will not contain any duplicate persons. | ||
*/ | ||
ObservableList<InventoryRecord> asUnmodifiableObservableList(); | ||
} |
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,46 @@ | ||
package nustorage.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 nustorage.commons.core.LogsCenter; | ||
import nustorage.model.record.InventoryRecord; | ||
|
||
public class InventoryPanel extends UiPart<Region> { | ||
private static final String FXML = "InventoryPanel.fxml"; | ||
private final Logger logger = LogsCenter.getLogger(InventoryPanel.class); | ||
|
||
@FXML | ||
private ListView<InventoryRecord> inventoryView; | ||
|
||
/** | ||
* Creates a {@code PersonListPanel} with the given {@code ObservableList}. | ||
*/ | ||
public InventoryPanel(ObservableList<InventoryRecord> recordList) { | ||
super(FXML); | ||
inventoryView.setItems(recordList); | ||
inventoryView.setCellFactory(listView -> new InventoryPanel.InventoryViewCell()); | ||
} | ||
|
||
/** | ||
* Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. | ||
*/ | ||
class InventoryViewCell extends ListCell<InventoryRecord> { | ||
@Override | ||
protected void updateItem(InventoryRecord record, boolean empty) { | ||
super.updateItem(record, empty); | ||
|
||
if (empty || record == null) { | ||
setGraphic(null); | ||
setText(null); | ||
} else { | ||
setGraphic(new InventoryRecordCard(record, getIndex() + 1).getRoot()); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.