Skip to content

Commit 5286ebc

Browse files
authored
Merge branch 'main' into fix/add-buttons
2 parents 01eb895 + 225bba6 commit 5286ebc

File tree

78 files changed

+1385
-775
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1385
-775
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
1111

1212
### Added
1313

14+
- We fixed an issue where "Print preview" would throw a `NullPointerException` if no printers were available. [#13708](https://github.com/JabRef/jabref/issues/13708)
1415
- We added the option to enable the language server in the preferences. [#13697](https://github.com/JabRef/jabref/pull/13697)
1516
- We introduced an option in Preferences under (under Linked files -> Linked file name conventions) to automatically rename linked files when an entry data changes. [#11316](https://github.com/JabRef/jabref/issues/11316)
1617
- We added tooltips (on hover) for 'Library-specific file directory', 'User-specific file directory' and 'LaTeX file directory' fields of the library properties window. [#12269](https://github.com/JabRef/jabref/issues/12269)

jabgui/src/main/java/org/jabref/gui/JabRefDialogService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,11 @@ public Optional<Path> showFileOpenFromArchiveDialog(Path archivePath) throws IOE
526526
}
527527

528528
@Override
529-
public void showCustomDialog(BaseDialog<?> aboutDialogView) {
530-
if (aboutDialogView.getOwner() == null) {
531-
aboutDialogView.initOwner(mainWindow);
529+
public void showCustomDialog(BaseDialog<?> dialogView) {
530+
if (dialogView.getOwner() == null) {
531+
dialogView.initOwner(mainWindow);
532532
}
533-
aboutDialogView.show();
533+
dialogView.show();
534534
}
535535

536536
@Override

jabgui/src/main/java/org/jabref/gui/JabRefGUI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ public void initialize() {
181181

182182
JabRefGUI.themeManager = new ThemeManager(
183183
preferences.getWorkspacePreferences(),
184-
fileUpdateMonitor,
185-
Runnable::run);
184+
fileUpdateMonitor
185+
);
186186
Injector.setModelOrService(ThemeManager.class, themeManager);
187187

188188
JabRefGUI.countingUndoManager = new CountingUndoManager();

jabgui/src/main/java/org/jabref/gui/actions/ActionHelper.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import javafx.collections.ObservableList;
1111

1212
import org.jabref.gui.StateManager;
13+
import org.jabref.logic.git.GitHandler;
14+
import org.jabref.logic.git.util.GitHandlerRegistry;
1315
import org.jabref.logic.preferences.CliPreferences;
1416
import org.jabref.logic.shared.DatabaseLocation;
1517
import org.jabref.logic.util.io.FileUtil;
@@ -104,4 +106,21 @@ public static BooleanExpression hasLinkedFileForSelectedEntries(StateManager sta
104106
return BooleanExpression.booleanExpression(EasyBind.reduce(stateManager.getSelectedEntries(),
105107
entries -> entries.anyMatch(entry -> !entry.getFiles().isEmpty())));
106108
}
109+
110+
public static BooleanExpression needsGitRemoteConfigured(StateManager stateManager) {
111+
return BooleanExpression.booleanExpression(
112+
EasyBind.map(stateManager.activeDatabaseProperty(), contextOptional -> {
113+
if (contextOptional.isPresent()) {
114+
return contextOptional.get().getDatabasePath()
115+
.map(path -> {
116+
GitHandler handler = new GitHandlerRegistry().get(path.getParent());
117+
return handler != null && handler.hasRemote("origin");
118+
})
119+
.orElse(false);
120+
} else {
121+
return false;
122+
}
123+
})
124+
);
125+
}
107126
}

jabgui/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.jabref.gui.DialogService;
1212
import org.jabref.gui.LibraryTabContainer;
1313
import org.jabref.gui.StateManager;
14-
import org.jabref.gui.theme.ThemeManager;
1514
import org.jabref.gui.util.BaseDialog;
1615
import org.jabref.gui.util.ViewModelListCellFactory;
1716
import org.jabref.logic.l10n.Localization;
@@ -34,7 +33,6 @@ public class FromAuxDialog extends BaseDialog<Void> {
3433

3534
@Inject private CliPreferences preferences;
3635
@Inject private DialogService dialogService;
37-
@Inject private ThemeManager themeManager;
3836
@Inject private StateManager stateManager;
3937

4038
private final LibraryTabContainer tabContainer;
@@ -57,8 +55,6 @@ public FromAuxDialog(LibraryTabContainer tabContainer) {
5755
}
5856
return null;
5957
});
60-
61-
themeManager.updateFontStyle(getDialogPane().getScene());
6258
}
6359

6460
@FXML

jabgui/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleView.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import javafx.collections.ListChangeListener;
44
import javafx.collections.ObservableList;
55
import javafx.fxml.FXML;
6+
import javafx.geometry.Pos;
67
import javafx.scene.Node;
78
import javafx.scene.control.ButtonType;
89
import javafx.scene.control.ContentDisplay;
@@ -24,7 +25,6 @@
2425
import org.jabref.gui.keyboard.KeyBinding;
2526
import org.jabref.gui.keyboard.KeyBindingRepository;
2627
import org.jabref.gui.preferences.GuiPreferences;
27-
import org.jabref.gui.theme.ThemeManager;
2828
import org.jabref.gui.util.BaseDialog;
2929
import org.jabref.gui.util.ControlHelper;
3030
import org.jabref.logic.l10n.Localization;
@@ -48,7 +48,6 @@ public class ErrorConsoleView extends BaseDialog<Void> {
4848
@Inject private ClipBoardManager clipBoardManager;
4949
@Inject private BuildInfo buildInfo;
5050
@Inject private KeyBindingRepository keyBindingRepository;
51-
@Inject private ThemeManager themeManager;
5251

5352
public ErrorConsoleView() {
5453
this.setTitle(Localization.lang("Event log"));
@@ -61,8 +60,6 @@ public ErrorConsoleView() {
6160
ControlHelper.setAction(copyLogButton, getDialogPane(), event -> copyLog());
6261
ControlHelper.setAction(clearLogButton, getDialogPane(), event -> clearLog());
6362
ControlHelper.setAction(createIssueButton, getDialogPane(), event -> createIssue());
64-
65-
themeManager.updateFontStyle(getDialogPane().getScene());
6663
}
6764

6865
@FXML
@@ -83,19 +80,21 @@ private void initialize() {
8380

8481
private Callback<ListView<LogEventViewModel>, ListCell<LogEventViewModel>> createCellFactory() {
8582
return cell -> new ListCell<>() {
86-
private HBox graphic;
87-
private Node icon;
88-
private VBox message;
89-
private Label heading;
90-
private Label stacktrace;
83+
private final HBox graphic;
84+
private final VBox message;
85+
private final Label heading;
86+
private final Label stacktrace;
9187

9288
{
93-
graphic = new HBox(10);
89+
graphic = new HBox();
9490
heading = new Label();
9591
stacktrace = new Label();
9692
message = new VBox();
93+
message.setAlignment(Pos.CENTER_LEFT);
9794
message.getChildren().setAll(heading, stacktrace);
95+
message.getStyleClass().add("message-box");
9896
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
97+
getStyleClass().add("error-console-cell");
9998
}
10099

101100
@Override
@@ -105,10 +104,17 @@ public void updateItem(LogEventViewModel event, boolean empty) {
105104
if ((event == null) || empty) {
106105
setGraphic(null);
107106
} else {
108-
icon = event.getIcon().getGraphicNode();
107+
Node icon = event.getIcon().getGraphicNode();
109108
heading.setText(event.getDisplayText());
110109
heading.getStyleClass().setAll(event.getStyleClass());
111-
stacktrace.setText(event.getStackTrace().orElse(""));
110+
event.getStackTrace().ifPresentOrElse(text -> {
111+
stacktrace.setText(text);
112+
stacktrace.setVisible(true);
113+
stacktrace.setManaged(true);
114+
}, () -> {
115+
stacktrace.setVisible(false);
116+
stacktrace.setManaged(false);
117+
});
112118
graphic.getStyleClass().setAll(event.getStyleClass());
113119
graphic.getChildren().setAll(icon, message);
114120
setGraphic(graphic);

jabgui/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.jabref.gui.actions.StandardActions;
3737
import org.jabref.gui.icon.JabRefIcon;
3838
import org.jabref.gui.preferences.GuiPreferences;
39-
import org.jabref.gui.theme.ThemeManager;
4039
import org.jabref.gui.util.BaseDialog;
4140
import org.jabref.gui.util.FileNodeViewModel;
4241
import org.jabref.gui.util.IconValidationDecorator;
@@ -59,7 +58,6 @@
5958
import org.controlsfx.control.CheckTreeView;
6059

6160
public class UnlinkedFilesDialogView extends BaseDialog<Void> {
62-
6361
private static final String REFRESH_CLASS = "refresh";
6462

6563
@FXML private TextField directoryPathField;
@@ -89,7 +87,6 @@ public class UnlinkedFilesDialogView extends BaseDialog<Void> {
8987
@Inject private UndoManager undoManager;
9088
@Inject private TaskExecutor taskExecutor;
9189
@Inject private FileUpdateMonitor fileUpdateMonitor;
92-
@Inject private ThemeManager themeManager;
9390

9491
private final ControlsFxVisualizer validationVisualizer;
9592
private UnlinkedFilesDialogViewModel viewModel;
@@ -112,8 +109,6 @@ public UnlinkedFilesDialogView() {
112109
saveConfiguration();
113110
return null;
114111
});
115-
116-
themeManager.updateFontStyle(getDialogPane().getScene());
117112
}
118113

119114
@FXML

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
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;
5251
import org.jabref.gui.undo.CountingUndoManager;
5352
import org.jabref.gui.undo.RedoAction;
5453
import org.jabref.gui.undo.UndoAction;
@@ -510,8 +509,7 @@ public void showWelcomeTab() {
510509
taskExecutor,
511510
fileHistory,
512511
Injector.instantiateModelOrService(BuildInfo.class),
513-
preferences.getWorkspacePreferences(),
514-
Injector.instantiateModelOrService(ThemeManager.class)
512+
preferences.getWorkspacePreferences()
515513
);
516514
tabbedPane.getTabs().add(welcomeTab);
517515
tabbedPane.getSelectionModel().select(welcomeTab);

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
import org.jabref.gui.externalfiles.AutoLinkFilesAction;
3838
import org.jabref.gui.externalfiles.DownloadFullTextAction;
3939
import org.jabref.gui.externalfiles.FindUnlinkedFilesAction;
40+
import org.jabref.gui.git.GitCommitAction;
41+
import org.jabref.gui.git.GitPullAction;
42+
import org.jabref.gui.git.GitPushAction;
4043
import org.jabref.gui.git.GitShareToGitHubAction;
4144
import org.jabref.gui.help.AboutAction;
4245
import org.jabref.gui.help.ErrorConsoleAction;
@@ -179,9 +182,12 @@ private void createMenu() {
179182
new SeparatorMenuItem(),
180183

181184
// region: Sharing of the library
182-
183185
// TODO: Should be only enabled if not yet shared.
184186
factory.createSubMenu(StandardActions.GIT,
187+
factory.createMenuItem(StandardActions.GIT_COMMIT, new GitCommitAction(dialogService, stateManager)),
188+
factory.createMenuItem(StandardActions.GIT_PULL, new GitPullAction(dialogService, stateManager, preferences, taskExecutor)),
189+
factory.createMenuItem(StandardActions.GIT_PUSH, new GitPushAction(dialogService, stateManager, preferences, taskExecutor)),
190+
new SeparatorMenuItem(),
185191
factory.createMenuItem(StandardActions.GIT_SHARE, new GitShareToGitHubAction(dialogService, stateManager))
186192
),
187193

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.jabref.gui.git;
2+
3+
import org.jabref.gui.DialogService;
4+
import org.jabref.gui.StateManager;
5+
import org.jabref.gui.actions.ActionHelper;
6+
import org.jabref.gui.actions.SimpleCommand;
7+
import org.jabref.logic.git.GitHandler;
8+
import org.jabref.logic.git.status.GitStatusChecker;
9+
import org.jabref.logic.l10n.Localization;
10+
11+
public class GitCommitAction extends SimpleCommand {
12+
13+
private final DialogService dialogService;
14+
private final StateManager stateManager;
15+
16+
public GitCommitAction(DialogService dialogService, StateManager stateManager) {
17+
this.dialogService = dialogService;
18+
this.stateManager = stateManager;
19+
20+
this.executable.bind(ActionHelper.needsDatabase(stateManager));
21+
}
22+
23+
@Override
24+
public void execute() {
25+
if (hasNothingToCommit()) {
26+
dialogService.notify(Localization.lang("Nothing to commit."));
27+
return;
28+
}
29+
30+
dialogService.showCustomDialogAndWait(
31+
new GitCommitDialogView()
32+
);
33+
}
34+
35+
private boolean hasNothingToCommit() {
36+
return stateManager.getActiveDatabase()
37+
.flatMap(context -> context.getDatabasePath())
38+
.flatMap(GitHandler::fromAnyPath)
39+
.map(GitStatusChecker::checkStatus)
40+
.map(status -> !status.uncommittedChanges())
41+
.orElse(true);
42+
}
43+
}

0 commit comments

Comments
 (0)