Skip to content

Commit

Permalink
Merge pull request #322 from junming403/master
Browse files Browse the repository at this point in the history
Fix location searching
  • Loading branch information
junming403 authored Nov 12, 2017
2 parents 4ebf312 + 1e84ab8 commit 2f370cb
Show file tree
Hide file tree
Showing 3 changed files with 400 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/main/java/seedu/address/ui/CombinePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.time.DayOfWeek;
import java.util.Objects;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.google.common.eventbus.Subscribe;

Expand Down Expand Up @@ -61,6 +63,8 @@ public class CombinePanel extends UiPart<Region> {
private static final int COL = 13;
private static final int START_TIME = 8;

private static final Pattern LOCATION_KEYWORD_PATTERN = Pattern.compile(".*(?=-)");

private final Logger logger = LogsCenter.getLogger(this.getClass());
private final Logic logic;
private GridData[][] gridData;
Expand Down Expand Up @@ -288,7 +292,19 @@ private int getTime(String text) {
/************* BROWSER PANNEL *********/

private void loadLessonPage(ReadOnlyLesson lesson) {
loadPage(NUS_MAP_SEARCH_URL_PREFIX + lesson.getLocation().toString());
loadPage(NUS_MAP_SEARCH_URL_PREFIX + getImportantKeywords(lesson.getLocation().toString()));
}

/**
* Get substring before hyphen.
*/
private String getImportantKeywords(String location) {
Matcher matcher = LOCATION_KEYWORD_PATTERN.matcher(location);
if (matcher.find()) {
return matcher.group(0);
} else {
return location;
}
}


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/ui/CommandBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public CommandBox(Logic logic) {
configPrefixList();
keywordLabel.getStyleClass().add("keyword-label-default");
keywordColorMap = getCommandKeywordColorMap();
String[] commands = {"help", "add", "list", "edit", "find",
"delete", "select", "history", "undo", "redo", "clear", "exit", "customise", "view", "swt"};
String[] commands = {"help", "add", "list", "edit", "find", "delete", "select", "history", "undo", "redo",
"clear", "exit", "customise", "view", "theme", "mark", "unmark", "remark", "color"};
TextFields.bindAutoCompletion(commandTextField, commands); // controlsfx
tick.setFitHeight(30);
tick.setFitWidth(30);
Expand Down
Loading

0 comments on commit 2f370cb

Please sign in to comment.