Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY1718S1#63 from ChenXiaoman/googleMap
Browse files Browse the repository at this point in the history
Add Google map in browser panel
  • Loading branch information
RonakLakhotia authored Oct 24, 2017
2 parents 681a015 + e5ed7ee commit 763f295
Show file tree
Hide file tree
Showing 23 changed files with 339 additions and 99 deletions.
8 changes: 1 addition & 7 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Weaver (Level 4)
= Weaver

image::docs/images/login.png[width="790"]

Expand All @@ -20,17 +20,11 @@ endif::[]
* This is a desktop Address Book application. It has a GUI but most of the user interactions happen using a CLI (Command Line Interface).
* It is a Java sample application intended for students learning Software Engineering while using Java as the main programming language.
* It is *written in OOP fashion*. It provides a *reasonably well-written* code example that is *significantly bigger* (around 6 KLoC)than what students usually write in beginner-level SE modules.
* What's different from https://github.com/se-edu/addressbook-level3[level 3]:
** A more sophisticated GUI that includes a list panel and an in-built Browser.
** More details about each user like Date Of Birth.
** More test cases, including automated GUI testing.
** Support for _Build Automation_ using Gradle and for _Continuous Integration_ using Travis CI.
== Site Map

* <<UserGuide#, User Guide>>
* <<DeveloperGuide#, Developer Guide>>
* <<LearningOutcomes#, Learning Outcomes>>
* <<AboutUs#, About Us>>
* <<ContactUs#, Contact Us>>

Expand Down
19 changes: 17 additions & 2 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ endif::[]
ifdef::env-github,env-browser[:outfilesuffix: .adoc]
:repoURL: https://github.com/se-edu/addressbook-level4/tree/master

By: `W13-B2`      Since: `Aug 2017`      Licence: `MIT`
By: `W13-B2` Since: `Aug 2017` Licence: `MIT`

*`Weaver`* is a command line based software for storing and managing contact information. It satisfies almost all functions might be needed by university students on storing and managing contact information.


== Introduction

=== Audiences

All university students. +
People who have the need for storing and managing contact information efficiently are suggested to use *`Weaver`*.

=== Purposes

. *`Weaver`* aims at providing efficient solution for university students to store and manage contact information.
. It devotes to improve the experience when users try to add person , delete person , edit person , remark person ect.
. Targeted at university students, *`Weaver`* is bringing shortcut for students to note meetings, calendars and course information.

*`Weaver`* is a command line based software for storing and managing contact information. It satisfies almost all functions might be needed by university students on storing and managing contact information.

Expand Down Expand Up @@ -1476,4 +1492,3 @@ Environment Bit
32/64 bits refer to the number of bits that compose a data element
....
[appendix]

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package seedu.address.commons.events.ui;

import seedu.address.commons.events.BaseEvent;

