Skip to content

Commit

Permalink
Merge branch 'JabRef:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
pal-anish authored Jan 30, 2024
2 parents 0c417fb + c848055 commit b7cf52b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added a fetcher for [ISIDORE](https://isidore.science/), simply paste in the link into the text field or the last 6 digits in the link that identify that paper. [#10423](https://github.com/JabRef/jabref/issues/10423)
- When importing entries form the "Citation relations" tab, the field [cites](https://docs.jabref.org/advanced/entryeditor/entrylinks) is now filled according to the relationship between the entries. [#10572](https://github.com/JabRef/jabref/pull/10752)
- We added a new group icon column to the main table showing the icons of the entry's groups. [#10801](https://github.com/JabRef/jabref/pull/10801)
- We added a new boolean to the style files for Openoffice/Libreoffice integration to switch between ZERO_WIDTH_SPACE (default) and no space. [#10843](https://github.com/JabRef/jabref/pull/10843)

### Changed

Expand Down
39 changes: 32 additions & 7 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.SplitPane;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.BorderPane;
import javafx.util.Duration;
Expand Down Expand Up @@ -261,7 +262,12 @@ private void onDatabaseLoadingFailed(Exception ex) {
}

private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
if (this.getTabPane().getSelectionModel().selectedItemProperty().get().equals(this)) {
TabPane tabPane = this.getTabPane();
if (tabPane == null) {
LOGGER.debug("User interrupted loading. Not showing any library.");
return;
}
if (tabPane.getSelectionModel().selectedItemProperty().get().equals(this)) {
LOGGER.debug("This case should not happen.");
stateManager.setActiveDatabase(bibDatabaseContext);
}
Expand Down Expand Up @@ -778,12 +784,31 @@ private void onCloseRequest(Event event) {
* Perform necessary cleanup when this Library is closed.
*/
private void onClosed(Event event) {
changeMonitor.ifPresent(DatabaseChangeMonitor::unregister);
PdfIndexerManager.shutdownIndexer(bibDatabaseContext);
AutosaveManager.shutdown(bibDatabaseContext);
BackupManager.shutdown(bibDatabaseContext,
preferencesService.getFilePreferences().getBackupDirectory(),
preferencesService.getFilePreferences().shouldCreateBackup());
if (dataLoadingTask != null) {
dataLoadingTask.cancel();
}
try {
changeMonitor.ifPresent(DatabaseChangeMonitor::unregister);
} catch (RuntimeException e) {
LOGGER.error("Problem when closing change monitor", e);
}
try {
PdfIndexerManager.shutdownIndexer(bibDatabaseContext);
} catch (RuntimeException e) {
LOGGER.error("Problem when shutting down PDF indexer", e);
}
try {
AutosaveManager.shutdown(bibDatabaseContext);
} catch (RuntimeException e) {
LOGGER.error("Problem when shutting down autosave manager", e);
}
try {
BackupManager.shutdown(bibDatabaseContext,
preferencesService.getFilePreferences().getBackupDirectory(),
preferencesService.getFilePreferences().shouldCreateBackup());
} catch (RuntimeException e) {
LOGGER.error("Problem when shutting down backup manager", e);
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/util/BackgroundTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import com.google.common.collect.ImmutableMap;
import com.tobiasdiez.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class is essentially a wrapper around {@link Task}.
Expand All @@ -37,6 +39,8 @@ public abstract class BackgroundTask<V> {
Localization.lang("Downloading"), IconTheme.JabRefIcons.DOWNLOAD.getGraphicNode()
);

private static final Logger LOGGER = LoggerFactory.getLogger(BackgroundTask.class);

private Runnable onRunning;
private Consumer<V> onSuccess;
private Consumer<Exception> onException;
Expand Down Expand Up @@ -92,6 +96,7 @@ public boolean isCanceled() {
}

public void cancel() {
LOGGER.debug("Canceling task");
this.isCanceled.set(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public static void fillCitationMarkInCursor(XTextDocument doc,

if (withText) {
OOText citationText2 = style.decorateCitationMarker(citationText);
// inject a ZERO_WIDTH_SPACE to hold the initial character format
final String ZERO_WIDTH_SPACE = "\u200b";
String ZERO_WIDTH_SPACE = "";
if (style.spaceBeforeCitation()) {
// inject a ZERO_WIDTH_SPACE to hold the initial character format
ZERO_WIDTH_SPACE = "\u200b";
}
citationText2 = OOText.fromString(ZERO_WIDTH_SPACE + citationText2.toString());
OOTextIntoOO.write(doc, cursor, citationText2);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class OOBibStyle implements Comparable<OOBibStyle> {
private static final String AUTHOR_FIELD = "AuthorField";
private static final String BRACKET_AFTER = "BracketAfter";
private static final String BRACKET_BEFORE = "BracketBefore";
private static final String SPACE_BEFORE = "SpaceBefore";
private static final String IS_NUMBER_ENTRIES = "IsNumberEntries";
private static final String IS_SORT_BY_POSITION = "IsSortByPosition";
private static final String SORT_ALGORITHM = "SortAlgorithm";
Expand Down Expand Up @@ -203,6 +204,7 @@ private void setDefaultProperties() {
citProperties.put(IN_TEXT_YEAR_SEPARATOR, " ");
citProperties.put(BRACKET_BEFORE, "(");
citProperties.put(BRACKET_AFTER, ")");
citProperties.put(SPACE_BEFORE, Boolean.TRUE);
citProperties.put(CITATION_SEPARATOR, "; ");
citProperties.put(PAGE_INFO_SEPARATOR, "; ");
citProperties.put(GROUPED_NUMBERS_SEPARATOR, "-");
Expand Down Expand Up @@ -493,6 +495,10 @@ public boolean isFormatCitations() {
return (Boolean) citProperties.get(FORMAT_CITATIONS);
}

public boolean spaceBeforeCitation() {
return (Boolean) citProperties.get(SPACE_BEFORE);
}

public boolean isCitationKeyCiteMarkers() {
return (Boolean) citProperties.get(CITATION_KEY_CITATIONS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ FormatCitations="false"
CitationCharacterFormat="Default"
PageInfoSeparator="; "
OxfordComma=","
SpaceBefore="true"

LAYOUT
article=<b>\format[Authors(LastFirst,Semicolon)]{\author}</b> (<b>\year\uniq</b>). <i>\title</i>, \journal \volume\begin{pages} : \format[FormatPagesForHTML]{\pages}\end{pages}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ FormatCitations="false"
CitationCharacterFormat="Default"
PageInfoSeparator="; "
OxfordComma=","
SpaceBefore="true"

LAYOUT

Expand Down

0 comments on commit b7cf52b

Please sign in to comment.