-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
add toggle to disable built-in journal list #15387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
477073d
94e6f92
15d763f
7d696cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ public class JournalAbbreviationsTabViewModel implements PreferenceTabViewModel | |
| private final SimpleBooleanProperty isEditableAndRemovable = new SimpleBooleanProperty(false); | ||
| private final SimpleBooleanProperty isAbbreviationEditableAndRemovable = new SimpleBooleanProperty(false); | ||
| private final SimpleBooleanProperty useFJournal = new SimpleBooleanProperty(true); | ||
| private final SimpleBooleanProperty useBuiltInList = new SimpleBooleanProperty(true); | ||
|
|
||
| private final DialogService dialogService; | ||
| private final TaskExecutor taskExecutor; | ||
|
|
@@ -107,6 +108,8 @@ public JournalAbbreviationsTabViewModel(JournalAbbreviationPreferences abbreviat | |
| public void setValues() { | ||
| journalFiles.clear(); | ||
|
|
||
| useBuiltInList.set(abbreviationsPreferences.shouldUseBuiltInList()); | ||
| useFJournal.set(abbreviationsPreferences.shouldUseFJournalField()); | ||
| createFileObjects(); | ||
| selectLastJournalFile(); | ||
| addBuiltInList(); | ||
|
Comment on lines
+111
to
115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5. Ui ignores built-in toggle JournalAbbreviationsTabViewModel.setValues always calls addBuiltInList(), so the Preferences UI will still show a “JabRef built in list” pseudo-file even when “Use JabRef built-in journal abbreviation list” is unchecked. Agent Prompt
|
||
|
|
@@ -311,6 +314,7 @@ public void storeSettings() { | |
|
|
||
| abbreviationsPreferences.setExternalJournalLists(journalStringList); | ||
| abbreviationsPreferences.setUseFJournalField(useFJournal.get()); | ||
| abbreviationsPreferences.setUseBuiltInList(useBuiltInList.get()); | ||
|
|
||
|
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
|
||
| if (shouldWriteLists) { | ||
| saveJournalAbbreviationFiles(); | ||
|
|
@@ -363,4 +367,8 @@ public SimpleBooleanProperty isFileRemovableProperty() { | |
| public SimpleBooleanProperty useFJournalProperty() { | ||
| return useFJournal; | ||
| } | ||
|
|
||
| public SimpleBooleanProperty useBuiltInListProperty() { | ||
| return useBuiltInList; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,10 @@ | |
| </Button> | ||
| </HBox> | ||
|
|
||
| <HBox alignment="CENTER_LEFT" spacing="10.0"> | ||
| <CheckBox fx:id="useBuiltInList" text="%Use JabRef built-in journal abbreviation list"/> | ||
| </HBox> | ||
|
|
||
|
Comment on lines
+85
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the two consecutive single child , |
||
| <HBox alignment="CENTER_LEFT" spacing="10.0"> | ||
| <CheckBox fx:id="useFJournal" text="%Use the field FJournal to store the full journal name for (un)abbreviations in the entry"/> | ||
| </HBox> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
|
|
||
| import org.jabref.logic.journals.ltwa.LtwaRepository; | ||
|
|
||
| import org.h2.mvstore.MVStore; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
@@ -35,23 +36,41 @@ public static Collection<Abbreviation> readAbbreviationsFromCsvFile(Path file) t | |
| public static JournalAbbreviationRepository loadRepository(JournalAbbreviationPreferences journalAbbreviationPreferences) { | ||
| JournalAbbreviationRepository repository; | ||
|
|
||
| // Initialize with built-in list | ||
| try (InputStream resourceAsStream = JournalAbbreviationRepository.class.getResourceAsStream("/journals/journal-list.mv")) { | ||
| if (resourceAsStream == null) { | ||
| LOGGER.warn("There is no journal-list.mv. We use a default journal list."); | ||
| repository = new JournalAbbreviationRepository(); | ||
| } else { | ||
| Path tempDir = Files.createTempDirectory("jabref-journal"); | ||
| Path tempJournalList = tempDir.resolve("journal-list.mv"); | ||
| Files.copy(resourceAsStream, tempJournalList); | ||
| repository = new JournalAbbreviationRepository(tempJournalList, loadLtwaRepository()); | ||
| if (!journalAbbreviationPreferences.shouldUseBuiltInList()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating an empty MVStore on disk just to get a The no arg new JournalAbbreviationRepository() is NOT a clean substitute either, it inserts a fake "Demonstration" entry and drops LTWA support. i suggested fix by adding a constructor that takes only then removes the MVStore import, temp-file dance, and the extra |
||
| LOGGER.debug("Built-in journal abbreviation list is disabled by user preference."); | ||
| try { | ||
| Path tempDir = Files.createTempDirectory("jabref-journal-empty"); | ||
| Path emptyJournalList = tempDir.resolve("journal-list.mv"); | ||
| // Write an empty MV store so the repository has no built-in entries | ||
| try (MVStore store = new MVStore.Builder() | ||
| .fileName(emptyJournalList.toAbsolutePath().toString()).open()) { | ||
| store.openMap("FullToAbbreviation"); | ||
| } | ||
| repository = new JournalAbbreviationRepository(emptyJournalList, loadLtwaRepository()); | ||
|
Comment on lines
+45
to
+49
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would want a second look on this by @koppor |
||
| tempDir.toFile().deleteOnExit(); | ||
| tempJournalList.toFile().deleteOnExit(); | ||
| LOGGER.debug("Loaded journal abbreviations from {}", tempJournalList.toAbsolutePath()); | ||
| emptyJournalList.toFile().deleteOnExit(); | ||
| } catch (IOException e) { | ||
| LOGGER.error("Error while creating empty journal abbreviation repository", e); | ||
| return null; | ||
| } | ||
|
Comment on lines
+52
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If creating the temp empty MV file fails, this returns the existing missing resource path already falls back to or better, i think it becomes unnecessary if you amke the constructor suggestion above |
||
| } else { | ||
|
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
|
||
| try (InputStream resourceAsStream = JournalAbbreviationRepository.class.getResourceAsStream("/journals/journal-list.mv")) { | ||
| if (resourceAsStream == null) { | ||
| LOGGER.warn("There is no journal-list.mv. We use a default journal list."); | ||
| repository = new JournalAbbreviationRepository(); | ||
| } else { | ||
| Path tempDir = Files.createTempDirectory("jabref-journal"); | ||
| Path tempJournalList = tempDir.resolve("journal-list.mv"); | ||
| Files.copy(resourceAsStream, tempJournalList); | ||
| repository = new JournalAbbreviationRepository(tempJournalList, loadLtwaRepository()); | ||
| tempDir.toFile().deleteOnExit(); | ||
|
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
|
||
| tempJournalList.toFile().deleteOnExit(); | ||
| LOGGER.debug("Loaded journal abbreviations from {}", tempJournalList.toAbsolutePath()); | ||
| } | ||
| } catch (IOException e) { | ||
| LOGGER.error("Error while loading journal abbreviation repository", e); | ||
| return null; | ||
| } | ||
| } catch (IOException e) { | ||
| LOGGER.error("Error while loading journal abbreviation repository", e); | ||
| return null; | ||
| } | ||
|
Comment on lines
36
to
74
|
||
|
|
||
| // Read external lists | ||
|
|
@@ -90,6 +109,6 @@ private static LtwaRepository loadLtwaRepository() throws IOException { | |
| } | ||
|
|
||
| public static JournalAbbreviationRepository loadBuiltInRepository() { | ||
| return loadRepository(new JournalAbbreviationPreferences(List.of(), true)); | ||
| return loadRepository(new JournalAbbreviationPreferences(List.of(), true, true)); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.