Skip to content

Commit

Permalink
Use Nameautocompleter for every PERSONNAME field
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed Apr 6, 2016
1 parent 770a8c1 commit 317a3fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package net.sf.jabref.logic.autocompleter;

import net.sf.jabref.bibtex.BibtexSingleFieldProperties;
import net.sf.jabref.bibtex.InternalBibtexFields;

import java.util.Arrays;
import java.util.Objects;

Expand All @@ -31,7 +34,7 @@ public AutoCompleterFactory(AutoCompletePreferences preferences) {
public AutoCompleter<String> forField(String fieldName) {
Objects.requireNonNull(fieldName);

if ("author".equals(fieldName) || "editor".equals(fieldName)) {
if (InternalBibtexFields.getFieldExtras(fieldName).contains(BibtexSingleFieldProperties.PERSON_NAMES)) {
return new NameFieldAutoCompleter(fieldName, preferences);
} else if ("crossref".equals(fieldName)) {
return new BibtexKeyAutoCompleter(preferences);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

import static org.mockito.Mockito.*;

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class AutoCompleterFactoryTest {
@Before
public void setup() {
Globals.prefs = mock(JabRefPreferences.class);
}

@After
public void teardown() {
Globals.prefs = null;
}

@Test(expected = NullPointerException.class)
public void initFactoryWithNullPreferenceThrowsException() {
Expand Down

0 comments on commit 317a3fd

Please sign in to comment.