Skip to content

Commit

Permalink
Merge branch 'quangtdn-fix_profilePage'
Browse files Browse the repository at this point in the history
merge quang pr
  • Loading branch information
erik0704 committed Nov 2, 2017
2 parents 6d8bf41 + b2f17e1 commit f069248
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public AddCommand parse(String args) throws ParseException {
&&(!arePrefixesPresent(argMultimap, PREFIX_ADDRESS))
&&(!arePrefixesPresent(argMultimap, PREFIX_PHONE))
&&(!arePrefixesPresent(argMultimap, PREFIX_EMAIL))
&&(!arePrefixesPresent(argMultimap, PREFIX_BIRTHDAY))
&&(!arePrefixesPresent(argMultimap, PREFIX_PROFILEPAGE))) {
&&(!arePrefixesPresent(argMultimap, PREFIX_BIRTHDAY))) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
}

Expand Down Expand Up @@ -83,9 +82,9 @@ public AddCommand parse(String args) throws ParseException {
address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get();
else {address=new Address();}

if(arePrefixesPresent(argMultimap, PREFIX_PROFILEPAGE))
profile = ParserUtil.parseProfilePage(argMultimap.getValue(PREFIX_PROFILEPAGE)).get();
else {profile=new ProfilePage();}

profile = ParserUtil.parseProfilePage(argMultimap.getValue(PREFIX_PROFILEPAGE)).get();


tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static Optional<Address> parseAddress(Optional<String> address) throws Il
*/
public static Optional<ProfilePage> parseProfilePage(Optional<String> profile) throws IllegalValueException {
requireNonNull(profile);
return profile.isPresent() ? Optional.of(new ProfilePage(profile.get())) : Optional.empty();
return profile.isPresent() ? Optional.of(new ProfilePage(profile.get())) : Optional.of(new ProfilePage(""));
}
//@@author

Expand Down
26 changes: 13 additions & 13 deletions src/main/java/seedu/address/model/person/ProfilePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ public class ProfilePage {
"Person Profile page should be a valid URL pointing to that person's profile";
public static final String PROFILEPAGE_VALIDATION_REGEX = "^(https?:\\/\\/)?(www\\.)?([\\w]+\\.)+[‌​\\w]{2,63}\\/?$";

public final String value;
//public static final String PROFILEPAGE_VALIDATION_REGEX = "(@)?(href=')?(HREF=')?(HREF=\")?(href=\")?(http://)?[a-zA-Z_0-9\\-]+(\\.\\w[a-zA-Z_0-9\\-]+)+(/[#&\\n\\-=?\\+\\%/\\.\\w]+)?";

public boolean hasProfilePage(){
return (!value.equals("www.unknown.com"));
}
public final String value;

/**
* Validates given birthday.
Expand All @@ -39,20 +37,22 @@ public ProfilePage(String profile) throws IllegalValueException {
}
}

public ProfilePage() throws IllegalValueException {
//requireNonNull(profile);
this.value = "www.unknown.com";
/*if (!isValidProfilePage(this.value)) {
throw new IllegalValueException(MESSAGE_PROFILEPAGE_CONSTRAINTS);
}*/
/**
* Returns if a given string is a valid person profile page.
*/
public static boolean isValidProfilePage(String test) {
if(test.equals("")) {
return true;
}

return test.matches(PROFILEPAGE_VALIDATION_REGEX);
}

/**
* Returns if a given string is a valid person birthday.
* Returns true if this person has a profile page.
*/
public static boolean isValidProfilePage(String test) {
return test.matches(PROFILEPAGE_VALIDATION_REGEX);
public boolean hasProfilePage(){
return (this.value.equals("") || this.value == null) ? false: true;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/storage/XmlAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class XmlAdaptedPerson {
private String address;
//@@author quangtdn
@XmlElement(required = false)
private String profile="";
private String profile = "";
//@@author

@XmlElement
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ private static String colorGetterForTag(String tagValue) {
private void bindListeners(ReadOnlyPerson person) {
name.textProperty().bind(Bindings.convert(person.nameProperty()));
phone.textProperty().bind(Bindings.convert(person.phoneProperty()));
//@@author yanji1221
birthday.textProperty().bind(Bindings.convert(person.birthdayProperty()));
//@@author
address.textProperty().bind(Bindings.convert(person.addressProperty()));
profile.textProperty().bind(Bindings.convert(person.profilepageProperty()));

if(!person.profilepageProperty().toString().equals("")) {
profile.textProperty().bind(Bindings.convert(person.profilepageProperty()));
profile.setVisible(true);
} else {
profile.setVisible(false);
}

email.textProperty().bind(Bindings.convert(person.emailProperty()));
person.tagProperty().addListener((observable, oldValue, newValue) -> {
tags.getChildren().clear();
Expand Down

0 comments on commit f069248

Please sign in to comment.