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

[W7.8][W12-3]Ler Wei Sheng #145

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/seedu/addressbook/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static String getMessageForPersonListShownSummary(List<? extends ReadOnly
return String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, personsDisplayed.size());
}


/**
* Executes the command and returns the result.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/seedu/addressbook/data/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import seedu.addressbook.data.person.UniquePersonList.DuplicatePersonException;
import seedu.addressbook.data.person.UniquePersonList.PersonNotFoundException;

import java.util.Set;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import

/**
* Represents the entire address book. Contains the data of the address book.
*/
Expand Down
9 changes: 8 additions & 1 deletion src/seedu/addressbook/data/person/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Represents a Person's address in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)}
*/
public class Address {
public class Address implements Printable{

public static final String EXAMPLE = "123, some street";
public static final String MESSAGE_ADDRESS_CONSTRAINTS = "Person addresses can be in any format";
Expand Down Expand Up @@ -55,4 +55,11 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

@Override
public String getPrintableString (Printable... printables) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of taking in printables argument?

return "Address: " + value;
}


}
9 changes: 8 additions & 1 deletion src/seedu/addressbook/data/person/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Represents a Person's email in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)}
*/
public class Email {
public class Email implements Printable{

public static final String EXAMPLE = "[email protected]";
public static final String MESSAGE_EMAIL_CONSTRAINTS =
Expand Down Expand Up @@ -58,4 +58,11 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

@Override
public String getPrintableString (Printable... printables) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: printables is unused

return "Email: " + value;
}


}
7 changes: 6 additions & 1 deletion src/seedu/addressbook/data/person/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Represents a Person's name in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidName(String)}
*/
public class Name {
public class Name implements Printable{

public static final String EXAMPLE = "John Doe";
public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters";
Expand Down Expand Up @@ -61,4 +61,9 @@ public int hashCode() {
return fullName.hashCode();
}

@Override
public String getPrintableString (Printable... printables) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printables is unused

return "Nama-ewa: " + fullName;
}

}
10 changes: 9 additions & 1 deletion src/seedu/addressbook/data/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Represents a Person's phone number in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)}
*/
public class Phone {
public class Phone implements Printable{

public static final String EXAMPLE = "123456789";
public static final String MESSAGE_PHONE_CONSTRAINTS = "Person phone numbers should only contain numbers";
Expand Down Expand Up @@ -56,4 +56,12 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}


@Override
public String getPrintableString (Printable... printables) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printables is unused

return "Phono-desu: " + value;
}


}
6 changes: 6 additions & 0 deletions src/seedu/addressbook/data/person/Printable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package seedu.addressbook.data.person;

public interface Printable {
public String getPrintableString (Printable... printables);
}

19 changes: 18 additions & 1 deletion src/seedu/addressbook/data/person/UniquePersonList.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @see Person#equals(Object)
* @see Utils#elementsAreUnique(Collection)
*/
public class UniquePersonList implements Iterable<Person> {
public class UniquePersonList implements Iterable<Person>, Printable {

/**
* Signals that an operation would have violated the 'no duplicates' property of the list.
Expand Down Expand Up @@ -46,6 +46,17 @@ public UniquePersonList(Person... persons) throws DuplicatePersonException {
internalList.addAll(initialTags);
}


@Override
public String getPrintableString (Printable... printables) {
String result = "";
for (Printable prints: printables) {
result += prints.getPrintableString() + " ";
}

return result;
}

/**
* Constructs a list from the items in the given collection.
* @param persons a collection of persons
Expand All @@ -63,8 +74,14 @@ public UniquePersonList(Collection<Person> persons) throws DuplicatePersonExcept
*/
public UniquePersonList(UniquePersonList source) {
internalList.addAll(source.internalList);

for (Person person: internalList) {
System.out.println(getPrintableString(person.getName(), person.getPhone(), person.getEmail()));
}
}



/**
* Unmodifiable java List view with elements cast as immutable {@link ReadOnlyPerson}s.
* For use with other methods/libraries.
Expand Down
1 change: 0 additions & 1 deletion src/seedu/addressbook/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public Command parseCommand(String userInput) {

case ExitCommand.COMMAND_WORD:
return new ExitCommand();

case HelpCommand.COMMAND_WORD: // Fallthrough
default:
return new HelpCommand();
Expand Down
Binary file added src/seedu/addressbook/resources/chinchin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/seedu/addressbook/ui/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
-fx-font-family: "Segoe UI Semibold";
-fx-font-size: 10pt;
-fx-padding: 5 5 5 5;
}
}
38 changes: 26 additions & 12 deletions src/seedu/addressbook/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import seedu.addressbook.commands.ExitCommand;
import seedu.addressbook.logic.Logic;
import seedu.addressbook.commands.CommandResult;
Expand All @@ -23,24 +25,12 @@ public class MainWindow {
private Logic logic;
private Stoppable mainApp;

public MainWindow(){
}

public void setLogic(Logic logic){
this.logic = logic;
}

public void setMainApp(Stoppable mainApp){
this.mainApp = mainApp;
}

@FXML
private TextArea outputConsole;

@FXML
private TextField commandInput;


@FXML
void onCommand(ActionEvent event) {
try {
Expand All @@ -58,6 +48,30 @@ void onCommand(ActionEvent event) {
}
}

@FXML
private void initialize() {
commandInput.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
// System.out.println(newValue);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this instead of just comment out.

}
});
}

public MainWindow(){
}


public void setLogic(Logic logic){
this.logic = logic;
}

public void setMainApp(Stoppable mainApp){
this.mainApp = mainApp;
}


private void exitApp() throws Exception {
mainApp.stop();
}
Expand Down
8 changes: 8 additions & 0 deletions src/seedu/addressbook/ui/mainwindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.VBox?>

<?import javafx.scene.image.ImageView?>
<?import javafx.scene.image.Image?>

<VBox stylesheets="@/seedu/addressbook/ui/DarkTheme.css" alignment="center" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="seedu.addressbook.ui.MainWindow">

<children>
<ImageView>
<image>
<Image url="@/seedu/addressbook/resources/[email protected]" />
</image>
</ImageView>

<TextField fx:id="commandInput" onAction="#onCommand" VBox.vgrow="NEVER">
</TextField>
Expand Down