Skip to content

Commit 01f65ea

Browse files
Add 'Get New Themes!' Button for Web Page Integration (JabRef#10349)
Co-authored-by: Siedlerchr <[email protected]>
1 parent e53c390 commit 01f65ea

File tree

6 files changed

+52
-24
lines changed

6 files changed

+52
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
1616
- We added support for customizing the citation command (e.g., `[@key1,@key2]`) when [pushing to external applications](https://docs.jabref.org/cite/pushtoapplications). [#10133](https://github.com/JabRef/jabref/issues/10133)
1717
- We added an integrity check for more special characters. [#8712](https://github.com/JabRef/jabref/issues/8712)
1818
- We added protected terms described as "Computer science". [#10222](https://github.com/JabRef/jabref/pull/10222)
19+
- We added a link "Get more themes..." in the preferences to that points to [themes.jabref.org](https://themes.jabref.org) allowing the user to download new themes. [#10243](https://github.com/JabRef/jabref/issues/10243)
1920
- We added a fetcher for [LOBID](https://lobid.org/resources/api) resources. [koppor#386](https://github.com/koppor/jabref/issues/386)
2021
- When in `biblatex` mode, the [integrity check](https://docs.jabref.org/finding-sorting-and-cleaning-entries/checkintegrity) for journal titles now also checks the field `journal`.
2122

2223
### Changed
2324

24-
- In the exports listrefs, tablerefs, tablerefsabsbib, use ISO date format in the footer.
25+
- The export formats `listrefs`, `tablerefs`, `tablerefsabsbib`, now use the ISO date format in the footer [#10383](https://github.com/JabRef/jabref/pull/10383).
2526

2627
### Fixed
2728

src/main/java/org/jabref/gui/preferences/general/GeneralTab.fxml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<?import javafx.scene.layout.HBox?>
1414
<?import javafx.scene.layout.VBox?>
1515
<?import org.jabref.gui.icon.JabRefIconView?>
16+
<?import javafx.scene.control.Hyperlink?>
1617
<fx:root spacing="10.0" type="VBox"
1718
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
1819
fx:controller="org.jabref.gui.preferences.general.GeneralTab">
@@ -58,6 +59,8 @@
5859
</HBox>
5960
</GridPane>
6061

62+
<Hyperlink fx:id="moreThemes" text = "%Get more themes..." onAction="#openBrowser"/>
63+
6164
<Label styleClass="sectionHeader" text="%User interface"/>
6265
<CheckBox fx:id="openLastStartup" text="%Open last edited libraries on startup"/>
6366
<CheckBox fx:id="showAdvancedHints"

src/main/java/org/jabref/gui/preferences/general/GeneralTab.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
import javafx.scene.control.TextFormatter;
1414
import javafx.util.converter.IntegerStringConverter;
1515

16-
import org.jabref.gui.Globals;
1716
import org.jabref.gui.actions.ActionFactory;
1817
import org.jabref.gui.actions.StandardActions;
1918
import org.jabref.gui.help.HelpAction;
2019
import org.jabref.gui.preferences.AbstractPreferenceTabView;
2120
import org.jabref.gui.preferences.PreferencesTab;
21+
import org.jabref.gui.theme.ThemeTypes;
2222
import org.jabref.gui.util.IconValidationDecorator;
2323
import org.jabref.gui.util.ViewModelListCellFactory;
2424
import org.jabref.logic.help.HelpFile;
@@ -33,7 +33,7 @@
3333
public class GeneralTab extends AbstractPreferenceTabView<GeneralTabViewModel> implements PreferencesTab {
3434

3535
@FXML private ComboBox<Language> language;
36-
@FXML private ComboBox<GeneralTabViewModel.ThemeTypes> theme;
36+
@FXML private ComboBox<ThemeTypes> theme;
3737
@FXML private TextField customThemePath;
3838
@FXML private Button customThemeBrowse;
3939
@FXML private CheckBox fontOverride;
@@ -91,14 +91,14 @@ public void initialize() {
9191
fontSize.getEditor().textProperty().bindBidirectional(viewModel.fontSizeProperty());
9292
fontSize.getEditor().setTextFormatter(fontSizeFormatter);
9393

94-
new ViewModelListCellFactory<GeneralTabViewModel.ThemeTypes>()
95-
.withText(GeneralTabViewModel.ThemeTypes::getDisplayName)
94+
new ViewModelListCellFactory<ThemeTypes>()
95+
.withText(ThemeTypes::getDisplayName)
9696
.install(theme);
9797
theme.itemsProperty().bind(viewModel.themesListProperty());
9898
theme.valueProperty().bindBidirectional(viewModel.selectedThemeProperty());
9999
customThemePath.textProperty().bindBidirectional(viewModel.customPathToThemeProperty());
100100
EasyBind.subscribe(viewModel.selectedThemeProperty(), theme -> {
101-
boolean isCustomTheme = theme == GeneralTabViewModel.ThemeTypes.CUSTOM;
101+
boolean isCustomTheme = theme == ThemeTypes.CUSTOM;
102102
customThemePath.disableProperty().set(!isCustomTheme);
103103
customThemeBrowse.disableProperty().set(!isCustomTheme);
104104
});
@@ -120,7 +120,7 @@ public void initialize() {
120120

121121
alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
122122
autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());
123-
ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
123+
ActionFactory actionFactory = new ActionFactory(preferencesService.getKeyBindingRepository());
124124
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE, dialogService, preferencesService.getFilePreferences()), autosaveLocalLibrariesHelp);
125125

126126
createBackup.selectedProperty().bindBidirectional(viewModel.createBackupProperty());
@@ -141,4 +141,9 @@ void importTheme() {
141141
public void backupFileDirBrowse() {
142142
viewModel.backupFileDirBrowse();
143143
}
144+
145+
@FXML
146+
public void openBrowser() {
147+
viewModel.openBrowser();
148+
}
144149
}

src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jabref.gui.preferences.general;
22

3+
import java.io.IOException;
34
import java.nio.file.Path;
45
import java.util.ArrayList;
56
import java.util.List;
@@ -18,8 +19,10 @@
1819
import javafx.scene.control.SpinnerValueFactory;
1920

2021
import org.jabref.gui.DialogService;
22+
import org.jabref.gui.desktop.JabRefDesktop;
2123
import org.jabref.gui.preferences.PreferenceTabViewModel;
2224
import org.jabref.gui.theme.Theme;
25+
import org.jabref.gui.theme.ThemeTypes;
2326
import org.jabref.gui.util.DirectoryDialogConfiguration;
2427
import org.jabref.gui.util.FileDialogConfiguration;
2528
import org.jabref.logic.l10n.Language;
@@ -40,31 +43,16 @@
4043
import de.saxsys.mvvmfx.utils.validation.Validator;
4144

4245
public class GeneralTabViewModel implements PreferenceTabViewModel {
43-
protected enum ThemeTypes {
44-
LIGHT(Localization.lang("Light")),
45-
DARK(Localization.lang("Dark")),
46-
CUSTOM(Localization.lang("Custom..."));
47-
48-
private final String displayName;
49-
50-
ThemeTypes(String displayName) {
51-
this.displayName = displayName;
52-
}
53-
54-
public String getDisplayName() {
55-
return displayName;
56-
}
57-
}
5846

5947
protected static SpinnerValueFactory<Integer> fontSizeValueFactory =
6048
new SpinnerValueFactory.IntegerSpinnerValueFactory(9, Integer.MAX_VALUE);
6149

6250
private final ReadOnlyListProperty<Language> languagesListProperty =
63-
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(Language.values()));;
51+
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(Language.values()));
6452
private final ObjectProperty<Language> selectedLanguageProperty = new SimpleObjectProperty<>();
6553

6654
private final ReadOnlyListProperty<ThemeTypes> themesListProperty =
67-
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(ThemeTypes.values()));;
55+
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(ThemeTypes.values()));
6856
private final ObjectProperty<ThemeTypes> selectedThemeProperty = new SimpleObjectProperty<>();
6957
private final StringProperty customPathToThemeProperty = new SimpleStringProperty();
7058

@@ -321,4 +309,13 @@ public void backupFileDirBrowse() {
321309
dialogService.showDirectorySelectionDialog(dirDialogConfiguration)
322310
.ifPresent(dir -> backupDirectoryProperty.setValue(dir.toString()));
323311
}
312+
313+
public void openBrowser() {
314+
String url = "https://themes.jabref.org";
315+
try {
316+
JabRefDesktop.openBrowser(url, preferences.getFilePreferences());
317+
} catch (IOException e) {
318+
dialogService.showErrorDialogAndWait(Localization.lang("Could not open website."), e);
319+
}
320+
}
324321
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.jabref.gui.theme;
2+
3+
import org.jabref.logic.l10n.Localization;
4+
5+
public enum ThemeTypes {
6+
7+
LIGHT(Localization.lang("Light")),
8+
DARK(Localization.lang("Dark")),
9+
CUSTOM(Localization.lang("Custom..."));
10+
11+
private final String displayName;
12+
13+
ThemeTypes(String displayName) {
14+
this.displayName = displayName;
15+
}
16+
17+
public String getDisplayName() {
18+
return displayName;
19+
}
20+
}

src/main/resources/l10n/JabRef_en.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,6 +2580,8 @@ Finished\ writing\ metadata\ for\ library\ %0\ (%1\ succeeded,\ %2\ skipped,\ %3
25802580
Processing...=Processing...
25812581
Writing\ metadata\ to\ %0=Writing metadata to %0
25822582
2583+
Get\ more\ themes...=Get more themes...
2584+
25832585
Add\ selected\ entries\ to\ database=Add selected entries to database
25842586
The\ selected\ entry\ doesn't\ have\ a\ DOI\ linked\ to\ it.\ Lookup\ a\ DOI\ and\ try\ again.=The selected entry doesn't have a DOI linked to it. Lookup a DOI and try again.
25852587
Cited\ By=Cited By

0 commit comments

Comments
 (0)