Skip to content
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

Fix wording and close window without action #2077

Merged
merged 3 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ public void initialize() {
pwButton.setOnAction(e -> {
if (!walletsManager.areWalletsEncrypted()) {
new Popup<>().backgroundInfo(Res.get("password.backupReminder"))
.closeButtonText(Res.get("password.backupWasDone"))
.onClose(() -> onApplyPassword(busyAnimation, deriveStatusLabel))
.secondaryActionButtonText(Res.get("password.backupWasDone"))
.onSecondaryAction(() -> onApplyPassword(busyAnimation, deriveStatusLabel))
.actionButtonTextWithGoTo("navigation.account.walletSeed")
.onAction(() -> {
navigation.setReturnPath(navigation.getCurrentPath());
navigation.navigateTo(MainView.class, AccountView.class, SeedWordsView.class);
})
.width(800)
.show();
} else {
onApplyPassword(busyAnimation, deriveStatusLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,10 @@ private HBox getToolBox() {
final Tuple3<VBox, Label, ComboBox<CurrencyListItem>> currencyComboBoxTuple = addTopLabelComboBox(Res.get("shared.currency"),
Res.get("list.currency.select"));
currencyComboBox = currencyComboBoxTuple.third;
currencyComboBox.setButtonCell(GUIUtil.getCurrencyListItemButtonCell(Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"), model.preferences));
currencyComboBox.setCellFactory(GUIUtil.getCurrencyListItemCellFactory(Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"), model.preferences));
currencyComboBox.setButtonCell(GUIUtil.getCurrencyListItemButtonCell(Res.get("shared.trade"),
Res.get("shared.trades"), model.preferences));
currencyComboBox.setCellFactory(GUIUtil.getCurrencyListItemCellFactory(Res.get("shared.trade"),
Res.get("shared.trades"), model.preferences));

currencyComboBox.setPromptText(Res.get("list.currency.select"));

Expand Down
91 changes: 60 additions & 31 deletions desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import java.io.File;
import java.io.IOException;

import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -132,35 +133,36 @@ protected enum Type {
}

protected final static double DEFAULT_WIDTH = 668;

protected Stage stage;
protected GridPane gridPane;
protected Pane owner;

protected int rowIndex = -1;
protected String headLine;
protected Label headlineIcon;
protected String message;
protected String closeButtonText;
protected String actionButtonText;
protected double width = DEFAULT_WIDTH;
protected Pane owner;
protected GridPane gridPane;
protected double buttonDistance = 20;

protected boolean showReportErrorButtons;
private boolean showBusyAnimation;
protected boolean hideCloseButton;
protected boolean isDisplayed;
protected boolean useAnimation = true;

protected Label headlineIcon, headLineLabel, messageLabel;
protected String headLine, message, closeButtonText, actionButtonText,
secondaryActionButtonText, dontShowAgainId, dontShowAgainText,
truncatedMessage;
private String headlineStyle;
protected Button actionButton, secondaryActionButton;
protected AutoTooltipButton closeButton;

protected Optional<Runnable> closeHandlerOptional = Optional.<Runnable>empty();
protected Optional<Runnable> actionHandlerOptional = Optional.<Runnable>empty();
protected Stage stage;
protected boolean showReportErrorButtons;
protected Label messageLabel;
protected String truncatedMessage;
private boolean showBusyAnimation;
protected Button actionButton;
protected Label headLineLabel;
protected String dontShowAgainId;
protected String dontShowAgainText;
protected Optional<Runnable> secondaryActionHandlerOptional = Optional.<Runnable>empty();
protected ChangeListener<Number> positionListener;

protected Timer centerTime;
protected double buttonDistance = 20;
protected Type type = Type.Undefined;
protected boolean hideCloseButton;
protected boolean useAnimation = true;
private String headlineStyle;
protected boolean isDisplayed;


///////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -182,7 +184,7 @@ public void show() {
if (showReportErrorButtons)
addReportErrorButtons();

addCloseButton();
addButtons();
addDontShowAgainCheckBox();
applyStyles();
onShow();
Expand Down Expand Up @@ -245,6 +247,12 @@ public T onAction(Runnable actionHandler) {
return (T) this;
}

public T onSecondaryAction(Runnable secondaryActionHandlerOptional) {
this.secondaryActionHandlerOptional = Optional.of(secondaryActionHandlerOptional);
//noinspection unchecked
return (T) this;
}

public T headLine(String headLine) {
this.headLine = headLine;
//noinspection unchecked
Expand Down Expand Up @@ -382,6 +390,12 @@ public T actionButtonTextWithGoTo(String target) {
return (T) this;
}

public T secondaryActionButtonTextWithGoTo(String target) {
this.secondaryActionButtonText = Res.get("shared.goTo", Res.get(target));
//noinspection unchecked
return (T) this;
}

public T closeButtonTextWithGoTo(String target) {
this.closeButtonText = Res.get("shared.goTo", Res.get(target));
//noinspection unchecked
Expand All @@ -394,9 +408,15 @@ public T actionButtonText(String actionButtonText) {
return (T) this;
}

public T secondaryActionButtonText(String secondaryActionButtonText) {
this.secondaryActionButtonText = secondaryActionButtonText;
//noinspection unchecked
return (T) this;
}

public T useShutDownButton() {
this.actionButtonText = Res.get("shared.shutDown");
this.actionHandlerOptional = Optional.of(BisqApp.getShutDownHandler()::run);
this.actionHandlerOptional = Optional.of(BisqApp.getShutDownHandler());
//noinspection unchecked
return (T) this;
}
Expand Down Expand Up @@ -831,7 +851,7 @@ protected void addDontShowAgainCheckBox() {
}
}

protected void addCloseButton() {
protected void addButtons() {
if (!hideCloseButton) {
closeButton = new AutoTooltipButton(closeButtonText == null ? Res.get("shared.close") : closeButtonText);
closeButton.getStyleClass().add("compact-button");
Expand All @@ -851,10 +871,22 @@ protected void addCloseButton() {
Pane spacer = new Pane();
HBox hBox = new HBox();
hBox.setSpacing(10);

hBox.getChildren().addAll(spacer, actionButton);

if (secondaryActionButtonText != null && secondaryActionHandlerOptional.isPresent()) {
secondaryActionButton = new AutoTooltipButton(secondaryActionButtonText);
secondaryActionButton.setOnAction(event -> {
hide();
secondaryActionHandlerOptional.ifPresent(Runnable::run);
});

hBox.getChildren().add(secondaryActionButton);
}

if (!hideCloseButton)
hBox.getChildren().addAll(spacer, actionButton, closeButton);
else
hBox.getChildren().addAll(spacer, actionButton);
hBox.getChildren().add(closeButton);

HBox.setHgrow(spacer, Priority.ALWAYS);
spacer.setMaxWidth(Double.MAX_VALUE);

Expand Down Expand Up @@ -882,10 +914,7 @@ protected void doClose() {
protected void setTruncatedMessage() {
if (message != null && message.length() > 1800)
truncatedMessage = StringUtils.abbreviate(message, 1800);
else if (message != null)
truncatedMessage = message;
else
truncatedMessage = "";
else truncatedMessage = Objects.requireNonNullElse(message, "");
}

protected double getDuration(double duration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
onShow();
}
Expand Down Expand Up @@ -290,9 +290,9 @@ protected void createGridPane() {
}

@Override
protected void addCloseButton() {
protected void addButtons() {
buttonDistance = 10;
super.addCloseButton();
super.addButtons();

actionButton.setOnAction(event -> save());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ protected void createGridPane() {
}

@Override
protected void addCloseButton() {
protected void addButtons() {
buttonDistance = 10;
super.addCloseButton();
super.addButtons();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
addDontShowAgainCheckBox();
applyStyles();
display();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down Expand Up @@ -201,8 +201,8 @@ public void onFailure(TxBroadcastException exception) {
}

@Override
protected void addCloseButton() {
super.addCloseButton();
protected void addButtons() {
super.addButtons();
actionButton.setOnAction(event -> actionHandlerOptional.ifPresent(Runnable::run));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void show() {
GridPane.setColumnSpan(infoLabel, 2);
gridPane.getChildren().add(infoLabel);

addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ public void show() {
gridPane.getColumnConstraints().get(0).setHalignment(HPos.LEFT);

addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
}

protected void addCloseButton() {
protected void addButtons() {
closeButton = new AutoTooltipButton(closeButtonText == null ? Res.get("shared.close") : closeButtonText);
closeButton.setOnAction(event -> doClose());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ private void addInputFields() {
keyInputTextField.textProperty().addListener(changeListener);
}

private void addButtons() {
@Override
protected void addButtons() {
final Tuple2<Button, Button> buttonButtonTuple2 = add2ButtonsAfterGroup(gridPane, ++rowIndex,
Res.get("shared.unlock"), Res.get("shared.close"));
unlockButton = buttonButtonTuple2.first;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ private void addInputFields() {
passwordTextField.textProperty().addListener(changeListener);
}

private void addButtons() {
@Override
protected void addButtons() {
BusyAnimation busyAnimation = new BusyAnimation(false);
Label deriveStatusLabel = new AutoTooltipLabel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void show() {
createGridPane();
addHeadLine();
addContent();
addCloseButton();
addButtons();
applyStyles();
display();
}
Expand All @@ -78,8 +78,8 @@ private void addContent() {
}

@Override
protected void addCloseButton() {
super.addCloseButton();
protected void addButtons() {
super.addButtons();

closeButton.setText(Res.get("shared.cancel"));

Expand Down
Loading