Skip to content
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

CSL4LibreOffice - C [GSoC '24] #11577

Merged
merged 105 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
42d2a8d
Handle numbers for one instance
subhramit Aug 2, 2024
caedc3a
Use reference marks
subhramit Aug 3, 2024
bf9d39e
Rehauled implementation
subhramit Aug 3, 2024
fa39637
Remove comment
subhramit Aug 3, 2024
bb441b4
Revert removals
subhramit Aug 3, 2024
649bcc6
Revert removals
subhramit Aug 3, 2024
9c47086
Revert removals
subhramit Aug 3, 2024
929cf1d
Cover edge cases of numeric citation types
subhramit Aug 3, 2024
89211c3
Cover edge cases of numeric citation types
subhramit Aug 3, 2024
1e4d5a9
Better handling of numeric styles
subhramit Aug 3, 2024
10bf9e0
Format doc
subhramit Aug 3, 2024
3d6c313
Move isNumericStyle method to CitationStyle core
subhramit Aug 3, 2024
2a24cfc
Log
subhramit Aug 3, 2024
1475130
Gosh, this finally works.
subhramit Aug 3, 2024
c9fe7a2
First Implementation - Make bibliography
subhramit Aug 3, 2024
6643bfd
Better implementation
subhramit Aug 3, 2024
05a50fc
Remove duplicate notification
subhramit Aug 3, 2024
c1f5c6a
Penultimate - finishing reference section, fix formatting
subhramit Aug 3, 2024
93b153e
Fix a-tag link text
subhramit Aug 3, 2024
0750f56
Rename functions: less confusing names
subhramit Aug 3, 2024
38c4731
Fixing in-text groups - phase 1
subhramit Aug 3, 2024
a04d826
in-text citations fix phase 2
subhramit Aug 3, 2024
622fda6
Broken implementation for future reference
subhramit Aug 3, 2024
f723bf8
Working model
subhramit Aug 3, 2024
1802ccb
Merge resolve
subhramit Aug 3, 2024
d105eaa
Rename: CSL Reference Mark Model & Handler files
subhramit Aug 4, 2024
47b5bda
Merge branch 'sync-numbers' into make-bibliography
subhramit Aug 4, 2024
e8def54
Merge, order of imports
subhramit Aug 4, 2024
38447c7
Fix: Local storage of last citation number
subhramit Aug 4, 2024
439e2d4
Remove unused initializer
subhramit Aug 4, 2024
6499546
Refactor begin
subhramit Aug 4, 2024
c492628
Refactoring - 2
subhramit Aug 4, 2024
ac09f0a
Wrap reference marks around bibliographic citations
subhramit Aug 4, 2024
1bf4599
Merge branch 'main' of https://github.com/JabRef/jabref into make-bib…
subhramit Aug 4, 2024
c19ecaa
Fix order of citations
subhramit Aug 4, 2024
dc97f11
Fix updateBibliography order
subhramit Aug 4, 2024
09e4218
Merge branch 'main' of https://github.com/JabRef/jabref into make-bib…
subhramit Aug 4, 2024
e0f281e
Simplify getCitationNumber(String citationKey)
koppor Aug 5, 2024
48d2f4d
Improve CSLReferenceMark
koppor Aug 5, 2024
2e2d408
Merge pull request #14 from subhramit/olly-improvements
subhramit Aug 5, 2024
df9d680
YAY REFRESH BIBLIOGRAPHY
subhramit Aug 6, 2024
898fcd0
Drastic improvements in CSL Reference Marks
subhramit Aug 7, 2024
3c3d7a7
Fix extra newline in numeric styles
subhramit Aug 7, 2024
a347ab8
fix helpertext
subhramit Aug 7, 2024
d0a329f
Add support for CSL styles with underline
subhramit Aug 7, 2024
aa25825
Move current cite in-text functionality to Cite button, disable Cite …
subhramit Aug 7, 2024
b8090d6
Smart spaces
subhramit Aug 7, 2024
fc156cc
Better comments for samrt spaces
subhramit Aug 7, 2024
9075f51
Merge remote-tracking branch 'origin/main' into make-bibliography
koppor Aug 7, 2024
ad67300
Use Java Iterator
koppor Aug 7, 2024
9547963
IntelliJ formatting
koppor Aug 7, 2024
689b43a
Change sync bibliography icon
subhramit Aug 7, 2024
1b72f94
Add support for in-text citations
koppor Aug 7, 2024
3ac3d81
Merge branch 'make-bibliography' of github.com:subhramit/jabref into …
koppor Aug 7, 2024
813fcb2
Disable irrelevant buttons for CSL
subhramit Aug 7, 2024
17bb8a9
Merge branch 'make-bibliography' of https://github.com/subhramit/jabr…
subhramit Aug 7, 2024
63bb146
Implement insert empty citations, disable cite special, refactor
subhramit Aug 7, 2024
e21ce3a
Merge olly x subhramit
subhramit Aug 7, 2024
4d7112a
Merge branch 'main' into make-bibliography
subhramit Aug 7, 2024
f59ee52
Remove unused variable
koppor Aug 8, 2024
6fdd792
Fix "cite in-text"
koppor Aug 8, 2024
e76fbaf
Bibliography title stage 1
subhramit Aug 8, 2024
739dbc1
Bibliography title stage 3
subhramit Aug 8, 2024
84d4a5b
Bibliography title stage 5
subhramit Aug 8, 2024
6992024
remove duplicate code
Siedlerchr Aug 8, 2024
d6bae52
Merge branch 'make-bibliography' of github.com:subhramit/jabref into …
Siedlerchr Aug 8, 2024
0a3437c
Bibliography title stage 7
subhramit Aug 8, 2024
56d8970
Fix updateSingleCitation
subhramit Aug 9, 2024
5eb30bb
Support more styles for InText non-numeric citation styles
koppor Aug 10, 2024
f512086
Make "authorsAlpha" public
koppor Aug 10, 2024
9eddf9d
Implement auto-select last used style tab
subhramit Aug 10, 2024
49851be
Fix checkstyle
koppor Aug 10, 2024
0aead54
Add support for alphanumeric citations
subhramit Aug 10, 2024
7057723
Merge branch 'make-bibliography' of https://github.com/subhramit/jabr…
subhramit Aug 10, 2024
fe4b446
Remove duplicated code
subhramit Aug 11, 2024
8c66b71
Enhanced exception handling
subhramit Aug 11, 2024
0b4e657
Enhanced exception handling for isNumericStyle
subhramit Aug 11, 2024
5a3eed5
Upgrade to StAX parsing for isNumericStyle
subhramit Aug 11, 2024
a095281
Merge branch 'main' of https://github.com/JabRef/jabref into make-bib…
subhramit Aug 11, 2024
9ebff4e
Fix catch indents
subhramit Aug 11, 2024
80da1aa
Mis-leading word
subhramit Aug 11, 2024
e479ad4
Better logs
subhramit Aug 11, 2024
b209708
Remove commented code
subhramit Aug 11, 2024
39c671f
Make update bibliography methods non-static
subhramit Aug 11, 2024
3e37e66
Fix log level & use slf4 logger
subhramit Aug 11, 2024
72b8ee9
Merge branch 'main' into make-bibliography
subhramit Aug 11, 2024
5392ee7
Field conversion - numeric style detection
subhramit Aug 11, 2024
8b7b880
Collapse XML parsing of title and isNumericStyle, use record type
subhramit Aug 11, 2024
98b9218
Avoid nulls
subhramit Aug 11, 2024
164ef09
No NPE needed
subhramit Aug 11, 2024
18f10b4
Fix submodules
subhramit Aug 11, 2024
254bc63
Change make bibliography icon
subhramit Aug 11, 2024
64fee09
Fix submodules
subhramit Aug 11, 2024
e9bbcd0
Merge branch 'main' into make-bibliography
subhramit Aug 12, 2024
91876e3
Add reference to authorsAlpha, better method name
subhramit Aug 12, 2024
3c86db3
Add more tests
koppor Aug 12, 2024
13d94f5
Use original authorsAlpha
subhramit Aug 12, 2024
55a7320
Merge branch 'make-bibliography' of github.com:subhramit/jabref into …
koppor Aug 12, 2024
50b0058
Remove static import
koppor Aug 12, 2024
b81444f
Discard changes to src/test/java/org/jabref/logic/citationkeypattern/…
koppor Aug 12, 2024
c1060bb
Fix extra newline
subhramit Aug 12, 2024
97a5546
Merge remote-tracking branch 'origin/make-bibliography' into make-bib…
subhramit Aug 12, 2024
30a19b2
Merge branch 'main' into make-bibliography
subhramit Aug 12, 2024
72e39b7
Fix checkstyle
subhramit Aug 12, 2024
cc36acc
Merge remote-tracking branch 'origin/make-bibliography' into make-bib…
subhramit Aug 12, 2024
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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ dependencies {

implementation 'commons-cli:commons-cli:1.8.0'

// region: LibreOffice
implementation 'org.libreoffice:unoloader:24.2.3'
implementation 'org.libreoffice:libreoffice:24.2.3'
// Required for ID generation
implementation 'io.github.thibaultmeyer:cuid:2.0.3'
// endregion

implementation 'io.github.java-diff-utils:java-diff-utils:4.12'
implementation 'info.debatty:java-string-similarity:2.0.0'
Expand Down
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
requires transitive org.jspecify;

// region: other libraries (alphabetically)
requires cuid;
requires dd.plist;
requires mslinks;
requires org.antlr.antlr4.runtime;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/icon/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ public enum JabRefIcons implements JabRefIcon {
REMOVE_TAGS(MaterialDesignC.CLOSE),
ACCEPT_LEFT(MaterialDesignS.SUBDIRECTORY_ARROW_LEFT),
ACCEPT_RIGHT(MaterialDesignS.SUBDIRECTORY_ARROW_RIGHT),
MERGE_GROUPS(MaterialDesignS.SOURCE_MERGE);
MERGE_GROUPS(MaterialDesignS.SOURCE_MERGE),
ADD_OR_MAKE_BIBLIOGRAPHY(JabRefMaterialDesignIcon.BIBLIOGRAPHY);
private final JabRefIcon icon;

JabRefIcons(Ikon... icons) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public enum JabRefMaterialDesignIcon implements Ikon {
CANCEL("jab-cancel", '\ue90e'),
SUBLIME_TEXT("jab-sublime-text", '\ue90f'),
TEXSHOP("jab-texshop", '\ue910'),
TEXWORKS("jab-texworks", '\ue911');
TEXWORKS("jab-texworks", '\ue911'),
BIBLIOGRAPHY("jab-bibliography", '\ue912');

private String description;
private int code;
Expand Down
107 changes: 94 additions & 13 deletions src/main/java/org/jabref/gui/openoffice/OOBibBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jabref.logic.openoffice.frontend.OOFrontend;
import org.jabref.logic.openoffice.frontend.RangeForOverlapCheck;
import org.jabref.logic.openoffice.oocsltext.CSLCitationOOAdapter;
import org.jabref.logic.openoffice.oocsltext.CSLUpdateBibliography;
import org.jabref.logic.openoffice.style.JStyle;
import org.jabref.logic.openoffice.style.OOStyle;
import org.jabref.model.database.BibDatabase;
Expand All @@ -44,6 +45,7 @@
import org.jabref.model.openoffice.util.OOResult;
import org.jabref.model.openoffice.util.OOVoidResult;

import com.airhacks.afterburner.injection.Injector;
import com.sun.star.beans.IllegalTypeException;
import com.sun.star.beans.NotRemoveableException;
import com.sun.star.beans.PropertyVetoException;
Expand All @@ -53,13 +55,14 @@
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.uno.Exception;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Class for manipulating the Bibliography of the currently started document in OpenOffice.
*/
class OOBibBase {
public class OOBibBase {

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

Expand All @@ -73,7 +76,7 @@ class OOBibBase {

private final OOBibBaseConnect connection;

private final CSLCitationOOAdapter cslCitationOOAdapter;
private CSLCitationOOAdapter cslCitationOOAdapter;

public OOBibBase(Path loPath, DialogService dialogService)
throws
Expand All @@ -85,11 +88,14 @@ public OOBibBase(Path loPath, DialogService dialogService)

this.refreshBibliographyDuringSyncWhenCiting = false;
this.alwaysAddCitedOnPages = false;
}

cslCitationOOAdapter = new CSLCitationOOAdapter();
private void initializeCitationAdapter(XTextDocument doc) throws WrappedTargetException, NoSuchElementException {
this.cslCitationOOAdapter = new CSLCitationOOAdapter(doc);
this.cslCitationOOAdapter.readExistingMarks();
}

public void guiActionSelectDocument(boolean autoSelectForSingle) {
public void guiActionSelectDocument(boolean autoSelectForSingle) throws WrappedTargetException, NoSuchElementException {
final String errorTitle = Localization.lang("Problem connecting");

try {
Expand All @@ -100,13 +106,14 @@ public void guiActionSelectDocument(boolean autoSelectForSingle) {
} catch (DisposedException ex) {
OOError.from(ex).setTitle(errorTitle).showErrorDialog(dialogService);
} catch (WrappedTargetException
| IndexOutOfBoundsException
| NoSuchElementException ex) {
| IndexOutOfBoundsException
| NoSuchElementException ex) {
LOGGER.warn("Problem connecting", ex);
OOError.fromMisc(ex).setTitle(errorTitle).showErrorDialog(dialogService);
}

if (this.isConnectedToDocument()) {
initializeCitationAdapter(this.getXTextDocument().get());
dialogService.notify(Localization.lang("Connected to document") + ": "
+ this.getCurrentDocumentTitle().orElse(""));
}
Expand Down Expand Up @@ -591,16 +598,26 @@ public void guiActionInsertEntry(List<BibEntry> entries,
}

try {

UnoUndo.enterUndoContext(doc, "Insert citation");
if (style instanceof CitationStyle citationStyle) {
// Handle insertion of CSL Style citations
if (citationType == CitationType.AUTHORYEAR_INTEXT) {
cslCitationOOAdapter.insertInText(doc, cursor.get(), citationStyle, entries, bibDatabaseContext, bibEntryTypesManager);
} else {
cslCitationOOAdapter.insertBibliography(doc, cursor.get(), citationStyle, entries, bibDatabaseContext, bibEntryTypesManager);

initializeCitationAdapter(doc);

if (citationType == CitationType.AUTHORYEAR_PAR) {
// "Cite" button
this.cslCitationOOAdapter.insertCitation(cursor.get(), citationStyle, entries, bibDatabaseContext, bibEntryTypesManager);
} else if (citationType == CitationType.AUTHORYEAR_INTEXT) {
// "Cite in-text" button
this.cslCitationOOAdapter.insertInTextCitation(cursor.get(), citationStyle, entries, bibDatabaseContext, bibEntryTypesManager);
} else if (citationType == CitationType.INVISIBLE_CIT) {
// "Insert empty citation"
this.cslCitationOOAdapter.insertEmpty(cursor.get(), entries);
}
} else if (style instanceof JStyle jStyle) {
// Handle insertion of JStyle citations

EditInsert.insertCitationGroup(doc,
frontend.get(),
cursor.get(),
Expand All @@ -626,6 +643,8 @@ public void guiActionInsertEntry(List<BibEntry> entries,
| NotRemoveableException ex) {
LOGGER.warn("Could not insert entry", ex);
OOError.fromMisc(ex).setTitle(errorTitle).showErrorDialog(dialogService);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
UnoUndo.leaveUndoContext(doc);
}
Expand Down Expand Up @@ -817,9 +836,8 @@ public Optional<BibDatabase> exportCitedHelper(List<BibDatabase> databases, bool
* @param style Style.
*/
public void guiActionUpdateDocument(List<BibDatabase> databases, OOStyle style) {
final String errorTitle = Localization.lang("Unable to synchronize bibliography");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this works, I think there was something about using vars for l10n https://devdocs.jabref.org/code-howtos/localization.html#general-hints

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This existed already (look below at removed line 821).
I can replace the variables with the string, but it will become ugly

Copy link
Collaborator Author

@subhramit subhramit Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this exists in the entire file (at 87 places). Doesn't seem like a good idea.

if (style instanceof JStyle jStyle) {
final String errorTitle = Localization.lang("Unable to synchronize bibliography");

try {

OOResult<XTextDocument, OOError> odoc = getXTextDocument();
Expand Down Expand Up @@ -871,10 +889,73 @@ public void guiActionUpdateDocument(List<BibDatabase> databases, OOStyle style)
OOError.from(ex).setTitle(errorTitle).showErrorDialog(dialogService);
} catch (DisposedException ex) {
OOError.from(ex).setTitle(errorTitle).showErrorDialog(dialogService);
} catch (CreationException
| WrappedTargetException
| com.sun.star.lang.IllegalArgumentException ex) {
LOGGER.warn("Could not update JStyle bibliography", ex);
OOError.fromMisc(ex).setTitle(errorTitle).showErrorDialog(dialogService);
}
} else if (style instanceof CitationStyle citationStyle) {
try {

CSLUpdateBibliography cslUpdateBibliography = new CSLUpdateBibliography();

OOResult<XTextDocument, OOError> odoc = getXTextDocument();
if (testDialog(errorTitle, odoc.asVoidResult())) {
return;
}

XTextDocument doc = odoc.get();

OOResult<FunctionalTextViewCursor, OOError> fcursor = getFunctionalTextViewCursor(doc, errorTitle);

if (testDialog(errorTitle,
fcursor.asVoidResult(),
checkIfOpenOfficeIsRecordingChanges(doc))) {
return;
}

try {
UnoUndo.enterUndoContext(doc, "Create CSL bibliography");

initializeCitationAdapter(doc);

// Collect only cited entries from all databases
List<BibEntry> citedEntries = new ArrayList<>();
for (BibDatabase database : databases) {
for (BibEntry entry : database.getEntries()) {
if (cslCitationOOAdapter.isCitedEntry(entry)) {
citedEntries.add(entry);
}
}
}

// If no entries are cited, show a message and return
if (citedEntries.isEmpty()) {
dialogService.showInformationDialogAndWait(
Localization.lang("Bibliography"),
Localization.lang("No cited entries found in the document.")
);
return;
}

// A separate database and database
BibDatabase bibDatabase = new BibDatabase(citedEntries);
BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(bibDatabase);

cslUpdateBibliography.rebuildCSLBibliography(doc, cslCitationOOAdapter, citedEntries, citationStyle, bibDatabaseContext, Injector.instantiateModelOrService(BibEntryTypesManager.class));

} catch (NoDocumentException
| NoSuchElementException e) {
throw new RuntimeException(e);
} finally {
UnoUndo.leaveUndoContext(doc);
fcursor.get().restore(doc);
}
} catch (CreationException
| WrappedTargetException
| com.sun.star.lang.IllegalArgumentException ex) {
LOGGER.warn("Could not update bibliography", ex);
LOGGER.warn("Could not update CSL bibliography", ex);
OOError.fromMisc(ex).setTitle(errorTitle).showErrorDialog(dialogService);
}
}
Expand Down
38 changes: 28 additions & 10 deletions src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
import org.jabref.preferences.PreferencesService;

import com.sun.star.comp.helper.BootstrapException;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.lang.WrappedTargetException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -121,6 +123,7 @@ public OpenOfficePanel(LibraryTabContainer tabContainer,
this.stateManager = stateManager;
this.clipBoardManager = clipBoardManager;
this.undoManager = undoManager;
this.currentStyle = preferencesService.getOpenOfficePreferences().getCurrentStyle();

ActionFactory factory = new ActionFactory();

Expand All @@ -143,7 +146,7 @@ public OpenOfficePanel(LibraryTabContainer tabContainer,
selectDocument.setMaxWidth(Double.MAX_VALUE);

update = new Button();
update.setGraphic(IconTheme.JabRefIcons.REFRESH.getGraphicNode());
update.setGraphic(IconTheme.JabRefIcons.ADD_OR_MAKE_BIBLIOGRAPHY.getGraphicNode());
update.setTooltip(new Tooltip(Localization.lang("Sync OpenOffice/LibreOffice bibliography")));
update.setMaxWidth(Double.MAX_VALUE);

Expand Down Expand Up @@ -195,7 +198,14 @@ private void initPanel() {
manualConnect.setOnAction(e -> connectManually());

selectDocument.setTooltip(new Tooltip(Localization.lang("Select which open Writer document to work on")));
selectDocument.setOnAction(e -> ooBase.guiActionSelectDocument(false));
selectDocument.setOnAction(e -> {
try {
ooBase.guiActionSelectDocument(false);
} catch (WrappedTargetException
| NoSuchElementException ex) {
throw new RuntimeException(ex);
}
});

setStyleFile.setMaxWidth(Double.MAX_VALUE);
setStyleFile.setOnAction(event -> {
Expand All @@ -213,6 +223,7 @@ private void initPanel() {
} else if (currentStyle instanceof CitationStyle cslStyle) {
dialogService.notify(Localization.lang("Currently selected CSL Style: '%0'", cslStyle.getName()));
}
updateButtonAvailability();
});
});

Expand All @@ -229,7 +240,7 @@ private void initPanel() {
pushEntriesAdvanced.setOnAction(e -> pushEntries(CitationType.AUTHORYEAR_INTEXT, true));
pushEntriesAdvanced.setMaxWidth(Double.MAX_VALUE);

update.setTooltip(new Tooltip(Localization.lang("Ensure that the bibliography is up-to-date")));
update.setTooltip(new Tooltip(Localization.lang("Make/Sync bibliography")));

update.setOnAction(event -> {
String title = Localization.lang("Could not update bibliography");
Expand Down Expand Up @@ -384,23 +395,25 @@ private void updateButtonAvailability() {
pushEntries.setDisable(!(isConnectedToDocument && hasStyle && hasDatabase));

boolean canCite = isConnectedToDocument && hasStyle && hasSelectedBibEntry;
boolean cslStyleSelected = preferencesService.getOpenOfficePreferences().getCurrentStyle() instanceof CitationStyle;
pushEntriesInt.setDisable(!canCite);
pushEntriesEmpty.setDisable(!canCite);
pushEntriesAdvanced.setDisable(!canCite);
pushEntriesAdvanced.setDisable(!canCite || cslStyleSelected);

boolean canRefreshDocument = isConnectedToDocument && hasStyle;

update.setDisable(!canRefreshDocument);
merge.setDisable(!canRefreshDocument);
unmerge.setDisable(!canRefreshDocument);
manageCitations.setDisable(!canRefreshDocument);
merge.setDisable(!canRefreshDocument || cslStyleSelected);
unmerge.setDisable(!canRefreshDocument || cslStyleSelected);
manageCitations.setDisable(!canRefreshDocument || cslStyleSelected);

exportCitations.setDisable(!(isConnectedToDocument && hasDatabase));
exportCitations.setDisable(!(isConnectedToDocument && hasDatabase) || cslStyleSelected);
}

private void connect() {
Task<OOBibBase> connectTask = new Task<>() {
@Override
protected OOBibBase call() throws Exception {
protected OOBibBase call() throws BootstrapException, CreationException {
updateProgress(ProgressBar.INDETERMINATE_PROGRESS, ProgressBar.INDETERMINATE_PROGRESS);

Path path = Path.of(preferencesService.getOpenOfficePreferences().getExecutablePath());
Expand All @@ -411,7 +424,12 @@ protected OOBibBase call() throws Exception {
connectTask.setOnSucceeded(value -> {
ooBase = connectTask.getValue();

ooBase.guiActionSelectDocument(true);
try {
ooBase.guiActionSelectDocument(true);
} catch (WrappedTargetException
| NoSuchElementException e) {
throw new RuntimeException(e);
}

// Enable actions that depend on a connection
updateButtonAvailability();
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ private void initialize() {
}
});

OOStyle currentStyle = preferencesService.getOpenOfficePreferences().getCurrentStyle();
if (currentStyle instanceof JStyle) {
tabPane.getSelectionModel().select(1);
} else {
tabPane.getSelectionModel().select(0);
}

viewModel.setSelectedTab(tabPane.getSelectionModel().getSelectedItem());
tabPane.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
viewModel.setSelectedTab(newValue);
});

updateCurrentStyleLabel();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ static String allAuthors(AuthorList authorList) {
* @param authorList an {@link AuthorList}
* @return the initials of all authors' names
*/
static String authorsAlpha(AuthorList authorList) {
public static String authorsAlpha(AuthorList authorList) {
StringBuilder alphaStyle = new StringBuilder();
int maxAuthors;
final boolean maxAuthorsExceeded;
Expand Down Expand Up @@ -874,7 +874,7 @@ static String authorsAlpha(AuthorList authorList) {
List<String> vonAndLastNames = authorList.getAuthors().stream()
.limit(maxAuthors)
.map(Author::getNamePrefixAndFamilyName)
.collect(Collectors.toList());
.toList();
for (String vonAndLast : vonAndLastNames) {
// replace all whitespaces by " "
// split the lastname at " "
Expand Down Expand Up @@ -902,7 +902,7 @@ static String authorsAlpha(AuthorList authorList) {
* @return a string consisting of authors' last names separated by a `delimiter` and with any authors excess of
* `maxAuthors` replaced with `suffix`
*/
private static String joinAuthorsOnLastName(AuthorList authorList, int maxAuthors, String delimiter, final String suffix) {
public static String joinAuthorsOnLastName(AuthorList authorList, int maxAuthors, String delimiter, final String suffix) {
final String finalSuffix = authorList.getNumberOfAuthors() > maxAuthors ? suffix : "";
return authorList.getAuthors().stream()
.map(author -> {
Expand Down
Loading
Loading