Skip to content

Commit

Permalink
Use material design link icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ripcurlx committed Feb 14, 2019
1 parent 3890c9c commit c815a88
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.GlyphIcons;

import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
Expand All @@ -39,7 +40,7 @@ public class AddressWithIconAndDirection extends HBox {
private static final Logger log = LoggerFactory.getLogger(AddressWithIconAndDirection.class);
private final Hyperlink hyperlink;

public AddressWithIconAndDirection(String text, String address, AwesomeIcon awesomeIcon, boolean received) {
public AddressWithIconAndDirection(String text, String address, GlyphIcons icon, boolean received) {
Label directionIcon = new Label();
directionIcon.getStyleClass().add("icon");
directionIcon.getStyleClass().add(received ? "received-funds-icon" : "sent-funds-icon");
Expand All @@ -54,7 +55,7 @@ public AddressWithIconAndDirection(String text, String address, AwesomeIcon awes
HBox.setMargin(directionIcon, new Insets(0, 3, 0, 0));
HBox.setHgrow(label, Priority.ALWAYS);

hyperlink = new HyperlinkWithIcon(address, awesomeIcon);
hyperlink = new HyperlinkWithIcon(address, icon);
HBox.setMargin(hyperlink, new Insets(0));
HBox.setHgrow(hyperlink, Priority.SOMETIMES);
// You need to set max width to Double.MAX_VALUE to make HBox.setHgrow working like expected!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,54 @@

package bisq.desktop.components;

import bisq.desktop.util.FormBuilder;

import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.GlyphIcons;

import javafx.scene.Node;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.text.Text;

import javafx.geometry.Insets;

import lombok.Getter;

public class HyperlinkWithIcon extends Hyperlink {
@Getter
private final Label icon;

public HyperlinkWithIcon(String text) {
this(text, AwesomeIcon.INFO_SIGN);
}

public HyperlinkWithIcon(String text, AwesomeIcon awesomeIcon) {

super(text);

icon = new Label();
Label icon = new Label();
AwesomeDude.setIcon(icon, awesomeIcon);
icon.setMinWidth(20);
icon.setOpacity(0.7);
icon.getStyleClass().addAll("hyperlink", "no-underline");
setPadding(new Insets(0));
icon.setPadding(new Insets(0));

setIcon(icon);
}

public HyperlinkWithIcon(String text, GlyphIcons icon) {
super(text);

Text textIcon = FormBuilder.getIcon(icon);
textIcon.setOpacity(0.7);
textIcon.getStyleClass().addAll("hyperlink", "no-underline");
setPadding(new Insets(0));

setIcon(textIcon);
}

private void setIcon(Node icon) {
setGraphic(icon);

setContentDisplay(ContentDisplay.RIGHT);
setGraphicTextGap(7.0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
Expand Down Expand Up @@ -304,7 +304,7 @@ public void updateItem(final BondListItem item, boolean empty) {

if (item != null && !empty) {
String lockupTxId = item.getLockupTxId();
hyperlinkWithIcon = new HyperlinkWithIcon(lockupTxId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(lockupTxId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(lockupTxId, preferences));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", lockupTxId)));
setGraphic(hyperlinkWithIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import com.google.common.base.Charsets;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.scene.control.Button;
import javafx.scene.control.TableCell;
Expand Down Expand Up @@ -393,7 +393,7 @@ public void updateItem(final MyReputationListItem item, boolean empty) {
//noinspection Duplicates
if (item != null && !empty) {
String transactionId = item.getTxId();
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(item.getTxId(), preferences));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId)));
setGraphic(hyperlinkWithIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
Expand Down Expand Up @@ -171,7 +171,7 @@ public void updateItem(final RolesListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
String link = item.getRole().getLink();
hyperlinkWithIcon = new HyperlinkWithIcon(link, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(link, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openWebPage(link));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("shared.openURL", link)));
setGraphic(hyperlinkWithIcon);
Expand Down Expand Up @@ -240,7 +240,7 @@ public void updateItem(final RolesListItem item, boolean empty) {
if (item != null && !empty) {
String transactionId = item.getBondedRole().getLockupTxId();
if (transactionId != null) {
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(transactionId, preferences));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId)));
setGraphic(hyperlinkWithIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.scene.control.Button;
import javafx.scene.control.TableCell;
Expand Down Expand Up @@ -400,7 +400,7 @@ public void updateItem(final MyProofOfBurnListItem item, boolean empty) {
//noinspection Duplicates
if (item != null && !empty) {
String transactionId = item.getTxId();
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(item.getTxId(), preferences));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId)));
setGraphic(hyperlinkWithIcon);
Expand Down Expand Up @@ -563,7 +563,7 @@ public void updateItem(final ProofOfBurnListItem item, boolean empty) {
//noinspection Duplicates
if (item != null && !empty) {
String transactionId = item.getTxId();
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(item.getTxId(), preferences));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId)));
setGraphic(hyperlinkWithIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
Expand Down Expand Up @@ -690,7 +691,7 @@ public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
final Proposal proposal = item.getProposal();
field = new HyperlinkWithIcon(proposal.getLink(), AwesomeIcon.EXTERNAL_LINK);
field = new HyperlinkWithIcon(proposal.getLink(), MaterialDesignIcon.LINK);
field.setOnAction(event -> GUIUtil.openWebPage(proposal.getLink()));
field.setTooltip(new Tooltip(proposal.getLink()));
setGraphic(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import com.jfoenix.controls.JFXProgressBar;

Expand Down Expand Up @@ -328,7 +329,7 @@ public void updateItem(final BsqTxListItem item, boolean empty) {
//noinspection Duplicates
if (item != null && !empty) {
String transactionId = item.getTxId();
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId)));
setGraphic(hyperlinkWithIcon);
Expand Down Expand Up @@ -399,7 +400,7 @@ public void updateItem(final BsqTxListItem item, boolean empty) {
// Received
String addressString = item.getAddress();
field = new AddressWithIconAndDirection(item.getDirection(), addressString,
AwesomeIcon.EXTERNAL_LINK, item.isReceived());
MaterialDesignIcon.LINK, item.isReceived());
field.setOnAction(event -> openAddressInBlockExplorer(item));
field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", addressString)));
setGraphic(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.fxml.FXML;

Expand Down Expand Up @@ -359,7 +359,7 @@ public void updateItem(final DepositListItem item, boolean empty) {

if (item != null && !empty) {
String address = item.getAddressString();
field = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
field = new HyperlinkWithIcon(address, MaterialDesignIcon.LINK);
field.setOnAction(event -> {
openBlockExplorer(item);
tableView.getSelectionModel().select(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.fxml.FXML;

Expand Down Expand Up @@ -298,7 +299,7 @@ public void updateItem(final LockedListItem item, boolean empty) {

if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(address, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(hyperlinkWithIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.fxml.FXML;

Expand Down Expand Up @@ -298,7 +299,7 @@ public void updateItem(final ReservedListItem item, boolean empty) {

if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(address, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(hyperlinkWithIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.fxml.FXML;

Expand Down Expand Up @@ -386,7 +387,7 @@ public void updateItem(final TransactionsListItem item, boolean empty) {
if (item != null && !empty) {
String addressString = item.getAddressString();
field = new AddressWithIconAndDirection(item.getDirection(), addressString,
AwesomeIcon.EXTERNAL_LINK, item.getReceived());
MaterialDesignIcon.LINK, item.getReceived());
field.setOnAction(event -> openAddressInBlockExplorer(item));
field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", addressString)));
setGraphic(field);
Expand Down Expand Up @@ -419,7 +420,7 @@ public void updateItem(final TransactionsListItem item, boolean empty) {
//noinspection Duplicates
if (item != null && !empty) {
String transactionId = item.getTxId();
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId)));
setGraphic(hyperlinkWithIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

import org.apache.commons.lang3.StringUtils;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.fxml.FXML;

Expand Down Expand Up @@ -548,7 +548,7 @@ public void updateItem(final WithdrawalListItem item, boolean empty) {

if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon = new HyperlinkWithIcon(address, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setAlignment(Pos.CENTER);
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/main/java/bisq/desktop/util/FormBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, int rowI
}

public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String url, double top) {
HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(title, AwesomeIcon.EXTERNAL_LINK);
HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(title, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(url));
GridPane.setRowIndex(hyperlinkWithIcon, rowIndex);
GridPane.setColumnIndex(hyperlinkWithIcon, 0);
Expand Down Expand Up @@ -340,7 +340,7 @@ public static Tuple2<Label, HyperlinkWithIcon> addLabelHyperlinkWithIcon(GridPan
double top) {
Label label = addLabel(gridPane, rowIndex, labelTitle, top);

HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(title, AwesomeIcon.EXTERNAL_LINK);
HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(title, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(url));
GridPane.setRowIndex(hyperlinkWithIcon, rowIndex);
GridPane.setMargin(hyperlinkWithIcon, new Insets(top, 0, 0, -4));
Expand Down Expand Up @@ -371,7 +371,7 @@ public static Tuple3<Label, HyperlinkWithIcon, VBox> addTopLabelHyperlinkWithIco
String value,
String url,
double top) {
HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(value, AwesomeIcon.EXTERNAL_LINK);
HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(value, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(url));
hyperlinkWithIcon.getStyleClass().add("hyperlink-with-icon");
GridPane.setRowIndex(hyperlinkWithIcon, rowIndex);
Expand Down

0 comments on commit c815a88

Please sign in to comment.