Skip to content
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

UI update v1.3 #67

Merged
merged 19 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: codecov

ignore:
- "src/main/java/seedu/address/ui"
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public EditTxnDescriptor() {}
* Copy constructor.
* A defensive copy of {@code tags} is used internally.
*/

public EditTxnDescriptor(EditTxnDescriptor toCopy) {
setDescription(toCopy.description);
setOwner(toCopy.owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
import seedu.address.logic.commands.RemarkCommand;
import seedu.address.logic.commands.StatusCommand;
import seedu.address.logic.commands.txncommands.AddTxnCommand;
//import seedu.address.logic.commands.txncommands.DeleteTxnCommand;
import seedu.address.logic.commands.txncommands.EditTxnCommand;
import seedu.address.logic.commands.txncommands.ListTxnCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.logic.parser.txncommandparser.AddTxnCommandParser;
//import seedu.address.logic.parser.txncommandparser.DeleteTxnCommandParser;
import seedu.address.logic.parser.txncommandparser.EditTxnCommandParser;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public EditTxnCommand parse(String args) throws ParseException {
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditTxnCommand.MESSAGE_USAGE), pe);
}

EditTxnCommand.EditTxnDescriptor editTxnDescriptor = new EditTxnDescriptor();
if (argMultimap.getValue(PREFIX_TXN_DESCRIPTION).isPresent()) {
editTxnDescriptor.setDescription(ParserUtil.parseDescription(
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/model/person/Gender.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ public class Gender {

/* The input should be "male" or "female" */
public static final String VALIDATION_REGEX = ".*\\bmale\\b|.*\\bfemale\\b";
public static final String SYMBOL_MALE = "(M)";
public static final String SYMBOL_FEMALE = "(F)";

public final String value;
public final String symbol;

/**
* Constructs a {@code Gender}.
Expand All @@ -26,6 +29,7 @@ public Gender(String gender) {
requireNonNull(gender);
checkArgument(isValidGender(gender), MESSAGE_CONSTRAINTS);
this.value = gender;
this.symbol = gender.equals("male") ? SYMBOL_MALE : SYMBOL_FEMALE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Description {
"Description should not be blank";

public static final String VALIDATION_REGEX = "[^\\s].*";

public final String value;

/**
Expand All @@ -21,6 +22,7 @@ public class Description {
public Description(String description) {
requireNonNull(description);
checkArgument(isValidDescription(description));

value = description;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MainWindow extends UiPart<Stage> {

// Independent Ui parts residing in this Ui container
private PersonListPanel personListPanel;
private TransactionListPanel transactionListPanel;
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;

Expand All @@ -44,6 +45,9 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane personListPanelPlaceholder;

@FXML
private StackPane transactionListPanelPlaceholder;

@FXML
private StackPane resultDisplayPlaceholder;

Expand Down Expand Up @@ -113,6 +117,9 @@ void fillInnerParts() {
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());

transactionListPanel = new TransactionListPanel(logic.getFilteredTransactionList());
transactionListPanelPlaceholder.getChildren().add(transactionListPanel.getRoot());

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label id;
@FXML
private Label gender;
@FXML
private Label phone;
@FXML
private Label address;
Expand All @@ -43,6 +45,14 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label remark;
@FXML
private Label industry;
@FXML
private Label company;
@FXML
private Label occupation;
@FXML
private Label jobTitle;
@FXML
private Label status;

/**
Expand All @@ -53,13 +63,18 @@ public PersonCard(Person person, int displayedIndex) {
this.person = person;
id.setText(displayedIndex + ". ");
name.setText(person.getName().fullName);
gender.setText(person.getGender().symbol);
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
remark.setText(person.getRemark().value);
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
industry.setText(person.getIndustry().value);
company.setText(person.getCompany().value);
occupation.setText(person.getOccupation().value);
jobTitle.setText(person.getJobTitle().value);
status.setText(person.getStatus().getStatusName().getLabel());
}

Expand Down
72 changes: 72 additions & 0 deletions src/main/java/seedu/address/ui/TransactionCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package seedu.address.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.model.transaction.Transaction;


/**
* An UI component that displays information of a {@code Person}.
*/
public class TransactionCard extends UiPart<Region> {

private static final String FXML = "TransactionListCard.fxml";
private static final String TITLE_TEXT_VALUE = "Value: $";
private static final String TITLE_TEXT_OWNER = "Owner: ";

/**
* 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 Transaction txn;

@FXML
private HBox cardPane;
@FXML
private Label id;
@FXML
private Label description;
@FXML
private Label value;
@FXML
private Label status;
@FXML
private Label owner;

/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
*/
public TransactionCard(Transaction txn, int displayedIndex) {
super(FXML);
this.txn = txn;
id.setText(displayedIndex + ". ");
description.setText(txn.getDescription().toString());
status.setText(txn.getStatus().value);
value.setText(txn.getValue().toString());
owner.setText(txn.getOwner().toString());
}

@Override
public boolean equals(Object other) {
// short circuit if same object
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof TransactionCard)) {
return false;
}

// state check
TransactionCard card = (TransactionCard) other;
return id.getText().equals(card.id.getText())
&& txn.equals(card.txn);
}
}
49 changes: 49 additions & 0 deletions src/main/java/seedu/address/ui/TransactionListPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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.transaction.Transaction;

/**
* Panel containing the list of persons.
*/
public class TransactionListPanel extends UiPart<Region> {
private static final String FXML = "TransactionListPanel.fxml";
private final Logger logger = LogsCenter.getLogger(TransactionListPanel.class);

@FXML
private ListView<Transaction> transactionListView;

/**
* Creates a {@code PersonListPanel} with the given {@code ObservableList}.
*/
public TransactionListPanel(ObservableList<Transaction> txnList) {
super(FXML);
transactionListView.setItems(txnList);
transactionListView.setCellFactory(listView -> new TransactionListViewCell());
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}.
*/
class TransactionListViewCell extends ListCell<Transaction> {
@Override
protected void updateItem(Transaction txn, boolean empty) {
super.updateItem(txn, empty);

if (empty || txn == null) {
setGraphic(null);
setText(null);
} else {
setGraphic(new TransactionCard(txn, getIndex() + 1).getRoot());
}
}
}

}
4 changes: 4 additions & 0 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@
-fx-font-size: 11;
}

.list-cell #separator {
-fx-border-width: 0;
}

