-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add setting: always add "Cited on pages" text to JStyles. #11732
Changes from 13 commits
68834e9
7243dda
a5a902b
cda2669
160721d
a4f05b1
3e507b8
09d9647
576eb92
21c7de1
9efdd4b
dd273f7
ee2ebb4
f2c3744
b43835a
7ce9dc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
[submodule "abbrv.jabref.org"] | ||
path = buildres/abbrv.jabref.org | ||
url = https://github.com/JabRef/abbrv.jabref.org.git | ||
ignore = all | ||
# ignore = all | ||
shallow = true | ||
[submodule "csl-styles"] | ||
path = src/main/resources/csl-styles | ||
url = https://github.com/citation-style-language/styles.git | ||
ignore = all | ||
# ignore = all | ||
shallow = true | ||
[submodule "csl-locales"] | ||
path = src/main/resources/csl-locales | ||
url = https://github.com/citation-style-language/locales.git | ||
ignore = all | ||
# ignore = all | ||
shallow = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import javafx.beans.property.SimpleObjectProperty; | ||
import javafx.concurrent.Task; | ||
import javafx.geometry.Insets; | ||
import javafx.geometry.Side; | ||
|
@@ -65,6 +66,7 @@ | |
import com.sun.star.comp.helper.BootstrapException; | ||
import com.sun.star.container.NoSuchElementException; | ||
import com.sun.star.lang.WrappedTargetException; | ||
import com.tobiasdiez.easybind.EasyBind; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
@@ -102,9 +104,12 @@ public class OpenOfficePanel { | |
private final LibraryTabContainer tabContainer; | ||
private final FileUpdateMonitor fileUpdateMonitor; | ||
private final BibEntryTypesManager entryTypesManager; | ||
private final OpenOfficePreferences openOfficePreferences; | ||
private OOBibBase ooBase; | ||
private OOStyle currentStyle; | ||
|
||
private final SimpleObjectProperty<OOStyle> currentStyleProperty; | ||
|
||
public OpenOfficePanel(LibraryTabContainer tabContainer, | ||
PreferencesService preferencesService, | ||
KeyBindingRepository keyBindingRepository, | ||
|
@@ -126,6 +131,7 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, | |
this.clipBoardManager = clipBoardManager; | ||
this.undoManager = undoManager; | ||
this.currentStyle = preferencesService.getOpenOfficePreferences().getCurrentStyle(); | ||
this.openOfficePreferences = preferencesService.getOpenOfficePreferences(); | ||
|
||
ActionFactory factory = new ActionFactory(); | ||
|
||
|
@@ -157,6 +163,8 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, | |
preferencesService.getLayoutFormatterPreferences(), | ||
abbreviationRepository); | ||
|
||
currentStyleProperty = new SimpleObjectProperty<>(currentStyle); | ||
|
||
initPanel(); | ||
} | ||
|
||
|
@@ -170,6 +178,7 @@ public Node getContent() { | |
*/ | ||
private boolean getOrUpdateTheStyle(String title) { | ||
currentStyle = loader.getUsedStyleUnified(); | ||
currentStyleProperty.set(currentStyle); | ||
final boolean FAIL = true; | ||
final boolean PASS = false; | ||
|
||
|
@@ -215,6 +224,8 @@ private void initPanel() { | |
dialogService.showCustomDialogAndWait(styleDialog) | ||
.ifPresent(selectedStyle -> { | ||
currentStyle = selectedStyle; | ||
currentStyleProperty.set(currentStyle); | ||
|
||
if (currentStyle instanceof JStyle jStyle) { | ||
try { | ||
jStyle.ensureUpToDate(); | ||
|
@@ -472,7 +483,7 @@ protected OOBibBase call() throws BootstrapException, CreationException { | |
} | ||
|
||
private OOBibBase createBibBase(Path loPath) throws BootstrapException, CreationException { | ||
return new OOBibBase(loPath, dialogService); | ||
return new OOBibBase(loPath, dialogService, openOfficePreferences); | ||
} | ||
|
||
/** | ||
|
@@ -614,12 +625,27 @@ private boolean checkThatEntriesHaveKeys(List<BibEntry> entries) { | |
} | ||
|
||
private ContextMenu createSettingsPopup() { | ||
OpenOfficePreferences openOfficePreferences = preferencesService.getOpenOfficePreferences(); | ||
|
||
Comment on lines
-617
to
-618
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why this was moved? Initializations are usually done at the beginning of the scope. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personal practice is to initialize as close to first usage as possible to increase refactorability, but if it's project standard to initialize at the beginning, then I will gladly undo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there is no general hard-and-fast best practice regarding this. Beginning-of-scope-initialization is preferred when a dependency is used throughout the scope multiple times in logically segregated segments. Near-first-use-initialization is used if the usage is confined, and refactorability is indeed the argument. I would have requested you to change back, but since moving it to the class level (my comment below on refactoring) will anyway do it at a more global level, this line will just be removed from here. |
||
ContextMenu contextMenu = new ContextMenu(); | ||
|
||
CheckMenuItem autoSync = new CheckMenuItem(Localization.lang("Automatically sync bibliography when inserting citations")); | ||
autoSync.selectedProperty().set(preferencesService.getOpenOfficePreferences().getSyncWhenCiting()); | ||
autoSync.selectedProperty().set(openOfficePreferences.getSyncWhenCiting()); | ||
|
||
CheckMenuItem alwaysAddCitedOnPagesText = new CheckMenuItem(Localization.lang("Automatically add \"Cited on pages...\" at the end of bibliographic entries")); | ||
alwaysAddCitedOnPagesText.selectedProperty().set(openOfficePreferences.getAlwaysAddCitedOnPages()); | ||
alwaysAddCitedOnPagesText.setOnAction(e -> openOfficePreferences.setAlwaysAddCitedOnPages(alwaysAddCitedOnPagesText.isSelected())); | ||
|
||
EasyBind.listen(currentStyleProperty, (obs, oldValue, newValue) -> { | ||
switch (newValue) { | ||
case JStyle ignored -> { | ||
if (!contextMenu.getItems().contains(alwaysAddCitedOnPagesText)) { | ||
contextMenu.getItems().add(1, alwaysAddCitedOnPagesText); | ||
} | ||
} | ||
case CitationStyle ignored -> | ||
contextMenu.getItems().remove(alwaysAddCitedOnPagesText); | ||
default -> { } | ||
} | ||
}); | ||
|
||
ToggleGroup toggleGroup = new ToggleGroup(); | ||
RadioMenuItem useActiveBase = new RadioMenuItem(Localization.lang("Look up BibTeX entries in the active tab only")); | ||
|
@@ -651,6 +677,10 @@ private ContextMenu createSettingsPopup() { | |
new SeparatorMenuItem(), | ||
clearConnectionSettings); | ||
|
||
if (currentStyle instanceof JStyle) { | ||
contextMenu.getItems().add(1, alwaysAddCitedOnPagesText); | ||
} | ||
|
||
return contextMenu; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my latest comment for a TL;DR (git submodules are a pain in the a**)