Skip to content

Moved Journal Abbreviation from Quality Menu to Cleanup Entries Dialog #12835

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

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
51680e5
Added AbbreviateJournalDefaultCleanup class to mimic default abbrevia…
GDeane Mar 21, 2025
be544f8
Passed down journalAbbreviationPreferences from MainMenu down to inst…
GDeane Mar 21, 2025
f8eb65f
Added BibDatabase field to AbbreviateJournalDefaultCleanup and create…
GDeane Mar 21, 2025
7baced3
Added more tests for AbbreviateJournalDefaultCleanup
GDeane Mar 21, 2025
5dd9fc7
Modified AbbreviateJournalCleanup to take a parameter (allowing for d…
GDeane Mar 21, 2025
0667f84
Added some more tests
GDeane Mar 21, 2025
1c5f877
Added cases in CleanupWorker for new instances of Cleanup classes to …
GDeane Mar 21, 2025
d8c2ee2
Created draft file for UnabbreviateJournalCleanup
GDeane Mar 21, 2025
f74a012
Added UI ComboBox for Journal-Related Cleanups and linked it to the A…
GDeane Mar 21, 2025
210d8e4
Made no changes the default in the JournalCleanupSelector
GDeane Mar 21, 2025
d89ed30
Fixed and added tests for UnabbreviateJournalCleanup. It should now m…
GDeane Mar 21, 2025
60f8fcf
Stripping out everything related to previous AbbreviateAction functio…
GDeane Mar 21, 2025
8266d20
saving journal abbreviation preferences across sessions (currently no…
jennifervlaar Mar 24, 2025
d6017ec
Fixed journal abbreviation preferences properly show up as a nice str…
GDeane Mar 24, 2025
8dfeab3
Deleted commented-out keybinding for abbreviate
GDeane Mar 24, 2025
c43ea4a
Modified tests that used needed an arbitrary KeyBinding and used KeyB…
GDeane Mar 24, 2025
ec8f98f
Merge branch 'JabRef:main' into gavin-jenny-logic-fix
GDeane Mar 25, 2025
56b2908
Modified JournalAbbreviationRepositoryTest to use AbbreviateJournalCl…
GDeane Mar 26, 2025
78a5816
Made sure No changes shows up first as a default in the Combobox menu…
GDeane Mar 26, 2025
7eed556
Merge branch 'JabRef:main' into gavin-jenny-logic-fix
GDeane Mar 26, 2025
d12c490
Updated CHANGELOG.md to include new change
GDeane Mar 26, 2025
018e5b0
Merge remote-tracking branch 'origin/gavin-jenny-logic-fix' into gavi…
GDeane Mar 26, 2025
7e84c38
Merge branch 'JabRef:main' into gavin-jenny-logic-fix
VShawFluenta Mar 28, 2025
2565b65
Update cleanup logic for failfast and exception handling
Mar 28, 2025
fd2b155
Update checkstyle
Mar 28, 2025
b99c751
Fixed tests from lines 40s to 177 in UnabbreviateJournalCleanupTest
VShawFluenta Mar 28, 2025
15ea2e2
Merge remote-tracking branch 'origin/gavin-jenny-logic-fix' into gavi…
VShawFluenta Mar 28, 2025
407d840
Merge branch 'JabRef:main' into gavin-jenny-logic-fix
GDeane Mar 29, 2025
5cd214d
Added/refactored string constants rather than hard-coding strings
GDeane Mar 30, 2025
2bfefc1
Cleaned up AbbreviateJournalCleanupTest and UnabbreviateJournalCleanu…
GDeane Mar 30, 2025
212d94f
Fixed UnabbreviateJournalCleanup so that Unabbreviate properly stores…
GDeane Mar 30, 2025
926b8ad
Merge branch 'main' into gavin-jenny-logic-fix
GDeane Mar 30, 2025
693d5e8
Removed logging, since abbreviationType is an enum and I didn't want …
GDeane Mar 30, 2025
ce77de5
Ran rewriteRun
GDeane Mar 30, 2025
544f5ae
Moved AbbreviationType into the logic package to respect layered arch…
GDeane Mar 30, 2025
e4aea43
Fixed up checkstyle
GDeane Mar 30, 2025
0e2e09d
Fixed obselete keys and missing keys in language file
GDeane Mar 30, 2025
2387693
Removed remaining 2 obselete keys
GDeane Mar 30, 2025
9f0d9a6
Merge branch 'JabRef:main' into gavin-jenny-logic-fix
colinseifert Mar 31, 2025
88bd504
Merge branch 'main' into gavin-jenny-logic-fix
GDeane Apr 1, 2025
d3e575b
Merge branch 'JabRef:main' into gavin-jenny-logic-fix
colinseifert Apr 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

- Added "$" to the citation key generator preferences default list of characters to remove [#12536](https://github.com/JabRef/jabref/issues/12536)
- We changed the message displayed in the Integrity Check Progress dialog to "Waiting for the check to finish...". [#12694](https://github.com/JabRef/jabref/issues/12694)
- We moved journal abbreviation from the Quality menu to the cleanup entries dialog [#11791](https://github.com/JabRef/jabref/issues/11791)
- We moved the "Generate a new key for imported entries" option from the "Web search" tab to the "Citation key generator" tab in preferences. [#12436](https://github.com/JabRef/jabref/pull/12436)
- We improved the offline parsing of BibTeX data from PDF-documents. [#12278](https://github.com/JabRef/jabref/issues/12278)
- The tab bar is now hidden when only one library is open. [#9971](https://github.com/JabRef/jabref/issues/9971)
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/jabref/gui/actions/StandardActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ public enum StandardActions implements Action {
COPY_LINKED_FILES(Localization.lang("Copy linked files to folder...")),
COPY_DOI(Localization.lang("Copy DOI")),
COPY_DOI_URL(Localization.lang("Copy DOI url")),
ABBREVIATE(Localization.lang("Abbreviate journal names")),
ABBREVIATE_DEFAULT(Localization.lang("default"), Localization.lang("Abbreviate journal names of the selected entries (DEFAULT abbreviation)"), KeyBinding.ABBREVIATE),
ABBREVIATE_DOTLESS(Localization.lang("dotless"), Localization.lang("Abbreviate journal names of the selected entries (DOTLESS abbreviation)")),
ABBREVIATE_SHORTEST_UNIQUE(Localization.lang("shortest unique"), Localization.lang("Abbreviate journal names of the selected entries (SHORTEST UNIQUE abbreviation)")),
UNABBREVIATE(Localization.lang("Unabbreviate journal names"), Localization.lang("Unabbreviate journal names of the selected entries"), KeyBinding.UNABBREVIATE),

MANAGE_CUSTOM_EXPORTS(Localization.lang("Manage custom exports")),
MANAGE_CUSTOM_IMPORTS(Localization.lang("Manage custom imports")),
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/jabref/gui/cleanup/CleanupAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jabref.logic.JabRefException;
import org.jabref.logic.cleanup.CleanupPreferences;
import org.jabref.logic.cleanup.CleanupWorker;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.preferences.CliPreferences;
import org.jabref.logic.util.BackgroundTask;
Expand All @@ -36,6 +37,7 @@ public class CleanupAction extends SimpleCommand {
private final StateManager stateManager;
private final TaskExecutor taskExecutor;
private final UndoManager undoManager;
private final JournalAbbreviationRepository abbreviationRepository;
private final List<JabRefException> failures;

private boolean isCanceled;
Expand All @@ -46,13 +48,15 @@ public CleanupAction(Supplier<LibraryTab> tabSupplier,
DialogService dialogService,
StateManager stateManager,
TaskExecutor taskExecutor,
UndoManager undoManager) {
UndoManager undoManager,
JournalAbbreviationRepository abbreviationRepository) {
this.tabSupplier = tabSupplier;
this.preferences = preferences;
this.dialogService = dialogService;
this.stateManager = stateManager;
this.taskExecutor = taskExecutor;
this.undoManager = undoManager;
this.abbreviationRepository = abbreviationRepository;
this.failures = new ArrayList<>();

this.executable.bind(ActionHelper.needsEntriesSelected(stateManager));
Expand Down Expand Up @@ -114,7 +118,9 @@ private boolean doCleanup(BibDatabaseContext databaseContext, CleanupPreferences
CleanupWorker cleaner = new CleanupWorker(
databaseContext,
preferences.getFilePreferences(),
preferences.getTimestampPreferences()
preferences.getTimestampPreferences(),
preferences.getJournalAbbreviationPreferences().shouldUseFJournalField(),
abbreviationRepository
);

List<FieldChange> changes = cleaner.cleanup(preset, entry);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.VBox?>
Expand Down Expand Up @@ -44,6 +45,14 @@
</VBox.margin>
</VBox>
<CheckBox fx:id="cleanUpDeletedFiles" text="Remove links to non existent files" />
</VBox>
<Label text="%Journal-related" />
<VBox>
<VBox.margin>
<Insets left="20.0" />
</VBox.margin>
<Label text="Choose how to handle journal names:" />
<ComboBox fx:id="journalCleanupSelector" />
</VBox>
<FieldFormatterCleanupsPanel fx:id="formatterCleanupsPanel" />
<padding>
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;

Expand All @@ -22,7 +23,6 @@
import com.airhacks.afterburner.views.ViewLoader;

public class CleanupPresetPanel extends VBox {

private final BibDatabaseContext databaseContext;
@FXML private Label cleanupRenamePDFLabel;
@FXML private CheckBox cleanUpDOI;
Expand All @@ -39,6 +39,7 @@ public class CleanupPresetPanel extends VBox {
@FXML private CheckBox cleanUpBibtex;
@FXML private CheckBox cleanUpTimestampToCreationDate;
@FXML private CheckBox cleanUpTimestampToModificationDate;
@FXML private ComboBox<String> journalCleanupSelector;
@FXML private FieldFormatterCleanupsPanel formatterCleanupsPanel;

public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreferences cleanupPreferences, FilePreferences filePreferences) {
Expand Down Expand Up @@ -96,6 +97,14 @@ private void init(CleanupPreferences cleanupPreferences, FilePreferences filePre
cleanUpTimestampToCreationDate.selectedProperty().setValue(false);
}
});
journalCleanupSelector.setItems(FXCollections.observableArrayList(
CleanupPreferences.JOURNAL_CLEANUP_ABBREVIATE_DEFAULT,
CleanupPreferences.JOURNAL_CLEANUP_ABBREVIATE_DOTLESS,
CleanupPreferences.JOURNAL_CLEANUP_ABBREVIATE_SHORTEST_UNIQUE,
CleanupPreferences.JOURNAL_CLEANUP_UNABBREVIATE,
CleanupPreferences.JOURNAL_CLEANUP_NO_CHANGES
));
journalCleanupSelector.getSelectionModel().select(CleanupPreferences.JOURNAL_CLEANUP_NO_CHANGES);
updateDisplay(cleanupPreferences);
}

Expand All @@ -117,6 +126,8 @@ private void updateDisplay(CleanupPreferences preset) {
cleanUpTimestampToModificationDate.setSelected(preset.isActive(CleanupPreferences.CleanupStep.CONVERT_TIMESTAMP_TO_MODIFICATIONDATE));
cleanUpTimestampToModificationDate.setSelected(preset.isActive(CleanupPreferences.CleanupStep.DO_NOT_CONVERT_TIMESTAMP));
cleanUpISSN.setSelected(preset.isActive(CleanupPreferences.CleanupStep.CLEAN_UP_ISSN));
journalCleanupSelector.getSelectionModel().select(preset.getSelectedJournalCleanupOption());

formatterCleanupsPanel.cleanupsDisableProperty().setValue(!preset.getFieldFormatterCleanups().isEnabled());
formatterCleanupsPanel.cleanupsProperty().setValue(FXCollections.observableArrayList(preset.getFieldFormatterCleanups().getConfiguredActions()));
}
Expand Down Expand Up @@ -167,6 +178,16 @@ public CleanupPreferences getCleanupPreset() {
if (cleanUpTimestampToModificationDate.isSelected()) {
activeJobs.add(CleanupPreferences.CleanupStep.CONVERT_TIMESTAMP_TO_MODIFICATIONDATE);
}
String selectedJournalOption = journalCleanupSelector.getSelectionModel().getSelectedItem();
if (CleanupPreferences.JOURNAL_CLEANUP_ABBREVIATE_DEFAULT.equals(selectedJournalOption)) {
activeJobs.add(CleanupPreferences.CleanupStep.ABBREVIATE_DEFAULT);
} else if (CleanupPreferences.JOURNAL_CLEANUP_ABBREVIATE_DOTLESS.equals(selectedJournalOption)) {
activeJobs.add(CleanupPreferences.CleanupStep.ABBREVIATE_DOTLESS);
} else if (CleanupPreferences.JOURNAL_CLEANUP_ABBREVIATE_SHORTEST_UNIQUE.equals(selectedJournalOption)) {
activeJobs.add(CleanupPreferences.CleanupStep.ABBREVIATE_SHORTEST_UNIQUE);
} else if (CleanupPreferences.JOURNAL_CLEANUP_UNABBREVIATE.equals(selectedJournalOption)) {
activeJobs.add(CleanupPreferences.CleanupStep.UNABBREVIATE);
}

activeJobs.add(CleanupPreferences.CleanupStep.FIX_FILE_LINKS);

Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/jabref/gui/cleanup/CleanupSingleAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jabref.logic.JabRefException;
import org.jabref.logic.cleanup.CleanupPreferences;
import org.jabref.logic.cleanup.CleanupWorker;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.preferences.CliPreferences;
import org.jabref.model.FieldChange;
Expand All @@ -29,16 +30,18 @@ public class CleanupSingleAction extends SimpleCommand {
private final StateManager stateManager;
private final BibEntry entry;
private final UndoManager undoManager;
private final JournalAbbreviationRepository abbreviationRepository;

private boolean isCanceled;
private int modifiedEntriesCount;

public CleanupSingleAction(BibEntry entry, CliPreferences preferences, DialogService dialogService, StateManager stateManager, UndoManager undoManager) {
public CleanupSingleAction(BibEntry entry, CliPreferences preferences, DialogService dialogService, StateManager stateManager, UndoManager undoManager, JournalAbbreviationRepository abbreviationRepository) {
this.entry = entry;
this.preferences = preferences;
this.dialogService = dialogService;
this.stateManager = stateManager;
this.undoManager = undoManager;
this.abbreviationRepository = abbreviationRepository;

this.executable.bind(ActionHelper.needsEntriesSelected(stateManager));
}
Expand Down Expand Up @@ -84,7 +87,9 @@ private void doCleanup(BibDatabaseContext databaseContext, CleanupPreferences pr
CleanupWorker cleaner = new CleanupWorker(
databaseContext,
preferences.getFilePreferences(),
preferences.getTimestampPreferences()
preferences.getTimestampPreferences(),
preferences.getJournalAbbreviationPreferences().shouldUseFJournalField(),
abbreviationRepository
);

List<FieldChange> changes = cleaner.cleanup(preset, entry);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void generateCiteKeyButton() {

@FXML
void generateCleanupButton() {
CleanupSingleAction action = new CleanupSingleAction(getCurrentlyEditedEntry(), preferences, dialogService, stateManager, undoManager);
CleanupSingleAction action = new CleanupSingleAction(getCurrentlyEditedEntry(), preferences, dialogService, stateManager, undoManager, journalAbbreviationRepository);
action.execute();
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/frame/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ private void initLayout() {
taskExecutor,
entryTypesManager,
clipBoardManager,
undoManager);
undoManager,
Injector.instantiateModelOrService(JournalAbbreviationRepository.class));

MainMenu mainMenu = new MainMenu(
this,
Expand Down
14 changes: 2 additions & 12 deletions src/main/java/org/jabref/gui/frame/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.jabref.gui.importer.actions.OpenDatabaseAction;
import org.jabref.gui.importer.fetcher.LookupIdentifierAction;
import org.jabref.gui.integrity.IntegrityCheckAction;
import org.jabref.gui.journals.AbbreviateAction;
import org.jabref.gui.libraryproperties.LibraryPropertiesAction;
import org.jabref.gui.linkedfile.RedownloadMissingFilesAction;
import org.jabref.gui.maintable.NewLibraryFromPdfActionOffline;
Expand Down Expand Up @@ -254,20 +253,11 @@ private void createMenu() {
factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, undoManager, preferences)),
factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, (UiTaskExecutor) taskExecutor, abbreviationRepository)),
factory.createMenuItem(StandardActions.CHECK_CONSISTENCY, new ConsistencyCheckAction(frame::getCurrentLibraryTab, dialogService, stateManager, preferences, entryTypesManager, (UiTaskExecutor) taskExecutor)),
factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new CleanupAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, taskExecutor, undoManager)),
factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new CleanupAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, taskExecutor, undoManager, abbreviationRepository)),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.SET_FILE_LINKS, new AutoLinkFilesAction(dialogService, preferences, stateManager, undoManager, (UiTaskExecutor) taskExecutor)),

new SeparatorMenuItem(),

factory.createSubMenu(StandardActions.ABBREVIATE,
factory.createMenuItem(StandardActions.ABBREVIATE_DEFAULT, new AbbreviateAction(StandardActions.ABBREVIATE_DEFAULT, frame::getCurrentLibraryTab, dialogService, stateManager, preferences.getJournalAbbreviationPreferences(), abbreviationRepository, taskExecutor, undoManager)),
factory.createMenuItem(StandardActions.ABBREVIATE_DOTLESS, new AbbreviateAction(StandardActions.ABBREVIATE_DOTLESS, frame::getCurrentLibraryTab, dialogService, stateManager, preferences.getJournalAbbreviationPreferences(), abbreviationRepository, taskExecutor, undoManager)),
factory.createMenuItem(StandardActions.ABBREVIATE_SHORTEST_UNIQUE, new AbbreviateAction(StandardActions.ABBREVIATE_SHORTEST_UNIQUE, frame::getCurrentLibraryTab, dialogService, stateManager, preferences.getJournalAbbreviationPreferences(), abbreviationRepository, taskExecutor, undoManager))),

factory.createMenuItem(StandardActions.UNABBREVIATE, new AbbreviateAction(StandardActions.UNABBREVIATE, frame::getCurrentLibraryTab, dialogService, stateManager, preferences.getJournalAbbreviationPreferences(), abbreviationRepository, taskExecutor, undoManager))
factory.createMenuItem(StandardActions.SET_FILE_LINKS, new AutoLinkFilesAction(dialogService, preferences, stateManager, undoManager, (UiTaskExecutor) taskExecutor))
);

Menu lookupIdentifiers = factory.createSubMenu(StandardActions.LOOKUP_DOC_IDENTIFIER);
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/jabref/gui/frame/MainToolBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.jabref.gui.undo.RedoAction;
import org.jabref.gui.undo.UndoAction;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.entry.BibEntryTypesManager;
Expand All @@ -63,6 +64,7 @@ public class MainToolBar extends ToolBar {
private final BibEntryTypesManager entryTypesManager;
private final ClipBoardManager clipBoardManager;
private final CountingUndoManager undoManager;
private final JournalAbbreviationRepository abbreviationRepository;

private PopOver entryFromIdPopOver;
private PopOver progressViewPopOver;
Expand All @@ -79,7 +81,8 @@ public MainToolBar(LibraryTabContainer tabContainer,
TaskExecutor taskExecutor,
BibEntryTypesManager entryTypesManager,
ClipBoardManager clipBoardManager,
CountingUndoManager undoManager) {
CountingUndoManager undoManager,
JournalAbbreviationRepository abbreviationRepository) {
this.frame = tabContainer;
this.pushToApplicationCommand = pushToApplicationCommand;
this.globalSearchBar = globalSearchBar;
Expand All @@ -92,6 +95,7 @@ public MainToolBar(LibraryTabContainer tabContainer,
this.entryTypesManager = entryTypesManager;
this.clipBoardManager = clipBoardManager;
this.undoManager = undoManager;
this.abbreviationRepository = abbreviationRepository;

createToolBar();
}
Expand Down Expand Up @@ -140,7 +144,7 @@ private void createToolBar() {
new HBox(
pushToApplicationButton,
factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new GenerateCitationKeyAction(frame::getCurrentLibraryTab, dialogService, stateManager, taskExecutor, preferences, undoManager)),
factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new CleanupAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, taskExecutor, undoManager))),
factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new CleanupAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, taskExecutor, undoManager, abbreviationRepository))),

new Separator(Orientation.VERTICAL),

Expand Down
Loading