.cell_lead_status_label {
-fx-text-fill: white;
-fx-font-family: "Segoe UI";
Expand Down
57 changes: 31 additions & 26 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import java.net.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.stage.*?>

<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
title="Address App" minWidth="450" minHeight="600" onCloseRequest="#handleExit">
<fx:root minHeight="750.0" minWidth="1000.0" onCloseRequest="#handleExit" title="SalesPUNCH" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<icons>
<Image url="@/images/address_book_32.png" />
</icons>
Expand All @@ -33,27 +29,36 @@
</Menu>
</MenuBar>

<StackPane VBox.vgrow="NEVER" fx:id="commandBoxPlaceholder" styleClass="pane-with-border">
<StackPane fx:id="commandBoxPlaceholder" styleClass="pane-with-border" VBox.vgrow="NEVER">
<padding>
<Insets top="5" right="10" bottom="5" left="10" />
<Insets bottom="5" left="10" right="10" top="5" />
</padding>
</StackPane>

<StackPane VBox.vgrow="NEVER" fx:id="resultDisplayPlaceholder" styleClass="pane-with-border"
minHeight="100" prefHeight="100" maxHeight="100">
<StackPane fx:id="resultDisplayPlaceholder" maxHeight="100" minHeight="100" prefHeight="100" styleClass="pane-with-border" VBox.vgrow="NEVER">
<padding>
<Insets top="5" right="10" bottom="5" left="10" />
<Insets bottom="5" left="10" right="10" top="5" />
</padding>
</StackPane>

<VBox fx:id="personList" styleClass="pane-with-border" minWidth="340" prefWidth="340" VBox.vgrow="ALWAYS">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>

<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
<SplitPane dividerPositions="0.55" prefHeight="160.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
<items>
<VBox fx:id="personList" minWidth="500.0" styleClass="pane-with-border" SplitPane.resizableWithParent="false">
<padding>
<Insets bottom="10" left="10" right="10" top="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" minWidth="480.0" VBox.vgrow="ALWAYS" />
</VBox>
<VBox fx:id="transactionList" layoutX="10.0" layoutY="10.0" minWidth="340" prefWidth="340" styleClass="pane-with-border">
<padding>
<Insets bottom="10" left="10" right="10" top="10" />
</padding>
<children>
<StackPane fx:id="transactionListPanelPlaceholder" VBox.vgrow="ALWAYS" />
</children>
</VBox>
</items>
</SplitPane>
<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
</VBox>
</Scene>
</scene>
Expand Down
Loading