Skip to content

Commit e94df5e

Browse files
committed
Merge remote-tracking branch 'origin/main' into LSP-add-features
2 parents df0a512 + 768c86a commit e94df5e

File tree

92 files changed

+1319
-689
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1319
-689
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
1212
### Added
1313

1414
- We added the option to enable the language server in the preferences. [#13697](https://github.com/JabRef/jabref/pull/13697)
15+
- We introduced an option in Preferences under (under Linked files -> Linked file name conventions) to automatically rename linked files when an entry data changes. [#11316](https://github.com/JabRef/jabref/issues/11316)
1516
- We added tooltips (on hover) for 'Library-specific file directory', 'User-specific file directory' and 'LaTeX file directory' fields of the library properties window. [#12269](https://github.com/JabRef/jabref/issues/12269)
1617
- A space is now added by default after citations inserted via the Libre/OpenOffice integration. [#13559](https://github.com/JabRef/jabref/issues/13559)
1718
- We added the option to configure 'Add space after citation' in Libre/OpenOffice panel settings. [#13559](https://github.com/JabRef/jabref/issues/13559)
@@ -78,12 +79,14 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
7879
- We introduced walkthrough functionality [#12664](https://github.com/JabRef/jabref/issues/12664)
7980
- The Welcome tab now has a responsive layout. [#12664](https://github.com/JabRef/jabref/issues/12664)
8081
- We introduced a donation prompt in the Welcome tab. [#12664](https://github.com/JabRef/jabref/issues/12664)
82+
- We changed to syntax for the websearch to the one of the main search bar. [#13607](https://github.com/JabRef/jabref/issues/13607)
8183

8284
### Fixed
8385

8486
- We fixed an issue where "Specify Bib(La)TeX" tab was not focused when Bib(La)TeX was in the clipboard [#13597](https://github.com/JabRef/jabref/issues/13597)
8587
- We fixed an issue whereby the 'About' dialog was not honouring the user's configured font preferences. [#13558](https://github.com/JabRef/jabref/issues/13558)
8688
- We fixed an issue where the Pagetotal column was sorting the values alphabetically instead of numerically. [#12533](https://github.com/JabRef/jabref/issues/12533)
89+
- We fixed an issue where URLs starting with "www." (without a protocol) in file fields caused an `IllegalArgumentException: URI is not absolute` error. [#12186](https://github.com/JabRef/jabref/issues/12186)
8790
- We fixed the dark mode of the BibTeX Source dialog in the Citation Relations tab. [#13599](https://github.com/JabRef/jabref/issues/13599)
8891
- We fixed an issue where the LibreOffice integration did not support citation keys containing Unicode characters. [#13301](https://github.com/JabRef/jabref/issues/13301)
8992
- We fixed an issue where the "Search ShortScience" action did not convert LaTeX-formatted titles to Unicode. [#13418](https://github.com/JabRef/jabref/issues/13418)

jabgui/src/main/java/org/jabref/gui/LibraryTab.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.jabref.gui.collab.DatabaseChangeMonitor;
4444
import org.jabref.gui.dialogs.AutosaveUiManager;
4545
import org.jabref.gui.exporter.SaveDatabaseAction;
46+
import org.jabref.gui.externalfiles.AutoRenameFileOnEntryChange;
4647
import org.jabref.gui.externalfiles.ImportHandler;
4748
import org.jabref.gui.fieldeditors.LinkedFileViewModel;
4849
import org.jabref.gui.importer.actions.OpenDatabaseAction;
@@ -128,6 +129,7 @@ public class LibraryTab extends Tab implements CommandSelectionTab {
128129
private FileAnnotationCache annotationCache;
129130
private MainTable mainTable;
130131
private DatabaseNotification databaseNotificationPane;
132+
private AutoRenameFileOnEntryChange autoRenameFileOnEntryChange;
131133

132134
// Indicates whether the tab is loading data using a dataloading task
133135
// The constructors take care to the right true/false assignment during start.
@@ -244,6 +246,9 @@ private void initializeComponentsAndListeners(boolean isDummyContext) {
244246

245247
this.getDatabase().registerListener(new UpdateTimestampListener(preferences));
246248

249+
autoRenameFileOnEntryChange = new AutoRenameFileOnEntryChange(bibDatabaseContext, preferences.getFilePreferences());
250+
coarseChangeFilter.registerListener(autoRenameFileOnEntryChange);
251+
247252
aiService.setupDatabase(bibDatabaseContext);
248253

249254
Platform.runLater(() -> {
@@ -717,6 +722,10 @@ private void onClosed(Event event) {
717722
tableModel.unbind();
718723
}
719724

725+
if (autoRenameFileOnEntryChange != null) {
726+
coarseChangeFilter.unregisterListener(autoRenameFileOnEntryChange);
727+
}
728+
720729
// clean up the groups map
721730
stateManager.clearSelectedGroups(bibDatabaseContext);
722731
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.jabref.gui.externalfiles;
2+
3+
import org.jabref.logic.FilePreferences;
4+
import org.jabref.logic.cleanup.RenamePdfCleanup;
5+
import org.jabref.model.database.BibDatabaseContext;
6+
import org.jabref.model.entry.BibEntry;
7+
import org.jabref.model.entry.event.FieldChangedEvent;
8+
import org.jabref.model.entry.field.StandardField;
9+
10+
import com.google.common.eventbus.Subscribe;
11+
import org.slf4j.Logger;
12+
import org.slf4j.LoggerFactory;
13+
14+
public class AutoRenameFileOnEntryChange {
15+
private static final Logger LOGGER = LoggerFactory.getLogger(AutoRenameFileOnEntryChange.class);
16+
17+
private final FilePreferences filePreferences;
18+
private final RenamePdfCleanup renamePdfCleanup;
19+
20+
public AutoRenameFileOnEntryChange(BibDatabaseContext bibDatabaseContext, FilePreferences filePreferences) {
21+
this.filePreferences = filePreferences;
22+
renamePdfCleanup = new RenamePdfCleanup(false, () -> bibDatabaseContext, filePreferences);
23+
}
24+
25+
@Subscribe
26+
public void listen(FieldChangedEvent event) {
27+
if (!filePreferences.shouldAutoRenameFilesOnChange()
28+
|| filePreferences.getFileNamePattern().isEmpty()
29+
|| filePreferences.getFileNamePattern() == null) {
30+
return;
31+
}
32+
33+
if (event.getField().equals(StandardField.FILE)) {
34+
return;
35+
}
36+
37+
BibEntry entry = event.getBibEntry();
38+
LOGGER.debug("Field changed for entry {}: {}", entry.getCitationKey().orElse("defaultCitationKey"), event.getField().getName());
39+
if (entry.getFiles().isEmpty()) {
40+
return;
41+
}
42+
renamePdfCleanup.cleanup(entry);
43+
}
44+
}

jabgui/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTab.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class LinkedFilesTab extends AbstractPreferenceTabView<LinkedFilesTabView
3636
@FXML private TextField autolinkRegexKey;
3737

3838
@FXML private CheckBox fulltextIndex;
39+
@FXML private CheckBox autoRenameFilesOnChange;
3940

4041
@FXML private ComboBox<String> fileNamePattern;
4142
@FXML private TextField fileDirectoryPattern;
@@ -73,6 +74,7 @@ public void initialize() {
7374
autolinkRegexKey.textProperty().bindBidirectional(viewModel.autolinkRegexKeyProperty());
7475
autolinkRegexKey.disableProperty().bind(autolinkUseRegex.selectedProperty().not());
7576
fulltextIndex.selectedProperty().bindBidirectional(viewModel.fulltextIndexProperty());
77+
autoRenameFilesOnChange.selectedProperty().bindBidirectional(viewModel.autoRenameFilesOnChangeProperty());
7678
fileNamePattern.valueProperty().bindBidirectional(viewModel.fileNamePatternProperty());
7779
fileNamePattern.itemsProperty().bind(viewModel.defaultFileNamePatternsProperty());
7880
fileDirectoryPattern.textProperty().bindBidirectional(viewModel.fileDirectoryPatternProperty());

jabgui/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class LinkedFilesTabViewModel implements PreferenceTabViewModel {
3737
private final ListProperty<String> defaultFileNamePatternsProperty =
3838
new SimpleListProperty<>(FXCollections.observableArrayList(FilePreferences.DEFAULT_FILENAME_PATTERNS));
3939
private final BooleanProperty fulltextIndex = new SimpleBooleanProperty();
40+
private final BooleanProperty autoRenameFilesOnChangeProperty = new SimpleBooleanProperty();
4041
private final StringProperty fileNamePatternProperty = new SimpleStringProperty();
4142
private final StringProperty fileDirectoryPatternProperty = new SimpleStringProperty();
4243
private final BooleanProperty confirmLinkedFileDeleteProperty = new SimpleBooleanProperty();
@@ -82,6 +83,7 @@ public void setValues() {
8283
useMainFileDirectoryProperty.setValue(!filePreferences.shouldStoreFilesRelativeToBibFile());
8384
useBibLocationAsPrimaryProperty.setValue(filePreferences.shouldStoreFilesRelativeToBibFile());
8485
fulltextIndex.setValue(filePreferences.shouldFulltextIndexLinkedFiles());
86+
autoRenameFilesOnChangeProperty.setValue(filePreferences.shouldAutoRenameFilesOnChange());
8587
fileNamePatternProperty.setValue(filePreferences.getFileNamePattern());
8688
fileDirectoryPatternProperty.setValue(filePreferences.getFileDirectoryPattern());
8789
confirmLinkedFileDeleteProperty.setValue(filePreferences.confirmDeleteLinkedFile());
@@ -104,6 +106,7 @@ public void storeSettings() {
104106
// External files preferences / Attached files preferences / File preferences
105107
filePreferences.setMainFileDirectory(mainFileDirectoryProperty.getValue());
106108
filePreferences.setStoreFilesRelativeToBibFile(useBibLocationAsPrimaryProperty.getValue());
109+
filePreferences.setAutoRenameFilesOnChange(autoRenameFilesOnChangeProperty.getValue());
107110
filePreferences.setFileNamePattern(fileNamePatternProperty.getValue());
108111
filePreferences.setFileDirectoryPattern(fileDirectoryPatternProperty.getValue());
109112
filePreferences.setFulltextIndexLinkedFiles(fulltextIndex.getValue());
@@ -179,6 +182,10 @@ public ListProperty<String> defaultFileNamePatternsProperty() {
179182
return defaultFileNamePatternsProperty;
180183
}
181184

185+
public BooleanProperty autoRenameFilesOnChangeProperty() {
186+
return autoRenameFilesOnChangeProperty;
187+
}
188+
182189
public StringProperty fileNamePatternProperty() {
183190
return fileNamePatternProperty;
184191
}

jabgui/src/main/java/org/jabref/gui/walkthrough/WalkthroughAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private Walkthrough createGroupWalkthrough() {
314314
new WindowEffect(HighlightEffect.PING),
315315
new WindowEffect(mainResolver, HighlightEffect.FULL_SCREEN_DARKEN)
316316
);
317-
String groupName = Localization.lang("Research Papers");
317+
String groupName = Localization.lang("Research");
318318
String addGroup = Localization.lang("Add group");
319319
String addSelectedEntries = Localization.lang("Add selected entries to this group");
320320

jabgui/src/main/java/org/jabref/gui/walkthrough/WalkthroughOverlay.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public class WalkthroughOverlay {
3535
private final Map<Window, WindowOverlay> overlays = new HashMap<>();
3636
private final Stage stage;
3737
private final Walkthrough walkthrough;
38-
private final WalkthroughHighlighter walkthroughHighlighter;
39-
private final WalkthroughReverter walkthroughReverter;
38+
private final WalkthroughHighlighter highlighter;
39+
private final WalkthroughReverter reverter;
4040
private final SideEffectExecutor sideEffectExecutor;
4141

4242
private @Nullable WalkthroughScroller scroller;
@@ -48,10 +48,10 @@ public class WalkthroughOverlay {
4848
public WalkthroughOverlay(Stage stage, Walkthrough walkthrough) {
4949
this.stage = stage;
5050
this.walkthrough = walkthrough;
51-
this.walkthroughHighlighter = new WalkthroughHighlighter();
51+
this.highlighter = new WalkthroughHighlighter();
52+
this.highlighter.setOnBackgroundClick(this::showQuitConfirmationAndQuit);
5253
this.sideEffectExecutor = new SideEffectExecutor();
53-
this.walkthroughReverter = new WalkthroughReverter(walkthrough, stage, sideEffectExecutor);
54-
this.walkthroughHighlighter.setOnBackgroundClick(this::showQuitConfirmationAndQuit);
54+
this.reverter = new WalkthroughReverter(walkthrough, stage, sideEffectExecutor);
5555
}
5656

5757
public void show(@NonNull WalkthroughStep step) {
@@ -67,7 +67,7 @@ case SideEffect(String title, WalkthroughSideEffect sideEffect) -> {
6767
} else {
6868
LOGGER.error("Failed to execute side effect: {}", sideEffect.description());
6969
LOGGER.warn("Side effect failed for step: {}", title);
70-
revertToPreviousStep();
70+
reverter.findAndUndo();
7171
}
7272
}
7373
case VisibleComponent component -> {
@@ -83,8 +83,8 @@ case SideEffect(String title, WalkthroughSideEffect sideEffect) -> {
8383

8484
public void detachAll() {
8585
cleanUp();
86-
walkthroughReverter.revertAll();
87-
walkthroughHighlighter.detachAll();
86+
reverter.revertAll();
87+
highlighter.detachAll();
8888
overlays.values().forEach(WindowOverlay::detach);
8989
overlays.clear();
9090
}
@@ -114,7 +114,7 @@ private void handleResolutionResult(WalkthroughResult result) {
114114
displayWalkthroughStep(result);
115115
} else {
116116
LOGGER.error("Failed to resolve node for step '{}'. Reverting.", walkthrough.getCurrentStep().title());
117-
revertToPreviousStep();
117+
reverter.findAndUndo();
118118
}
119119
resolver = null;
120120
}
@@ -134,7 +134,7 @@ private void displayWalkthroughStep(WalkthroughResult result) {
134134
this.scroller = new WalkthroughScroller(resolvedNode);
135135
}
136136

137-
walkthroughHighlighter.applyHighlight(
137+
highlighter.applyHighlight(
138138
component.highlight().orElse(null),
139139
resolvedWindow.getScene(),
140140
resolvedNode);
@@ -146,11 +146,7 @@ private void displayWalkthroughStep(WalkthroughResult result) {
146146
case PanelStep panel -> overlay.showPanel(panel, resolvedNode, this::prepareForNavigation);
147147
}
148148

149-
walkthroughReverter.attach(resolvedWindow, resolvedNode);
150-
}
151-
152-
private void revertToPreviousStep() {
153-
walkthroughReverter.findAndUndo();
149+
reverter.attach(resolvedWindow, resolvedNode);
154150
}
155151

156152
private void cleanUp() {
@@ -160,7 +156,7 @@ private void cleanUp() {
160156
resolver = null;
161157
}
162158

163-
walkthroughReverter.detach();
159+
reverter.detach();
164160
if (scroller != null) {
165161
scroller.cleanup();
166162
scroller = null;
@@ -189,7 +185,7 @@ private void cleanUp() {
189185
///
190186
/// So the current hack is we will hide [WindowOverlay] so that they won't get hacked restored.
191187
private void prepareForNavigation() {
192-
walkthroughReverter.detach();
188+
reverter.detach();
193189
hide();
194190
}
195191
}

jabgui/src/main/java/org/jabref/gui/walkthrough/WalkthroughRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public Node render(TooltipStep step, Walkthrough walkthrough, Runnable beforeNav
4141
titleContainer.getChildren().add(titleFlow);
4242

4343
VBox contentContainer = createContent(step, walkthrough, beforeNavigate);
44-
contentContainer.getStyleClass().add("walkthrough-tooltip-content");
44+
contentContainer.getStyleClass().add("walkthrough-content");
4545
VBox.setVgrow(contentContainer, Priority.ALWAYS);
4646

4747
HBox actionsContainer = createActions(step, walkthrough, beforeNavigate);
48-
actionsContainer.getStyleClass().add("walkthrough-tooltip-actions");
48+
actionsContainer.getStyleClass().add("walkthrough-actions");
4949

5050
step.maxHeight().ifPresent(tooltip::setMaxHeight);
5151
step.maxWidth().ifPresent(tooltip::setMaxWidth);

jabgui/src/main/java/org/jabref/gui/walkthrough/WindowOverlay.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ public void detach() {
267267
private PopOver createPopover(TooltipStep step, Runnable beforeNavigate) {
268268
Node content = renderer.render(step, walkthrough, beforeNavigate);
269269
PopOver popover = new PopOver();
270-
popover.getScene().getStylesheets().setAll(window.getScene().getStylesheets());
270+
popover.getStyleClass().add("walkthrough-tooltip");
271+
popover.getScene().getStylesheets().setAll(window.getScene().getStylesheets()); // NOTE: Hack because ThemeManager cannot consistently apply themes
271272
popover.setContentNode(content);
272273
popover.setDetachable(false);
273274
popover.setCloseButtonEnabled(false);

0 commit comments

Comments
 (0)