Use radiobutton that displays a tooltip when text is truncated

This commit is contained in:
Christoph Atteneder 2018-01-23 16:26:17 +01:00
parent db460ae111
commit fa59686a93
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
5 changed files with 62 additions and 25 deletions

View file

@ -0,0 +1,35 @@
package io.bisq.gui.components;
import com.sun.javafx.scene.control.skin.RadioButtonSkin;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Skin;
import static io.bisq.gui.components.TooltipUtil.showTooltipIfTruncated;
public class AutoTooltipRadioButton extends RadioButton {
public AutoTooltipRadioButton() {
super();
}
public AutoTooltipRadioButton(String text) {
super(text);
}
@Override
protected Skin<?> createDefaultSkin() {
return new AutoTooltipRadioButtonSkin(this);
}
private class AutoTooltipRadioButtonSkin extends RadioButtonSkin {
public AutoTooltipRadioButtonSkin(RadioButton radioButton) {
super(radioButton);
}
@Override
protected void layoutChildren(double x, double y, double w, double h) {
super.layoutChildren(x, y, w, h);
showTooltipIfTruncated(this, getSkinnable());
}
}
}

View file

@ -21,6 +21,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import io.bisq.gui.components.AutoTooltipLabel?>
<?import io.bisq.gui.components.AutoTooltipRadioButton?>
<VBox fx:id="root" fx:controller="io.bisq.gui.main.funds.withdrawal.WithdrawalView"
spacing="10" xmlns:fx="http://javafx.com/fxml">
<padding>
@ -41,22 +42,22 @@
</padding>
<AutoTooltipLabel fx:id="inputsLabel" GridPane.rowIndex="0"/>
<RadioButton fx:id="useAllInputsRadioButton" GridPane.rowIndex="0" GridPane.columnIndex="1">
<AutoTooltipRadioButton fx:id="useAllInputsRadioButton" GridPane.rowIndex="0" GridPane.columnIndex="1">
<padding>
<Insets bottom="0.0" left="0.0" right="5.0" top="0.0"/>
</padding>
</RadioButton>
<RadioButton fx:id="useCustomInputsRadioButton" GridPane.rowIndex="0" GridPane.columnIndex="2"/>
</AutoTooltipRadioButton>
<AutoTooltipRadioButton fx:id="useCustomInputsRadioButton" GridPane.rowIndex="0" GridPane.columnIndex="2"/>
<AutoTooltipLabel fx:id="amountLabel" GridPane.rowIndex="1"/>
<TextField fx:id="amountTextField" GridPane.rowIndex="1" GridPane.columnIndex="1" prefWidth="120"/>
<RadioButton fx:id="feeExcludedRadioButton" GridPane.rowIndex="1" GridPane.columnIndex="2">
<AutoTooltipRadioButton fx:id="feeExcludedRadioButton" GridPane.rowIndex="1" GridPane.columnIndex="2">
<padding>
<Insets bottom="0.0" left="5.0" right="5.0" top="0.0"/>
</padding>
</RadioButton>
<RadioButton fx:id="feeIncludedRadioButton" GridPane.rowIndex="1" GridPane.columnIndex="3"/>
</AutoTooltipRadioButton>
<AutoTooltipRadioButton fx:id="feeIncludedRadioButton" GridPane.rowIndex="1" GridPane.columnIndex="3"/>
<AutoTooltipLabel fx:id="fromLabel" GridPane.rowIndex="2"/>
<TextField fx:id="withdrawFromTextField" editable="false" focusTraversable="false"

View file

