Skip to content

Commit bd53428

Browse files
committed
refactor: move areAnyJournalSourcesEnabled() method from AbbreviateAction.java to JournalAbbreviationPreferences.java
1 parent 50c3549 commit bd53428

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/main/java/org/jabref/gui/journals/AbbreviateAction.java

+1-26
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public AbbreviateAction(StandardActions action,
8585

8686
@Override
8787
public void execute() {
88-
if (action == StandardActions.UNABBREVIATE && !areAnyJournalSourcesEnabled()) {
88+
if (action == StandardActions.UNABBREVIATE && !journalAbbreviationPreferences.areAnyJournalSourcesEnabled()) {
8989
dialogService.notify(Localization.lang("Cannot unabbreviate: all journal lists are disabled."));
9090
return;
9191
}
@@ -307,29 +307,4 @@ private JournalAbbreviationPreferences clonePreferences() {
307307
journalAbbreviationPreferences.getEnabledExternalLists()
308308
);
309309
}
310-
311-
/**
312-
* Checks if any journal abbreviation source is enabled in the preferences.
313-
* This includes both the built-in list and any external journal lists.
314-
*
315-
* @return true if at least one source is enabled, false if all sources are disabled
316-
*/
317-
private boolean areAnyJournalSourcesEnabled() {
318-
boolean anySourceEnabled = journalAbbreviationPreferences.isSourceEnabled(JournalAbbreviationRepository.BUILTIN_LIST_ID);
319-
320-
if (!anySourceEnabled) {
321-
for (String listPath : journalAbbreviationPreferences.getExternalJournalLists()) {
322-
if (listPath != null && !listPath.isBlank()) {
323-
// Just check the filename since that's what's used as the source key
324-
String fileName = Path.of(listPath).getFileName().toString();
325-
if (journalAbbreviationPreferences.isSourceEnabled(fileName)) {
326-
anySourceEnabled = true;
327-
break;
328-
}
329-
}
330-
}
331-
}
332-
333-
return anySourceEnabled;
334-
}
335310
}

src/main/java/org/jabref/logic/journals/JournalAbbreviationPreferences.java

+25
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,29 @@ public BooleanProperty enabledListsChangedProperty() {
139139
public boolean hasExplicitEnabledSetting(String sourcePath) {
140140
return enabledExternalLists.containsKey(sourcePath);
141141
}
142+
143+
/**
144+
* Checks if any journal abbreviation source is enabled in the preferences.
145+
* This includes both the built-in list and any external journal lists.
146+
*
147+
* @return true if at least one source is enabled, false if all sources are disabled
148+
*/
149+
public boolean areAnyJournalSourcesEnabled() {
150+
boolean anySourceEnabled = isSourceEnabled(JournalAbbreviationRepository.BUILTIN_LIST_ID);
151+
152+
if (!anySourceEnabled) {
153+
for (String listPath : getExternalJournalLists()) {
154+
if (listPath != null && !listPath.isBlank()) {
155+
// Just check the filename since that's what's used as the source key
156+
String fileName = java.nio.file.Path.of(listPath).getFileName().toString();
157+
if (isSourceEnabled(fileName)) {
158+
anySourceEnabled = true;
159+
break;
160+
}
161+
}
162+
}
163+
}
164+
165+
return anySourceEnabled;
166+
}
142167
}

0 commit comments

Comments
 (0)