diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index a1e1d7c18d00..6e3b3fa305c9 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -218,6 +218,88 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa This section describes some noteworthy details on how certain features are implemented. +=== Email Function + +The email function allows a user to email the selected person by opening an email client on the user's +PC with the 'to:' field filled with the receiver's email. + +This function has been mapped to `EmailButton` + +Once a `PersonPanelSelectionChangedEvent` is raised, `EmailButton` will save the currently selected +email under the "email" attribute. +[source,java] +---- + @Subscribe + private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedEvent event) { + this.selectedEmail = event.getNewSelection().person.emailProperty().getValue().toString(); + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + } +---- + + +The following sequence diagram describes how `OpenEmailClient` passes in the "email" attribute to `Desktop` + +image::OpenEmailClientSequenceDiagram.png[width="800"] + + +=== Mapping a command to a JavaFX Button + +This section describes how a command can be mapped to a JavaFX button. + +We will use the `DeleteButton` as an example but it can work for any command currently availble +in the application. + +To initialise the button, we have to create a `StackPane` placeholder for it in `MainWindow` +[source,java] +---- +@FXML + private StackPane deleteButtonPlaceholder; +---- +Next, we create the `DeleteButton` class with the following constructor: +[source,java] +---- + public DeleteButton(Logic logic, int selectedIn) { + super(FXML); + this.logic = logic; + this.selectedIndex = selectedIn; + registerAsAnEventHandler(this); + } +---- + +The `DeleteButton` will be instatiated in `MainWindow` where the +placeholder adds the corresponding button element: +[source,java] +---- + + deleteButton = new DeleteButton(logic, 0); + deleteButtonPlaceholder.getChildren().add(deleteButton.getRoot()); +---- + +Once a `PersonPanelSelectionChangedEvent` is raised, `DeleteButton` will save the currently selected +index under the "selectedIndex" attribute. + +The `DeleteButton` has an instance of `Logic` and `CommandResult` which performs a similar function +to `CommandBox`. + +When the DeleteButton is pressed, it will be handled by the handleDeleteButtonPressed() function: + +[source,java] +---- + @FXML + private void handleDeleteButtonPressed() throws CommandException, ParseException { + CommandResult commandResult = logic.execute("delete " + getSelectedIndex()); + logger.info("Result: " + commandResult.feedbackToUser); + } +---- + + + + + + + + + // tag::undoredo[] === Undo/Redo mechanism diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 73ce80eb71ef..0aa082f66d29 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -143,6 +143,18 @@ Another way to delete a contact in the list: 3. Selected person will be deleted from the list **** +=== Email a person + +Opens an email client with the recipient's email address. + +**** +1. Select a person in the list +2. Click the "Email" Button +3. Proceed to compose email on email client +**** + + + === Selecting a person : `select` Selects the person identified by the index number used in the last person listing. + diff --git a/docs/images/OpenEmailClientSequenceDiagram.png b/docs/images/OpenEmailClientSequenceDiagram.png new file mode 100644 index 000000000000..67e103651c71 Binary files /dev/null and b/docs/images/OpenEmailClientSequenceDiagram.png differ diff --git a/docs/images/UIClassDiagram.png b/docs/images/UIClassDiagram.png new file mode 100644 index 000000000000..934105e68217 Binary files /dev/null and b/docs/images/UIClassDiagram.png differ diff --git a/docs/images/Ui.png b/docs/images/Ui.png index f49b5e1e02cc..7a62998c11c2 100644 Binary files a/docs/images/Ui.png and b/docs/images/Ui.png differ diff --git a/docs/images/UiClassDiagram.png b/docs/images/UiClassDiagram.png deleted file mode 100644 index 369469ef176e..000000000000 Binary files a/docs/images/UiClassDiagram.png and /dev/null differ diff --git a/src/main/java/seedu/address/commons/core/Config.java b/src/main/java/seedu/address/commons/core/Config.java index 8f4d737d0e24..4c70be10f00b 100644 --- a/src/main/java/seedu/address/commons/core/Config.java +++ b/src/main/java/seedu/address/commons/core/Config.java @@ -11,7 +11,7 @@ public class Config { public static final String DEFAULT_CONFIG_FILE = "config.json"; // Config values customizable through config file - private String appTitle = "Address App"; + private String appTitle = "ConnectUs"; private Level logLevel = Level.INFO; private String userPrefsFilePath = "preferences.json"; diff --git a/src/main/java/seedu/address/ui/BrowserPanel.java b/src/main/java/seedu/address/ui/BrowserPanel.java index 98689931eb17..fe2843a1cc5d 100644 --- a/src/main/java/seedu/address/ui/BrowserPanel.java +++ b/src/main/java/seedu/address/ui/BrowserPanel.java @@ -21,8 +21,9 @@ public class BrowserPanel extends UiPart { public static final String DEFAULT_PAGE = "default.html"; - public static final String GOOGLE_SEARCH_URL_PREFIX = "https://www.google.com.sg/search?safe=off&q="; - public static final String GOOGLE_SEARCH_URL_SUFFIX = "&cad=h"; + //public static final String GOOGLE_SEARCH_URL_PREFIX = "https://www.google.com.sg/search?safe=off&q="; + public static final String GOOGLE_SEARCH_URL_PREFIX = "https://www.google.com.sg/maps/place/"; + //public static final String GOOGLE_SEARCH_URL_SUFFIX = "&cad=h"; private static final String FXML = "BrowserPanel.fxml"; @@ -33,7 +34,7 @@ public class BrowserPanel extends UiPart { public BrowserPanel() { super(FXML); - + browser.getEngine().setUserAgent(DEFAULT_PAGE.replace("Macintosh‌​; ", "")); // To prevent triggering events for typing inside the loaded Web page. getRoot().setOnKeyPressed(Event::consume); @@ -42,8 +43,9 @@ public BrowserPanel() { } private void loadPersonPage(ReadOnlyPerson person) { - loadPage(GOOGLE_SEARCH_URL_PREFIX + person.getName().fullName.replaceAll(" ", "+") - + GOOGLE_SEARCH_URL_SUFFIX); + browser.getEngine().setUserAgent("Mozilla/5.0 " + + "(Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0"); + loadPage(GOOGLE_SEARCH_URL_PREFIX + person.getAddress().toString().replaceAll(" ", "+")); } public void loadPage(String url) { diff --git a/src/main/java/seedu/address/ui/EmailButton.java b/src/main/java/seedu/address/ui/EmailButton.java new file mode 100644 index 000000000000..bee8ec7fbf56 --- /dev/null +++ b/src/main/java/seedu/address/ui/EmailButton.java @@ -0,0 +1,51 @@ +package seedu.address.ui; + +import java.io.IOException; +import java.util.logging.Logger; + +import com.google.common.eventbus.Subscribe; + +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.layout.Region; +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.logic.parser.exceptions.ParseException; + +/** + * The UI component that is responsible for emailing the selected person. + */ +public class EmailButton extends UiPart { + + public static final String ERROR_STYLE_CLASS = "error"; + private static final String FXML = "EmailButton.fxml"; + + private final Logger logger = LogsCenter.getLogger(CommandBox.class); + private String selectedEmail = ""; + + @FXML + private Button emailButton; + public EmailButton() { + super(FXML); + registerAsAnEventHandler(this); + } + + /** + * Handles the Email button pressed event. + */ + @FXML + private void handleEmailButtonPressed() throws CommandException, ParseException, IOException { + OpenEmailClient emailClient = new OpenEmailClient(this.selectedEmail); + emailClient.sendMail(); + } + + @Subscribe + private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedEvent event) { + this.selectedEmail = event.getNewSelection().person.emailProperty().getValue().toString(); + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + } + + + +} diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index c8281fd9eed6..bf03dd61f6aa 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -30,7 +30,7 @@ */ public class MainWindow extends UiPart { - private static final String ICON = "/images/address_book_32.png"; + private static final String ICON = "/images/connectus_icon.png"; private static final String FXML = "MainWindow.fxml"; private static final int MIN_HEIGHT = 600; private static final int MIN_WIDTH = 450; @@ -47,6 +47,7 @@ public class MainWindow extends UiPart { private Config config; private UserPrefs prefs; private DeleteButton deleteButton; + private EmailButton emailButton; @FXML private VBox vBox; @@ -81,6 +82,9 @@ public class MainWindow extends UiPart { @FXML private StackPane deleteButtonPlaceholder; + @FXML + private StackPane emailButtonPlaceholder; + public MainWindow(Stage primaryStage, Config config, UserPrefs prefs, Logic logic) { super(FXML); @@ -149,6 +153,8 @@ void fillInnerParts() { deleteButton = new DeleteButton(logic, 0); deleteButtonPlaceholder.getChildren().add(deleteButton.getRoot()); + emailButton = new EmailButton(); + emailButtonPlaceholder.getChildren().add(emailButton.getRoot()); browserPanel = new BrowserPanel(); browserPlaceholder.getChildren().add(browserPanel.getRoot()); diff --git a/src/main/java/seedu/address/ui/OpenEmailClient.java b/src/main/java/seedu/address/ui/OpenEmailClient.java new file mode 100644 index 000000000000..3e56fd32b6ba --- /dev/null +++ b/src/main/java/seedu/address/ui/OpenEmailClient.java @@ -0,0 +1,34 @@ +package seedu.address.ui; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; + + +/** + * Handles the opening of email client + */ +public class OpenEmailClient { + private Desktop desktop = Desktop.getDesktop(); + private String mailTo; + + /** + * Handles the opening of email client + */ + public OpenEmailClient(String mailTo) { + this.mailTo = mailTo.trim(); + } + + public void setMail (String m) { + mailTo = m; + } + /** + * Handles the sending mail + */ + public void sendMail () throws IOException { + + URI uri = URI.create("mailto:" + this.mailTo); + desktop.mail(uri); + + } +} diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java index 9147fe72d289..1c4ccca7e872 100644 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ b/src/main/java/seedu/address/ui/PersonListPanel.java @@ -36,6 +36,7 @@ public PersonListPanel(ObservableList personList) { private void setConnections(ObservableList personList) { ObservableList mappedList = EasyBind.map( personList, (person) -> new PersonCard(person, personList.indexOf(person) + 1)); + //create a new personcard for each person added to the list personListView.setItems(mappedList); personListView.setCellFactory(listView -> new PersonListViewCell()); setEventHandlerForSelectionChangeEvent(); diff --git a/src/main/resources/images/connectus.png b/src/main/resources/images/connectus.png new file mode 100644 index 000000000000..191913811cec Binary files /dev/null and b/src/main/resources/images/connectus.png differ diff --git a/src/main/resources/images/connectus_icon.png b/src/main/resources/images/connectus_icon.png new file mode 100644 index 000000000000..8d1e57388dc4 Binary files /dev/null and b/src/main/resources/images/connectus_icon.png differ diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index d06336391cca..3bfc6aa303ee 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -3,6 +3,30 @@ background-color: #383838; /* Used in the default.html file */ } +body { + -fx-background-color: derive(#1d1d1d, 20%); + background-color: #383838; /* Used in the default.html file */ +} + +h1 { + font-size: 32pt; + font-family: "Segoe UI", Helvetica, Arial, sans-serif; + text-fill: white; + color: white; +} + +h2 { + font-size: 20pt; + font-family: "Segoe UI", Helvetica, Arial, sans-serif; + text-fill: white; + color: white; +} + +.welcomeImage { + width: 100%; +} + + .label { -fx-font-size: 11pt; -fx-font-family: "Segoe UI Semibold"; diff --git a/src/main/resources/view/EmailButton.fxml b/src/main/resources/view/EmailButton.fxml new file mode 100644 index 000000000000..1f37082e849f --- /dev/null +++ b/src/main/resources/view/EmailButton.fxml @@ -0,0 +1,6 @@ + + + + + +