Skip to content

Commit 00fc407

Browse files
authored
Add more walkthroughs, donation prompt, and responsive layout for welcome tab (#13679)
* Add "Add Group" walkthrough, tweak quick settings, and tweak welcome tab * Refactor search modifier buttons to bind bidirectionally with SearchPreferences * Fix issue with repeated localization * Add donation popup in WelcomeTab * Add search walkthrough and responsive layout for WelcomeTab * Additional fix to responsive layout * Fix walkthrough color * Update CHANGELOG.md * Small tweaaks to Walkthroughs * Add search walkthrough and responsive layout for WelcomeTab * Additional fix to responsive layout * Fix walkthrough color * Update CHANGELOG.md * Small tweaaks to Walkthroughs * test(donation): Add test to DonationProvider and refactored the display calculation * fix(donation): Applied all the suggested changes * test(donation): Apply open rewrite * test(donation): Use appropriate mock parameters for testing * fix(donation): Fix imports in GuiPreferences * style: Remove extra newlines at end of new walkthroughs and donations * fix: update according to Subhramit and Carl's suggestion * fix: fix the GlobalSearchBarTest
1 parent 106b74f commit 00fc407

File tree

27 files changed

+1497
-217
lines changed

27 files changed

+1497
-217
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
7373
- We changed the validation error dialog for overriding the default file directories to a confirmation dialog for saving other preferences under the library properties. [#13488](https://github.com/JabRef/jabref/pull/13488)
7474
- We improved file exists warning dialog with clearer options and tooltips [#12565](https://github.com/JabRef/jabref/issues/12565)
7575
- We introduced walkthrough functionality [#12664](https://github.com/JabRef/jabref/issues/12664)
76+
- The Welcome tab now has a responsive layout. [#12664](https://github.com/JabRef/jabref/issues/12664)
77+
- We introduced a donation prompt in the Welcome tab. [#12664](https://github.com/JabRef/jabref/issues/12664)
7678

7779
### Fixed
7880

jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.jabref.gui.search.SearchType;
4949
import org.jabref.gui.sidepane.SidePane;
5050
import org.jabref.gui.sidepane.SidePaneType;
51+
import org.jabref.gui.theme.ThemeManager;
5152
import org.jabref.gui.undo.CountingUndoManager;
5253
import org.jabref.gui.undo.RedoAction;
5354
import org.jabref.gui.undo.UndoAction;
@@ -447,7 +448,8 @@ private void initBindings() {
447448
}
448449

449450
private void updateTabBarVisible() {
450-
if (preferences.getWorkspacePreferences().shouldHideTabBar() && stateManager.getOpenDatabases().size() <= 1) {
451+
// When WelcomeTab is open, the tabbar should be visible
452+
if (preferences.getWorkspacePreferences().shouldHideTabBar() && tabbedPane.getTabs().size() <= 1) {
451453
if (!tabbedPane.getStyleClass().contains("hide-tab-bar")) {
452454
tabbedPane.getStyleClass().add("hide-tab-bar");
453455
}
@@ -507,7 +509,9 @@ public void showWelcomeTab() {
507509
clipBoardManager,
508510
taskExecutor,
509511
fileHistory,
510-
Injector.instantiateModelOrService(BuildInfo.class)
512+
Injector.instantiateModelOrService(BuildInfo.class),
513+
preferences.getWorkspacePreferences(),
514+
Injector.instantiateModelOrService(ThemeManager.class)
511515
);
512516
tabbedPane.getTabs().add(welcomeTab);
513517
tabbedPane.getSelectionModel().select(welcomeTab);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.jabref.gui.preferences;
2+
3+
import javafx.beans.property.BooleanProperty;
4+
import javafx.beans.property.IntegerProperty;
5+
import javafx.beans.property.SimpleBooleanProperty;
6+
import javafx.beans.property.SimpleIntegerProperty;
7+
8+
public class DonationPreferences {
9+
private final BooleanProperty neverShowAgain = new SimpleBooleanProperty();
10+
private final IntegerProperty lastShownEpochDay = new SimpleIntegerProperty();
11+
12+
public DonationPreferences(boolean neverShowAgain, int lastShownEpochDay) {
13+
this.neverShowAgain.set(neverShowAgain);
14+
this.lastShownEpochDay.set(lastShownEpochDay);
15+
}
16+
17+
public boolean isNeverShowAgain() {
18+
return neverShowAgain.get();
19+
}
20+
21+
public void setNeverShowAgain(boolean value) {
22+
this.neverShowAgain.set(value);
23+
}
24+
25+
public BooleanProperty neverShowAgainProperty() {
26+
return neverShowAgain;
27+
}
28+
29+
public int getLastShownEpochDay() {
30+
return lastShownEpochDay.get();
31+
}
32+
33+
public void setLastShownEpochDay(int value) {
34+
this.lastShownEpochDay.set(value);
35+
}
36+
37+
public IntegerProperty lastShownEpochDayProperty() {
38+
return lastShownEpochDay;
39+
}
40+
}

jabgui/src/main/java/org/jabref/gui/preferences/GuiPreferences.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ public interface GuiPreferences extends CliPreferences {
5858
KeyBindingRepository getKeyBindingRepository();
5959

6060
NewEntryPreferences getNewEntryPreferences();
61+
62+
DonationPreferences getDonationPreferences();
6163
}

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre
204204
private static final String INCLUDE_CROSS_REFERENCES = "includeCrossReferences";
205205
private static final String ASK_FOR_INCLUDING_CROSS_REFERENCES = "askForIncludingCrossReferences";
206206

207+
// region Donation preferences
208+
private static final String DONATION_NEVER_SHOW = "donationNeverShow";
209+
private static final String DONATION_LAST_SHOWN_EPOCH_DAY = "donationLastShownEpochDay";
210+
// endregion
211+
207212
// region NewEntryPreferences
208213
private static final String CREATE_ENTRY_APPROACH = "latestApproach";
209214
private static final String CREATE_ENTRY_EXPAND_RECOMMENDED = "typesRecommendedExpanded";
@@ -236,6 +241,7 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre
236241
private KeyBindingRepository keyBindingRepository;
237242
private CopyToPreferences copyToPreferences;
238243
private NewEntryPreferences newEntryPreferences;
244+
private DonationPreferences donationPreferences;
239245

240246
private JabRefGuiPreferences() {
241247
super();
@@ -378,6 +384,11 @@ private JabRefGuiPreferences() {
378384
defaults.put(ASK_FOR_INCLUDING_CROSS_REFERENCES, Boolean.TRUE);
379385
defaults.put(INCLUDE_CROSS_REFERENCES, Boolean.FALSE);
380386

387+
// region donation defaults
388+
defaults.put(DONATION_NEVER_SHOW, Boolean.FALSE);
389+
defaults.put(DONATION_LAST_SHOWN_EPOCH_DAY, -1);
390+
// endregion
391+
381392
// region NewEntryUnifierPreferences
382393
defaults.put(CREATE_ENTRY_APPROACH, List.of(NewEntryDialogTab.values()).indexOf(NewEntryDialogTab.CHOOSE_ENTRY_TYPE));
383394
defaults.put(CREATE_ENTRY_EXPAND_RECOMMENDED, true);
@@ -1192,6 +1203,17 @@ public NewEntryPreferences getNewEntryPreferences() {
11921203
return newEntryPreferences;
11931204
}
11941205

1206+
public DonationPreferences getDonationPreferences() {
1207+
if (donationPreferences != null) {
1208+
return donationPreferences;
1209+
}
1210+
1211+
donationPreferences = new DonationPreferences(getBoolean(DONATION_NEVER_SHOW), getInt(DONATION_LAST_SHOWN_EPOCH_DAY));
1212+
EasyBind.listen(donationPreferences.neverShowAgainProperty(), (_, _, newValue) -> putBoolean(DONATION_NEVER_SHOW, newValue));
1213+
EasyBind.listen(donationPreferences.lastShownEpochDayProperty(), (_, _, newValue) -> putInt(DONATION_LAST_SHOWN_EPOCH_DAY, newValue.intValue()));
1214+
return donationPreferences;
1215+
}
1216+
11951217
/**
11961218
* In GUI mode, we can lookup the directory better
11971219
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class GeneralTab extends AbstractPreferenceTabView<GeneralTabViewModel> i
4949
@FXML private CheckBox confirmDelete;
5050
@FXML private CheckBox shouldAskForIncludingCrossReferences;
5151
@FXML private CheckBox confirmHideTabBar;
52+
@FXML private CheckBox donationNeverShow;
5253
@FXML private ComboBox<BibDatabaseMode> biblatexMode;
5354
@FXML private CheckBox alwaysReformatBib;
5455
@FXML private CheckBox autosaveLocalLibraries;
@@ -125,6 +126,7 @@ public void initialize() {
125126
confirmDelete.selectedProperty().bindBidirectional(viewModel.confirmDeleteProperty());
126127
shouldAskForIncludingCrossReferences.selectedProperty().bindBidirectional(viewModel.shouldAskForIncludingCrossReferences());
127128
confirmHideTabBar.selectedProperty().bindBidirectional(viewModel.confirmHideTabBarProperty());
129+
donationNeverShow.selectedProperty().bindBidirectional(viewModel.donationNeverShowProperty());
128130

129131
new ViewModelListCellFactory<BibDatabaseMode>()
130132
.withText(BibDatabaseMode::getFormattedName)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public class GeneralTabViewModel implements PreferenceTabViewModel {
8484
private final BooleanProperty confirmDeleteProperty = new SimpleBooleanProperty();
8585
private final BooleanProperty shouldAskForIncludingCrossReferencesProperty = new SimpleBooleanProperty();
8686
private final BooleanProperty hideTabBarProperty = new SimpleBooleanProperty();
87+
private final BooleanProperty donationNeverShowProperty = new SimpleBooleanProperty();
8788

8889
private final ListProperty<BibDatabaseMode> bibliographyModeListProperty = new SimpleListProperty<>();
8990
private final ObjectProperty<BibDatabaseMode> selectedBiblatexModeProperty = new SimpleObjectProperty<>();
@@ -210,6 +211,7 @@ public void setValues() {
210211
confirmDeleteProperty.setValue(workspacePreferences.shouldConfirmDelete());
211212
shouldAskForIncludingCrossReferencesProperty.setValue(preferences.getCopyToPreferences().getShouldAskForIncludingCrossReferences());
212213
hideTabBarProperty.setValue(workspacePreferences.shouldHideTabBar());
214+
donationNeverShowProperty.setValue(preferences.getDonationPreferences().isNeverShowAgain());
213215

214216
bibliographyModeListProperty.setValue(FXCollections.observableArrayList(BibDatabaseMode.values()));
215217
selectedBiblatexModeProperty.setValue(libraryPreferences.getDefaultBibDatabaseMode());
@@ -256,6 +258,7 @@ public void storeSettings() {
256258
workspacePreferences.setConfirmDelete(confirmDeleteProperty.getValue());
257259
preferences.getCopyToPreferences().setShouldAskForIncludingCrossReferences(shouldAskForIncludingCrossReferencesProperty.getValue());
258260
workspacePreferences.setHideTabBar(confirmHideTabBarProperty().getValue());
261+
preferences.getDonationPreferences().setNeverShowAgain(donationNeverShowProperty.getValue());
259262

260263
libraryPreferences.setDefaultBibDatabaseMode(selectedBiblatexModeProperty.getValue());
261264

@@ -423,6 +426,10 @@ public BooleanProperty confirmHideTabBarProperty() {
423426
return this.hideTabBarProperty;
424427
}
425428

429+
public BooleanProperty donationNeverShowProperty() {
430+
return this.donationNeverShowProperty;
431+
}
432+
426433
public ListProperty<BibDatabaseMode> biblatexModeListProperty() {
427434
return this.bibliographyModeListProperty;
428435
}

jabgui/src/main/java/org/jabref/gui/search/GlobalSearchBar.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,14 @@ private void initSearchModifierButtons() {
278278
regexButton.setSelected(searchPreferences.isRegularExpression());
279279
regexButton.setTooltip(new Tooltip(Localization.lang("Regular expression") + "\n" + Localization.lang("This only affects unfielded terms. For using RegEx in a fielded term, use =~ operator.")));
280280
initSearchModifierButton(regexButton);
281-
regexButton.setOnAction(event -> {
281+
searchPreferences.getObservableSearchFlags().addListener((SetChangeListener<SearchFlags>) change -> {
282+
if (change.wasAdded() && change.getElementAdded() == SearchFlags.REGULAR_EXPRESSION) {
283+
regexButton.setSelected(true);
284+
} else if (change.wasRemoved() && change.getElementRemoved() == SearchFlags.REGULAR_EXPRESSION) {
285+
regexButton.setSelected(false);
286+
}
287+
});
288+
regexButton.setOnAction(_ -> {
282289
searchPreferences.setSearchFlag(SearchFlags.REGULAR_EXPRESSION, regexButton.isSelected());
283290
searchField.requestFocus();
284291
updateSearchQuery();
@@ -287,7 +294,14 @@ private void initSearchModifierButtons() {
287294
caseSensitiveButton.setSelected(searchPreferences.isCaseSensitive());
288295
caseSensitiveButton.setTooltip(new Tooltip(Localization.lang("Case sensitive") + "\n" + Localization.lang("This only affects unfielded terms. For using case-sensitive in a fielded term, use =! operator.")));
289296
initSearchModifierButton(caseSensitiveButton);
290-
caseSensitiveButton.setOnAction(event -> {
297+
searchPreferences.getObservableSearchFlags().addListener((SetChangeListener<SearchFlags>) change -> {
298+
if (change.wasAdded() && change.getElementAdded() == SearchFlags.CASE_SENSITIVE) {
299+
caseSensitiveButton.setSelected(true);
300+
} else if (change.wasRemoved() && change.getElementRemoved() == SearchFlags.CASE_SENSITIVE) {
301+
caseSensitiveButton.setSelected(false);
302+
}
303+
});
304+
caseSensitiveButton.setOnAction(_ -> {
291305
searchPreferences.setSearchFlag(SearchFlags.CASE_SENSITIVE, caseSensitiveButton.isSelected());
292306
searchField.requestFocus();
293307
updateSearchQuery();
@@ -296,15 +310,17 @@ private void initSearchModifierButtons() {
296310
keepSearchString.setSelected(searchPreferences.shouldKeepSearchString());
297311
keepSearchString.setTooltip(new Tooltip(Localization.lang("Keep search string across libraries")));
298312
initSearchModifierButton(keepSearchString);
299-
keepSearchString.selectedProperty().addListener((obs, oldVal, newVal) -> {
313+
searchPreferences.keepSearchStringProperty().addListener((_, _, newVal) -> keepSearchString.setSelected(newVal));
314+
keepSearchString.selectedProperty().addListener((_, _, newVal) -> {
300315
searchPreferences.setKeepSearchString(newVal);
301316
searchField.requestFocus();
302317
});
303318

304319
filterModeButton.setSelected(searchPreferences.getSearchDisplayMode() == SearchDisplayMode.FILTER);
305320
filterModeButton.setTooltip(new Tooltip(Localization.lang("Filter search results")));
306321
initSearchModifierButton(filterModeButton);
307-
filterModeButton.setOnAction(event -> {
322+
searchPreferences.searchDisplayModeProperty().addListener((_, _, newVal) -> filterModeButton.setSelected(newVal == SearchDisplayMode.FILTER));
323+
filterModeButton.setOnAction(_ -> {
308324
searchPreferences.setSearchDisplayMode(filterModeButton.isSelected() ? SearchDisplayMode.FILTER : SearchDisplayMode.FLOAT);
309325
searchField.requestFocus();
310326
});

jabgui/src/main/java/org/jabref/gui/util/URLs.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public class URLs {
2323
public static final String GROBID_DOC = "https://docs.jabref.org/collect/newentryfromplaintext#grobid";
2424
public static final String ENTRY_TABLE_COLUMNS_DOC = "https://docs.jabref.org/advanced/main-window";
2525

26+
// Walkthroughs URLs
27+
public static final String GROUPS_DOC = "https://docs.jabref.org/finding-sorting-and-cleaning-entries/groups";
28+
public static final String SEARCH_WITH_IN_LIBRARY_DOC = "https://docs.jabref.org/finding-sorting-and-cleaning-entries/search";
29+
public static final String MANAGE_ASSOCIATED_FILES_DOC = "https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks";
30+
public static final String LINK_EXTERNAL_FILE_WALKTHROUGH_EXAMPLE_PDF = "https://nutritionandmetabolism.biomedcentral.com/counter/pdf/10.1186/1743-7075-3-2.pdf";
31+
public static final String ADD_PDF_DOC = "https://docs.jabref.org/collect/add-pdfs-to-an-entry";
32+
public static final String FIND_UNLINKED_FILES_DOC = "https://docs.jabref.org/collect/findunlinkedfiles";
33+
2634
// AboutDialogViewModel URLs
2735
public static final String HOMEPAGE_URL = "https://www.jabref.org";
2836
public static final String DONATION_URL = "https://donations.jabref.org";

0 commit comments

Comments
 (0)