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

[v1.1][F12-B1] NUS F&T #73

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f5be020
Replace verbose loops with lambda expressions
vivekscl Jan 21, 2018
cf8761d
UniquePersonList#setPersons(List<Person>): refactor verbose loop
vivekscl Jan 21, 2018
529d75f
[#634] Replace all verbose loops with lambda expression (#805)
Zhiyuan-Amos Feb 22, 2018
0cc5f39
AddressBook#removePerson(Person): update return type
nicholaschuayunzhi Feb 28, 2018
f090090
UniquePersonList#remove(Person): update return type
nicholaschuayunzhi Feb 28, 2018
088db25
MainWindow.fxml: update onCloseRequest event to call handleExit()
yamidark Feb 16, 2018
2f4405c
[#830] UniquePersonList, AddressBook: update return type for remove a…
Zhiyuan-Amos Mar 2, 2018
da85890
change repoURL
zhuleyan Mar 6, 2018
acca022
updates DeveloperGuide and UserGuide repo URL
A0155428B Mar 9, 2018
c6f99b1
edit repoURL
zhuleyan Mar 9, 2018
f3770cf
Merge pull request #2 from A0155428B/v1.0
A0155428B Mar 9, 2018
de4bad7
corrects typo for UserGuide & DeveloperGuide repo URL
A0155428B Mar 9, 2018
e5982f6
Merge pull request #4 from A0155428B/v1.0
A0155428B Mar 9, 2018
336a399
Merge pull request #5 from zhuleyan/repoURL
zhuleyan Mar 9, 2018
5b5b3a5
test
zhuleyan Mar 9, 2018
6764454
Merge branch 'master' of https://github.com/CS2103JAN2018-F12-B1/main
zhuleyan Mar 11, 2018
a66db04
add user stories
zhuleyan Mar 13, 2018
c67eae0
add remark command
zhuleyan Mar 14, 2018
4bac6e4
test
zhuleyan Mar 14, 2018
dc69643
adds ! in HelpCommand
A0155428B Mar 14, 2018
99056f3
Reverts changes to previous commit and updates the build status and c…
A0155428B Mar 14, 2018
c3ef2ea
Remove codacy badge
A0155428B Mar 14, 2018
d5002ff
Merge pull request #14 from A0155428B/travis_test
A0155428B Mar 14, 2018
1513fc6
Corrects typo in README.adoc
A0155428B Mar 14, 2018
1d58475
Merge pull request #15 from A0155428B/travis_test
A0155428B Mar 14, 2018
0126fb8
Updates README.adoc to match project
A0155428B Mar 14, 2018
179ad87
Merge pull request #20 from A0155428B/travis_test
A0155428B Mar 14, 2018
8c2e7bb
edit aboutus file
zhuleyan Mar 14, 2018
82aac1b
Merge pull request #21 from zhuleyan/aboutus
zhuleyan Mar 14, 2018
99318f9
Updates target user and value proposition in DeveloperGuide
A0155428B Mar 14, 2018
ab448df
Updates NFR in DeveloperGuide
A0155428B Mar 14, 2018
d5742f0
Update use cases in DeveloperGuide
A0155428B Mar 14, 2018
f53c13d
Merge pull request #22 from A0155428B/v1.0_document_update
A0155428B Mar 14, 2018
2af26af
Updates BrowserPanel to implement google search
A0155428B Mar 14, 2018
7b21485
Merge pull request #23 from A0155428B/select_command
A0155428B Mar 14, 2018
15530d4
Adds alias for Add, Clear, Delete, Edit, Find, List, Redo, Select, Un…
A0155428B Mar 14, 2018
57865f4
Updates AddressBookParser to recognise Command Alias
A0155428B Mar 14, 2018
7ceb5fe
Adds tests for Command Alias in AddressBookParserTest
A0155428B Mar 14, 2018
2303218
Corrests indentation
A0155428B Mar 14, 2018
2efe71e
Corrects typo
A0155428B Mar 14, 2018
c0707db
update aboutus page
zhuleyan Mar 15, 2018
273c41a
Merge pull request #26 from zhuleyan/aboutus
zhuleyan Mar 15, 2018
d728190
update user stories to be more specific
zhuleyan Mar 15, 2018
842a9a0
update java test of remark command
zhuleyan Mar 15, 2018
79e074d
resolve trailing whitespace
zhuleyan Mar 15, 2018
0217e95
resolve checkstyle
zhuleyan Mar 15, 2018
9397724
solve requireNonNull problem
zhuleyan Mar 15, 2018
ea42eb1
Updates UserGuide to include alias
A0155428B Mar 15, 2018
1c5cbd5
Updates icon to suit project
A0155428B Mar 15, 2018
863dda1
Adds a picture of nus logo in default page
A0155428B Mar 15, 2018
10abc60
Merge pull request #28 from zhuleyan/v1.1
zhuleyan Mar 16, 2018
4c64579
Merge pull request #29 from A0155428B/UI_updates
A0155428B Mar 16, 2018
2f98fb0
Merge branch 'master' into Alias
A0155428B Mar 16, 2018
ffada1f
Corrects typo
A0155428B Mar 16, 2018
dae074f
Removes whitespace
A0155428B Mar 16, 2018
1bb6680
Removes more whitespace
A0155428B Mar 16, 2018
7692e66
Remove trailing whitespace
A0155428B Mar 16, 2018
666120e
Merge pull request #25 from A0155428B/Alias
A0155428B Mar 16, 2018
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
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
endif::[]
:repoURL: https://github.com/se-edu/addressbook-level4/tree/master
:repoURL: https://github.com/CS2103JAN2018-F12-B1/main/tree/master

By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT`

Expand Down
2 changes: 1 addition & 1 deletion docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
endif::[]
:repoURL: https://github.com/se-edu/addressbook-level4
:repoURL: https://github.com/CS2103JAN2018-F12-B1/main

By: `Team SE-EDU` Since: `Jun 2016` Licence: `MIT`

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/seedu/address/commons/core/LogsCenter.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package seedu.address.commons.core;

import java.io.IOException;
import java.util.Arrays;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
Expand Down Expand Up @@ -76,10 +76,8 @@ private static void addConsoleHandler(Logger logger) {
* Remove all the handlers from {@code logger}.
*/
private static void removeHandlers(Logger logger) {
Handler[] handlers = logger.getHandlers();
for (Handler handler : handlers) {
logger.removeHandler(handler);
}
Arrays.stream(logger.getHandlers())
.forEach(logger::removeHandler);
}

/**
Expand Down
11 changes: 1 addition & 10 deletions src/main/java/seedu/address/commons/util/CollectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -39,13 +37,6 @@ public static boolean isAnyNonNull(Object... items) {
* Returns true if every element in a collection are unique by {@link Object#equals(Object)}.
*/
public static boolean elementsAreUnique(Collection<?> items) {
final Set<Object> testSet = new HashSet<>();
for (Object item : items) {
final boolean itemAlreadyExists = !testSet.add(item); // see Set documentation
if (itemAlreadyExists) {
return false;
}
}
return true;
return items.size() == items.stream().distinct().count();
}
}
9 changes: 3 additions & 6 deletions src/main/java/seedu/address/commons/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;

/**
* Helper functions for handling strings.
Expand Down Expand Up @@ -33,12 +34,8 @@ public static boolean containsWordIgnoreCase(String sentence, String word) {
String preppedSentence = sentence;
String[] wordsInPreppedSentence = preppedSentence.split("\\s+");

for (String wordInSentence: wordsInPreppedSentence) {
if (wordInSentence.equalsIgnoreCase(preppedWord)) {
return true;
}
}
return false;
return Arrays.stream(wordsInPreppedSentence)
.anyMatch(preppedWord::equalsIgnoreCase);
}

/**
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package seedu.address.logic.parser;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* Tokenizes arguments string of the form: {@code preamble <prefix>value <prefix>value ...}<br>
Expand Down Expand Up @@ -34,13 +36,9 @@ public static ArgumentMultimap tokenize(String argsString, Prefix... prefixes) {
* @return List of zero-based prefix positions in the given arguments string
*/
private static List<PrefixPosition> findAllPrefixPositions(String argsString, Prefix... prefixes) {
List<PrefixPosition> positions = new ArrayList<>();

for (Prefix prefix : prefixes) {
positions.addAll(findPrefixPositions(argsString, prefix));
}

return positions;
return Arrays.stream(prefixes)
.flatMap(prefix -> findPrefixPositions(argsString, prefix).stream())
.collect(Collectors.toList());
}

/**
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,8 @@ private Person syncWithMasterTagList(Person person) {
* Removes {@code key} from this {@code AddressBook}.
* @throws PersonNotFoundException if the {@code key} is not in this {@code AddressBook}.
*/
public boolean removePerson(Person key) throws PersonNotFoundException {
if (persons.remove(key)) {
return true;
} else {
throw new PersonNotFoundException();
}
public void removePerson(Person key) throws PersonNotFoundException {
persons.remove(key);
}

//// tag-level operations
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/seedu/address/model/person/UniquePersonList.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ public void setPerson(Person target, Person editedPerson)
*
* @throws PersonNotFoundException if no such person could be found in the list.
*/
public boolean remove(Person toRemove) throws PersonNotFoundException {
public void remove(Person toRemove) throws PersonNotFoundException {
requireNonNull(toRemove);
final boolean personFoundAndDeleted = internalList.remove(toRemove);
if (!personFoundAndDeleted) {
if (!internalList.remove(toRemove)) {
throw new PersonNotFoundException();
}
return personFoundAndDeleted;
}

public void setPersons(UniquePersonList replacement) {
Expand All @@ -87,11 +85,11 @@ public void setPersons(UniquePersonList replacement) {

public void setPersons(List<Person> persons) throws DuplicatePersonException {
requireAllNonNull(persons);
final UniquePersonList replacement = new UniquePersonList();
for (final Person person : persons) {
replacement.add(person);
if (!CollectionUtil.elementsAreUnique(persons)) {
throw new DuplicatePersonException();
}
setPersons(replacement);

this.internalList.setAll(persons);
}

/**
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package seedu.address.model.util;

import java.util.HashSet;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
Expand Down Expand Up @@ -56,12 +57,9 @@ public static ReadOnlyAddressBook getSampleAddressBook() {
* Returns a tag set containing the list of strings given.
*/
public static Set<Tag> getTagSet(String... strings) {
HashSet<Tag> tags = new HashSet<>();
for (String s : strings) {
tags.add(new Tag(s));
}

return tags;
return Arrays.stream(strings)
.map(Tag::new)
.collect(Collectors.toSet());
}

}
8 changes: 4 additions & 4 deletions src/main/java/seedu/address/storage/XmlAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import javax.xml.bind.annotation.XmlElement;

Expand Down Expand Up @@ -64,10 +65,9 @@ public XmlAdaptedPerson(Person source) {
phone = source.getPhone().value;
email = source.getEmail().value;
address = source.getAddress().value;
tagged = new ArrayList<>();
for (Tag tag : source.getTags()) {
tagged.add(new XmlAdaptedTag(tag));
}
tagged = source.getTags().stream()
.map(XmlAdaptedTag::new)
.collect(Collectors.toList());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<?import javafx.scene.layout.VBox?>

<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
minWidth="450" minHeight="600">
minWidth="450" minHeight="600" onCloseRequest="#handleExit">
<icons>
<Image url="@/images/address_book_32.png" />
</icons>
Expand Down
83 changes: 83 additions & 0 deletions src/test/java/seedu/address/ui/MainWindowCloseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package seedu.address.ui;

import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.testfx.api.FxToolkit;

import guitests.guihandles.StageHandle;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import seedu.address.commons.core.Config;
import seedu.address.commons.events.ui.ExitAppRequestEvent;
import seedu.address.logic.LogicManager;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.ui.testutil.EventsCollectorRule;

/**
* Contains tests for closing of the {@code MainWindow}.
*/
public class MainWindowCloseTest extends GuiUnitTest {
@Rule
public final EventsCollectorRule eventsCollectorRule = new EventsCollectorRule();

private MainWindow mainWindow;
private EmptyMainWindowHandle mainWindowHandle;
private Stage stage;

@Before
public void setUp() throws Exception {
FxToolkit.setupStage(stage -> {
this.stage = stage;
mainWindow = new MainWindow(stage, new Config(), new UserPrefs(), new LogicManager(new ModelManager()));
mainWindowHandle = new EmptyMainWindowHandle(stage);

stage.setScene(mainWindow.getRoot().getScene());
mainWindowHandle.focus();
});
FxToolkit.showStage();
}

@Test
public void close_menuBarExitButton_exitAppRequestEventPosted() {
mainWindowHandle.clickOnMenuExitButton();
assertTrue(eventsCollectorRule.eventsCollector.getMostRecent() instanceof ExitAppRequestEvent);
assertTrue(eventsCollectorRule.eventsCollector.getSize() == 1);
}

@Test
public void close_externalRequest_exitAppRequestEventPosted() {
mainWindowHandle.closeMainWindowExternally();
assertTrue(eventsCollectorRule.eventsCollector.getMostRecent() instanceof ExitAppRequestEvent);
assertTrue(eventsCollectorRule.eventsCollector.getSize() == 1);
}

/**
* A handle for an empty {@code MainWindow}. The components in {@code MainWindow} are not initialized.
*/
private class EmptyMainWindowHandle extends StageHandle {

private EmptyMainWindowHandle(Stage stage) {
super(stage);
}

/**
* Closes the {@code MainWindow} by clicking on the menu bar's exit button.
*/
private void clickOnMenuExitButton() {
guiRobot.clickOn("File");
guiRobot.clickOn("Exit");
}

/**
* Closes the {@code MainWindow} through an external request {@code MainWindow} (e.g pressing the 'X' button on
* the {@code MainWindow} or closing the app through the taskbar).
*/
private void closeMainWindowExternally() {
guiRobot.interact(() -> stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST)));
}
}
}