diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.fxml b/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.fxml index b0e16fed45..4d84a66a37 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.fxml +++ b/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.fxml @@ -32,5 +32,4 @@ - diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java b/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java index 9f73974a86..d63ee659ae 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java @@ -53,8 +53,8 @@ import java.util.Date; import javax.annotation.Nullable; +import static bisq.desktop.util.FormBuilder.add2Buttons; import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static bisq.desktop.util.FormBuilder.addButton; @FxmlView public class BackupView extends ActivatableView { @@ -100,10 +100,12 @@ public class BackupView extends ActivatableView { updateButtons(); FormBuilder.addTitledGroupBg(root, ++gridRow, 2, Res.get("account.backup.appDir"), Layout.GROUP_DISTANCE); - openDataDirButton = addButton(root, gridRow, Res.get("account.backup.openDirectory"), Layout.FIRST_ROW_AND_GROUP_DISTANCE); - openDataDirButton.setDefaultButton(false); - openLogsButton = addButton(root, ++gridRow, Res.get("account.backup.openLogFile")); - openLogsButton.setDefaultButton(false); + + final Tuple2 applicationDataDirTuple2 = add2Buttons(root, gridRow, Res.get("account.backup.openDirectory"), + Res.get("account.backup.openLogFile"), Layout.FIRST_ROW_AND_GROUP_DISTANCE, false); + + openDataDirButton = applicationDataDirTuple2.first; + openLogsButton = applicationDataDirTuple2.second; } @Override @@ -128,24 +130,8 @@ public class BackupView extends ActivatableView { } }); - openDataDirButton.setOnAction(event -> { - try { - Utilities.openFile(dataDir); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.getMessage()); - showWrongPathWarningAndReset(e); - } - }); - openLogsButton.setOnAction(event -> { - try { - Utilities.openFile(logFile); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.getMessage()); - showWrongPathWarningAndReset(e); - } - }); + openFileOrShowWarning(openDataDirButton, dataDir); + openFileOrShowWarning(openLogsButton, logFile); backupNow.setOnAction(event -> { String backupDirectory = preferences.getBackupDirectory(); @@ -164,6 +150,18 @@ public class BackupView extends ActivatableView { }); } + private void openFileOrShowWarning(Button button, File dataDir) { + button.setOnAction(event -> { + try { + Utilities.openFile(dataDir); + } catch (IOException e) { + e.printStackTrace(); + log.error(e.getMessage()); + showWrongPathWarningAndReset(e); + } + }); + } + @Override protected void deactivate() { backUpLocationTextField.focusedProperty().removeListener(backUpLocationTextFieldFocusListener); diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.fxml b/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.fxml index bb067fd5bc..e03e20b81b 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.fxml +++ b/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.fxml @@ -30,6 +30,6 @@ - + diff --git a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java index 6307d85a5a..4822f72a26 100644 --- a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java +++ b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java @@ -1072,9 +1072,18 @@ public class FormBuilder { public static Tuple3 addTopLabel2Buttons(GridPane gridPane, int rowIndex, String labelText, String title1, String title2, double top) { HBox hBox = new HBox(); hBox.setSpacing(10); + Button button1 = new AutoTooltipButton(title1); button1.setDefaultButton(true); + button1.getStyleClass().add("action-button"); + button1.setDefaultButton(true); + button1.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button1, Priority.ALWAYS); + Button button2 = new AutoTooltipButton(title2); + button2.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button2, Priority.ALWAYS); + hBox.getChildren().addAll(button1, button2); final Tuple2 topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, labelText, hBox, top); @@ -1095,10 +1104,20 @@ public class FormBuilder { return addButton(gridPane, rowIndex, title, 15); } + public static Button addPrimaryActionButton(GridPane gridPane, int rowIndex, String title, double top) { + return addButton(gridPane, rowIndex, title, top, true); + } + public static Button addButton(GridPane gridPane, int rowIndex, String title, double top) { + return addButton(gridPane, rowIndex, title, top, false); + } + + public static Button addButton(GridPane gridPane, int rowIndex, String title, double top, boolean isPrimaryAction) { Button button = new AutoTooltipButton(title); - button.setDefaultButton(true); - button.getStyleClass().add("action-button"); + if (isPrimaryAction) { + button.setDefaultButton(true); + button.getStyleClass().add("action-button"); + } GridPane.setRowIndex(button, rowIndex); GridPane.setColumnIndex(button, 0); @@ -1123,7 +1142,15 @@ public class FormBuilder { int rowIndex, String title1, String title2) { - return add2Buttons(gridPane, rowIndex, title1, title2, 15); + return add2ButtonsAfterGroup(gridPane, rowIndex, title1, title2, true); + } + + public static Tuple2 add2ButtonsAfterGroup(GridPane gridPane, + int rowIndex, + String title1, + String title2, + boolean hasPrimaryButton) { + return add2Buttons(gridPane, rowIndex, title1, title2, 15, hasPrimaryButton); } public static Tuple2 add2Buttons(GridPane gridPane, @@ -1131,13 +1158,30 @@ public class FormBuilder { String title1, String title2, double top) { + return add2Buttons(gridPane, rowIndex, title1, title2, top, true); + } + + public static Tuple2 add2Buttons(GridPane gridPane, int rowIndex, String title1, + String title2, double top, boolean hasPrimaryButton) { HBox hBox = new HBox(); hBox.setSpacing(10); + Button button1 = new AutoTooltipButton(title1); - button1.getStyleClass().add("action-button"); - button1.setDefaultButton(true); + + if (hasPrimaryButton) { + button1.getStyleClass().add("action-button"); + button1.setDefaultButton(true); + } + + button1.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button1, Priority.ALWAYS); + Button button2 = new AutoTooltipButton(title2); + button2.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button2, Priority.ALWAYS); + hBox.getChildren().addAll(button1, button2); + GridPane.setRowIndex(hBox, rowIndex); GridPane.setColumnIndex(hBox, 0); GridPane.setMargin(hBox, new Insets(top, 10, 0, 0)); @@ -1174,9 +1218,20 @@ public class FormBuilder { HBox hBox = new HBox(); hBox.setSpacing(10); Button button1 = new AutoTooltipButton(title1); + + button1.getStyleClass().add("action-button"); button1.setDefaultButton(true); + button1.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button1, Priority.ALWAYS); + Button button2 = new AutoTooltipButton(title2); + button2.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button2, Priority.ALWAYS); + Button button3 = new AutoTooltipButton(title3); + button3.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button3, Priority.ALWAYS); + hBox.getChildren().addAll(button1, button2, button3); GridPane.setRowIndex(hBox, rowIndex); GridPane.setColumnIndex(hBox, 0);