From 30c827fe3caec9f0e876c0137d3fb4cebde02e9c Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 20 Mar 2016 14:58:19 +0100 Subject: [PATCH] Add hyperlink to tac window --- .../windows/DisplayAlertMessageWindow.java | 7 ++-- .../gui/main/overlays/windows/TacWindow.java | 14 ++++++- .../io/bitsquare/gui/util/FormBuilder.java | 37 ++++++++++++++----- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/DisplayAlertMessageWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/DisplayAlertMessageWindow.java index f6fe7e4621..493ff5782e 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/DisplayAlertMessageWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/DisplayAlertMessageWindow.java @@ -72,9 +72,10 @@ public class DisplayAlertMessageWindow extends Overlay Utilities.openWebPage(url)); + HyperlinkWithIcon hyperlinkWithIcon = addLabelHyperlinkWithIcon(gridPane, ++rowIndex, + "Download:", url).second; + hyperlinkWithIcon.setOnAction(e -> Utilities.openWebPage(url)); + hyperlinkWithIcon.setMaxWidth(550); } else { headLine = "Important information!"; headLineLabel.setStyle("-fx-text-fill: -bs-error-red; -fx-font-weight: bold; -fx-font-size: 22;"); diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java index 1d9812a9c6..33077dd170 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java @@ -2,11 +2,15 @@ package io.bitsquare.gui.main.overlays.windows; import com.google.inject.Inject; import io.bitsquare.app.BitsquareApp; +import io.bitsquare.common.util.Utilities; +import io.bitsquare.gui.components.HyperlinkWithIcon; import io.bitsquare.gui.main.overlays.Overlay; import io.bitsquare.user.Preferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static io.bitsquare.gui.util.FormBuilder.addHyperlinkWithIcon; + public class TacWindow extends Overlay { private static final Logger log = LoggerFactory.getLogger(TacWindow.class); private final Preferences preferences; @@ -35,7 +39,7 @@ public class TacWindow extends Overlay { " - You must reply within 48 hours to each arbitrator inquiry.\n" + " - Failure to follow the above requirements may result in loss of your security deposit.\n\n" + "For more details and a general overview please read the full documentation about the " + - "arbitration system and the dispute process at: https://bitsquare.io/arbitration_system.pdf"; + "arbitration system and the dispute process at:"; message(text); actionButtonText("I agree"); closeButtonText("I disagree and quit"); @@ -45,6 +49,14 @@ public class TacWindow extends Overlay { } } + @Override + protected void addMessage() { + super.addMessage(); + String url = "https://bitsquare.io/arbitration_system.pdf"; + HyperlinkWithIcon hyperlinkWithIcon = addHyperlinkWithIcon(gridPane, ++rowIndex, url, -8); + hyperlinkWithIcon.setOnAction(e -> Utilities.openWebPage(url)); + } + @Override protected void onShow() { display(); diff --git a/gui/src/main/java/io/bitsquare/gui/util/FormBuilder.java b/gui/src/main/java/io/bitsquare/gui/util/FormBuilder.java index 85009fe853..4bad610105 100644 --- a/gui/src/main/java/io/bitsquare/gui/util/FormBuilder.java +++ b/gui/src/main/java/io/bitsquare/gui/util/FormBuilder.java @@ -158,6 +158,23 @@ public class FormBuilder { return new Tuple2<>(label, textField); } + /////////////////////////////////////////////////////////////////////////////////////////// + // HyperlinkWithIcon + /////////////////////////////////////////////////////////////////////////////////////////// + + public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, int rowIndex, String url) { + return addHyperlinkWithIcon(gridPane, rowIndex, url, 0); + } + + public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, int rowIndex, String url, double top) { + HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(url, AwesomeIcon.EXTERNAL_LINK); + GridPane.setRowIndex(hyperlinkWithIcon, rowIndex); + GridPane.setColumnIndex(hyperlinkWithIcon, 0); + GridPane.setMargin(hyperlinkWithIcon, new Insets(top, 0, 0, -4)); + gridPane.getChildren().add(hyperlinkWithIcon); + return hyperlinkWithIcon; + } + /////////////////////////////////////////////////////////////////////////////////////////// // Label + HyperlinkWithIcon @@ -167,22 +184,22 @@ public class FormBuilder { return addLabelHyperlinkWithIcon(gridPane, rowIndex, title, "", 0); } - public static Tuple2 addLabelHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String value) { - return addLabelHyperlinkWithIcon(gridPane, rowIndex, title, value, 0); + public static Tuple2 addLabelHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String url) { + return addLabelHyperlinkWithIcon(gridPane, rowIndex, title, url, 0); } - public static Tuple2 addLabelHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String value, double top) { + public static Tuple2 addLabelHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String url, double top) { Label label = addLabel(gridPane, rowIndex, title, top); - HyperlinkWithIcon textField = new HyperlinkWithIcon(value, AwesomeIcon.EXTERNAL_LINK); - GridPane.setRowIndex(textField, rowIndex); - GridPane.setColumnIndex(textField, 1); - GridPane.setMargin(textField, new Insets(top, 0, 0, 0)); - gridPane.getChildren().add(textField); - - return new Tuple2<>(label, textField); + HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(url, AwesomeIcon.EXTERNAL_LINK); + GridPane.setRowIndex(hyperlinkWithIcon, rowIndex); + GridPane.setColumnIndex(hyperlinkWithIcon, 1); + GridPane.setMargin(hyperlinkWithIcon, new Insets(top, 0, 0, -4)); + gridPane.getChildren().add(hyperlinkWithIcon); + return new Tuple2<>(label, hyperlinkWithIcon); } + /////////////////////////////////////////////////////////////////////////////////////////// // Label + TextArea ///////////////////////////////////////////////////////////////////////////////////////////