@ -30,6 +30,7 @@ import io.bisq.core.btc.wallet.TradeWalletService;
import io.bisq.core.offer.Offer;
import io.bisq.core.trade.Contract;
import io.bisq.gui.components.AutoTooltipCheckBox;
import io.bisq.gui.components.AutoTooltipRadioButton;
import io.bisq.gui.components.InputTextField;
import io.bisq.gui.main.overlays.Overlay;
import io.bisq.gui.main.overlays.popups.Popup;
@ -275,16 +276,16 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
Label distributionLabel = addLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.payout"), 10);
GridPane.setValignment(distributionLabel, VPos.TOP);
buyerGetsTradeAmountRadioButton = new RadioButton(Res.get("disputeSummaryWindow.payout.getsTradeAmount",
buyerGetsTradeAmountRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.payout.getsTradeAmount",
Res.get("shared.buyer")));
buyerGetsAllRadioButton = new RadioButton(Res.get("disputeSummaryWindow.payout.getsAll",
buyerGetsAllRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.payout.getsAll",
Res.get("shared.buyer")));
sellerGetsTradeAmountRadioButton = new RadioButton(Res.get("disputeSummaryWindow.payout.getsTradeAmount",
sellerGetsTradeAmountRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.payout.getsTradeAmount",
Res.get("shared.seller")));
sellerGetsAllRadioButton = new RadioButton(Res.get("disputeSummaryWindow.payout.getsAll",
sellerGetsAllRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.payout.getsAll",
Res.get("shared.seller")));
customRadioButton = new RadioButton(Res.get("disputeSummaryWindow.payout.custom"));
customRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.payout.custom"));
VBox radioButtonPane = new VBox();
radioButtonPane.setSpacing(10);
radioButtonPane.getChildren().addAll(buyerGetsTradeAmountRadioButton, buyerGetsAllRadioButton,
@ -392,13 +393,13 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
private void addReasonControls() {
Label label = addLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.reason"), 10);
GridPane.setValignment(label, VPos.TOP);
reasonWasBugRadioButton = new RadioButton(Res.get("disputeSummaryWindow.reason.bug"));
reasonWasUsabilityIssueRadioButton = new RadioButton(Res.get("disputeSummaryWindow.reason.usability"));
reasonProtocolViolationRadioButton = new RadioButton(Res.get("disputeSummaryWindow.reason.protocolViolation"));
reasonNoReplyRadioButton = new RadioButton(Res.get("disputeSummaryWindow.reason.noReply"));
reasonWasScamRadioButton = new RadioButton(Res.get("disputeSummaryWindow.reason.scam"));
reasonWasBankRadioButton = new RadioButton(Res.get("disputeSummaryWindow.reason.bank"));
reasonWasOtherRadioButton = new RadioButton(Res.get("disputeSummaryWindow.reason.other"));
reasonWasBugRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.reason.bug"));
reasonWasUsabilityIssueRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.reason.usability"));
reasonProtocolViolationRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.reason.protocolViolation"));
reasonNoReplyRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.reason.noReply"));
reasonWasScamRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.reason.scam"));
reasonWasBankRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.reason.bank"));
reasonWasOtherRadioButton = new AutoTooltipRadioButton(Res.get("disputeSummaryWindow.reason.other"));
HBox feeRadioButtonPane = new HBox();
feeRadioButtonPane.setSpacing(20);

View file

@ -45,9 +45,9 @@
<AutoTooltipLabel fx:id="bitcoinNodesLabel" GridPane.rowIndex="2"/>
<HBox GridPane.rowIndex="2" GridPane.columnIndex="1" spacing="10">
<RadioButton fx:id="useProvidedNodesRadio"/>
<RadioButton fx:id="useCustomNodesRadio"/>
<RadioButton fx:id="usePublicNodesRadio"/>
<AutoTooltipRadioButton fx:id="useProvidedNodesRadio"/>
<AutoTooltipRadioButton fx:id="useCustomNodesRadio"/>
<AutoTooltipRadioButton fx:id="usePublicNodesRadio"/>
</HBox>
<AutoTooltipLabel fx:id="btcNodesLabel" GridPane.rowIndex="3"/>

View file

@ -489,7 +489,7 @@ public class FormBuilder {
///////////////////////////////////////////////////////////////////////////////////////////
public static RadioButton addRadioButton(GridPane gridPane, int rowIndex, ToggleGroup toggleGroup, String title) {
RadioButton radioButton = new RadioButton(title);
RadioButton radioButton = new AutoTooltipRadioButton(title);
radioButton.setToggleGroup(toggleGroup);
GridPane.setRowIndex(radioButton, rowIndex);
GridPane.setColumnIndex(radioButton, 1);
@ -505,7 +505,7 @@ public class FormBuilder {
radioButtonTitle) {
Label label = addLabel(gridPane, rowIndex, title, 0);
RadioButton radioButton = new RadioButton(radioButtonTitle);
RadioButton radioButton = new AutoTooltipRadioButton(radioButtonTitle);
radioButton.setToggleGroup(toggleGroup);
radioButton.setPadding(new Insets(6, 0, 0, 0));
GridPane.setRowIndex(radioButton, rowIndex);
@ -528,11 +528,11 @@ public class FormBuilder {
String radioButtonTitle2) {
Label label = addLabel(gridPane, rowIndex, title, 0);
RadioButton radioButton1 = new RadioButton(radioButtonTitle1);
RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
radioButton1.setToggleGroup(toggleGroup);
radioButton1.setPadding(new Insets(6, 0, 0, 0));
RadioButton radioButton2 = new RadioButton(radioButtonTitle2);
RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
radioButton2.setToggleGroup(toggleGroup);
radioButton2.setPadding(new Insets(6, 0, 0, 0));