loaded) {
/**
* Run an entry fetcher from the command line.
- *
- * Note that this only works headlessly if the EntryFetcher does not show any GUI.
*
- * @param fetchCommand A string containing both the fetcher to use (id of EntryFetcherExtension minus Fetcher) and
+ * @param fetchCommand A string containing both the name of the fetcher to use and
* the search query, separated by a :
* @return A parser result containing the entries fetched or null if an error occurred.
*/
private Optional fetch(String fetchCommand) {
-
if ((fetchCommand == null) || !fetchCommand.contains(":") || (fetchCommand.split(":").length != 2)) {
System.out.println(Localization.lang("Expected syntax for --fetch=':'"));
System.out.println(Localization.lang("The following fetchers are available:"));
@@ -555,38 +552,36 @@ private Optional fetch(String fetchCommand) {
String[] split = fetchCommand.split(":");
String engine = split[0];
+ String query = split[1];
- EntryFetchers fetchers = new EntryFetchers(Globals.journalAbbreviationLoader);
- EntryFetcher fetcher = null;
- for (EntryFetcher e : fetchers.getEntryFetchers()) {
- if (engine.equalsIgnoreCase(e.getClass().getSimpleName().replace("Fetcher", ""))) {
- fetcher = e;
- }
- }
-
- if (fetcher == null) {
+ List fetchers = WebFetchers.getSearchBasedFetchers(Globals.prefs.getImportFormatPreferences());
+ Optional selectedFetcher = fetchers.stream()
+ .filter(fetcher -> fetcher.getName().equalsIgnoreCase(engine))
+ .findFirst();
+ if (!selectedFetcher.isPresent()) {
System.out.println(Localization.lang("Could not find fetcher '%0'", engine));
- System.out.println(Localization.lang("The following fetchers are available:"));
-
- for (EntryFetcher e : fetchers.getEntryFetchers()) {
- System.out.println(
- " " + e.getClass().getSimpleName().replace("Fetcher", "").toLowerCase(Locale.ENGLISH));
- }
- return Optional.empty();
- }
- String query = split[1];
- System.out.println(Localization.lang("Running query '%0' with fetcher '%1'.", query, engine) + " "
- + Localization.lang("Please wait..."));
- Collection result = new ImportInspectionCommandLine().query(query, fetcher);
+ System.out.println(Localization.lang("The following fetchers are available:"));
+ fetchers.forEach(fetcher -> System.out.println(" " + fetcher.getName()));
- if (result.isEmpty()) {
- System.out.println(
- Localization.lang("Query '%0' with fetcher '%1' did not return any results.", query, engine));
return Optional.empty();
+ } else {
+ System.out.println(Localization.lang("Running query '%0' with fetcher '%1'.", query, engine));
+ System.out.print(Localization.lang("Please wait..."));
+ try {
+ List matches = selectedFetcher.get().performSearch(query);
+ if (matches.isEmpty()) {
+ System.out.println("\r" + Localization.lang("No results found."));
+ return Optional.empty();
+ } else {
+ System.out.println("\r" + Localization.lang("Found %0 results.", String.valueOf(matches.size())));
+ return Optional.of(new ParserResult(matches));
+ }
+ } catch (FetcherException e) {
+ LOGGER.error("Error while fetching", e);
+ return Optional.empty();
+ }
}
-
- return Optional.of(new ParserResult(result));
}
public boolean isBlank() {
diff --git a/src/main/java/org/jabref/cli/ImportInspectionCommandLine.java b/src/main/java/org/jabref/cli/ImportInspectionCommandLine.java
deleted file mode 100644
index bf3d66ba544..00000000000
--- a/src/main/java/org/jabref/cli/ImportInspectionCommandLine.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.jabref.cli;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jabref.gui.importer.fetcher.EntryFetcher;
-import org.jabref.logic.importer.ImportInspector;
-import org.jabref.logic.importer.OutputPrinter;
-import org.jabref.logic.l10n.Localization;
-import org.jabref.model.entry.BibEntry;
-
-public class ImportInspectionCommandLine implements ImportInspector {
-
- private final List entries = new LinkedList<>();
-
- private final OutputPrinter status = new SystemOutputPrinter();
-
- @Override
- public void addEntry(BibEntry entry) {
- entries.add(entry);
- }
-
- @Override
- public void setProgress(int current, int max) {
- status.setStatus(Localization.lang("Progress: %0 of %1", String.valueOf(current), String
- .valueOf(max)));
- }
-
- public Collection query(String query, EntryFetcher fetcher) {
- entries.clear();
- if (fetcher.processQuery(query, ImportInspectionCommandLine.this, status)) {
- return entries;
- }
- return Collections.emptyList();
- }
-}
diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java
index 54938361525..5fee5ee992c 100644
--- a/src/main/java/org/jabref/gui/BasePanel.java
+++ b/src/main/java/org/jabref/gui/BasePanel.java
@@ -36,7 +36,7 @@
import javafx.scene.layout.StackPane;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.actions.Actions;
import org.jabref.gui.actions.BaseAction;
import org.jabref.gui.actions.CleanupAction;
@@ -62,6 +62,7 @@
import org.jabref.gui.filelist.FileListEntry;
import org.jabref.gui.filelist.FileListTableModel;
import org.jabref.gui.groups.GroupAddRemoveDialog;
+import org.jabref.gui.icon.JabRefIcon;
import org.jabref.gui.importer.actions.AppendDatabaseAction;
import org.jabref.gui.journals.AbbreviateAction;
import org.jabref.gui.journals.UnabbreviateAction;
@@ -674,7 +675,7 @@ private void openExternalFile() {
return;
}
FileListEntry flEntry = fileListTableModel.getEntry(0);
- ExternalFileMenuItem item = new ExternalFileMenuItem(frame(), "", flEntry.getLink(), flEntry.getType().get().getIcon().getSmallIcon(), bibDatabaseContext, flEntry.getType());
+ ExternalFileMenuItem item = new ExternalFileMenuItem(frame(), "", flEntry.getLink(), flEntry.getType().map(ExternalFileType::getIcon).map(JabRefIcon::getSmallIcon).orElse(null), bibDatabaseContext, flEntry.getType());
item.doClick();
});
}
diff --git a/src/main/java/org/jabref/gui/DuplicateSearch.java b/src/main/java/org/jabref/gui/DuplicateSearch.java
index 8331483d01f..83c433a3959 100644
--- a/src/main/java/org/jabref/gui/DuplicateSearch.java
+++ b/src/main/java/org/jabref/gui/DuplicateSearch.java
@@ -15,7 +15,7 @@
import javax.swing.SwingUtilities;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.DuplicateResolverDialog.DuplicateResolverResult;
import org.jabref.gui.DuplicateResolverDialog.DuplicateResolverType;
import org.jabref.gui.actions.SimpleCommand;
diff --git a/src/main/java/org/jabref/gui/EntryTypeDialog.java b/src/main/java/org/jabref/gui/EntryTypeDialog.java
index b4cdc9a0abc..93cc5a73a3d 100644
--- a/src/main/java/org/jabref/gui/EntryTypeDialog.java
+++ b/src/main/java/org/jabref/gui/EntryTypeDialog.java
@@ -9,6 +9,7 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
@@ -316,7 +317,7 @@ protected void done() {
final BasePanel panel = frame.getCurrentBasePanel();
ImportInspectionDialog diag = new ImportInspectionDialog(frame, panel, Localization.lang("Import"), false);
- diag.addEntry(bibEntry);
+ diag.addEntries(Collections.singletonList(bibEntry));
diag.entryListComplete();
diag.setVisible(true);
diag.toFront();
diff --git a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java
index b51c89b1a27..c5f52ac19f2 100644
--- a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java
+++ b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java
@@ -66,7 +66,7 @@
import javax.swing.tree.TreePath;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.JabRefGUI;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java
index 17e74927d22..206a61528dd 100644
--- a/src/main/java/org/jabref/gui/JabRefFrame.java
+++ b/src/main/java/org/jabref/gui/JabRefFrame.java
@@ -49,7 +49,7 @@
import javafx.stage.Stage;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.Actions;
import org.jabref.gui.actions.AutoLinkFilesAction;
@@ -252,7 +252,7 @@ private void init() {
// groupSidePane.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class));
//previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled());
- //generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GeneralFetcher.class));
+ //generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(WebSearchPane.class));
//openOfficePanel.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(OpenOfficeSidePanel.class));
// TODO: Can't notify focus listener since it is expecting a swing component
//Globals.getFocusListener().setFocused(currentBasePanel.getMainTable());
@@ -395,7 +395,7 @@ public void openAction(String filePath) {
* The MacAdapter calls this method when "About" is selected from the application menu.
*/
public void about() {
- HelpAction.getCommand().execute();
+ HelpAction.getMainHelpPageCommand().execute();
}
public JabRefPreferences prefs() {
@@ -922,7 +922,7 @@ private MenuBar createMenu() {
);
help.getItems().addAll(
- factory.createMenuItem(StandardActions.HELP, HelpAction.getCommand()),
+ factory.createMenuItem(StandardActions.HELP, HelpAction.getMainHelpPageCommand()),
factory.createMenuItem(StandardActions.OPEN_FORUM, new OpenBrowserAction("http://discourse.jabref.org/")),
new SeparatorMenuItem(),
diff --git a/src/main/java/org/jabref/gui/SidePaneManager.java b/src/main/java/org/jabref/gui/SidePaneManager.java
index ca122c86a71..5a09bdcd1ab 100644
--- a/src/main/java/org/jabref/gui/SidePaneManager.java
+++ b/src/main/java/org/jabref/gui/SidePaneManager.java
@@ -10,7 +10,7 @@
import org.jabref.Globals;
import org.jabref.gui.collab.FileUpdatePanel;
import org.jabref.gui.groups.GroupSidePane;
-import org.jabref.gui.importer.fetcher.GeneralFetcher;
+import org.jabref.gui.importer.fetcher.WebSearchPane;
import org.jabref.gui.openoffice.OpenOfficeSidePanel;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.preferences.JabRefPreferences;
@@ -33,7 +33,7 @@ public SidePaneManager(JabRefPreferences preferences, JabRefFrame frame) {
Stream.of(
new FileUpdatePanel(this),
new GroupSidePane(this, preferences, frame.getDialogService()),
- new GeneralFetcher(this, preferences, frame),
+ new WebSearchPane(this, preferences, frame),
new OpenOfficeSidePanel(this, openOfficePreferences, frame))
.forEach(pane -> components.put(pane.getType(), pane));
@@ -45,6 +45,10 @@ public SidePaneManager(JabRefPreferences preferences, JabRefFrame frame) {
show(SidePaneType.OPEN_OFFICE);
}
+ if (preferences.getBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE)) {
+ show(SidePaneType.WEB_SEARCH);
+ }
+
updateView();
}
diff --git a/src/main/java/org/jabref/gui/actions/AutoLinkFilesAction.java b/src/main/java/org/jabref/gui/actions/AutoLinkFilesAction.java
index 7b77c9f59b4..42cf89fdae7 100644
--- a/src/main/java/org/jabref/gui/actions/AutoLinkFilesAction.java
+++ b/src/main/java/org/jabref/gui/actions/AutoLinkFilesAction.java
@@ -5,7 +5,7 @@
import javax.swing.JDialog;
import javax.swing.JFrame;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.JabRefGUI;
import org.jabref.gui.externalfiles.AutoSetLinks;
import org.jabref.gui.undo.NamedCompound;
diff --git a/src/main/java/org/jabref/gui/collab/ChangeScanner.java b/src/main/java/org/jabref/gui/collab/ChangeScanner.java
index 553d17cb3a2..28cea93ce2c 100644
--- a/src/main/java/org/jabref/gui/collab/ChangeScanner.java
+++ b/src/main/java/org/jabref/gui/collab/ChangeScanner.java
@@ -11,7 +11,7 @@
import javax.swing.tree.DefaultMutableTreeNode;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.JabRefFrame;
import org.jabref.logic.bibtex.DuplicateCheck;
diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java
index 8b4424e870b..4dca126e9f2 100644
--- a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java
+++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java
@@ -7,7 +7,7 @@
import javax.swing.SwingUtilities;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.SidePaneManager;
import org.jabref.gui.SidePaneType;
diff --git a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
index cfff8fb441c..c9c1a515aa4 100644
--- a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
+++ b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
@@ -129,20 +129,15 @@ public static boolean openExternalFileAnyFormat(final BibDatabaseContext databas
}
Optional file = FileHelper.expandFilename(databaseContext, link, Globals.prefs.getFileDirectoryPreferences());
- if (file.isPresent() && Files.exists(file.get()) && (type.isPresent())) {
+ if (file.isPresent() && Files.exists(file.get())) {
// Open the file:
String filePath = file.get().toString();
openExternalFilePlatformIndependent(type, filePath);
return true;
} else {
// No file matched the name, try to open it directly using the given app
- if (type.isPresent()) {
- openExternalFilePlatformIndependent(type, link);
- return true;
- }
-
- // Run out of ideas what to do...
- return false;
+ openExternalFilePlatformIndependent(type, link);
+ return true;
}
}
@@ -160,6 +155,10 @@ private static void openExternalFilePlatformIndependent(Optional {
- LinkedFile newLinkedFile = new LinkedFile("", newFile.toString(), "");
- LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(newLinkedFile);
+ LinkedFile linkedFile = LinkedFilesEditorViewModel.fromFile(newFile, panel.getBibDatabaseContext().getFileDirectoriesAsPaths(Globals.prefs.getFileDirectoryPreferences()));
+
+ LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(linkedFile);
dialog.showAndWait()
.ifPresent(editedLinkedFile -> {
diff --git a/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java b/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java
index 5a24ba38822..492cda62592 100644
--- a/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java
@@ -26,6 +26,9 @@
import org.jabref.model.util.FileHelper;
import org.jabref.preferences.PreferencesService;
+import org.fxmisc.easybind.EasyBind;
+import org.fxmisc.easybind.monadic.MonadicObservableValue;
+
public class LinkedFilesEditDialogViewModel extends AbstractViewModel {
private static final Pattern REMOTE_LINK_PATTERN = Pattern.compile("[a-z]+://.*");
@@ -33,6 +36,7 @@ public class LinkedFilesEditDialogViewModel extends AbstractViewModel {
private final StringProperty description = new SimpleStringProperty("");
private final ListProperty allExternalFileTypes = new SimpleListProperty<>(FXCollections.emptyObservableList());
private final ObjectProperty selectedExternalFileType = new SimpleObjectProperty<>();
+ private final MonadicObservableValue monadicSelectedExternalFileType;
private final BibDatabaseContext database;
private final DialogService dialogService;
private final PreferencesService preferences;
@@ -44,6 +48,8 @@ public LinkedFilesEditDialogViewModel(LinkedFile linkedFile, BibDatabaseContext
this.preferences = preferences;
this.externalFileTypes = externalFileTypes;
allExternalFileTypes.set(FXCollections.observableArrayList(externalFileTypes.getExternalFileTypeSelection()));
+
+ monadicSelectedExternalFileType = EasyBind.monadic(selectedExternalFileType);
setValues(linkedFile);
}
@@ -119,8 +125,7 @@ public ObjectProperty selectedExternalFileTypeProperty() {
}
public LinkedFile getNewLinkedFile() {
- return new LinkedFile(description.getValue(), link.getValue(), selectedExternalFileType.getValue().toString());
-
+ return new LinkedFile(description.getValue(), link.getValue(), monadicSelectedExternalFileType.map(ExternalFileType::toString).getOrElse(""));
}
}
diff --git a/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java b/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java
index 70c0bfaec3d..e715e004e5f 100644
--- a/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java
+++ b/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java
@@ -24,7 +24,7 @@
import javax.swing.JTable;
import javax.swing.TransferHandler;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.externalfiles.DroppedFileHandler;
diff --git a/src/main/java/org/jabref/gui/help/HelpAction.java b/src/main/java/org/jabref/gui/help/HelpAction.java
index 402d8900a13..ab7ae84e027 100644
--- a/src/main/java/org/jabref/gui/help/HelpAction.java
+++ b/src/main/java/org/jabref/gui/help/HelpAction.java
@@ -110,7 +110,7 @@ public void actionPerformed(ActionEvent e) {
openHelpPage(helpPage);
}
- public static SimpleCommand getCommand() {
+ public static SimpleCommand getMainHelpPageCommand() {
return new SimpleCommand() {
@Override
public void execute() {
@@ -118,4 +118,13 @@ public void execute() {
}
};
}
+
+ public SimpleCommand getCommand() {
+ return new SimpleCommand() {
+ @Override
+ public void execute() {
+ openHelpPage(helpPage);
+ }
+ };
+ }
}
diff --git a/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java b/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java
index 8b53cfd793b..903e116e533 100644
--- a/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java
+++ b/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java
@@ -51,7 +51,7 @@
import javafx.scene.Scene;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.BasePanelPreferences;
import org.jabref.gui.DuplicateResolverDialog;
@@ -84,7 +84,6 @@
import org.jabref.logic.bibtex.comparator.FieldComparator;
import org.jabref.logic.bibtexkeypattern.BibtexKeyGenerator;
import org.jabref.logic.help.HelpFile;
-import org.jabref.logic.importer.ImportInspector;
import org.jabref.logic.importer.OutputPrinter;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.UpdateField;
@@ -144,7 +143,7 @@
* receiving this call).
*/
-public class ImportInspectionDialog extends JabRefDialog implements ImportInspector, OutputPrinter {
+public class ImportInspectionDialog extends JabRefDialog implements OutputPrinter {
private static final Logger LOGGER = LoggerFactory.getLogger(ImportInspectionDialog.class);
private static final List INSPECTION_FIELDS = Arrays.asList(FieldName.AUTHOR, FieldName.TITLE, FieldName.YEAR, BibEntry.KEY_FIELD);
@@ -168,7 +167,6 @@ public class ImportInspectionDialog extends JabRefDialog implements ImportInspec
*/
private final List entriesToDelete = new ArrayList<>();
private final String undoName;
- private final List callBacks = new ArrayList<>();
private final boolean newDatabase;
private final JPopupMenu popup = new JPopupMenu();
private final JButton deselectAllDuplicates = new JButton(Localization.lang("Deselect all duplicates"));
@@ -286,7 +284,6 @@ public ImportInspectionDialog(JabRefFrame frame, BasePanel panel, String undoNam
generate.setEnabled(false);
ok.addActionListener(new OkListener());
cancel.addActionListener(e -> {
- signalStopFetching();
dispose();
frame.output(Localization.lang("Import canceled by user"));
});
@@ -297,7 +294,6 @@ public ImportInspectionDialog(JabRefFrame frame, BasePanel panel, String undoNam
generateKeys(); // Generate the keys.
});
stop.addActionListener(e -> {
- signalStopFetching();
entryListComplete();
});
selectAll.addActionListener(new SelectionButton(true));
@@ -345,29 +341,6 @@ public void actionPerformed(ActionEvent e) {
}
- /* (non-Javadoc)
- * @see package org.jabref.logic.importer.ImportInspector#setProgress(int, int)
- */
- @Override
- public void setProgress(int current, int max) {
- SwingUtilities.invokeLater(() -> {
- progressBar.setIndeterminate(false);
- progressBar.setMinimum(0);
- progressBar.setMaximum(max);
- progressBar.setValue(current);
- });
- }
-
- /* (non-Javadoc)
- * @see package org.jabref.logic.importer.ImportInspector#addEntry(org.jabref.model.entry.BibEntry)
- */
- @Override
- public void addEntry(BibEntry entry) {
- List list = new ArrayList<>();
- list.add(entry);
- addEntries(list);
- }
-
public void addEntries(Collection entriesToAdd) {
for (BibEntry entry : entriesToAdd) {
@@ -559,14 +532,6 @@ private AbstractAction getAction(GroupTreeNode node) {
return action;
}
- public void addCallBack(CallBack cb) {
- callBacks.add(cb);
- }
-
- private void signalStopFetching() {
- callBacks.forEach(CallBack::stopFetching);
- }
-
private void setWidths() {
TableColumnModel cm = glTable.getColumnModel();
cm.getColumn(0).setPreferredWidth(55);
diff --git a/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java
index 03834a8e1ed..96c789b6dbf 100644
--- a/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java
+++ b/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java
@@ -8,7 +8,7 @@
import javax.swing.undo.CompoundEdit;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
diff --git a/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java b/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java
index 2a76c406f62..c1aa6a96b74 100644
--- a/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java
+++ b/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java
@@ -4,7 +4,7 @@
import org.jabref.gui.BasePanel;
import org.jabref.logic.importer.ParserResult;
-import org.jabref.migrations.MergeReviewIntoCommentMigration;
+import org.jabref.logic.migrations.MergeReviewIntoCommentMigration;
import org.jabref.model.entry.BibEntry;
public class MergeReviewIntoCommentAction implements GUIPostOpenAction {
diff --git a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java
index ef98593fc5a..25f2bcbffec 100644
--- a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java
+++ b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java
@@ -17,7 +17,7 @@
import javax.swing.SwingUtilities;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.BasePanelPreferences;
import org.jabref.gui.DialogService;
@@ -37,7 +37,7 @@
import org.jabref.logic.shared.exception.NotASharedDatabaseException;
import org.jabref.logic.util.StandardFileType;
import org.jabref.logic.util.io.FileBasedLock;
-import org.jabref.migrations.FileLinksUpgradeWarning;
+import org.jabref.gui.migrations.FileLinksUpgradeWarning;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.shared.DatabaseNotSupportedException;
import org.jabref.preferences.JabRefPreferences;
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/EntryFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/EntryFetcher.java
deleted file mode 100644
index f2470d68fb3..00000000000
--- a/src/main/java/org/jabref/gui/importer/fetcher/EntryFetcher.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.jabref.gui.importer.fetcher;
-
-import javax.swing.JPanel;
-
-import org.jabref.gui.importer.ImportInspectionDialog;
-import org.jabref.logic.help.HelpFile;
-import org.jabref.logic.importer.ImportInspector;
-import org.jabref.logic.importer.OutputPrinter;
-
-/**
- * @Deprecated
- * Use {@link SearchBasedEntryFetcher} instead
- * Implement this interface to add another activeFetcher (something that grabs records
- * from the Web for JabRef). Have a look at the existing implemenations
- * IEEEXploreFetcher, JStorFetcher and
- * CiteSeerEntryFetcher.
- *
- * Note: You also need to implement the method stopFetching from
- * ImportInspectionDialog.Callback
- *
- * A Fetcher should not execute any GUI Operations, because it might be run in
- * headless mode, but rather use the OutputPrinter for talking to the user.
- */
-@Deprecated
-public interface EntryFetcher extends ImportInspectionDialog.CallBack {
-
- /**
- * Handle a query entered by the user.
- *
- * The method is expected to block the caller until all entries have been
- * reported to the inspector.
- *
- * @param query
- * The query text.
- * @param inspector
- * The dialog to add imported entries to.
- * @param status
- * An OutputPrinter passed to the activeFetcher for reporting about the
- * status of the fetching.
- *
- * @return True if the query was completed successfully, false if an error
- * occurred.
- */
- boolean processQuery(String query, ImportInspector inspector, OutputPrinter status);
-
- /**
- * The title for this activeFetcher, displayed in the menu and in the side pane.
- *
- * @return The title
- */
- String getTitle();
-
- /**
- * Get the name of the help page for this activeFetcher.
- *
- * If given, a question mark is displayed in the side pane which leads to
- * the help page.
- *
- * @return The {@link HelpFile} enum constant for the help page
- */
- HelpFile getHelpPage();
-
- /**
- * If this activeFetcher requires additional options, a panel for setting up these
- * should be returned in a JPanel by this method. This JPanel will be added
- * to the side pane component automatically.
- *
- * @return Options panel for this activeFetcher or null if this activeFetcher does not
- * have any options.
- */
- JPanel getOptionsPanel();
-}
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/EntryFetchers.java b/src/main/java/org/jabref/gui/importer/fetcher/EntryFetchers.java
deleted file mode 100644
index 353eddde4ae..00000000000
--- a/src/main/java/org/jabref/gui/importer/fetcher/EntryFetchers.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.jabref.gui.importer.fetcher;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jabref.Globals;
-import org.jabref.logic.importer.WebFetchers;
-import org.jabref.logic.journals.JournalAbbreviationLoader;
-
-public class EntryFetchers {
-
- private final List entryFetchers = new LinkedList<>();
-
- public EntryFetchers(JournalAbbreviationLoader abbreviationLoader) {
- WebFetchers.getSearchBasedFetchers(Globals.prefs.getImportFormatPreferences()).stream()
- .map(SearchBasedEntryFetcher::new)
- .forEach(entryFetchers::add);
- }
-
- public List getEntryFetchers() {
- return Collections.unmodifiableList(this.entryFetchers);
- }
-}
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java
deleted file mode 100644
index a5bdd0696e3..00000000000
--- a/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java
+++ /dev/null
@@ -1,216 +0,0 @@
-package org.jabref.gui.importer.fetcher;
-
-import java.awt.BorderLayout;
-import java.awt.CardLayout;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-
-import javafx.embed.swing.SwingNode;
-import javafx.scene.Node;
-import javafx.scene.layout.Priority;
-
-import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
-import org.jabref.gui.JabRefFrame;
-import org.jabref.gui.SidePaneComponent;
-import org.jabref.gui.SidePaneManager;
-import org.jabref.gui.SidePaneType;
-import org.jabref.gui.actions.Action;
-import org.jabref.gui.actions.StandardActions;
-import org.jabref.gui.help.HelpAction;
-import org.jabref.gui.icon.IconTheme;
-import org.jabref.gui.importer.ImportInspectionDialog;
-import org.jabref.logic.l10n.Localization;
-import org.jabref.logic.util.OS;
-import org.jabref.preferences.JabRefPreferences;
-
-public class GeneralFetcher extends SidePaneComponent implements ActionListener {
-
- private final JTextField tf = new JTextField();
-
- private final CardLayout optionsCards = new CardLayout();
- private final JPanel optionsPanel = new JPanel(optionsCards);
- private final JPanel optPanel = new JPanel(new BorderLayout());
-
- private final JabRefFrame frame;
- private final JabRefPreferences preferences;
- private EntryFetcher activeFetcher;
-
- public GeneralFetcher(SidePaneManager sidePaneManager, JabRefPreferences preferences, JabRefFrame frame) {
- super(sidePaneManager, IconTheme.JabRefIcons.WWW, Localization.lang("Web search"));
- this.frame = frame;
- this.preferences = preferences;
- }
-
- @Override
- public Action getToggleAction() {
- return StandardActions.TOGGLE_WEB_SEARCH;
- }
-
- @Override
- protected Node createContentPane() {
- List fetchers = new EntryFetchers(Globals.journalAbbreviationLoader).getEntryFetchers();
- EntryFetcher[] fetcherArray = fetchers.toArray(new EntryFetcher[fetchers.size()]);
- Arrays.sort(fetcherArray, new EntryFetcherComparator());
- String[] choices = new String[fetcherArray.length];
- for (int i = 0; i < fetcherArray.length; i++) {
- choices[i] = fetcherArray[i].getTitle();
- }
- JComboBox fetcherChoice = new JComboBox<>(choices);
- int defaultFetcher = preferences.getInt(JabRefPreferences.SELECTED_FETCHER_INDEX);
- if (defaultFetcher >= fetcherArray.length) {
- defaultFetcher = 0;
- }
- this.activeFetcher = fetcherArray[defaultFetcher];
- fetcherChoice.setSelectedIndex(defaultFetcher);
- if (this.activeFetcher.getOptionsPanel() != null) {
- optPanel.add(this.activeFetcher.getOptionsPanel(), BorderLayout.CENTER);
- }
- HelpAction help = new HelpAction(activeFetcher.getHelpPage());
- JButton helpBut = help.getHelpButton();
- helpBut.setEnabled(activeFetcher.getHelpPage() != null);
-
- fetcherChoice.addActionListener(actionEvent -> {
- activeFetcher = fetcherArray[fetcherChoice.getSelectedIndex()];
- preferences.putInt(JabRefPreferences.SELECTED_FETCHER_INDEX, fetcherChoice.getSelectedIndex());
- if (activeFetcher.getHelpPage() == null) {
- helpBut.setEnabled(false);
- } else {
- help.setHelpFile(activeFetcher.getHelpPage());
- helpBut.setEnabled(true);
- }
- optionsCards.show(optionsPanel, String.valueOf(fetcherChoice.getSelectedIndex()));
- optPanel.removeAll();
- if (activeFetcher.getOptionsPanel() != null) {
- optPanel.add(activeFetcher.getOptionsPanel(), BorderLayout.CENTER);
- }
- });
-
- helpBut.setMargin(new Insets(0, 0, 0, 0));
- tf.setPreferredSize(new Dimension(1, tf.getPreferredSize().height));
- if (OS.OS_X) {
- tf.putClientProperty("JTextField.variant", "search");
- }
-
- tf.setName("tf");
- // add action to reset-button. resets tf and requests focus
- JButton reset = new JButton(Localization.lang("Reset"));
- reset.addActionListener(event -> {
- tf.setText("");
- tf.requestFocus();
- });
-
- JPanel main = new JPanel();
- GridBagLayout gbl = new GridBagLayout();
- main.setLayout(gbl);
- GridBagConstraints con = new GridBagConstraints();
- con.fill = GridBagConstraints.BOTH;
- con.insets = new Insets(0, 0, 2, 0);
- con.gridwidth = GridBagConstraints.REMAINDER;
- con.weightx = 1;
- con.weighty = 1;
- con.insets = new Insets(1, 0, 1, 0);
- con.fill = GridBagConstraints.BOTH;
- gbl.setConstraints(fetcherChoice, con);
- main.add(fetcherChoice);
- con.insets = new Insets(0, 0, 0, 0);
- gbl.setConstraints(tf, con);
- main.add(tf);
-
- // Go Button
- con.weighty = 0;
- con.gridwidth = 1;
- JButton go = new JButton(Localization.lang("Fetch"));
- gbl.setConstraints(go, con);
- main.add(go);
-
- // Reset Button
- reset.setName("reset");
- gbl.setConstraints(reset, con);
- main.add(reset);
-
- // Help Button
- con.gridwidth = GridBagConstraints.REMAINDER;
- gbl.setConstraints(helpBut, con);
- main.add(helpBut);
-
- gbl.setConstraints(optPanel, con);
- main.add(optPanel);
-
- main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
- go.addActionListener(this);
- tf.addActionListener(this);
-
- SwingNode swingNode = new SwingNode();
- SwingUtilities.invokeLater(() -> swingNode.setContent(main));
- return swingNode;
- }
-
- @Override
- public SidePaneType getType() {
- return SidePaneType.WEB_SEARCH;
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (tf.getText().trim().isEmpty()) {
- frame.output(Localization.lang("Please enter a search string"));
- return;
- }
-
- if (frame.getCurrentBasePanel() == null) {
- frame.output(Localization.lang("Please open or start a new library before searching"));
- return;
- }
-
- final ImportInspectionDialog dialog = new ImportInspectionDialog(frame, frame.getCurrentBasePanel(),
- activeFetcher.getTitle(), false);
- dialog.addCallBack(activeFetcher);
- dialog.setVisible(true);
-
- JabRefExecutorService.INSTANCE.execute(() -> {
- if (activeFetcher.processQuery(tf.getText().trim(), dialog, dialog)) {
- dialog.entryListComplete();
- } else {
- dialog.dispose();
- }
- });
- }
-
- @Override
- public void beforeClosing() {
- preferences.putBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE, Boolean.FALSE);
- }
-
- @Override
- public void afterOpening() {
- preferences.putBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE, Boolean.TRUE);
- }
-
- @Override
- public Priority getResizePolicy() {
- return Priority.NEVER;
- }
-
- private static class EntryFetcherComparator implements Comparator {
-
- @Override
- public int compare(EntryFetcher entryFetcher, EntryFetcher entryFetcher1) {
- return entryFetcher.getTitle().compareTo(entryFetcher1.getTitle());
- }
- }
-}
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/SearchBasedEntryFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/SearchBasedEntryFetcher.java
deleted file mode 100644
index b5d3f398a28..00000000000
--- a/src/main/java/org/jabref/gui/importer/fetcher/SearchBasedEntryFetcher.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.jabref.gui.importer.fetcher;
-
-import java.util.List;
-import java.util.Objects;
-
-import javax.swing.JPanel;
-
-import org.jabref.gui.importer.ImportInspectionDialog;
-import org.jabref.logic.help.HelpFile;
-import org.jabref.logic.importer.FetcherException;
-import org.jabref.logic.importer.ImportInspector;
-import org.jabref.logic.importer.OutputPrinter;
-import org.jabref.logic.importer.SearchBasedFetcher;
-import org.jabref.logic.l10n.Localization;
-import org.jabref.model.entry.BibEntry;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Wrapper around {@link SearchBasedFetcher} which implements the old {@link EntryFetcher} interface.
- */
-public class SearchBasedEntryFetcher implements EntryFetcher {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SearchBasedEntryFetcher.class);
- private final SearchBasedFetcher fetcher;
-
- public SearchBasedEntryFetcher(SearchBasedFetcher fetcher) {
- this.fetcher = Objects.requireNonNull(fetcher);
- }
-
- @Override
- public boolean processQuery(String query, ImportInspector inspector, OutputPrinter status) {
- status.setStatus(Localization.lang("Processing %0", query));
- try {
- List matches = fetcher.performSearch(query);
- matches.forEach(inspector::addEntry);
- return !matches.isEmpty();
- } catch (FetcherException e) {
- LOGGER.error("Error while fetching from " + getTitle(), e);
- ((ImportInspectionDialog)inspector).showErrorMessage(this.getTitle(), e.getLocalizedMessage());
- }
-
- return false;
- }
-
- @Override
- public String getTitle() {
- return fetcher.getName();
- }
-
- @Override
- public HelpFile getHelpPage() {
- return fetcher.getHelpPage();
- }
-
- @Override
- public JPanel getOptionsPanel() {
- // not supported
- return null;
- }
-
- @Override
- public void stopFetching() {
- // not supported
- }
-}
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java
new file mode 100644
index 00000000000..1f9c0d637d6
--- /dev/null
+++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java
@@ -0,0 +1,107 @@
+package org.jabref.gui.importer.fetcher;
+
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.scene.control.Button;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
+import javafx.scene.layout.StackPane;
+import javafx.scene.layout.VBox;
+
+import org.jabref.gui.JabRefFrame;
+import org.jabref.gui.SidePaneComponent;
+import org.jabref.gui.SidePaneManager;
+import org.jabref.gui.SidePaneType;
+import org.jabref.gui.actions.Action;
+import org.jabref.gui.actions.ActionFactory;
+import org.jabref.gui.actions.StandardActions;
+import org.jabref.gui.help.HelpAction;
+import org.jabref.gui.icon.IconTheme;
+import org.jabref.gui.search.SearchTextField;
+import org.jabref.gui.util.ViewModelListCellFactory;
+import org.jabref.logic.importer.SearchBasedFetcher;
+import org.jabref.logic.l10n.Localization;
+import org.jabref.preferences.JabRefPreferences;
+
+import org.fxmisc.easybind.EasyBind;
+
+public class WebSearchPane extends SidePaneComponent {
+
+ private final JabRefPreferences preferences;
+ private final WebSearchPaneViewModel viewModel;
+
+ public WebSearchPane(SidePaneManager sidePaneManager, JabRefPreferences preferences, JabRefFrame frame) {
+ super(sidePaneManager, IconTheme.JabRefIcons.WWW, Localization.lang("Web search"));
+ this.preferences = preferences;
+ this.viewModel = new WebSearchPaneViewModel(preferences.getImportFormatPreferences(), frame, preferences);
+ }
+
+ @Override
+ public Action getToggleAction() {
+ return StandardActions.TOGGLE_WEB_SEARCH;
+ }
+
+ @Override
+ protected Node createContentPane() {
+ // Setup combo box for fetchers
+ ComboBox fetchers = new ComboBox<>();
+ new ViewModelListCellFactory()
+ .withText(SearchBasedFetcher::getName)
+ .install(fetchers);
+ fetchers.itemsProperty().bind(viewModel.fetchersProperty());
+ fetchers.valueProperty().bindBidirectional(viewModel.selectedFetcherProperty());
+ fetchers.setMaxWidth(Double.POSITIVE_INFINITY);
+
+ // Create help button for currently selected fetcher
+ StackPane helpButtonContainer = new StackPane();
+ ActionFactory factory = new ActionFactory(preferences.getKeyBindingRepository());
+ EasyBind.subscribe(viewModel.selectedFetcherProperty(), fetcher -> {
+ if ((fetcher != null) && fetcher.getHelpPage().isPresent()) {
+ HelpAction helpCommand = new HelpAction(fetcher.getHelpPage().get());
+ Button helpButton = factory.createIconButton(StandardActions.HELP, helpCommand.getCommand());
+ helpButtonContainer.getChildren().setAll(helpButton);
+ } else {
+ helpButtonContainer.getChildren().clear();
+ }
+ });
+ HBox fetcherContainer = new HBox(fetchers, helpButtonContainer);
+ HBox.setHgrow(fetchers, Priority.ALWAYS);
+
+ // Create text field for query input
+ TextField query = SearchTextField.create();
+ viewModel.queryProperty().bind(query.textProperty());
+
+ // Create button that triggers search
+ Button search = new Button(Localization.lang("Search"));
+ search.setDefaultButton(true);
+ search.setOnAction(event -> viewModel.search());
+
+ // Put everything together
+ VBox container = new VBox();
+ container.setAlignment(Pos.CENTER);
+ container.getChildren().addAll(fetcherContainer, query, search);
+ return container;
+ }
+
+ @Override
+ public SidePaneType getType() {
+ return SidePaneType.WEB_SEARCH;
+ }
+
+ @Override
+ public void beforeClosing() {
+ preferences.putBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE, Boolean.FALSE);
+ }
+
+ @Override
+ public void afterOpening() {
+ preferences.putBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE, Boolean.TRUE);
+ }
+
+ @Override
+ public Priority getResizePolicy() {
+ return Priority.NEVER;
+ }
+}
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java
new file mode 100644
index 00000000000..87fc803a95a
--- /dev/null
+++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java
@@ -0,0 +1,117 @@
+package org.jabref.gui.importer.fetcher;
+
+import java.util.Comparator;
+import java.util.List;
+
+import javax.swing.SwingUtilities;
+
+import javafx.beans.property.ListProperty;
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.SimpleListProperty;
+import javafx.beans.property.SimpleObjectProperty;
+import javafx.beans.property.SimpleStringProperty;
+import javafx.beans.property.StringProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+import org.jabref.logic.JabRefExecutorService;
+import org.jabref.gui.JabRefFrame;
+import org.jabref.gui.importer.ImportInspectionDialog;
+import org.jabref.logic.importer.FetcherException;
+import org.jabref.logic.importer.ImportFormatPreferences;
+import org.jabref.logic.importer.SearchBasedFetcher;
+import org.jabref.logic.importer.WebFetcher;
+import org.jabref.logic.importer.WebFetchers;
+import org.jabref.logic.l10n.Localization;
+import org.jabref.model.entry.BibEntry;
+import org.jabref.model.strings.StringUtil;
+import org.jabref.preferences.JabRefPreferences;
+
+import org.fxmisc.easybind.EasyBind;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WebSearchPaneViewModel {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(WebSearchPaneViewModel.class);
+
+ private final ObjectProperty selectedFetcher = new SimpleObjectProperty<>();
+ private final ListProperty fetchers = new SimpleListProperty<>(FXCollections.observableArrayList());
+ private final StringProperty query = new SimpleStringProperty();
+ private final JabRefFrame frame;
+
+ public WebSearchPaneViewModel(ImportFormatPreferences importPreferences, JabRefFrame frame, JabRefPreferences preferences) {
+ // TODO: Rework so that we don't rely on JabRefFrame and not the complete preferences
+ this.frame = frame;
+
+ List allFetchers = WebFetchers.getSearchBasedFetchers(importPreferences);
+ allFetchers.sort(Comparator.comparing(WebFetcher::getName));
+ fetchers.setAll(allFetchers);
+
+ // Choose last-selected fetcher as default
+ int defaultFetcherIndex = preferences.getInt(JabRefPreferences.SELECTED_FETCHER_INDEX);
+ if ((defaultFetcherIndex <= 0) || (defaultFetcherIndex >= fetchers.size())) {
+ selectedFetcherProperty().setValue(fetchers.get(0));
+ } else {
+ selectedFetcherProperty().setValue(fetchers.get(defaultFetcherIndex));
+ }
+ EasyBind.subscribe(selectedFetcherProperty(), newFetcher -> {
+ int newIndex = fetchers.indexOf(newFetcher);
+ preferences.putInt(JabRefPreferences.SELECTED_FETCHER_INDEX, newIndex);
+ });
+ }
+
+ public ObservableList getFetchers() {
+ return fetchers.get();
+ }
+
+ public ListProperty fetchersProperty() {
+ return fetchers;
+ }
+
+ public SearchBasedFetcher getSelectedFetcher() {
+ return selectedFetcher.get();
+ }
+
+ public ObjectProperty selectedFetcherProperty() {
+ return selectedFetcher;
+ }
+
+ public String getQuery() {
+ return query.get();
+ }
+
+ public StringProperty queryProperty() {
+ return query;
+ }
+
+ public void search() {
+ if (StringUtil.isBlank(getQuery())) {
+ frame.output(Localization.lang("Please enter a search string"));
+ return;
+ }
+
+ if (frame.getCurrentBasePanel() == null) {
+ frame.output(Localization.lang("Please open or start a new library before searching"));
+ return;
+ }
+
+ SearchBasedFetcher activeFetcher = getSelectedFetcher();
+ final ImportInspectionDialog dialog = new ImportInspectionDialog(frame, frame.getCurrentBasePanel(),
+ activeFetcher.getName(), false);
+
+ SwingUtilities.invokeLater(() -> dialog.setVisible(true));
+
+ JabRefExecutorService.INSTANCE.execute(() -> {
+ dialog.setStatus(Localization.lang("Processing %0", getQuery()));
+ try {
+ List matches = activeFetcher.performSearch(getQuery().trim());
+ dialog.addEntries(matches);
+ dialog.entryListComplete();
+ } catch (FetcherException e) {
+ LOGGER.error("Error while fetching from " + activeFetcher.getName(), e);
+ dialog.showErrorMessage(activeFetcher.getName(), e.getLocalizedMessage());
+ }
+ });
+ }
+}
diff --git a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java
index 283905fb435..7ae99570098 100644
--- a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java
+++ b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java
@@ -8,7 +8,7 @@
import java.util.concurrent.Future;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.actions.BaseAction;
import org.jabref.gui.undo.NamedCompound;
diff --git a/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java b/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
index 83cd9613807..6356f501ba5 100644
--- a/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
+++ b/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
@@ -7,7 +7,7 @@
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java b/src/main/java/org/jabref/gui/migrations/CustomEntryTypePreferenceMigration.java
similarity index 98%
rename from src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java
rename to src/main/java/org/jabref/gui/migrations/CustomEntryTypePreferenceMigration.java
index f4573c62236..5d85e19691d 100644
--- a/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java
+++ b/src/main/java/org/jabref/gui/migrations/CustomEntryTypePreferenceMigration.java
@@ -1,4 +1,4 @@
-package org.jabref.migrations;
+package org.jabref.gui.migrations;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java b/src/main/java/org/jabref/gui/migrations/FileLinksUpgradeWarning.java
similarity index 99%
rename from src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java
rename to src/main/java/org/jabref/gui/migrations/FileLinksUpgradeWarning.java
index 8668bc30843..cf645fbbf6d 100644
--- a/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java
+++ b/src/main/java/org/jabref/gui/migrations/FileLinksUpgradeWarning.java
@@ -1,4 +1,4 @@
-package org.jabref.migrations;
+package org.jabref.gui.migrations;
import java.util.List;
diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/gui/migrations/PreferencesMigrations.java
similarity index 99%
rename from src/main/java/org/jabref/migrations/PreferencesMigrations.java
rename to src/main/java/org/jabref/gui/migrations/PreferencesMigrations.java
index f0923915177..37699a9157b 100644
--- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java
+++ b/src/main/java/org/jabref/gui/migrations/PreferencesMigrations.java
@@ -1,4 +1,4 @@
-package org.jabref.migrations;
+package org.jabref.gui.migrations;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/src/main/java/org/jabref/gui/preftabs/PreferencesDialog.java b/src/main/java/org/jabref/gui/preftabs/PreferencesDialog.java
index 61b497f8c8d..03f978153e5 100644
--- a/src/main/java/org/jabref/gui/preftabs/PreferencesDialog.java
+++ b/src/main/java/org/jabref/gui/preftabs/PreferencesDialog.java
@@ -26,7 +26,7 @@
import javafx.scene.layout.Region;
import org.jabref.Globals;
-import org.jabref.JabRefException;
+import org.jabref.logic.JabRefException;
import org.jabref.gui.DialogService;
import org.jabref.gui.GUIGlobals;
import org.jabref.gui.JabRefFrame;
diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationAction.java b/src/main/java/org/jabref/gui/push/PushToApplicationAction.java
index 468fb8b57dc..c07a8f20104 100644
--- a/src/main/java/org/jabref/gui/push/PushToApplicationAction.java
+++ b/src/main/java/org/jabref/gui/push/PushToApplicationAction.java
@@ -8,7 +8,7 @@
import javax.swing.Action;
import javax.swing.SwingUtilities;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.JabRefFrame;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/push/PushToEmacs.java b/src/main/java/org/jabref/gui/push/PushToEmacs.java
index 3603bd646cb..ee2369b5267 100644
--- a/src/main/java/org/jabref/gui/push/PushToEmacs.java
+++ b/src/main/java/org/jabref/gui/push/PushToEmacs.java
@@ -5,7 +5,7 @@
import java.util.List;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
diff --git a/src/main/java/org/jabref/gui/push/PushToLyx.java b/src/main/java/org/jabref/gui/push/PushToLyx.java
index 265d9f0fbbe..1514c4604d9 100644
--- a/src/main/java/org/jabref/gui/push/PushToLyx.java
+++ b/src/main/java/org/jabref/gui/push/PushToLyx.java
@@ -7,7 +7,7 @@
import java.util.List;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
diff --git a/src/main/java/org/jabref/gui/push/PushToVim.java b/src/main/java/org/jabref/gui/push/PushToVim.java
index 46af5b2556d..54d576abc19 100644
--- a/src/main/java/org/jabref/gui/push/PushToVim.java
+++ b/src/main/java/org/jabref/gui/push/PushToVim.java
@@ -5,7 +5,7 @@
import java.util.List;
import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
+import org.jabref.logic.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
diff --git a/src/main/java/org/jabref/gui/search/SearchTextField.java b/src/main/java/org/jabref/gui/search/SearchTextField.java
index b752b744ccf..cbb8ef0e650 100644
--- a/src/main/java/org/jabref/gui/search/SearchTextField.java
+++ b/src/main/java/org/jabref/gui/search/SearchTextField.java
@@ -1,7 +1,5 @@
package org.jabref.gui.search;
-import javafx.scene.control.TextField;
-
import org.jabref.gui.icon.IconTheme;
import org.jabref.logic.l10n.Localization;
@@ -10,7 +8,7 @@
public class SearchTextField {
- public static TextField create() {
+ public static CustomTextField create() {
CustomTextField textField = (CustomTextField) TextFields.createClearableTextField();
textField.setPromptText(Localization.lang("Search") + "...");
textField.setLeft(IconTheme.JabRefIcons.SEARCH.getGraphicNode());
diff --git a/src/main/java/org/jabref/gui/shared/ConnectToSharedDatabaseDialog.java b/src/main/java/org/jabref/gui/shared/ConnectToSharedDatabaseDialog.java
index 9dd594d2418..a42586827d7 100644
--- a/src/main/java/org/jabref/gui/shared/ConnectToSharedDatabaseDialog.java
+++ b/src/main/java/org/jabref/gui/shared/ConnectToSharedDatabaseDialog.java
@@ -31,7 +31,7 @@
import javax.swing.KeyStroke;
import org.jabref.Globals;
-import org.jabref.JabRefException;
+import org.jabref.logic.JabRefException;
import org.jabref.JabRefGUI;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
diff --git a/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java b/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java
index e33bd4cbccc..e628e1c371e 100644
--- a/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java
+++ b/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java
@@ -3,6 +3,7 @@
import java.util.function.BiConsumer;
import javafx.scene.Node;
+import javafx.scene.control.ComboBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
@@ -107,6 +108,11 @@ public ViewModelListCellFactory setOnDragOver(BiConsumer comboBox) {
+ comboBox.setButtonCell(this.call(null));
+ comboBox.setCellFactory(this);
+ }
+
@Override
public ListCell call(ListView param) {
diff --git a/src/main/java/org/jabref/logic/importer/ImportInspector.java b/src/main/java/org/jabref/logic/importer/ImportInspector.java
deleted file mode 100644
index 80ec91e9bb5..00000000000
--- a/src/main/java/org/jabref/logic/importer/ImportInspector.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.jabref.logic.importer;
-
-import org.jabref.model.entry.BibEntry;
-
-/**
- * An ImportInspector can be passed to a EntryFetcher and will receive entries
- * as they are fetched from somewhere.
- *
- * Currently there are two implementations: ImportInspectionDialog and
- * ImportInspectionCommandLine
- *
- */
-public interface ImportInspector {
-
- /**
- * Notify the ImportInspector about the progress of the operation.
- *
- * The Inspector for instance could display a progress bar with the given
- * values.
- *
- * @param current
- * A number that is related to the work already done.
- *
- * @param max
- * A current estimate for the total amount of work to be done.
- */
- void setProgress(int current, int max);
-
- /**
- * Add the given entry to the list of entries managed by the inspector.
- *
- * @param entry
- * The entry to add.
- */
- void addEntry(BibEntry entry);
-}
diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java
index 6270350cc84..4a0a4b19466 100644
--- a/src/main/java/org/jabref/preferences/JabRefPreferences.java
+++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java
@@ -35,7 +35,7 @@
import java.util.stream.Collectors;
import org.jabref.Globals;
-import org.jabref.JabRefException;
+import org.jabref.logic.JabRefException;
import org.jabref.JabRefMain;
import org.jabref.gui.SidePaneType;
import org.jabref.gui.autocompleter.AutoCompleteFirstNameMode;
@@ -702,8 +702,8 @@ private JabRefPreferences() {
defaults.put(EMAIL_SUBJECT, Localization.lang("References"));
defaults.put(OPEN_FOLDERS_OF_ATTACHED_FILES, Boolean.FALSE);
defaults.put(ALLOW_FILE_AUTO_OPEN_BROWSE, Boolean.TRUE);
- defaults.put(WEB_SEARCH_VISIBLE, Boolean.FALSE);
- defaults.put(GROUP_SIDEPANE_VISIBLE, Boolean.FALSE);
+ defaults.put(WEB_SEARCH_VISIBLE, Boolean.TRUE);
+ defaults.put(GROUP_SIDEPANE_VISIBLE, Boolean.TRUE);
defaults.put(SELECTED_FETCHER_INDEX, 0);
defaults.put(BIB_LOC_AS_PRIMARY_DIR, Boolean.FALSE);
defaults.put(DB_CONNECT_SERVER_TYPE, "MySQL");
@@ -1035,6 +1035,10 @@ public void putInt(String key, int value) {
prefs.putInt(key, value);
}
+ public void putInt(String key, Number value) {
+ prefs.putInt(key, value.intValue());
+ }
+
public void putDouble(String key, double value) {
prefs.putDouble(key, value);
}
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 55b6f2209de..d2de9afd87d 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -416,8 +416,6 @@ External\ programs=External programs
External\ viewer\ called=External viewer called
-Fetch=Fetch
-
Field=Field
field=field
@@ -1180,7 +1178,6 @@ Your\ new\ key\ bindings\ have\ been\ stored.=Your new key bindings have been st
The\ following\ fetchers\ are\ available\:=The following fetchers are available:
Could\ not\ find\ fetcher\ '%0'=Could not find fetcher '%0'
Running\ query\ '%0'\ with\ fetcher\ '%1'.=Running query '%0' with fetcher '%1'.
-Query\ '%0'\ with\ fetcher\ '%1'\ did\ not\ return\ any\ results.=Query '%0' with fetcher '%1' did not return any results.
Move\ file=Move file
Rename\ file=Rename file
@@ -1192,7 +1189,6 @@ Could\ not\ move\ file\ '%0'.=Could not move file '%0'.
Could\ not\ find\ file\ '%0'.=Could not find file '%0'.
Number\ of\ entries\ successfully\ imported=Number of entries successfully imported
Import\ canceled\ by\ user=Import canceled by user
-Progress\:\ %0\ of\ %1=Progress: %0 of %1
Error\ while\ fetching\ from\ %0=Error while fetching from %0
Show\ search\ results\ in\ a\ window=Show search results in a window
diff --git a/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java b/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java
index 5c47dec695e..ea4ad6f637b 100644
--- a/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java
+++ b/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java
@@ -12,7 +12,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import org.jabref.JabRefException;
+import org.jabref.logic.JabRefException;
import org.jabref.gui.DialogService;
import org.jabref.gui.util.CurrentThreadTaskExecutor;
import org.jabref.gui.util.TaskExecutor;
diff --git a/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java b/src/test/java/org/jabref/gui/migrations/PreferencesMigrationsTest.java
similarity index 99%
rename from src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java
rename to src/test/java/org/jabref/gui/migrations/PreferencesMigrationsTest.java
index be1d34e8f39..b00d6332170 100644
--- a/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java
+++ b/src/test/java/org/jabref/gui/migrations/PreferencesMigrationsTest.java
@@ -1,4 +1,4 @@
-package org.jabref.migrations;
+package org.jabref.gui.migrations;
import java.util.prefs.Preferences;
diff --git a/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java b/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java
deleted file mode 100644
index 6be9c501a00..00000000000
--- a/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.jabref.logic.exporter;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.jabref.logic.importer.ImportFormatPreferences;
-import org.jabref.logic.importer.fileformat.BibtexImporter;
-import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.entry.BibEntry;
-import org.jabref.model.util.DummyFileUpdateMonitor;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-import org.mockito.Answers;
-import org.xmlunit.builder.Input;
-import org.xmlunit.builder.Input.Builder;
-import org.xmlunit.diff.DefaultNodeMatcher;
-import org.xmlunit.diff.ElementSelectors;
-import org.xmlunit.matchers.CompareMatcher;
-
-import static org.mockito.Mockito.mock;
-
-@RunWith(Parameterized.class)
-public class BibTeXMLExporterTestFiles {
-
- public BibDatabaseContext databaseContext;
- public Charset charset;
- public File tempFile;
- public BibTeXMLExporter bibtexmlExportFormat;
- public BibtexImporter testImporter;
-
- @Parameter
- public String filename;
- public Path resourceDir;
-
- @Rule
- public TemporaryFolder testFolder = new TemporaryFolder();
-
- @Parameters(name = "{0}")
- public static Collection fileNames() throws IOException, URISyntaxException {
- try (Stream stream = Files.list(Paths.get(BibTeXMLExporterTestFiles.class.getResource("").toURI()))) {
- return stream.map(n -> n.getFileName().toString()).filter(n -> n.endsWith(".bib"))
- .filter(n -> n.startsWith("BibTeXML")).collect(Collectors.toList());
- }
- }
-
- @Before
- public void setUp() throws Exception {
- resourceDir = Paths.get(BibTeXMLExporterTestFiles.class.getResource("").toURI());
- databaseContext = new BibDatabaseContext();
- charset = StandardCharsets.UTF_8;
- bibtexmlExportFormat = new BibTeXMLExporter();
- tempFile = testFolder.newFile();
- testImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS), new DummyFileUpdateMonitor());
- }
-
- @Test
- public final void testPerformExport() throws IOException, SaveException {
- String xmlFileName = filename.replace(".bib", ".xml");
- Path importFile = resourceDir.resolve(filename);
- String tempFilename = tempFile.getCanonicalPath();
-
- List entries = testImporter.importDatabase(importFile, StandardCharsets.UTF_8).getDatabase()
- .getEntries();
-
- bibtexmlExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);
-
- Builder control = Input.from(Files.newInputStream(resourceDir.resolve(xmlFileName)));
- Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));
-
- Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
- .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
- }
-}
diff --git a/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java b/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java
deleted file mode 100644
index c078e3e4b2b..00000000000
--- a/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.jabref.logic.exporter;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.jabref.logic.importer.ImportFormatPreferences;
-import org.jabref.logic.importer.fileformat.BibtexImporter;
-import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.entry.BibEntry;
-import org.jabref.model.util.DummyFileUpdateMonitor;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-import org.mockito.Answers;
-import org.xmlunit.builder.Input;
-import org.xmlunit.builder.Input.Builder;
-import org.xmlunit.diff.DefaultNodeMatcher;
-import org.xmlunit.diff.ElementSelectors;
-import org.xmlunit.matchers.CompareMatcher;
-
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-
-@RunWith(Parameterized.class)
-public class MSBibExportFormatTestFiles {
-
- public BibDatabaseContext databaseContext;
- public Charset charset;
- public Path tempFile;
- public MSBibExporter msBibExportFormat;
- public BibtexImporter testImporter;
-
- @Parameter
- public String filename;
- public Path resourceDir;
-
- @Rule
- public TemporaryFolder testFolder = new TemporaryFolder();
-
-
- @Parameters(name = "{0}")
- public static Collection fileNames() throws IOException, URISyntaxException {
- try (Stream stream = Files.list(Paths.get(MSBibExportFormatTestFiles.class.getResource("").toURI()))) {
- return stream.map(n -> n.getFileName().toString()).filter(n -> n.endsWith(".bib"))
- .filter(n -> n.startsWith("MsBib")).collect(Collectors.toList());
- }
- }
-
- @Before
- public void setUp() throws Exception {
- resourceDir = Paths.get(MSBibExportFormatTestFiles.class.getResource("").toURI());
- databaseContext = new BibDatabaseContext();
- charset = StandardCharsets.UTF_8;
- msBibExportFormat = new MSBibExporter();
- tempFile = testFolder.newFile().toPath();
- testImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS), new DummyFileUpdateMonitor());
- }
-
- @Test
- public final void testPerformExport() throws IOException, SaveException {
- String xmlFileName = filename.replace(".bib", ".xml");
- Path importFile = resourceDir.resolve(filename);
-
- List entries = testImporter.importDatabase(importFile, StandardCharsets.UTF_8).getDatabase()
- .getEntries();
-
- msBibExportFormat.export(databaseContext, tempFile, charset, entries);
-
- Builder control = Input.from(Files.newInputStream(resourceDir.resolve(xmlFileName)));
- Builder test = Input.from(Files.newInputStream(tempFile));
-
- assertThat(test, CompareMatcher.isSimilarTo(control)
- .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
- }
-}
diff --git a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java
deleted file mode 100644
index 3faf73dd291..00000000000
--- a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.jabref.logic.exporter;
-
-import java.io.File;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.jabref.logic.bibtex.BibEntryAssert;
-import org.jabref.logic.importer.ImportFormatPreferences;
-import org.jabref.logic.importer.fileformat.BibtexImporter;
-import org.jabref.logic.importer.fileformat.ModsImporter;
-import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.entry.BibEntry;
-import org.jabref.model.util.DummyFileUpdateMonitor;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-import org.mockito.Answers;
-import org.xmlunit.builder.Input;
-import org.xmlunit.builder.Input.Builder;
-import org.xmlunit.diff.DefaultNodeMatcher;
-import org.xmlunit.diff.ElementSelectors;
-import org.xmlunit.matchers.CompareMatcher;
-
-import static org.mockito.Mockito.mock;
-
-@RunWith(Parameterized.class)
-public class ModsExportFormatTestFiles {
-
- public Charset charset;
- private BibDatabaseContext databaseContext;
- private File tempFile;
- private ModsExporter modsExportFormat;
- private BibtexImporter bibtexImporter;
- private ModsImporter modsImporter;
- private Path importFile;
-
-
- @Parameter
- public String filename;
-
- @Rule
- public TemporaryFolder testFolder = new TemporaryFolder();
-
-
- @Parameters(name = "{0}")
- public static Collection fileNames() throws Exception {
- try (Stream stream = Files.list(Paths.get(ModsExportFormatTestFiles.class.getResource("").toURI()))) {
- // stream.forEach(n -> System.out.println(n));
- return stream.map(n -> n.getFileName().toString()).filter(n -> n.endsWith(".bib"))
- .filter(n -> n.startsWith("Mods")).collect(Collectors.toList());
- }
- }
-
- @Before
- public void setUp() throws Exception {
- databaseContext = new BibDatabaseContext();
- importFile = Paths.get(ModsExportFormatTestFiles.class.getResource(filename).toURI());
- charset = StandardCharsets.UTF_8;
- modsExportFormat = new ModsExporter();
- tempFile = testFolder.newFile();
- bibtexImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS), new DummyFileUpdateMonitor());
- modsImporter = new ModsImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS));
- }
-
- @Test
- public final void testPerformExport() throws Exception {
- String xmlFileName = filename.replace(".bib", ".xml");
- String tempFilename = tempFile.getCanonicalPath();
- List entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries();
- Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());
-
- modsExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);
-
- Builder control = Input.from(Files.newInputStream(xmlFile));
- Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));
-
- Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
- .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
- }
-
- @Test
- public final void testExportAsModsAndThenImportAsMods() throws Exception {
- List entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries();
-
- modsExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);
- BibEntryAssert.assertEquals(entries, Paths.get(tempFile.getPath()), modsImporter);
- }
-
- @Test
- public final void testImportAsModsAndExportAsMods() throws Exception {
- String xmlFileName = filename.replace(".bib", ".xml");
- String tempFilename = tempFile.getCanonicalPath();
- Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());
-
- List entries = modsImporter.importDatabase(xmlFile, charset).getDatabase().getEntries();
-
- modsExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);
-
- Builder control = Input.from(Files.newInputStream(xmlFile));
- Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));
-
- Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
- .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
- }
-
-}
diff --git a/src/test/java/org/jabref/logic/net/MimeTypeDetectorTest.java b/src/test/java/org/jabref/logic/net/MimeTypeDetectorTest.java
deleted file mode 100644
index 225808a91ee..00000000000
--- a/src/test/java/org/jabref/logic/net/MimeTypeDetectorTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package org.jabref.logic.net;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.any;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.head;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class MimeTypeDetectorTest {
-
- @Rule public WireMockRule wireMockRule = new WireMockRule();
-
- @Test
- public void handlePermanentRedirections() throws IOException {
- String redirectedUrl = "http://localhost:8080/redirection";
-
- stubFor(any(urlEqualTo("/redirection"))
- .willReturn(
- aResponse()
- .withStatus(301)
- .withHeader("Location", "http://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.pdf")
- )
- );
-
- assertTrue(new URLDownload(redirectedUrl).isMimeType("application/pdf"));
- }
-
- @Test
- public void beFalseForUnreachableUrl() throws IOException {
- String invalidUrl = "http://idontknowthisurlforsure.de";
- assertFalse(new URLDownload(invalidUrl).isMimeType("application/pdf"));
- }
-
- @Test
- public void beTrueForPdfMimeType() throws IOException {
- String pdfUrl = "http://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.pdf";
- assertTrue(new URLDownload(pdfUrl).isMimeType("application/pdf"));
- }
-
- @Test
- public void beTrueForLocalPdfUri() throws URISyntaxException, IOException {
- String localPath = MimeTypeDetectorTest.class.getResource("empty.pdf").toURI().toASCIIString();
- assertTrue(new URLDownload(localPath).isMimeType("application/pdf"));
- }
-
- @Test
- public void beTrueForPDFMimeTypeVariations() throws IOException {
- String mimeTypeVariation = "http://localhost:8080/mimevariation";
-
- stubFor(any(urlEqualTo("/mimevariation"))
- .willReturn(
- aResponse().withHeader("Content-Type", "application/pdf;charset=ISO-8859-1")
- )
- );
-
- assertTrue(new URLDownload(mimeTypeVariation).isMimeType("application/pdf"));
- }
-
- @Test
- public void beAbleToUseHeadRequest() throws IOException {
- String mimeTypeVariation = "http://localhost:8080/mimevariation";
-
- stubFor(head(urlEqualTo("/mimevariation"))
- .willReturn(
- aResponse().withHeader("Content-Type", "application/pdf;charset=ISO-8859-1")
- )
- );
-
- assertTrue(new URLDownload(mimeTypeVariation).isMimeType("application/pdf"));
- }
-
- @Test
- public void beAbleToUseGetRequest() throws IOException {
- String mimeTypeVariation = "http://localhost:8080/mimevariation";
-
- stubFor(head(urlEqualTo("/mimevariation"))
- .willReturn(
- aResponse().withStatus(404)
- )
- );
- stubFor(get(urlEqualTo("/mimevariation"))
- .willReturn(
- aResponse().withHeader("Content-Type", "application/pdf;charset=ISO-8859-1")
- )
- );
-
- assertTrue(new URLDownload(mimeTypeVariation).isMimeType("application/pdf"));
- }
-}
diff --git a/src/test/java/org/jabref/testutils/TestUtils.java b/src/test/java/org/jabref/testutils/TestUtils.java
deleted file mode 100644
index 83120f4c62c..00000000000
--- a/src/test/java/org/jabref/testutils/TestUtils.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.jabref.testutils;
-
-import org.jabref.JabRefGUI;
-import org.jabref.JabRefMain;
-
-public class TestUtils {
-
- private static final String PATH_TO_TEST_BIBTEX = "src/test/resources/org/jabref/bibtexFiles/test.bib";
-
- /**
- * Initialize JabRef. Can be cleaned up with
- * {@link TestUtils#closeJabRef()}
- *
- * @see TestUtils#closeJabRef()
- */
- public static void initJabRef() {
- String[] args = {"-p", " ", TestUtils.PATH_TO_TEST_BIBTEX};
- JabRefMain.main(args);
- }
-
- /**
- * Closes the current instance of JabRef.
- */
- public static void closeJabRef() {
- if (JabRefGUI.getMainFrame() != null) {
- }
- }
-
-}
diff --git a/src/test/resources/log4j2-test.xml b/src/test/resources/log4j2-test.xml
new file mode 100644
index 00000000000..0422d0bd80d
--- /dev/null
+++ b/src/test/resources/log4j2-test.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/org/jabref/model/entry/FileFieldBibEntryTest.java b/src/test/resources/org/jabref/model/entry/FileFieldBibEntryTest.java
similarity index 100%
rename from src/test/java/org/jabref/model/entry/FileFieldBibEntryTest.java
rename to src/test/resources/org/jabref/model/entry/FileFieldBibEntryTest.java
diff --git a/src/test/java/org/jabref/model/groups/TexGroupTest.java b/src/test/resources/org/jabref/model/groups/TexGroupTest.java
similarity index 100%
rename from src/test/java/org/jabref/model/groups/TexGroupTest.java
rename to src/test/resources/org/jabref/model/groups/TexGroupTest.java
diff --git a/xjc.gradle b/xjc.gradle
deleted file mode 100644
index ea33b543a03..00000000000
--- a/xjc.gradle
+++ /dev/null
@@ -1,41 +0,0 @@
-configurations {
- xjc
-}
-
-dependencies {
- // Cannot be updated.
- xjc 'com.sun.xml.bind:jaxb-xjc:2.2.4-1'
-}
-
-task xjc {
- inputs.dir "src/main/resources/xjc/medline/"
- inputs.dir "src/main/resources/xjc/bibtexml/"
- inputs.dir "src/main/resources/xjc/endnote/"
- inputs.dir "src/main/resources/xjc/mods/"
- outputs.dir "src/main/gen/org/jabref/logic/importer/fileformat/medline"
- outputs.dir "src/main/gen/org/jabref/logic/importer/fileformat/bibtexml"
- outputs.dir "src/main/gen/org/jabref/logic/importer/fileformat/endnote"
- outputs.dir "src/main/gen/org/jabref/logic/importer/fileformat/mods"
-
- ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.xjc.asPath)
-
- doLast {
- ant.xjc(destdir: 'src/main/gen/', package: 'org.jabref.logic.importer.fileformat.medline') {
- schema(dir: 'src/main/resources/xjc/medline', includes: 'medline.xsd')
- }
- ant.xjc(destdir: 'src/main/gen/', package: 'org.jabref.logic.importer.fileformat.bibtexml') {
- schema(dir: 'src/main/resources/xjc/bibtexml', includes: 'bibtexml.xsd')
- }
- ant.xjc(destdir: 'src/main/gen/', package: 'org.jabref.logic.importer.fileformat.endnote') {
- arg(value: '-dtd')
- schema(dir: 'src/main/resources/xjc/endnote', includes: 'RSXML.dtd')
- }
- ant.xjc(destdir: 'src/main/gen/', package: 'org.jabref.logic.importer.fileformat.mods') {
- arg(value: '-npa') //don't create package-info.java because it was manually added in src/main/java to ensure the namespace prefix mapping
- schema(dir: 'src/main/resources/xjc/mods', includes: 'mods-3-7.xsd')
- binding(dir: 'src/main/resources/xjc/mods', includes: 'mods-binding.xjb')
- }
- }
-}
-
-tasks.compileJava.dependsOn xjc