New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add list panels and first UI prototype #66
Changes from all commits
518605b
3e33ec4
3b2bb50
691864b
657d074
c93892a
20d1328
cce08c5
3e0fbcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package seedu.address.ui; | ||
package seedu.address.ui.cards; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to Package Cards |
||
|
||
import java.util.Comparator; | ||
|
||
|
@@ -8,6 +8,7 @@ | |
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Region; | ||
import seedu.address.model.customer.Customer; | ||
import seedu.address.ui.UiPart; | ||
|
||
/** | ||
* An UI component that displays information of a {@code Customer}. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package seedu.address.ui.cards; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
|
||
import java.util.Comparator; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.FlowPane; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Region; | ||
import seedu.address.model.phone.Phone; | ||
import seedu.address.ui.UiPart; | ||
|
||
|
||
/** | ||
* An UI component that displays information of a {@code Phone} | ||
*/ | ||
public class PhoneCard extends UiPart<Region> { | ||
|
||
private static final String FXML = "PhoneListCard.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 Phone phone; | ||
|
||
// No price displayed here for phone | ||
@FXML | ||
private HBox cardPane; | ||
@FXML | ||
private Label name; | ||
@FXML | ||
private Label colour; | ||
@FXML | ||
private Label cost; | ||
@FXML | ||
private Label capacity; | ||
@FXML | ||
private Label brand; | ||
@FXML | ||
private Label id; | ||
@FXML | ||
private FlowPane tags; | ||
|
||
public PhoneCard(Phone phone, int displayedIndex) { | ||
super(FXML); | ||
this.phone = phone; | ||
id.setText(displayedIndex + ". "); | ||
EugeneTeu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
brand.setText(phone.getBrand().value); | ||
capacity.setText(phone.getCapacity().value); | ||
colour.setText(phone.getColour().value); | ||
cost.setText(phone.getCost().value); | ||
name.setText(phone.getName().fullName); | ||
phone.getTags().stream() | ||
.sorted(Comparator.comparing(tag -> tag.tagName)) | ||
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); | ||
|
||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object other) { | ||
// short circuit if same object | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof PhoneCard)) { | ||
return false; | ||
} | ||
|
||
// state check | ||
PhoneCard card = (PhoneCard) other; | ||
return id.getText().equals(card.id.getText()) | ||
&& phone.equals(card.phone); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package seedu.address.ui; | ||
package seedu.address.ui.panels; | ||
|
||
import java.util.logging.Logger; | ||
|
||
|
@@ -9,9 +9,11 @@ | |
import javafx.scene.layout.Region; | ||
import seedu.address.commons.core.LogsCenter; | ||
import seedu.address.model.customer.Customer; | ||
import seedu.address.ui.UiPart; | ||
import seedu.address.ui.cards.CustomerCard; | ||
|
||
/** | ||
* Panel containing the list of persons. | ||
* Panel containing the list of customers. | ||
*/ | ||
public class CustomerListPanel extends UiPart<Region> { | ||
private static final String FXML = "PersonListPanel.fxml"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to be updated yet? |
||
|
@@ -27,7 +29,7 @@ public CustomerListPanel(ObservableList<Customer> customerList) { | |
} | ||
|
||
/** | ||
* Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. | ||
* Custom {@code ListCell} that displays the graphics of a {@code Customer} using a {@code CustomerCard}. | ||
*/ | ||
class CustomerListViewCell extends ListCell<Customer> { | ||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package seedu.address.ui.panels; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to package Panels |
||
|
||
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.phone.Phone; | ||
import seedu.address.ui.UiPart; | ||
import seedu.address.ui.cards.PhoneCard; | ||
|
||
/** | ||
* Panel containing the list of phones. | ||
*/ | ||
public class PhoneListPanel extends UiPart<Region> { | ||
private static final String FXML = "PersonListPanel.fxml"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to be updated yet? |
||
private final Logger logger = LogsCenter.getLogger(CustomerListPanel.class); | ||
|
||
@FXML | ||
private ListView<Phone> phoneListView; | ||
|
||
public PhoneListPanel(ObservableList<Phone> phoneList) { | ||
super(FXML); | ||
phoneListView.setItems(phoneList); | ||
phoneListView.setCellFactory(listView -> new PhoneListViewCell()); | ||
} | ||
|
||
/** | ||
* Custom {@code ListCell} that displays the graphics of a {@code Phone} using a {@code PhoneCard}. | ||
*/ | ||
class PhoneListViewCell extends ListCell<Phone> { | ||
@Override | ||
protected void updateItem(Phone phone, boolean empty) { | ||
super.updateItem(phone, empty); | ||
|
||
if (empty || phone == null) { | ||
setGraphic(null); | ||
setText(null); | ||
} else { | ||
setGraphic(new PhoneCard(phone, getIndex() + 1).getRoot()); | ||
} | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.FlowPane?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.Region?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<GridPane HBox.hgrow="ALWAYS"> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" /> | ||
</columnConstraints> | ||
<VBox alignment="CENTER_LEFT" minHeight="105" GridPane.columnIndex="0"> | ||
<padding> | ||
<Insets top="5" right="5" bottom="5" left="15" /> | ||
</padding> | ||
<HBox spacing="5" alignment="CENTER_LEFT"> | ||
<Label fx:id="id" styleClass="cell_big_label"> | ||
<minWidth> | ||
<!-- Ensures that the label text is never truncated --> | ||
<Region fx:constant="USE_PREF_SIZE" /> | ||
</minWidth> | ||
</Label> | ||
<Label fx:id="name" text="\$first" styleClass="cell_big_label" /> | ||
</HBox> | ||
<FlowPane fx:id="tags" /> | ||
<Label fx:id="contactNumber" styleClass="cell_small_label" text="\$contactNumber" /> | ||
<Label fx:id="email" styleClass="cell_small_label" text="\$email" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think need to update right? haha all the labels |
||
</VBox> | ||
</GridPane> | ||
</HBox> |
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="customerListView" VBox.vgrow="ALWAYS" styleClass="pane-with-border"/> | ||
</VBox> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uberSaiyan as discussed, switched this to value to keep with convention in PhoneCard