Skip to content

Commit

Permalink
Removed unrequired dependency and fixed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Jul 17, 2016
1 parent c15f2ce commit 21b8984
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void putData(String key, List<String> orderedData) {
*/
private void putGroups(List<String> orderedData) throws ParseException {
try {
groupsRoot = GroupTreeNode.parse(orderedData);
groupsRoot = GroupTreeNode.parse(orderedData, Globals.prefs);
} catch (ParseException e) {
throw new ParseException(Localization.lang(
"Group tree could not be parsed. If you save the BibTeX database, all groups will be lost."), e);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/sf/jabref/logic/groups/AbstractGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.Optional;

import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.importer.fileformat.ParseException;
import net.sf.jabref.logic.search.SearchMatcher;
import net.sf.jabref.model.database.BibDatabase;
Expand Down Expand Up @@ -62,18 +63,18 @@ public abstract class AbstractGroup implements SearchMatcher {
* @throws ParseException If an error occurred and a group could not be created,
* e.g. due to a malformed regular expression.
*/
public static AbstractGroup fromString(String s) throws ParseException {
public static AbstractGroup fromString(String s, JabRefPreferences jabRefPreferences) throws ParseException {
if (s.startsWith(KeywordGroup.ID)) {
return KeywordGroup.fromString(s);
return KeywordGroup.fromString(s, jabRefPreferences);
}
if (s.startsWith(AllEntriesGroup.ID)) {
return AllEntriesGroup.fromString(s);
}
if (s.startsWith(SearchGroup.ID)) {
return SearchGroup.fromString(s);
return SearchGroup.fromString(s, jabRefPreferences);
}
if (s.startsWith(ExplicitGroup.ID)) {
return ExplicitGroup.fromString(s);
return ExplicitGroup.fromString(s, jabRefPreferences);
}
return null; // unknown group
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/sf/jabref/logic/groups/GroupTreeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.importer.fileformat.ParseException;
import net.sf.jabref.logic.search.SearchMatcher;
import net.sf.jabref.logic.search.matchers.MatcherSet;
Expand Down Expand Up @@ -248,8 +249,9 @@ public GroupTreeNode copyNode() {
return GroupTreeNode.fromGroup(group);
}

public static GroupTreeNode parse(List<String> orderedData) throws ParseException {
return GroupsParser.importGroups(orderedData);
public static GroupTreeNode parse(List<String> orderedData, JabRefPreferences jabRefPreferences)
throws ParseException {
return GroupsParser.importGroups(orderedData, jabRefPreferences);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/sf/jabref/logic/groups/GroupsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.List;

import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.importer.fileformat.ParseException;
import net.sf.jabref.logic.l10n.Localization;

Expand All @@ -27,7 +28,8 @@
*/
class GroupsParser {

public static GroupTreeNode importGroups(List<String> orderedData) throws ParseException {
public static GroupTreeNode importGroups(List<String> orderedData, JabRefPreferences jabRefPreferences)
throws ParseException {
GroupTreeNode cursor = null;
GroupTreeNode root = null;
for (String string : orderedData) {
Expand All @@ -42,7 +44,7 @@ public static GroupTreeNode importGroups(List<String> orderedData) throws ParseE
throw new ParseException(Localization.lang("Expected \"%0\" to contain whitespace", string));
}
int level = Integer.parseInt(string.substring(0, spaceIndex));
AbstractGroup group = AbstractGroup.fromString(string.substring(spaceIndex + 1));
AbstractGroup group = AbstractGroup.fromString(string.substring(spaceIndex + 1), jabRefPreferences);
GroupTreeNode newNode = GroupTreeNode.fromGroup(group);
if (cursor == null) {
// create new root
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/sf/jabref/logic/openoffice/OOBibStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.TreeSet;
import java.util.regex.Pattern;

import net.sf.jabref.JabRefMain;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.logic.journals.JournalAbbreviationLoader;
import net.sf.jabref.logic.layout.Layout;
Expand Down Expand Up @@ -172,7 +171,7 @@ public OOBibStyle(String resourcePath, JabRefPreferences prefs, JournalAbbreviat
this.prefs = Objects.requireNonNull(prefs);
this.encoding = StandardCharsets.UTF_8;
setDefaultProperties();
initialize(JabRefMain.class.getResource(resourcePath).openStream());
initialize(OOBibStyle.class.getResource(resourcePath).openStream());
fromResource = true;
path = resourcePath;
}
Expand Down

0 comments on commit 21b8984

Please sign in to comment.