/**
* Indicates an address in a person panel is pressed
*/
public class PersonPanelAddressPressedEvent extends BaseEvent {

private String personName;
private String address;

public PersonPanelAddressPressedEvent(String personName, String address) {

this.personName = personName;
this.address = address;
}

@Override
public String toString() {
return this.getClass().getSimpleName();
}

/**
* Get the address from the event
*/
public String getAddress() {
return address;
}

/**
* Get the name of the person from the event
*/
public String getPersonName() {
return personName;
}
}
22 changes: 11 additions & 11 deletions src/main/java/seedu/address/logic/commands/PhotoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class PhotoCommand extends UndoableCommand {
public static final String MESSAGE_FILE_PATH_NOT_FOUND = "Incorrect file path";

private final Index targetIndex;
private String FilePath;
private String filePath;

public PhotoCommand(Index targetIndex, String FilePath) {
public PhotoCommand(Index targetIndex, String filePath) {
this.targetIndex = targetIndex;
this.FilePath = FilePath;
this.filePath = filePath;
}

@Override
Expand All @@ -52,30 +52,30 @@ public CommandResult executeUndoableCommand() throws CommandException {

ReadOnlyPerson personToAddPhoto = lastShownList.get(targetIndex.getZeroBased());

if (personToAddPhoto.getImage().getFilePath().equals("") && FilePath.equalsIgnoreCase("delete")) {
if (personToAddPhoto.getImage().getFilePath().equals("") && filePath.equalsIgnoreCase("delete")) {
throw new CommandException(Messages.MESSAGE_NO_IMAGE_TO_DELETE);
}
if (FilePath.equalsIgnoreCase("Delete")) {
FilePath = "";
if (filePath.equalsIgnoreCase("Delete")) {
filePath = "";
}

try {
Person editedPerson = new Person(personToAddPhoto.getName(), personToAddPhoto.getPhone(),
personToAddPhoto.getEmail(),
personToAddPhoto.getAddress(), personToAddPhoto.getDateOfBirth(), personToAddPhoto.getRemark(),
new FileImage(FilePath), personToAddPhoto.getTags());
new FileImage(filePath), personToAddPhoto.getTags());

model.addPhotoPerson(personToAddPhoto, FilePath, targetIndex);
model.addPhotoPerson(personToAddPhoto, filePath, targetIndex);
model.updatePerson(personToAddPhoto, editedPerson);
ImageStorage imageStorage = new ImageStorage();

FilePath = (imageStorage.execute(FilePath,
filePath = (imageStorage.execute(filePath,
personToAddPhoto.getEmail().hashCode()));

editedPerson = new Person(personToAddPhoto.getName(),
personToAddPhoto.getPhone(), personToAddPhoto.getEmail(),
personToAddPhoto.getAddress(), personToAddPhoto.getDateOfBirth(), personToAddPhoto.getRemark(),
new FileImage(FilePath), personToAddPhoto.getTags());
new FileImage(filePath), personToAddPhoto.getTags());
model.updatePerson(personToAddPhoto, editedPerson);

} catch (PersonNotFoundException pnfe) {
Expand All @@ -85,7 +85,7 @@ public CommandResult executeUndoableCommand() throws CommandException {
} catch (IllegalValueException ive) {
assert false : "Invalid input";
}
if (FilePath.equals("")) {
if (filePath.equals("")) {
return new CommandResult(String.format(DELETE_SUCCESS, personToAddPhoto));
} else {
return new CommandResult(String.format(MESSAGE_PHOTO_PERSON_SUCCESS, personToAddPhoto));
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/seedu/address/logic/parser/PhotoCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public class PhotoCommandParser implements Parser<PhotoCommand> {
public PhotoCommand parse(String args) throws ParseException {

String trimmedArgs = args.trim();
String[] Keywords = trimmedArgs.split("\\s+");
String[] keywords = trimmedArgs.split("\\s+");

if (trimmedArgs.isEmpty() || Keywords.length != 2) {
if (trimmedArgs.isEmpty() || keywords.length != 2) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, PhotoCommand.MESSAGE_USAGE));
}
String home = System.getProperty("user.home");
String inputFile = Keywords[1];
String inputFile = keywords[1];
java.nio.file.Path path = java.nio.file.Paths.get(home, "Desktop");
String url = path + "";
System.out.println(path + " " + inputFile);
Expand All @@ -44,8 +44,8 @@ public PhotoCommand parse(String args) throws ParseException {
}

try {
Index index = ParserUtil.parseIndex(Keywords[0]);
return new PhotoCommand(index, (Keywords[1]));
Index index = ParserUtil.parseIndex(keywords[0]);
return new PhotoCommand(index, (keywords[1]));
} catch (IllegalValueException ive) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, PhotoCommand.MESSAGE_USAGE));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface Model {
void addPerson(ReadOnlyPerson person) throws DuplicatePersonException;

/** Adds photo to person */
void addPhotoPerson(ReadOnlyPerson person, String FilePath, Index targetIndex)
void addPhotoPerson(ReadOnlyPerson person, String filePath, Index targetIndex)
throws PersonNotFoundException, FileNotFoundException,
IOException;

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,15 @@ public synchronized void addPerson(ReadOnlyPerson person) throws DuplicatePerson
}

@Override
public synchronized void addPhotoPerson(ReadOnlyPerson person, String FilePath, Index targetIndex)
public synchronized void addPhotoPerson(ReadOnlyPerson person, String filePath, Index targetIndex)
throws PersonNotFoundException,
FileNotFoundException, IOException {

try {
person.imageProperty().setValue( new FileImage(FilePath));
person.imageProperty().setValue(new FileImage(filePath));
updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
indicateAddressBookChanged();
}
catch (IllegalValueException ive) {
} catch (IllegalValueException ive) {
System.out.println("Error encountered");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/UserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setGuiSettings(double width, double height, int x, int y, String fon
}

public void setGuiSettings(double width, double height, int x, int y) {
guiSettings = new GuiSettings(width, height, x, y, FontSize.FONT_SIZE_M_LABEL);
guiSettings = new GuiSettings(width, height, x, y, FontSize.getCurrentFontSizeLabel());
}

public String getAddressBookFilePath() {
Expand Down
36 changes: 35 additions & 1 deletion src/main/java/seedu/address/model/font/FontSize.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public int hashCode() {
/**
* Get the associate fx format string for a give font size
* @param inputFontSize
* @return
*/
public static String getassociatefxfontsizestring(String inputFontSize) {
assert (FontSize.isValidFontSize(inputFontSize));
Expand Down Expand Up @@ -183,4 +182,39 @@ public static String getassociatefxfontsizestring(String inputFontSize) {
return fxFontSizeString;
}

/**
* Get associate image size from a given font size
* @param inputFontSize
* @return
*/
public static int getAssociateImageSizeFromFontSize(String inputFontSize) {
assert (FontSize.isValidFontSize(inputFontSize));
int imageSize;
switch (inputFontSize) {
case FONT_SIZE_XS_LABEL:
imageSize = 15;
break;

case FONT_SIZE_S_LABEL:
imageSize = 20;
break;

case FONT_SIZE_M_LABEL:
imageSize = 25;
break;

case FONT_SIZE_L_LABEL:
imageSize = 30;
break;

case FONT_SIZE_XL_LABEL:
imageSize = 35;
break;

default:
imageSize = 25;
}
return imageSize;
}

}
11 changes: 9 additions & 2 deletions src/main/java/seedu/address/ui/BrowserPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javafx.scene.web.WebView;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.events.ui.FaceBookEvent;
import seedu.address.commons.events.ui.PersonPanelAddressPressedEvent;
import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent;
import seedu.address.model.person.ReadOnlyPerson;

Expand All @@ -30,7 +31,7 @@ public class BrowserPanel extends UiPart<Region> {
public static final String FACEBOOK_PROFILE_PAGE = "https://www.facebook.com/";
public static final String NUSMODS_SEARCH_URL_PREFIX = "https://nusmods.com/timetable/2017-2018/sem1?";
public static final String FACEBOOK_MESSENGER_URL_PREFIX = "https://www.facebook.com/messages/t/";

public static final String GOOGLE_MAP_SEARCH_URL_PREFIX = "https://www.google.com.sg/maps/search/";

private static final String FXML = "BrowserPanel.fxml";

Expand Down Expand Up @@ -105,6 +106,13 @@ private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedE
logger.info(LogsCenter.getEventHandlingLogMessage(event));
loadPersonPage(event.getNewSelection().person);
}

@Subscribe
private void handlePersonPanelAddressPressedEvent(PersonPanelAddressPressedEvent event) {
logger.info(LogsCenter.getEventHandlingLogMessage(event));
loadPage(GOOGLE_MAP_SEARCH_URL_PREFIX + event.getAddress());
}

/**
* Shows Facebook profile picture of user
*/
Expand All @@ -122,5 +130,4 @@ public void handleFaceBookEvent(FaceBookEvent event) {
loadPersonFaceBookPage(event.getPerson(), event.getUsername());
}


}
Loading

0 comments on commit 763f295

Please sign in to comment.