From 9c0fa85c4ab1653f1654427db2a41c0d166ce20a Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Fri, 6 Mar 2020 10:57:43 +0100 Subject: [PATCH] Code: Tex --> Latex (in the context of ParseLatex) (#6019) --- src/main/java/org/jabref/gui/JabRefFrame.java | 4 +- .../jabref/gui/actions/StandardActions.java | 2 +- .../LatexCitationsTabViewModel.java | 12 ++-- ...seTexAction.java => ParseLatexAction.java} | 6 +- ...seTexDialog.fxml => ParseLatexDialog.fxml} | 4 +- ...logView.java => ParseLatexDialogView.java} | 16 ++--- ...el.java => ParseLatexDialogViewModel.java} | 42 ++++++------- ...arseTexResult.css => ParseLatexResult.css} | 0 ...seTexResult.fxml => ParseLatexResult.fxml} | 2 +- ...ultView.java => ParseLatexResultView.java} | 12 ++-- ...el.java => ParseLatexResultViewModel.java} | 8 +-- ...TexParser.java => DefaultLatexParser.java} | 42 ++++++------- .../texparser/TexBibEntriesResolver.java | 16 ++--- ...ava => LatexBibEntriesResolverResult.java} | 28 ++++----- .../jabref/model/texparser/LatexParser.java | 34 +++++++++++ ...rserResult.java => LatexParserResult.java} | 8 +-- .../org/jabref/model/texparser/TexParser.java | 31 ---------- .../logic/texparser/DefaultTexParserTest.java | 60 +++++++++---------- ...exParserTest.java => LatexParserTest.java} | 36 +++++------ .../texparser/TexBibEntriesResolverTest.java | 40 ++++++------- 20 files changed, 203 insertions(+), 200 deletions(-) rename src/main/java/org/jabref/gui/texparser/{ParseTexAction.java => ParseLatexAction.java} (75%) rename src/main/java/org/jabref/gui/texparser/{ParseTexDialog.fxml => ParseLatexDialog.fxml} (92%) rename src/main/java/org/jabref/gui/texparser/{ParseTexDialogView.java => ParseLatexDialogView.java} (85%) rename src/main/java/org/jabref/gui/texparser/{ParseTexDialogViewModel.java => ParseLatexDialogViewModel.java} (84%) rename src/main/java/org/jabref/gui/texparser/{ParseTexResult.css => ParseLatexResult.css} (100%) rename src/main/java/org/jabref/gui/texparser/{ParseTexResult.fxml => ParseLatexResult.fxml} (92%) rename src/main/java/org/jabref/gui/texparser/{ParseTexResultView.java => ParseLatexResultView.java} (83%) rename src/main/java/org/jabref/gui/texparser/{ParseTexResultViewModel.java => ParseLatexResultViewModel.java} (89%) rename src/main/java/org/jabref/logic/texparser/{DefaultTexParser.java => DefaultLatexParser.java} (83%) rename src/main/java/org/jabref/model/texparser/{TexBibEntriesResolverResult.java => LatexBibEntriesResolverResult.java} (58%) create mode 100644 src/main/java/org/jabref/model/texparser/LatexParser.java rename src/main/java/org/jabref/model/texparser/{TexParserResult.java => LatexParserResult.java} (96%) delete mode 100644 src/main/java/org/jabref/model/texparser/TexParser.java rename src/test/java/org/jabref/logic/texparser/{TexParserTest.java => LatexParserTest.java} (78%) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index c7bc0a63088..696c8e1fd4a 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -98,7 +98,7 @@ import org.jabref.gui.search.GlobalSearchBar; import org.jabref.gui.shared.ConnectToSharedDatabaseCommand; import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory; -import org.jabref.gui.texparser.ParseTexAction; +import org.jabref.gui.texparser.ParseLatexAction; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.DefaultTaskExecutor; @@ -786,7 +786,7 @@ private MenuBar createMenu() { pushToApplicationsManager.setMenuItem(pushToApplicationMenuItem); tools.getItems().addAll( - factory.createMenuItem(StandardActions.PARSE_TEX, new ParseTexAction(stateManager)), + factory.createMenuItem(StandardActions.PARSE_LATEX, new ParseLatexAction(stateManager)), factory.createMenuItem(StandardActions.NEW_SUB_LIBRARY_FROM_AUX, new NewSubLibraryAction(this, stateManager)), new SeparatorMenuItem(), diff --git a/src/main/java/org/jabref/gui/actions/StandardActions.java b/src/main/java/org/jabref/gui/actions/StandardActions.java index 930d710a495..b06d2e8d037 100644 --- a/src/main/java/org/jabref/gui/actions/StandardActions.java +++ b/src/main/java/org/jabref/gui/actions/StandardActions.java @@ -86,7 +86,7 @@ public enum StandardActions implements Action { TOOGLE_OO(Localization.lang("OpenOffice/LibreOffice"), IconTheme.JabRefIcons.FILE_OPENOFFICE, KeyBinding.OPEN_OPEN_OFFICE_LIBRE_OFFICE_CONNECTION), TOGGLE_WEB_SEARCH(Localization.lang("Web search"), Localization.lang("Toggle web search interface"), IconTheme.JabRefIcons.WWW, KeyBinding.WEB_SEARCH), - PARSE_TEX(Localization.lang("Search for citations in LaTeX files..."), IconTheme.JabRefIcons.LATEX_CITATIONS), + PARSE_LATEX(Localization.lang("Search for citations in LaTeX files..."), IconTheme.JabRefIcons.LATEX_CITATIONS), NEW_SUB_LIBRARY_FROM_AUX(Localization.lang("New sublibrary based on AUX file") + "...", Localization.lang("New BibTeX sublibrary") + Localization.lang("This feature generates a new library based on which entries are needed in an existing LaTeX document."), IconTheme.JabRefIcons.NEW), WRITE_XMP(Localization.lang("Write XMP metadata to PDFs"), Localization.lang("Will write XMP metadata to the PDFs linked from selected entries."), KeyBinding.WRITE_XMP), OPEN_FOLDER(Localization.lang("Open folder"), Localization.lang("Open folder"), KeyBinding.OPEN_FOLDER), diff --git a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java index 13546cbc64e..5bda2a4c3c0 100644 --- a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java +++ b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java @@ -26,11 +26,11 @@ import org.jabref.gui.util.DirectoryDialogConfiguration; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; -import org.jabref.logic.texparser.DefaultTexParser; +import org.jabref.logic.texparser.DefaultLatexParser; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.texparser.Citation; -import org.jabref.model.texparser.TexParserResult; +import org.jabref.model.texparser.LatexParserResult; import org.jabref.preferences.PreferencesService; import org.slf4j.Logger; @@ -56,7 +56,7 @@ enum Status { private final ObjectProperty status; private final StringProperty searchError; private Future searchTask; - private TexParserResult texParserResult; + private LatexParserResult latexParserResult; private BibEntry currentEntry; public LatexCitationsTabViewModel(BibDatabaseContext databaseContext, PreferencesService preferencesService, @@ -129,7 +129,7 @@ private Collection searchAndParse(String citeKey) throws IOException { Path newDirectory = databaseContext.getMetaData().getLatexFileDirectory(preferencesService.getUser()) .orElseGet(preferencesService::getWorkingDir); - if (texParserResult == null || !newDirectory.equals(directory.get())) { + if (latexParserResult == null || !newDirectory.equals(directory.get())) { directory.set(newDirectory); if (!newDirectory.toFile().exists()) { @@ -137,10 +137,10 @@ private Collection searchAndParse(String citeKey) throws IOException { } List texFiles = searchDirectory(newDirectory, new ArrayList<>()); - texParserResult = new DefaultTexParser().parse(texFiles); + latexParserResult = new DefaultLatexParser().parse(texFiles); } - return texParserResult.getCitationsByKey(citeKey); + return latexParserResult.getCitationsByKey(citeKey); } private List searchDirectory(Path directory, List texFiles) { diff --git a/src/main/java/org/jabref/gui/texparser/ParseTexAction.java b/src/main/java/org/jabref/gui/texparser/ParseLatexAction.java similarity index 75% rename from src/main/java/org/jabref/gui/texparser/ParseTexAction.java rename to src/main/java/org/jabref/gui/texparser/ParseLatexAction.java index 215711e2f27..1c5a2bc8274 100644 --- a/src/main/java/org/jabref/gui/texparser/ParseTexAction.java +++ b/src/main/java/org/jabref/gui/texparser/ParseLatexAction.java @@ -5,11 +5,11 @@ import org.jabref.gui.actions.SimpleCommand; import org.jabref.model.database.BibDatabaseContext; -public class ParseTexAction extends SimpleCommand { +public class ParseLatexAction extends SimpleCommand { private final StateManager stateManager; - public ParseTexAction(StateManager stateManager) { + public ParseLatexAction(StateManager stateManager) { this.stateManager = stateManager; executable.bind(ActionHelper.needsDatabase(stateManager)); } @@ -17,7 +17,7 @@ public ParseTexAction(StateManager stateManager) { @Override public void execute() { BibDatabaseContext database = stateManager.getActiveDatabase().orElseThrow(NullPointerException::new); - ParseTexDialogView dialog = new ParseTexDialogView(database); + ParseLatexDialogView dialog = new ParseLatexDialogView(database); dialog.showAndWait(); } } diff --git a/src/main/java/org/jabref/gui/texparser/ParseTexDialog.fxml b/src/main/java/org/jabref/gui/texparser/ParseLatexDialog.fxml similarity index 92% rename from src/main/java/org/jabref/gui/texparser/ParseTexDialog.fxml rename to src/main/java/org/jabref/gui/texparser/ParseLatexDialog.fxml index 956d744f5ad..05f86c531ed 100644 --- a/src/main/java/org/jabref/gui/texparser/ParseTexDialog.fxml +++ b/src/main/java/org/jabref/gui/texparser/ParseLatexDialog.fxml @@ -10,14 +10,14 @@