Bugfixes, refactorings,...

This commit is contained in:
Manfred Karrer 2016-01-30 23:43:58 +01:00
parent d933110a8d
commit 9dd9decb96
22 changed files with 124 additions and 82 deletions

View file

@ -27,13 +27,11 @@ import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.AnchorPane;
import java.util.function.Consumer;
public class TextFieldWithCopyIcon extends AnchorPane {
private final StringProperty text = new SimpleStringProperty();
private final TextField textField;
private Consumer<String> handler;
private boolean copyWithoutCurrencyPostFix;
///////////////////////////////////////////////////////////////////////////////////////////
@ -48,10 +46,19 @@ public class TextFieldWithCopyIcon extends AnchorPane {
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
AnchorPane.setRightAnchor(copyIcon, 0.0);
copyIcon.setOnMouseClicked(e -> {
if (getText() != null && getText().length() > 0) {
Utilities.copyToClipboard(getText());
if (handler != null)
handler.accept(getText());
String text = getText();
if (text != null && text.length() > 0) {
String copyText;
if (copyWithoutCurrencyPostFix) {
String[] strings = text.split(" ");
if (strings.length > 1)
copyText = strings[0]; // exclude the BTC postfix
else
copyText = text;
} else {
copyText = text;
}
Utilities.copyToClipboard(copyText);
}
});
textField = new TextField();
@ -85,7 +92,8 @@ public class TextFieldWithCopyIcon extends AnchorPane {
this.text.set(text);
}
public void setHandler(Consumer<String> handler) {
this.handler = handler;
public void setCopyWithoutCurrencyPostFix(boolean copyWithoutCurrencyPostFix) {
this.copyWithoutCurrencyPostFix = copyWithoutCurrencyPostFix;
}
}

View file

@ -54,20 +54,20 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
public static final String TITLE_KEY = "view.title";
public static BorderPane getBaseApplicationContainer() {
return baseApplicationContainer;
public static StackPane getRootContainer() {
return MainView.rootContainer;
}
public static void blur() {
transitions.blur(MainView.base);
transitions.blur(MainView.rootContainer);
}
public static void blurLight() {
transitions.blur(MainView.base, Transitions.DEFAULT_DURATION, true, false, 5);
transitions.blur(MainView.rootContainer, Transitions.DEFAULT_DURATION, true, false, 5);
}
public static void removeBlur() {
transitions.removeBlur(baseApplicationContainer);
transitions.removeBlur(MainView.rootContainer);
}
private final ToggleGroup navButtons = new ToggleGroup();
@ -86,9 +86,9 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
private ProgressBar btcSyncIndicator;
private Label btcSplashInfo;
private List<String> persistedFilesCorrupted;
private static BorderPane baseApplicationContainer;
private static StackPane base;
private BorderPane baseApplicationContainer;
private Popup p2PNetworkWarnMsgPopup, btcNetworkWarnMsgPopup;
private static StackPane rootContainer;
@Inject
public MainView(MainViewModel model, CachingViewLoader viewLoader, Navigation navigation, Transitions transitions,
@ -102,8 +102,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
@Override
protected void initialize() {
MainView.base = this.root;
MainView.rootContainer = this.root;
ToggleButton marketButton = new NavButton(MarketView.class, "Market");
ToggleButton buyButton = new NavButton(BuyOfferView.class, "Buy BTC");
ToggleButton sellButton = new NavButton(SellOfferView.class, "Sell BTC");

View file

@ -225,7 +225,8 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
private void onRequestUpload() {
if (tempAttachments.size() < 3) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open file to attach");
int maxSizeInKB = Connection.getMaxMsgSize() / 1024;
fileChooser.setTitle("Open file to attach (max. file size: " + maxSizeInKB + " kb)");
/* if (Utilities.isUnix())
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));*/
File result = fileChooser.showOpenDialog(stage);
@ -238,7 +239,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
tempAttachments.add(new DisputeDirectMessage.Attachment(result.getName(), filesAsBytes));
inputTextArea.setText(inputTextArea.getText() + "\n[Attachment " + result.getName() + "]");
} else {
new Popup().error("The max. allowed file size is 100 kB.").show();
new Popup().error("The max. allowed file size is " + maxSizeInKB + " kB.").show();
}
} catch (java.io.IOException e) {
e.printStackTrace();

View file

@ -19,6 +19,7 @@ package io.bitsquare.gui.main.portfolio.pendingtrades.steps;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.gui.components.TextFieldWithCopyIcon;
import io.bitsquare.gui.components.TitledGroupBg;
import io.bitsquare.gui.components.TxIdTextField;
import io.bitsquare.gui.components.paymentmethods.*;
@ -208,8 +209,9 @@ public class StartPaymentView extends TradeStepDetailsView {
txIdTextField = addLabelTxIdTextField(gridPane, gridRow, "Deposit transaction ID:", Layout.FIRST_ROW_DISTANCE).second;
TitledGroupBg accountTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 1, "Payments details", Layout.GROUP_DISTANCE);
addLabelTextFieldWithCopyIcon(gridPane, gridRow, "Amount to transfer:", model.getFiatAmount(),
Layout.FIRST_ROW_AND_GROUP_DISTANCE);
TextFieldWithCopyIcon field = addLabelTextFieldWithCopyIcon(gridPane, gridRow, "Amount to transfer:", model.getFiatAmount(),
Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
field.setCopyWithoutCurrencyPostFix(true);
PaymentAccountContractData paymentAccountContractData = model.dataModel.getSellersPaymentAccountContractData();
String paymentMethodName = paymentAccountContractData.getPaymentMethodName();

View file

@ -103,6 +103,7 @@ public class ContractPopup extends Popup {
if (sellerPaymentAccountContractData instanceof BlockChainAccountContractData &&
((BlockChainAccountContractData) sellerPaymentAccountContractData).getPaymentId() != null) {
rows++;
isPaymentIdAvailable = true;
}
addTitledGroupBg(gridPane, ++rowIndex, rows, "Contract");
addLabelTextFieldWithCopyIcon(gridPane, rowIndex, "Offer ID:", offer.getId(),
@ -123,7 +124,7 @@ public class ContractPopup extends Popup {
addLabelTextField(gridPane, ++rowIndex, "Selected arbitrator:", contract.arbitratorNodeAddress.getFullAddress());
addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "Buyer payment details:",
BSResources.get(contract.getBuyerPaymentAccountContractData().getPaymentDetails())).second.setMouseTransparent(false);
addLabelTextField(gridPane, ++rowIndex, "Seller payment details:",
addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "Seller payment details:",
BSResources.get(sellerPaymentAccountContractData.getPaymentDetails())).second.setMouseTransparent(false);
if (isPaymentIdAvailable)
addLabelTextField(gridPane, ++rowIndex, "Seller payment ID:",

View file

@ -208,7 +208,7 @@ public class Popup {
protected void createPopup() {
if (owner == null)
owner = MainView.getBaseApplicationContainer();
owner = MainView.getRootContainer();
stage = new Stage();
Scene scene = new Scene(gridPane);