Skip to content

Commit

Permalink
Do not trim text for TitleBasedFetcher
Browse files Browse the repository at this point in the history
Fixes #4014
  • Loading branch information
Siedlerchr committed May 6, 2018
1 parent b8ea55b commit 891546c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/main/java/org/jabref/gui/EntryTypeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.IdBasedFetcher;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.importer.fetcher.TitleFetcher;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.EntryTypes;
import org.jabref.model.database.BibDatabaseMode;
Expand Down Expand Up @@ -73,6 +74,7 @@ public EntryTypeDialog(JabRefFrame frame) {
setTitle(Localization.lang("Select entry type"));

addWindowListener(new WindowAdapter() {

@Override
public void windowClosing(WindowEvent e) {
cancelAction.actionPerformed(null);
Expand Down Expand Up @@ -246,7 +248,6 @@ static class TypeButton extends JButton implements Comparable<TypeButton> {

private final EntryType type;


TypeButton(String label, EntryType type) {
super(label);
this.type = type;
Expand All @@ -263,6 +264,7 @@ public EntryType getType() {
}

class CancelAction extends AbstractAction {

public CancelAction() {
super("Cancel");
}
Expand All @@ -275,6 +277,7 @@ public void actionPerformed(ActionEvent e) {
}

private class FetcherWorker extends SwingWorker<Optional<BibEntry>, Void> {

private boolean fetcherException = false;
private String fetcherExceptionMessage = "";
private IdBasedFetcher fetcher = null;
Expand All @@ -288,10 +291,16 @@ protected Optional<BibEntry> doInBackground() throws Exception {
generateButton.setText(Localization.lang("Searching..."));
});

Globals.prefs.put(JabRefPreferences.ID_ENTRY_GENERATOR,String.valueOf(comboBox.getSelectedItem()));
searchID = idTextField.getText().trim();
searchID = searchID.replaceAll(" ", "");
Globals.prefs.put(JabRefPreferences.ID_ENTRY_GENERATOR, String.valueOf(comboBox.getSelectedItem()));

fetcher = WebFetchers.getIdBasedFetchers(Globals.prefs.getImportFormatPreferences()).get(comboBox.getSelectedIndex());

searchID = idTextField.getText();
if (!(fetcher instanceof TitleFetcher)) {
searchID = searchID.trim();
searchID = searchID.replaceAll(" ", "");
}

if (!searchID.isEmpty()) {
try {
bibEntry = fetcher.performSearchById(searchID);
Expand All @@ -311,7 +320,7 @@ protected void done() {
if (result.isPresent()) {
final BibEntry bibEntry = result.get();
if ((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())) {
//If there are duplicates starts ImportInspectionDialog
//If there are duplicates starts ImportInspectionDialog
final BasePanel panel = (BasePanel) frame.getTabbedPane().getSelectedComponent();

ImportInspectionDialog diag = new ImportInspectionDialog(frame, panel, Localization.lang("Import"), false);
Expand All @@ -321,7 +330,7 @@ protected void done() {
diag.setVisible(true);
diag.toFront();
} else {
// Regenerate CiteKey of imported BibEntry
// Regenerate CiteKey of imported BibEntry
new BibtexKeyGenerator(frame.getCurrentBasePanel().getBibDatabaseContext(), Globals.prefs.getBibtexKeyPatternPreferences()).generateAndSetKey(bibEntry);
// Update Timestamps
if (Globals.prefs.getTimestampPreferences().includeCreatedTimestamp()) {
Expand Down

0 comments on commit 891546c

Please sign in to comment.