This commit is contained in:
Manfred Karrer 2014-09-26 02:21:34 +02:00
parent 63df466281
commit 76b6bcfc22
75 changed files with 318 additions and 760 deletions

View file

@ -1,143 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.image.*;
import javafx.scene.layout.*;
import javafx.scene.paint.*;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;
import org.controlsfx.control.PopOver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NotificationTest extends Application {
private static final Logger log = LoggerFactory.getLogger(NotificationTest.class);
private Scene notificationScene;
private Stage notificationStage;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Pane view = new StackPane();
Button b = new Button("open");
b.setOnAction(e -> addItem());
view.getChildren().addAll(b);
Scene scene = new Scene(view, 1000, 750);
scene.getStylesheets().setAll(getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm(),
getClass().getResource("/io/bitsquare/gui/images.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setMinWidth(750);
primaryStage.setMinHeight(500);
primaryStage.show();
initNotification();
}
private List<PopOver> popOvers = new ArrayList<>();
private HBox getNotificationItem(String headline, String info) {
Label headlineLabel = new Label(headline);
Label infoLabel = new Label(info);
ImageView icon = new ImageView();
icon.setId("image-info");
VBox vBox = new VBox();
vBox.setPadding(new Insets(10, 10, 10, 10));
vBox.setSpacing(10);
vBox.getChildren().addAll(headlineLabel, infoLabel);
HBox hBox = new HBox();
hBox.setPadding(new Insets(10, 10, 10, 10));
hBox.setSpacing(10);
hBox.getChildren().addAll(icon, vBox);
return hBox;
}
private void addItem() {
HBox hBox = getNotificationItem("Headline " + new Random().nextInt(), "test " + new Random().nextInt());
PopOver popOver = new PopOver(hBox);
popOver.setDetachable(false);
popOver.setArrowSize(0);
popOver.setPrefSize(200, 100);
popOver.show(notificationScene.getWindow(), Screen.getPrimary().getBounds().getWidth() - 200, 0);
popOvers.add(popOver);
// Add a timeline for popup fade out
KeyValue fadeOutBegin = new KeyValue(popOver.opacityProperty(), 1.0);
KeyValue fadeOutEnd = new KeyValue(popOver.opacityProperty(), 0.0);
KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
KeyFrame kfEnd = new KeyFrame(Duration.millis(5000), fadeOutEnd);
Timeline timeline = new Timeline(kfBegin, kfEnd);
timeline.setDelay(Duration.millis(500));
timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
popOvers.remove(popOver);
}));
if (notificationStage.isShowing()) {
notificationStage.toFront();
}
else {
notificationStage.show();
}
popOver.show(notificationStage);
timeline.play();
}
private void initNotification() {
Region region = new Region();
region.setMouseTransparent(true);
region.setStyle("-fx-background-color:transparent;");
region.setPrefSize(1, 1);
notificationScene = new Scene(region);
notificationScene.setFill(Color.TRANSPARENT);
notificationScene.getStylesheets().setAll(getClass().getResource("/io/bitsquare/gui/bitsquare.css")
.toExternalForm(),
getClass().getResource("/io/bitsquare/gui/images.css").toExternalForm());
notificationStage = new Stage();
notificationStage.initStyle(StageStyle.TRANSPARENT);
notificationStage.setScene(notificationScene);
}
@Override
public void stop() throws Exception {
}
}

View file

@ -105,8 +105,8 @@ public class SeedNode extends Thread {
} }
} }
public Peer startupPeer() { public void startupPeer() {
Peer peer = null; Peer peer;
try { try {
peer = new PeerBuilder( peer = new PeerBuilder(
Number160.createHash(seedNodeAddress.getId())).ports(seedNodeAddress.getPort()).start(); Number160.createHash(seedNodeAddress.getId())).ports(seedNodeAddress.getPort()).start();
@ -139,7 +139,6 @@ public class SeedNode extends Thread {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return peer;
} }
private void ping(Peer peer) { private void ping(Peer peer) {

View file

@ -33,7 +33,6 @@ import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -45,7 +44,7 @@ import org.slf4j.LoggerFactory;
* possible. This means that the transaction is the most likely to get confirmed. Note that this means we may end up * possible. This means that the transaction is the most likely to get confirmed. Note that this means we may end up
* "spending" more priority than would be required to get the transaction we are creating confirmed. * "spending" more priority than would be required to get the transaction we are creating confirmed.
*/ */
public class AddressBasedCoinSelector extends DefaultCoinSelector { class AddressBasedCoinSelector extends DefaultCoinSelector {
private static final Logger log = LoggerFactory.getLogger(AddressBasedCoinSelector.class); private static final Logger log = LoggerFactory.getLogger(AddressBasedCoinSelector.class);
private final NetworkParameters params; private final NetworkParameters params;
private final AddressEntry addressEntry; private final AddressEntry addressEntry;
@ -63,31 +62,28 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector {
@VisibleForTesting @VisibleForTesting
static void sortOutputs(ArrayList<TransactionOutput> outputs) { static void sortOutputs(ArrayList<TransactionOutput> outputs) {
Collections.sort(outputs, new Comparator<TransactionOutput>() { Collections.sort(outputs, (a, b) -> {
@Override int depth1 = 0;
public int compare(TransactionOutput a, TransactionOutput b) { int depth2 = 0;
int depth1 = 0; TransactionConfidence conf1 = a.getParentTransaction().getConfidence();
int depth2 = 0; TransactionConfidence conf2 = b.getParentTransaction().getConfidence();
TransactionConfidence conf1 = a.getParentTransaction().getConfidence(); if (conf1.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
TransactionConfidence conf2 = b.getParentTransaction().getConfidence(); depth1 = conf1.getDepthInBlocks();
if (conf1.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) if (conf2.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
depth1 = conf1.getDepthInBlocks(); depth2 = conf2.getDepthInBlocks();
if (conf2.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) Coin aValue = a.getValue();
depth2 = conf2.getDepthInBlocks(); Coin bValue = b.getValue();
Coin aValue = a.getValue(); BigInteger aCoinDepth = BigInteger.valueOf(aValue.value).multiply(BigInteger.valueOf(depth1));
Coin bValue = b.getValue(); BigInteger bCoinDepth = BigInteger.valueOf(bValue.value).multiply(BigInteger.valueOf(depth2));
BigInteger aCoinDepth = BigInteger.valueOf(aValue.value).multiply(BigInteger.valueOf(depth1)); int c1 = bCoinDepth.compareTo(aCoinDepth);
BigInteger bCoinDepth = BigInteger.valueOf(bValue.value).multiply(BigInteger.valueOf(depth2)); if (c1 != 0) return c1;
int c1 = bCoinDepth.compareTo(aCoinDepth); // The "coin*days" destroyed are equal, sort by value alone to get the lowest transaction size.
if (c1 != 0) return c1; int c2 = bValue.compareTo(aValue);
// The "coin*days" destroyed are equal, sort by value alone to get the lowest transaction size. if (c2 != 0) return c2;
int c2 = bValue.compareTo(aValue); // They are entirely equivalent (possibly pending) so sort by hash to ensure a total ordering.
if (c2 != 0) return c2; BigInteger aHash = a.getParentTransaction().getHash().toBigInteger();
// They are entirely equivalent (possibly pending) so sort by hash to ensure a total ordering. BigInteger bHash = b.getParentTransaction().getHash().toBigInteger();
BigInteger aHash = a.getParentTransaction().getHash().toBigInteger(); return aHash.compareTo(bHash);
BigInteger bHash = b.getParentTransaction().getHash().toBigInteger();
return aHash.compareTo(bHash);
}
}); });
} }
@ -121,7 +117,7 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector {
} }
} }
protected boolean matchesRequiredAddress(TransactionOutput transactionOutput) { private boolean matchesRequiredAddress(TransactionOutput transactionOutput) {
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH
()) { ()) {
Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params); Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params);

View file

@ -383,10 +383,9 @@ public class WalletFacade {
addressConfidenceListener.onTransactionConfidenceChanged(transactionConfidence); addressConfidenceListener.onTransactionConfidenceChanged(transactionConfidence);
} }
for (TxConfidenceListener txConfidenceListener : txConfidenceListeners) { txConfidenceListeners.stream().filter(txConfidenceListener -> tx.getHashAsString().equals
if (tx.getHashAsString().equals(txConfidenceListener.getTxID())) (txConfidenceListener.getTxID())).forEach(txConfidenceListener -> txConfidenceListener
txConfidenceListener.onTransactionConfidenceChanged(tx.getConfidence()); .onTransactionConfidenceChanged(tx.getConfidence()));
}
} }
private TransactionConfidence getTransactionConfidence(Transaction tx, Address address) { private TransactionConfidence getTransactionConfidence(Transaction tx, Address address) {
@ -571,8 +570,7 @@ public class WalletFacade {
return tx; return tx;
} }
public void broadcastCreateOfferFeeTx(Transaction tx, FutureCallback<Transaction> callback) throws public void broadcastCreateOfferFeeTx(Transaction tx, FutureCallback<Transaction> callback) {
InsufficientMoneyException {
log.trace("broadcast tx"); log.trace("broadcast tx");
ListenableFuture<Transaction> future = walletAppKit.peerGroup().broadcastTransaction(tx); ListenableFuture<Transaction> future = walletAppKit.peerGroup().broadcastTransaction(tx);
Futures.addCallback(future, callback); Futures.addCallback(future, callback);

View file

@ -88,8 +88,8 @@ public class BitSquareModule extends AbstractModule {
bind(NetworkParameters.class).toProvider(NetworkParametersProvider.class).asEagerSingleton(); bind(NetworkParameters.class).toProvider(NetworkParametersProvider.class).asEagerSingleton();
// we will probably later disc storage instead of memory storage for TomP2P // we will probably later disc storage instead of memory storage for TomP2P
// bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(new Boolean(true)); // bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(true);
bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(new Boolean(false)); bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(false);
// might be better in a config file? // might be better in a config file?
bind(SeedNodeAddress.StaticSeedNodeAddresses.class).annotatedWith( bind(SeedNodeAddress.StaticSeedNodeAddresses.class).annotatedWith(

View file

@ -34,8 +34,8 @@ public class Navigation {
// New listeners can be added during iteration so we use CopyOnWriteArrayList to prevent invalid array // New listeners can be added during iteration so we use CopyOnWriteArrayList to prevent invalid array
// modification // modification
private List<Listener> listeners = new CopyOnWriteArrayList<>(); private final List<Listener> listeners = new CopyOnWriteArrayList<>();
private Persistence persistence; private final Persistence persistence;
private Item[] currentItems; private Item[] currentItems;
// Used for returning to the last important view // Used for returning to the last important view

View file

@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
public class OverlayManager { public class OverlayManager {
private static final Logger log = LoggerFactory.getLogger(OverlayManager.class); private static final Logger log = LoggerFactory.getLogger(OverlayManager.class);
private List<OverlayListener> listeners = new ArrayList<>(); private final List<OverlayListener> listeners = new ArrayList<>();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -40,11 +40,11 @@ public class OverlayManager {
} }
public void blurContent() { public void blurContent() {
listeners.stream().forEach((e) -> e.onBlurContentRequested()); listeners.stream().forEach(OverlayListener::onBlurContentRequested);
} }
public void removeBlurContent() { public void removeBlurContent() {
listeners.stream().forEach((e) -> e.onRemoveBlurContentRequested()); listeners.stream().forEach(OverlayListener::onRemoveBlurContentRequested);
} }
public void addListener(OverlayListener listener) { public void addListener(OverlayListener listener) {

View file

@ -27,11 +27,11 @@ public class ViewCB<T extends PresentationModel> implements Initializable {
@FXML protected Parent root; @FXML protected Parent root;
public ViewCB(T presentationModel) { protected ViewCB(T presentationModel) {
this.presentationModel = presentationModel; this.presentationModel = presentationModel;
} }
public ViewCB() { protected ViewCB() {
} }
/** /**

View file

@ -58,7 +58,7 @@ public class AddressTextField extends AnchorPane {
private final StringProperty address = new SimpleStringProperty(); private final StringProperty address = new SimpleStringProperty();
private final StringProperty paymentLabel = new SimpleStringProperty(); private final StringProperty paymentLabel = new SimpleStringProperty();
public final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>(); private final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>();
private OverlayManager overlayManager; private OverlayManager overlayManager;
@ -81,9 +81,7 @@ public class AddressTextField extends AnchorPane {
} }
}); });
addressLabel.focusTraversableProperty().set(focusTraversableProperty().get()); addressLabel.focusTraversableProperty().set(focusTraversableProperty().get());
focusedProperty().addListener((ov, oldValue, newValue) -> { focusedProperty().addListener((ov, oldValue, newValue) -> addressLabel.requestFocus());
addressLabel.requestFocus();
});
Label copyIcon = new Label(); Label copyIcon = new Label();
copyIcon.setLayoutY(3); copyIcon.setLayoutY(3);

View file

@ -1,38 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.components;
import javafx.scene.layout.*;
// TODO remove and use margin or padding instead
@Deprecated
public class HSpacer extends Pane {
public HSpacer() {
}
public HSpacer(double width) {
setPrefWidth(width);
}
@Override
protected double computePrefWidth(double width) {
return getPrefWidth();
}
}

View file

@ -58,3 +58,15 @@ public class NetworkSyncPane extends HBox {
fade.setOnFinished(e -> getChildren().clear()); fade.setOnFinished(e -> getChildren().clear());
} }
} }
class HSpacer extends Pane {
public HSpacer(double width) {
setPrefWidth(width);
}
@Override
protected double computePrefWidth(double width) {
return getPrefWidth();
}
}

View file

@ -60,9 +60,7 @@ public class TextFieldWithCopyIcon extends AnchorPane {
AnchorPane.setRightAnchor(txIdLabel, 30.0); AnchorPane.setRightAnchor(txIdLabel, 30.0);
AnchorPane.setLeftAnchor(txIdLabel, 0.0); AnchorPane.setLeftAnchor(txIdLabel, 0.0);
txIdLabel.focusTraversableProperty().set(focusTraversableProperty().get()); txIdLabel.focusTraversableProperty().set(focusTraversableProperty().get());
focusedProperty().addListener((ov, oldValue, newValue) -> { focusedProperty().addListener((ov, oldValue, newValue) -> txIdLabel.requestFocus());
txIdLabel.requestFocus();
});
getChildren().addAll(txIdLabel, copyIcon); getChildren().addAll(txIdLabel, copyIcon);
} }

View file

@ -30,7 +30,7 @@ public class TitledGroupBg extends Pane {
private static final Logger log = LoggerFactory.getLogger(TitledGroupBg.class); private static final Logger log = LoggerFactory.getLogger(TitledGroupBg.class);
private final Label label; private final Label label;
private StringProperty text = new SimpleStringProperty(); private final StringProperty text = new SimpleStringProperty();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor

View file

@ -30,8 +30,7 @@ public class TitledSeparator extends Pane {
private static final Logger log = LoggerFactory.getLogger(TitledSeparator.class); private static final Logger log = LoggerFactory.getLogger(TitledSeparator.class);
private final Label label; private final Label label;
private final Separator separator; private final StringProperty text = new SimpleStringProperty();
private StringProperty text = new SimpleStringProperty();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -41,7 +40,7 @@ public class TitledSeparator extends Pane {
GridPane.setMargin(this, new Insets(-10, -10, -10, -10)); GridPane.setMargin(this, new Insets(-10, -10, -10, -10));
GridPane.setColumnSpan(this, 2); GridPane.setColumnSpan(this, 2);
separator = new Separator(); Separator separator = new Separator();
separator.prefWidthProperty().bind(widthProperty()); separator.prefWidthProperty().bind(widthProperty());
separator.setLayoutX(0); separator.setLayoutX(0);
separator.setLayoutY(6); separator.setLayoutY(6);

View file

@ -79,9 +79,7 @@ public class TxIdTextField extends AnchorPane {
AnchorPane.setRightAnchor(txIdLabel, 55.0); AnchorPane.setRightAnchor(txIdLabel, 55.0);
AnchorPane.setLeftAnchor(txIdLabel, 0.0); AnchorPane.setLeftAnchor(txIdLabel, 0.0);
txIdLabel.focusTraversableProperty().set(focusTraversableProperty().get()); txIdLabel.focusTraversableProperty().set(focusTraversableProperty().get());
focusedProperty().addListener((ov, oldValue, newValue) -> { focusedProperty().addListener((ov, oldValue, newValue) -> txIdLabel.requestFocus());
txIdLabel.requestFocus();
});
getChildren().addAll(txIdLabel, copyIcon, progressIndicator); getChildren().addAll(txIdLabel, copyIcon, progressIndicator);
} }

View file

@ -1,38 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.components;
import javafx.scene.layout.*;
// TODO remove and use margin or padding instead
@Deprecated
public class VSpacer extends Pane {
public VSpacer() {
}
public VSpacer(double height) {
setPrefHeight(height);
}
@Override
protected double computePrefHeight(double width) {
return getPrefHeight();
}
}

View file

@ -1,196 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.components;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyIntegerProperty;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.*;
import javafx.scene.effect.*;
import javafx.scene.paint.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>
* TextField with regex-based real-time input validation.
* JavaFX 2 and FXML compatible. </p>
* <p>
* FXML code example:<div>
* {@code <ValidatedTextField fx:id="validatedTextField" minLength="1" maxLength="1" mask="^[0-9]*$" />}
* </div>
* </p>
*/
//TODO replace with ValidatingTextField
@Deprecated
public class ValidatedTextField extends TextField {
private static final Logger log = LoggerFactory.getLogger(ValidatedTextField.class);
private final BooleanProperty invalid = new SimpleBooleanProperty(false);
private final StringProperty mask;
private final IntegerProperty minLength;
private final IntegerProperty maxLength;
private Effect invalidEffect = new DropShadow(BlurType.THREE_PASS_BOX, Color.RED, 4, 0.0, 0, 0);
public ValidatedTextField() {
super();
this.mask = new SimpleStringProperty("^[0-9.,]*$");
this.minLength = new SimpleIntegerProperty(1);
this.maxLength = new SimpleIntegerProperty(12);
bind();
}
public ValidatedTextField(String mask, int minLength, int maxLength, boolean nullable) {
this(mask, minLength, maxLength, nullable, null);
}
public ValidatedTextField(String mask, int minLength, int maxLength, boolean nullable, String string) {
super(string);
this.mask = new SimpleStringProperty(mask);
this.minLength = new SimpleIntegerProperty(minLength);
this.maxLength = new SimpleIntegerProperty(maxLength);
bind();
}
public ReadOnlyBooleanProperty invalidProperty() {
return invalid;
}
public ReadOnlyStringProperty maskProperty() {
return mask;
}
public ReadOnlyIntegerProperty minLengthProperty() {
return minLength;
}
public ReadOnlyIntegerProperty maxLengthProperty() {
return maxLength;
}
public boolean isInvalid() {
return invalid.get();
}
public String getMask() {
return mask.get();
}
public void setMask(String mask) {
this.mask.set(mask);
}
public int getMinLength() {
return minLength.get();
}
public void setMinLength(int minLength) {
this.minLength.set(minLength);
}
public int getMaxLength() {
return maxLength.get();
}
public void setMaxLength(int maxLength) {
this.maxLength.set(maxLength);
}
public Effect getInvalidEffect() {
return this.invalidEffect;
}
public void setInvalidEffect(Effect effect) {
this.invalidEffect = effect;
}
private void bind() {
this.invalid.bind(maskCheck().or(minLengthCheck()));
this.textProperty().addListener((ov, t, t1) -> {
if (textProperty().get() != null && textProperty().get().length() > maxLength.get()) {
setText(t);
}
});
this.invalid.addListener((ov, t, t1) -> {
if (t ^ t1) {
if (t1) {
// setStyle("-fx-font-weight: bold; -fx-text-fill: red;");
setEffect(invalidEffect);
}
else {
// setStyle("-fx-font-weight: normal; -fx-text-fill: inherit;");
setEffect(null);
}
}
});
}
private BooleanBinding maskCheck() {
return new BooleanBinding() {
{
super.bind(textProperty(), mask);
}
@Override
protected boolean computeValue() {
return (textProperty().get() != null) ? !textProperty().get().matches(mask.get()) : false;
}
};
}
private BooleanBinding minLengthCheck() {
return new BooleanBinding() {
{
super.bind(textProperty(), minLength);
}
@Override
protected boolean computeValue() {
return (textProperty().get() != null) ? textProperty().get().length() < minLength.get() : false;
}
};
}
private BooleanBinding maxLengthCheck() {
return new BooleanBinding() {
{
super.bind(textProperty(), maxLength);
}
@Override
protected boolean computeValue() {
return textProperty().get().length() > maxLength.get();
}
};
}
}

View file

@ -26,7 +26,7 @@ import javafx.scene.control.*;
public class ProcessStepBar<T> extends Control { public class ProcessStepBar<T> extends Control {
private List<ProcessStepItem> processStepItems; private List<ProcessStepItem> processStepItems;
private IntegerProperty selectedIndex = new SimpleIntegerProperty(0); private final IntegerProperty selectedIndex = new SimpleIntegerProperty(0);
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -43,7 +43,6 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
private final ProcessStepBar<T> controller; private final ProcessStepBar<T> controller;
private LabelWithBorder currentLabelWithBorder; private LabelWithBorder currentLabelWithBorder;
private LabelWithBorder prevLabelWithBorder; private LabelWithBorder prevLabelWithBorder;
private int index;
private final List<LabelWithBorder> labelWithBorders = new ArrayList<>(); private final List<LabelWithBorder> labelWithBorders = new ArrayList<>();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -66,8 +65,8 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
public void reset() { public void reset() {
prevLabelWithBorder = null; prevLabelWithBorder = null;
for (int i = 0; i < labelWithBorders.size(); i++) { for (LabelWithBorder labelWithBorder : labelWithBorders) {
currentLabelWithBorder = labelWithBorders.get(i); currentLabelWithBorder = labelWithBorder;
currentLabelWithBorder.open(); currentLabelWithBorder.open();
} }
} }
@ -97,8 +96,6 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
} }
public void setSelectedIndex(int index) { public void setSelectedIndex(int index) {
this.index = index;
if (index < labelWithBorders.size()) { if (index < labelWithBorders.size()) {
for (int i = 0; i <= index; i++) { for (int i = 0; i <= index; i++) {

View file

@ -46,7 +46,7 @@
/* naviagtion buttons */ /* navigation buttons */
#image-nav-home { #image-nav-home {
-fx-image: url("../../../images/nav/home.png"); -fx-image: url("../../../images/nav/home.png");
} }

View file

@ -27,6 +27,7 @@ import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.components.SystemNotification; import io.bitsquare.gui.components.SystemNotification;
import io.bitsquare.gui.util.Profiler; import io.bitsquare.gui.util.Profiler;
import io.bitsquare.gui.util.Transitions; import io.bitsquare.gui.util.Transitions;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.util.ViewLoader; import io.bitsquare.util.ViewLoader;
import java.io.IOException; import java.io.IOException;
@ -76,11 +77,18 @@ public class MainViewCB extends ViewCB<MainPM> {
@Inject @Inject
private MainViewCB(MainPM presentationModel, Navigation navigation, private MainViewCB(MainPM presentationModel, Navigation navigation,
OverlayManager overlayManager) { OverlayManager overlayManager, TradeManager tradeManager) {
super(presentationModel); super(presentationModel);
this.navigation = navigation; this.navigation = navigation;
this.overlayManager = overlayManager; this.overlayManager = overlayManager;
tradeManager.featureNotImplementedWarningProperty().addListener((ov, oldValue, newValue) -> {
if (oldValue == null && newValue != null) {
Popups.openWarningPopup(newValue);
tradeManager.setFeatureNotImplementedWarning(null);
}
});
} }

View file

@ -51,6 +51,7 @@ class AccountModel extends UIModel {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -48,6 +48,7 @@ class AccountPM extends PresentationModel<AccountModel> {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -42,7 +42,7 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
private static final Logger log = LoggerFactory.getLogger(AccountViewCB.class); private static final Logger log = LoggerFactory.getLogger(AccountViewCB.class);
private Navigation navigation; private final Navigation navigation;
private Navigation.Listener listener; private Navigation.Listener listener;
@FXML Tab tab; @FXML Tab tab;

View file

@ -46,6 +46,7 @@ class ChangePasswordModel extends UIModel {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -67,6 +67,7 @@ class ChangePasswordPM extends PresentationModel<ChangePasswordModel> {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -36,13 +36,13 @@ import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
class ChangePasswordViewCB extends CachedViewCB<ChangePasswordPM> implements ContextAware { public class ChangePasswordViewCB extends CachedViewCB<ChangePasswordPM> implements ContextAware {
private static final Logger log = LoggerFactory.getLogger(ChangePasswordViewCB.class); private static final Logger log = LoggerFactory.getLogger(ChangePasswordViewCB.class);
@FXML HBox buttonsHBox; @FXML HBox buttonsHBox;
@FXML Button saveButton, skipButton; @FXML Button saveButton, skipButton;
@FXML PasswordField passwordField, repeatedPasswordField; @FXML PasswordField oldPasswordField, passwordField, repeatedPasswordField;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -47,6 +47,7 @@ class PasswordModel extends UIModel {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -67,6 +67,7 @@ class PasswordPM extends PresentationModel<PasswordModel> {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -53,7 +53,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
private static final Logger log = LoggerFactory.getLogger(RegistrationViewCB.class); private static final Logger log = LoggerFactory.getLogger(RegistrationViewCB.class);
private OverlayManager overlayManager; private final OverlayManager overlayManager;
@FXML TextField feeTextField; @FXML TextField feeTextField;
@FXML AddressTextField addressTextField; @FXML AddressTextField addressTextField;

View file

@ -57,7 +57,9 @@ public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements
private static final Logger log = LoggerFactory.getLogger(RestrictionsViewCB.class); private static final Logger log = LoggerFactory.getLogger(RestrictionsViewCB.class);
@FXML ListView languagesListView, countriesListView, arbitratorsListView; @FXML ListView<Locale> languagesListView;
@FXML ListView<Country> countriesListView;
@FXML ListView<Arbitrator> arbitratorsListView;
@FXML ComboBox<Locale> languageComboBox; @FXML ComboBox<Locale> languageComboBox;
@FXML ComboBox<Region> regionComboBox; @FXML ComboBox<Region> regionComboBox;
@FXML ComboBox<Country> countryComboBox; @FXML ComboBox<Country> countryComboBox;

View file

@ -54,6 +54,7 @@ class SeedWordsModel extends UIModel {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -57,6 +57,7 @@ class SeedWordsPM extends PresentationModel<SeedWordsModel> {
seedWords.set(BSFormatter.mnemonicCodeToString(model.getMnemonicCode())); seedWords.set(BSFormatter.mnemonicCodeToString(model.getMnemonicCode()));
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -51,7 +51,7 @@ public class AccountSettingsViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(AccountSettingsViewCB.class); private static final Logger log = LoggerFactory.getLogger(AccountSettingsViewCB.class);
private MenuItem seedWords, password, restrictions, fiatAccount, registration; private MenuItem seedWords, password, restrictions, fiatAccount, registration;
private Navigation navigation; private final Navigation navigation;
private Navigation.Listener listener; private Navigation.Listener listener;
@FXML VBox leftVBox; @FXML VBox leftVBox;
@ -117,8 +117,7 @@ public class AccountSettingsViewCB extends CachedViewCB {
Navigation.Item.ACCOUNT_SETTINGS, Navigation.Item.SEED_WORDS); Navigation.Item.ACCOUNT_SETTINGS, Navigation.Item.SEED_WORDS);
} }
else { else {
if (items != null && if (items.length == 4 &&
items.length == 4 &&
items[2] == Navigation.Item.ACCOUNT_SETTINGS) { items[2] == Navigation.Item.ACCOUNT_SETTINGS) {
loadView(items[3]); loadView(items[3]);
selectMainMenuButton(items[3]); selectMainMenuButton(items[3]);

View file

@ -55,7 +55,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
private static final Logger log = LoggerFactory.getLogger(AccountSetupViewCB.class); private static final Logger log = LoggerFactory.getLogger(AccountSetupViewCB.class);
private WizardItem seedWords, password, fiatAccount, restrictions, registration; private WizardItem seedWords, password, fiatAccount, restrictions, registration;
private Navigation navigation; private final Navigation navigation;
private Navigation.Listener listener; private Navigation.Listener listener;
@FXML VBox leftVBox; @FXML VBox leftVBox;
@ -83,8 +83,6 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
if (navigationItems != null && if (navigationItems != null &&
navigationItems.length == 4 && navigationItems.length == 4 &&
navigationItems[2] == Navigation.Item.ACCOUNT_SETUP) { navigationItems[2] == Navigation.Item.ACCOUNT_SETUP) {
log.debug("### " + navigationItems[3]);
//loadView(navigationItems[3]);
switch (navigationItems[3]) { switch (navigationItems[3]) {
case SEED_WORDS: case SEED_WORDS:
childController = seedWords.show(); childController = seedWords.show();
@ -115,17 +113,17 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
} }
}; };
seedWords = new WizardItem(navigation, this, "Backup wallet seed", "Write down the seed word for your wallet", seedWords = new WizardItem(this, "Backup wallet seed", "Write down the seed word for your wallet",
Navigation.Item.SEED_WORDS); Navigation.Item.SEED_WORDS);
password = new WizardItem(navigation, this, "Setup password", "Protect your wallet with a password", password = new WizardItem(this, "Setup password", "Protect your wallet with a password",
Navigation.Item.ADD_PASSWORD); Navigation.Item.ADD_PASSWORD);
restrictions = new WizardItem(navigation, this, "Setup your preferences", restrictions = new WizardItem(this, "Setup your preferences",
"Define your preferences with whom you want to trade", "Define your preferences with whom you want to trade",
Navigation.Item.RESTRICTIONS); Navigation.Item.RESTRICTIONS);
fiatAccount = new WizardItem(navigation, this, " Setup Payments account(s)", fiatAccount = new WizardItem(this, " Setup Payments account(s)",
"You need to add a payments account to your trading account", "You need to add a payments account to your trading account",
Navigation.Item.FIAT_ACCOUNT); Navigation.Item.FIAT_ACCOUNT);
registration = new WizardItem(navigation, this, "Register your account", registration = new WizardItem(this, "Register your account",
"Pay in the registration fee of 0.0002 BTC and store your account in the BTC block chain", "Pay in the registration fee of 0.0002 BTC and store your account in the BTC block chain",
Navigation.Item.REGISTRATION); Navigation.Item.REGISTRATION);
@ -134,7 +132,6 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
super.initialize(url, rb); super.initialize(url, rb);
navigation.addListener(listener); navigation.addListener(listener);
childController = seedWords.show(); childController = seedWords.show();
} }
@ -209,13 +206,11 @@ class WizardItem extends HBox {
private final ImageView imageView; private final ImageView imageView;
private final Label titleLabel; private final Label titleLabel;
private final Label subTitleLabel; private final Label subTitleLabel;
private AccountSetupViewCB host; private final AccountSetupViewCB host;
private final Navigation.Item navigationItem; private final Navigation.Item navigationItem;
private final Navigation navigation;
WizardItem(Navigation navigation, AccountSetupViewCB host, String title, String subTitle, WizardItem(AccountSetupViewCB host, String title, String subTitle,
Navigation.Item navigationItem) { Navigation.Item navigationItem) {
this.navigation = navigation;
this.host = host; this.host = host;
this.navigationItem = navigationItem; this.navigationItem = navigationItem;

View file

@ -51,7 +51,7 @@ public class DepositController extends CachedViewController {
private ObservableList<DepositListItem> addressList; private ObservableList<DepositListItem> addressList;
@FXML TableView<DepositListItem> tableView; @FXML TableView<DepositListItem> tableView;
@FXML TableColumn<String, DepositListItem> labelColumn, addressColumn, balanceColumn, copyColumn, @FXML TableColumn<DepositListItem, DepositListItem> labelColumn, addressColumn, balanceColumn, copyColumn,
confidenceColumn; confidenceColumn;
@ -117,13 +117,15 @@ public class DepositController extends CachedViewController {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void setLabelColumnCellFactory() { private void setLabelColumnCellFactory() {
labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
labelColumn.setCellFactory(new Callback<TableColumn<String, DepositListItem>, TableCell<String, labelColumn.setCellFactory(new Callback<TableColumn<DepositListItem, DepositListItem>,
DepositListItem>>() { TableCell<DepositListItem,
DepositListItem>>() {
@Override @Override
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column) { public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem,
return new TableCell<String, DepositListItem>() { DepositListItem> column) {
return new TableCell<DepositListItem, DepositListItem>() {
Hyperlink hyperlink; Hyperlink hyperlink;
@ -154,13 +156,15 @@ public class DepositController extends CachedViewController {
} }
private void setBalanceColumnCellFactory() { private void setBalanceColumnCellFactory() {
balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
balanceColumn.setCellFactory( balanceColumn.setCellFactory(
new Callback<TableColumn<String, DepositListItem>, TableCell<String, DepositListItem>>() { new Callback<TableColumn<DepositListItem, DepositListItem>, TableCell<DepositListItem,
DepositListItem>>() {
@Override @Override
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column) { public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem,
return new TableCell<String, DepositListItem>() { DepositListItem> column) {
return new TableCell<DepositListItem, DepositListItem>() {
@Override @Override
public void updateItem(final DepositListItem item, boolean empty) { public void updateItem(final DepositListItem item, boolean empty) {
super.updateItem(item, empty); super.updateItem(item, empty);
@ -178,13 +182,15 @@ public class DepositController extends CachedViewController {
} }
private void setCopyColumnCellFactory() { private void setCopyColumnCellFactory() {
copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
copyColumn.setCellFactory( copyColumn.setCellFactory(
new Callback<TableColumn<String, DepositListItem>, TableCell<String, DepositListItem>>() { new Callback<TableColumn<DepositListItem, DepositListItem>, TableCell<DepositListItem,
DepositListItem>>() {
@Override @Override
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column) { public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem,
return new TableCell<String, DepositListItem>() { DepositListItem> column) {
return new TableCell<DepositListItem, DepositListItem>() {
final Label copyIcon = new Label(); final Label copyIcon = new Label();
{ {
@ -217,14 +223,16 @@ public class DepositController extends CachedViewController {
} }
private void setConfidenceColumnCellFactory() { private void setConfidenceColumnCellFactory() {
confidenceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue confidenceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue
())); ()));
confidenceColumn.setCellFactory(new Callback<TableColumn<String, DepositListItem>, TableCell<String, confidenceColumn.setCellFactory(new Callback<TableColumn<DepositListItem, DepositListItem>,
DepositListItem>>() { TableCell<DepositListItem,
DepositListItem>>() {
@Override @Override
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column) { public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem,
return new TableCell<String, DepositListItem>() { DepositListItem> column) {
return new TableCell<DepositListItem, DepositListItem>() {
@Override @Override
public void updateItem(final DepositListItem item, boolean empty) { public void updateItem(final DepositListItem item, boolean empty) {

View file

@ -47,9 +47,8 @@ public class TransactionsController extends CachedViewController {
private ObservableList<TransactionsListItem> transactionsListItems; private ObservableList<TransactionsListItem> transactionsListItems;
@FXML TableView<TransactionsListItem> tableView; @FXML TableView<TransactionsListItem> tableView;
@FXML TableColumn<String, TransactionsListItem> dateColumn, addressColumn, amountColumn, typeColumn, @FXML TableColumn<TransactionsListItem, TransactionsListItem> dateColumn, addressColumn, amountColumn, typeColumn,
confidenceColumn; confidenceColumn;
@FXML Button addNewAddressButton;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -112,14 +111,15 @@ public class TransactionsController extends CachedViewController {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void setAddressColumnCellFactory() { private void setAddressColumnCellFactory() {
addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
addressColumn.setCellFactory( addressColumn.setCellFactory(
new Callback<TableColumn<String, TransactionsListItem>, TableCell<String, TransactionsListItem>>() { new Callback<TableColumn<TransactionsListItem, TransactionsListItem>, TableCell<TransactionsListItem,
TransactionsListItem>>() {
@Override @Override
public TableCell<String, TransactionsListItem> call(TableColumn<String, public TableCell<TransactionsListItem, TransactionsListItem> call(TableColumn<TransactionsListItem,
TransactionsListItem> column) { TransactionsListItem> column) {
return new TableCell<String, TransactionsListItem>() { return new TableCell<TransactionsListItem, TransactionsListItem>() {
Hyperlink hyperlink; Hyperlink hyperlink;
@Override @Override
@ -145,14 +145,15 @@ public class TransactionsController extends CachedViewController {
private void setConfidenceColumnCellFactory() { private void setConfidenceColumnCellFactory() {
confidenceColumn.setCellValueFactory((addressListItem) -> confidenceColumn.setCellValueFactory((addressListItem) ->
new ReadOnlyObjectWrapper(addressListItem.getValue())); new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
confidenceColumn.setCellFactory( confidenceColumn.setCellFactory(
new Callback<TableColumn<String, TransactionsListItem>, TableCell<String, TransactionsListItem>>() { new Callback<TableColumn<TransactionsListItem, TransactionsListItem>, TableCell<TransactionsListItem,
TransactionsListItem>>() {
@Override @Override
public TableCell<String, TransactionsListItem> call(TableColumn<String, public TableCell<TransactionsListItem, TransactionsListItem> call(TableColumn<TransactionsListItem,
TransactionsListItem> column) { TransactionsListItem> column) {
return new TableCell<String, TransactionsListItem>() { return new TableCell<TransactionsListItem, TransactionsListItem>() {
@Override @Override
public void updateItem(final TransactionsListItem item, boolean empty) { public void updateItem(final TransactionsListItem item, boolean empty) {

View file

@ -55,6 +55,8 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
import org.controlsfx.control.action.Action; import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog; import org.controlsfx.dialog.Dialog;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -66,7 +68,7 @@ public class WithdrawalController extends CachedViewController {
private ObservableList<WithdrawalListItem> addressList; private ObservableList<WithdrawalListItem> addressList;
@FXML TableView<WithdrawalListItem> tableView; @FXML TableView<WithdrawalListItem> tableView;
@FXML TableColumn<String, WithdrawalListItem> labelColumn, addressColumn, balanceColumn, copyColumn, @FXML TableColumn<WithdrawalListItem, WithdrawalListItem> labelColumn, addressColumn, balanceColumn, copyColumn,
confidenceColumn; confidenceColumn;
@FXML Button addNewAddressButton; @FXML Button addNewAddressButton;
@FXML TextField withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField; @FXML TextField withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField;
@ -156,12 +158,12 @@ public class WithdrawalController extends CachedViewController {
BitSquareValidator.resetTextFields( BitSquareValidator.resetTextFields(
withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField); withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField);
if (transaction != null) { if (transaction != null) {
log.info("onWithdraw onSuccess txid:" + transaction.getHashAsString()); log.info("onWithdraw onSuccess tx ID:" + transaction.getHashAsString());
} }
} }
@Override @Override
public void onFailure(Throwable t) { public void onFailure(@NotNull Throwable t) {
log.debug("onWithdraw onFailure"); log.debug("onWithdraw onFailure");
} }
}; };
@ -213,13 +215,15 @@ public class WithdrawalController extends CachedViewController {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void setLabelColumnCellFactory() { private void setLabelColumnCellFactory() {
labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
labelColumn.setCellFactory(new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, labelColumn.setCellFactory(new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>,
WithdrawalListItem>>() { TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override @Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) { public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
return new TableCell<String, WithdrawalListItem>() { WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
Hyperlink hyperlink; Hyperlink hyperlink;
@ -250,13 +254,15 @@ public class WithdrawalController extends CachedViewController {
} }
private void setBalanceColumnCellFactory() { private void setBalanceColumnCellFactory() {
balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
balanceColumn.setCellFactory( balanceColumn.setCellFactory(
new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>() { new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override @Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) { public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
return new TableCell<String, WithdrawalListItem>() { WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
@Override @Override
public void updateItem(final WithdrawalListItem item, boolean empty) { public void updateItem(final WithdrawalListItem item, boolean empty) {
super.updateItem(item, empty); super.updateItem(item, empty);
@ -268,13 +274,15 @@ public class WithdrawalController extends CachedViewController {
} }
private void setCopyColumnCellFactory() { private void setCopyColumnCellFactory() {
copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
copyColumn.setCellFactory( copyColumn.setCellFactory(
new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>() { new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override @Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) { public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
return new TableCell<String, WithdrawalListItem>() { WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
final Label copyIcon = new Label(); final Label copyIcon = new Label();
{ {
@ -308,13 +316,15 @@ public class WithdrawalController extends CachedViewController {
private void setConfidenceColumnCellFactory() { private void setConfidenceColumnCellFactory() {
confidenceColumn.setCellValueFactory((addressListItem) -> confidenceColumn.setCellValueFactory((addressListItem) ->
new ReadOnlyObjectWrapper(addressListItem.getValue())); new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
confidenceColumn.setCellFactory( confidenceColumn.setCellFactory(
new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>() { new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override @Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) { public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
return new TableCell<String, WithdrawalListItem>() { WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
@Override @Override
public void updateItem(final WithdrawalListItem item, boolean empty) { public void updateItem(final WithdrawalListItem item, boolean empty) {

View file

@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
// will be probably only used for arbitration communication, will be renamed and the icon changed // will be probably only used for arbitration communication, will be renamed and the icon changed
public class MsgController extends CachedViewCB { public class MsgController extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(MsgController.class); private static final Logger log = LoggerFactory.getLogger(MsgController.class);
@ -49,22 +50,25 @@ public class MsgController extends CachedViewCB {
// Lifecycle // Lifecycle
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override @Override
public void initialize(URL url, ResourceBundle rb) { public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb); super.initialize(url, rb);
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void terminate() { public void terminate() {
super.terminate(); super.terminate();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void deactivate() { public void deactivate() {
super.deactivate(); super.deactivate();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();

View file

@ -43,8 +43,8 @@ import org.slf4j.LoggerFactory;
public class OrdersViewCB extends CachedViewCB { public class OrdersViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(OrdersViewCB.class); private static final Logger log = LoggerFactory.getLogger(OrdersViewCB.class);
private Navigation navigation; private final Navigation navigation;
private TradeManager tradeManager; private final TradeManager tradeManager;
private Navigation.Listener navigationListener; private Navigation.Listener navigationListener;
@FXML Tab offersTab, pendingTradesTab, closedTradesTab; @FXML Tab offersTab, pendingTradesTab, closedTradesTab;
@ -71,16 +71,12 @@ public class OrdersViewCB extends CachedViewCB {
@Override @Override
public void initialize(URL url, ResourceBundle rb) { public void initialize(URL url, ResourceBundle rb) {
navigationListener = navigationItems -> { navigationListener = navigationItems -> {
if (navigationItems != null && navigationItems.length == 3 && navigationItems[1] == Navigation.Item if (navigationItems != null && navigationItems.length == 3
.ORDERS) { && navigationItems[1] == Navigation.Item.ORDERS)
log.debug("#### Orders " + navigationItems[2]);
loadView(navigationItems[2]); loadView(navigationItems[2]);
}
}; };
tabChangeListener = (ov, oldValue, newValue) -> { tabChangeListener = (ov, oldValue, newValue) -> {
log.debug("#### newValue " + newValue.getText());
if (newValue == offersTab) if (newValue == offersTab)
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ORDERS, Navigation.Item.OFFERS); navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ORDERS, Navigation.Item.OFFERS);
else if (newValue == pendingTradesTab) else if (newValue == pendingTradesTab)

View file

@ -22,7 +22,10 @@ import io.bitsquare.trade.Trade;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClosedTradesListItem { /**
* We could remove that wrapper if it is not needed for additional UI only fields.
*/
class ClosedTradesListItem {
private static final Logger log = LoggerFactory.getLogger(ClosedTradesListItem.class); private static final Logger log = LoggerFactory.getLogger(ClosedTradesListItem.class);
private final Trade trade; private final Trade trade;

View file

@ -30,12 +30,12 @@ import javafx.collections.ObservableList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClosedTradesModel extends UIModel { class ClosedTradesModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(ClosedTradesModel.class); private static final Logger log = LoggerFactory.getLogger(ClosedTradesModel.class);
private TradeManager tradeManager; private final TradeManager tradeManager;
private ObservableList<ClosedTradesListItem> list = FXCollections.observableArrayList(); private final ObservableList<ClosedTradesListItem> list = FXCollections.observableArrayList();
private MapChangeListener<String, Trade> mapChangeListener; private MapChangeListener<String, Trade> mapChangeListener;

View file

@ -27,9 +27,9 @@ import javafx.collections.ObservableList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClosedTradesPM extends PresentationModel<ClosedTradesModel> { class ClosedTradesPM extends PresentationModel<ClosedTradesModel> {
private static final Logger log = LoggerFactory.getLogger(ClosedTradesPM.class); private static final Logger log = LoggerFactory.getLogger(ClosedTradesPM.class);
private BSFormatter formatter; private final BSFormatter formatter;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -46,23 +46,22 @@ public class ClosedTradesPM extends PresentationModel<ClosedTradesModel> {
// Lifecycle // Lifecycle
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override @Override
public void initialize() { public void initialize() {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();
} }
@SuppressWarnings("EmptyMethod") @SuppressWarnings("EmptyMethod")
@Override @Override
public void deactivate() { public void deactivate() {
super.deactivate(); super.deactivate();
} }
@SuppressWarnings("EmptyMethod") @SuppressWarnings("EmptyMethod")

View file

@ -38,7 +38,7 @@ public class ClosedTradesViewCB extends CachedViewCB<ClosedTradesPM> {
@FXML TableColumn<ClosedTradesListItem, ClosedTradesListItem> priceColumn, amountColumn, volumeColumn, @FXML TableColumn<ClosedTradesListItem, ClosedTradesListItem> priceColumn, amountColumn, volumeColumn,
directionColumn, dateColumn, tradeIdColumn, removeItemColumn; directionColumn, dateColumn, tradeIdColumn;
@FXML TableView<ClosedTradesListItem> table; @FXML TableView<ClosedTradesListItem> table;
@ -77,6 +77,7 @@ public class ClosedTradesViewCB extends CachedViewCB<ClosedTradesPM> {
table.setItems(presentationModel.getList()); table.setItems(presentationModel.getList());
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void deactivate() { public void deactivate() {
super.deactivate(); super.deactivate();
@ -104,7 +105,7 @@ public class ClosedTradesViewCB extends CachedViewCB<ClosedTradesPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void setTradeIdColumnCellFactory() { private void setTradeIdColumnCellFactory() {
tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue())); tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
tradeIdColumn.setCellFactory( tradeIdColumn.setCellFactory(
new Callback<TableColumn<ClosedTradesListItem, ClosedTradesListItem>, TableCell<ClosedTradesListItem, new Callback<TableColumn<ClosedTradesListItem, ClosedTradesListItem>, TableCell<ClosedTradesListItem,
ClosedTradesListItem>>() { ClosedTradesListItem>>() {

View file

@ -17,61 +17,20 @@
package io.bitsquare.gui.main.orders.offer; package io.bitsquare.gui.main.orders.offer;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.trade.Offer; import io.bitsquare.trade.Offer;
import javafx.beans.property.SimpleStringProperty; /**
import javafx.beans.property.StringProperty; * We could remove that wrapper if it is not needed for additional UI only fields.
*/
public class OfferListItem { class OfferListItem {
private final StringProperty price = new SimpleStringProperty();
private final StringProperty amount = new SimpleStringProperty();
private final StringProperty date = new SimpleStringProperty();
private final StringProperty volume = new SimpleStringProperty();
private final Offer offer; private final Offer offer;
private final String offerId;
public OfferListItem(Offer offer) { public OfferListItem(Offer offer) {
this.offer = offer; this.offer = offer;
this.date.set(BSFormatter.formatDateTime(offer.getCreationDate()));
this.price.set(BSFormatter.formatFiat(offer.getPrice()));
this.amount.set(BSFormatter.formatCoin(
offer.getAmount()) + " (" + BSFormatter.formatCoin(offer.getMinAmount()) + ")");
this.volume.set(BSFormatter.formatVolumeWithMinVolume(offer));
this.offerId = offer.getId();
} }
public Offer getOffer() { public Offer getOffer() {
return offer; return offer;
} }
// called form table columns
public final StringProperty dateProperty() {
return this.date;
}
public final StringProperty priceProperty() {
return this.price;
}
public final StringProperty amountProperty() {
return this.amount;
}
public final StringProperty volumeProperty() {
return this.volume;
}
public String getOfferId() {
return offerId;
}
} }

View file

@ -32,12 +32,12 @@ import javafx.collections.ObservableList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class OffersModel extends UIModel { class OffersModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(OffersModel.class); private static final Logger log = LoggerFactory.getLogger(OffersModel.class);
private TradeManager tradeManager; private final TradeManager tradeManager;
private ObservableList<OfferListItem> list = FXCollections.observableArrayList(); private final ObservableList<OfferListItem> list = FXCollections.observableArrayList();
private MapChangeListener<String, Offer> offerMapChangeListener; private MapChangeListener<String, Offer> offerMapChangeListener;
@ -61,7 +61,7 @@ public class OffersModel extends UIModel {
if (change.wasAdded()) if (change.wasAdded())
list.add(new OfferListItem(change.getValueAdded())); list.add(new OfferListItem(change.getValueAdded()));
else if (change.wasRemoved()) else if (change.wasRemoved())
list.removeIf(e -> e.getOfferId().equals(change.getValueRemoved().getId())); list.removeIf(e -> e.getOffer().getId().equals(change.getValueRemoved().getId()));
}; };
super.initialize(); super.initialize();

View file

@ -27,9 +27,9 @@ import javafx.collections.ObservableList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class OffersPM extends PresentationModel<OffersModel> { class OffersPM extends PresentationModel<OffersModel> {
private static final Logger log = LoggerFactory.getLogger(OffersPM.class); private static final Logger log = LoggerFactory.getLogger(OffersPM.class);
private BSFormatter formatter; private final BSFormatter formatter;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -46,23 +46,22 @@ public class OffersPM extends PresentationModel<OffersModel> {
// Lifecycle // Lifecycle
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override @Override
public void initialize() { public void initialize() {
super.initialize(); super.initialize();
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void activate() { public void activate() {
super.activate(); super.activate();
} }
@SuppressWarnings("EmptyMethod") @SuppressWarnings("EmptyMethod")
@Override @Override
public void deactivate() { public void deactivate() {
super.deactivate(); super.deactivate();
} }
@SuppressWarnings("EmptyMethod") @SuppressWarnings("EmptyMethod")
@ -88,9 +87,9 @@ public class OffersPM extends PresentationModel<OffersModel> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
String getTradeId(OfferListItem item) { String getTradeId(OfferListItem item) {
return item.getOfferId(); return item.getOffer().getId();
} }
String getAmount(OfferListItem item) { String getAmount(OfferListItem item) {

View file

@ -79,6 +79,7 @@ public class OffersViewCB extends CachedViewCB<OffersPM> {
table.setItems(presentationModel.getList()); table.setItems(presentationModel.getList());
} }
@SuppressWarnings("EmptyMethod")
@Override @Override
public void deactivate() { public void deactivate() {
super.deactivate(); super.deactivate();
@ -110,7 +111,7 @@ public class OffersViewCB extends CachedViewCB<OffersPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void setOfferIdColumnCellFactory() { private void setOfferIdColumnCellFactory() {
offerIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue())); offerIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
offerIdColumn.setCellFactory( offerIdColumn.setCellFactory(
new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() { new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@ -244,7 +245,7 @@ public class OffersViewCB extends CachedViewCB<OffersPM> {
private void setRemoveColumnCellFactory() { private void setRemoveColumnCellFactory() {
removeItemColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue())); removeItemColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
removeItemColumn.setCellFactory( removeItemColumn.setCellFactory(
new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() { new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override @Override

View file

@ -89,9 +89,6 @@ class PendingTradesModel extends UIModel {
faultChangeListener = (ov, oldValue, newValue) -> fault.set(newValue); faultChangeListener = (ov, oldValue, newValue) -> fault.set(newValue);
mapChangeListener = change -> { mapChangeListener = change -> {
log.debug("######## " + change);
log.debug("######## " + change.getValueAdded());
log.debug("######## " + change.getValueRemoved());
if (change.wasAdded()) if (change.wasAdded())
list.add(new PendingTradesListItem(change.getValueAdded())); list.add(new PendingTradesListItem(change.getValueAdded()));
else if (change.wasRemoved()) else if (change.wasRemoved())

View file

@ -67,7 +67,6 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
private ChangeListener<PendingTradesPM.State> offererStateChangeListener; private ChangeListener<PendingTradesPM.State> offererStateChangeListener;
private ChangeListener<PendingTradesPM.State> takerStateChangeListener; private ChangeListener<PendingTradesPM.State> takerStateChangeListener;
private ChangeListener<Throwable> faultChangeListener; private ChangeListener<Throwable> faultChangeListener;
private ChangeListener<PendingTradesListItem> listItemChangeListener;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -416,7 +415,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void setTradeIdColumnCellFactory() { private void setTradeIdColumnCellFactory() {
tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue())); tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
tradeIdColumn.setCellFactory( tradeIdColumn.setCellFactory(
new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>, new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>,
TableCell<PendingTradesListItem, PendingTradesListItem>>() { TableCell<PendingTradesListItem, PendingTradesListItem>>() {

View file

@ -55,7 +55,7 @@ public class TradeViewCB extends CachedViewCB implements TradeNavigator {
private TakeOfferViewCB takeOfferViewCB; private TakeOfferViewCB takeOfferViewCB;
private Node createOfferView; private Node createOfferView;
private Node takeOfferView; private Node takeOfferView;
private Navigation navigation; private final Navigation navigation;
private Navigation.Listener listener; private Navigation.Listener listener;
private Navigation.Item navigationItem; private Navigation.Item navigationItem;
private Direction direction; private Direction direction;

View file

@ -260,6 +260,7 @@ class CreateOfferModel extends UIModel {
} }
} }
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isMinAmountLessOrEqualAmount() { boolean isMinAmountLessOrEqualAmount() {
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (minAmountAsCoin.get() != null && amountAsCoin.get() != null) if (minAmountAsCoin.get() != null && amountAsCoin.get() != null)

View file

@ -77,8 +77,8 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
private static final Logger log = LoggerFactory.getLogger(CreateOfferViewCB.class); private static final Logger log = LoggerFactory.getLogger(CreateOfferViewCB.class);
private Navigation navigation; private final Navigation navigation;
private OverlayManager overlayManager; private final OverlayManager overlayManager;
private CloseListener closeListener; private CloseListener closeListener;
private boolean detailsVisible; private boolean detailsVisible;

View file

@ -74,10 +74,7 @@ public class OrderBook {
this.user = user; this.user = user;
bankAccountChangeListener = (observableValue, oldValue, newValue) -> setBankAccount(newValue); bankAccountChangeListener = (observableValue, oldValue, newValue) -> setBankAccount(newValue);
invalidationListener = (ov, oldValue, newValue) -> { invalidationListener = (ov, oldValue, newValue) -> requestOffers();
log.debug("#### invalidationListener " + newValue);
requestOffers();
};
orderBookListener = new OrderBookListener() { orderBookListener = new OrderBookListener() {
@Override @Override
@ -89,7 +86,7 @@ public class OrderBook {
public void onOffersReceived(List<Offer> offers) { public void onOffersReceived(List<Offer> offers) {
//TODO use deltas instead replacing the whole list //TODO use deltas instead replacing the whole list
orderBookListItems.clear(); orderBookListItems.clear();
offers.stream().forEach(offer -> addOfferToOrderBookListItems(offer)); offers.stream().forEach(e -> addOfferToOrderBookListItems(e));
} }
@Override @Override
@ -164,7 +161,6 @@ public class OrderBook {
} }
private void requestOffers() { private void requestOffers() {
log.debug("#### requestOffers");
messageFacade.getOffers(fiatCode); messageFacade.getOffers(fiatCode);
} }

View file

@ -70,7 +70,6 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
private final OptionalBtcValidator optionalBtcValidator; private final OptionalBtcValidator optionalBtcValidator;
private final OptionalFiatValidator optionalFiatValidator; private final OptionalFiatValidator optionalFiatValidator;
private Navigation.Item navigationItem;
private boolean detailsVisible; private boolean detailsVisible;
private boolean advancedScreenInited; private boolean advancedScreenInited;
@ -175,8 +174,6 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
public void setDirection(Direction direction) { public void setDirection(Direction direction) {
presentationModel.setDirection(direction); presentationModel.setDirection(direction);
navigationItem = (direction == Direction.BUY) ? Navigation.Item.BUY : Navigation.Item.SELL;
} }

View file

@ -211,6 +211,7 @@ class TakeOfferModel extends UIModel {
} }
} }
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isMinAmountLessOrEqualAmount() { boolean isMinAmountLessOrEqualAmount() {
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (offer != null && offer.getMinAmount() != null && amountAsCoin.get() != null) if (offer != null && offer.getMinAmount() != null && amountAsCoin.get() != null)

View file

@ -72,8 +72,8 @@ import org.slf4j.LoggerFactory;
public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> { public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
private static final Logger log = LoggerFactory.getLogger(TakeOfferViewCB.class); private static final Logger log = LoggerFactory.getLogger(TakeOfferViewCB.class);
private Navigation navigation; private final Navigation navigation;
private OverlayManager overlayManager; private final OverlayManager overlayManager;
private CloseListener closeListener; private CloseListener closeListener;
private boolean detailsVisible; private boolean detailsVisible;

View file

@ -284,11 +284,11 @@ public class BSFormatter {
} }
public static String countryLocalesToString(List<Country> countries) { public static String countryLocalesToString(List<Country> countries) {
return countries.stream().map(e -> e.getName()).collect(Collectors.joining(", ")); return countries.stream().map(Country::getName).collect(Collectors.joining(", "));
} }
public static String arbitratorsToString(List<Arbitrator> arbitrators) { public static String arbitratorsToString(List<Arbitrator> arbitrators) {
return arbitrators.stream().map(e -> e.getName()).collect(Collectors.joining(", ")); return arbitrators.stream().map(Arbitrator::getName).collect(Collectors.joining(", "));
} }
public static String languageLocalesToString(List<Locale> languageLocales) { public static String languageLocalesToString(List<Locale> languageLocales) {
@ -334,6 +334,7 @@ public class BSFormatter {
input = input.replace(",", "."); input = input.replace(",", ".");
// don't use String.valueOf(Double.parseDouble(input)) as return value as it gives scientific // don't use String.valueOf(Double.parseDouble(input)) as return value as it gives scientific
// notation (1.0E-6) which screw up coinFormat.parse // notation (1.0E-6) which screw up coinFormat.parse
//noinspection ResultOfMethodCallIgnored
Double.parseDouble(input); Double.parseDouble(input);
return input; return input;
} }

View file

@ -146,6 +146,7 @@ public class BitSquareValidator {
public static boolean validateStringAsDouble(String input) { public static boolean validateStringAsDouble(String input) {
try { try {
input = input.replace(",", "."); input = input.replace(",", ".");
//noinspection ResultOfMethodCallIgnored
Double.parseDouble(input); Double.parseDouble(input);
return true; return true;
} catch (NumberFormatException | NullPointerException e) { } catch (NumberFormatException | NullPointerException e) {

View file

@ -33,23 +33,13 @@ public class Profiler {
private static final Stopwatch globalStopwatch = Stopwatch.createStarted(); private static final Stopwatch globalStopwatch = Stopwatch.createStarted();
private static final ThreadLocal<Stopwatch> threadStopwatch = ThreadLocal.withInitial(Stopwatch::createStarted); private static final ThreadLocal<Stopwatch> threadStopwatch = ThreadLocal.withInitial(Stopwatch::createStarted);
private static final ThreadLocal<Long> last = ThreadLocal.withInitial(() -> 0L); private static final ThreadLocal<Long> last = ThreadLocal.withInitial(() -> 0L);
private static long lastCurrentTimeMillis = System.currentTimeMillis();
private static long lastFPSTime = System.currentTimeMillis(); private static long lastFPSTime = System.currentTimeMillis();
private static long counter = 0;
public static void printMsgWithTime(String msg) { public static void printMsgWithTime(String msg) {
final long elapsed = threadStopwatch.get().elapsed(TimeUnit.MILLISECONDS); final long elapsed = threadStopwatch.get().elapsed(TimeUnit.MILLISECONDS);
log.trace("\n\nCalled by: {} \nElapsed time: {}ms \nTotal time: {}ms\n\n", log.trace("\n\nCalled by: {} \nElapsed time: {}ms \nTotal time: {}ms\n\n",
msg, elapsed - last.get(), globalStopwatch.elapsed(TimeUnit.MILLISECONDS)); msg, elapsed - last.get(), globalStopwatch.elapsed(TimeUnit.MILLISECONDS));
/* log.trace("Msg: {} elapsed: {}ms / total time:[globalStopwatch: {}ms / threadStopwatch: {}ms / " +
"currentTimeMillis: {}ms]",
msg,
elapsed - last.get(),
globalStopwatch.elapsed(TimeUnit.MILLISECONDS),
elapsed,
System.currentTimeMillis() - lastCurrentTimeMillis);*/
lastCurrentTimeMillis = System.currentTimeMillis();
last.set(elapsed); last.set(elapsed);
} }
@ -57,7 +47,6 @@ public class Profiler {
AnimationTimer fpsTimer = new AnimationTimer() { AnimationTimer fpsTimer = new AnimationTimer() {
@Override @Override
public void handle(long l) { public void handle(long l) {
counter++;
long elapsed = (System.currentTimeMillis() - lastFPSTime); long elapsed = (System.currentTimeMillis() - lastFPSTime);
if (elapsed > 19) if (elapsed > 19)
log.trace("Profiler: last frame used {}ms", elapsed); log.trace("Profiler: last frame used {}ms", elapsed);

View file

@ -44,6 +44,7 @@ public abstract class NumberValidator extends InputValidator {
protected ValidationResult validateIfNumber(String input) { protected ValidationResult validateIfNumber(String input) {
try { try {
//noinspection ResultOfMethodCallIgnored
Double.parseDouble(input); Double.parseDouble(input);
return new ValidationResult(true); return new ValidationResult(true);
} catch (Exception e) { } catch (Exception e) {

View file

@ -88,8 +88,8 @@ public class CountryUtil {
List<Country> allEuroCountries = new ArrayList<>(); List<Country> allEuroCountries = new ArrayList<>();
String[] code = {"BE", "DE", "EE", "FI", "FR", "GR", "IE", "IT", "LV", "LU", "MT", "NL", "PT", "SK", "SI", String[] code = {"BE", "DE", "EE", "FI", "FR", "GR", "IE", "IT", "LV", "LU", "MT", "NL", "PT", "SK", "SI",
"ES", "AT", "CY"}; "ES", "AT", "CY"};
for (int i = 0; i < code.length; i++) { for (String aCode : code) {
Locale locale = new Locale("", code[i], ""); Locale locale = new Locale("", aCode, "");
String regionCode = getRegionCode(locale.getCountry()); String regionCode = getRegionCode(locale.getCountry());
final Region region = new Region(regionCode, getRegionName(regionCode)); final Region region = new Region(regionCode, getRegionName(regionCode));
final Country country = new Country(locale.getCountry(), locale.getDisplayCountry(), region); final Country country = new Country(locale.getCountry(), locale.getDisplayCountry(), region);

View file

@ -292,7 +292,7 @@ public class BootstrappedPeerFactory {
log.debug("Start setup relay was successful."); log.debug("Start setup relay was successful.");
futureRelay.relays().forEach(e -> log.debug("remotePeer = " + e.remotePeer())); futureRelay.relays().forEach(e -> log.debug("remotePeer = " + e.remotePeer()));
findNeighbors2(peerDHT, nodeBehindNat, bootstrapAddress); findNeighbors2(peerDHT, bootstrapAddress);
} }
else { else {
log.error("setupRelay failed. Reason: " + futureRelay.failedReason()); log.error("setupRelay failed. Reason: " + futureRelay.failedReason());
@ -314,7 +314,7 @@ public class BootstrappedPeerFactory {
}); });
} }
private void findNeighbors2(PeerDHT peerDHT, PeerNAT nodeBehindNat, PeerAddress bootstrapAddress) { private void findNeighbors2(PeerDHT peerDHT, PeerAddress bootstrapAddress) {
// find neighbors again // find neighbors again
FutureBootstrap futureBootstrap2 = peerDHT.peer().bootstrap().peerAddress(bootstrapAddress).start(); FutureBootstrap futureBootstrap2 = peerDHT.peer().bootstrap().peerAddress(bootstrapAddress).start();
BootstrappedPeerFactory ref = this; BootstrappedPeerFactory ref = this;

View file

@ -135,25 +135,20 @@ public class MessageFacade implements MessageBroker {
public void getPeerAddress(PublicKey publicKey, GetPeerAddressListener listener) { public void getPeerAddress(PublicKey publicKey, GetPeerAddressListener listener) {
final Number160 locationKey = Utils.makeSHAHash(publicKey.getEncoded()); final Number160 locationKey = Utils.makeSHAHash(publicKey.getEncoded());
try { FutureGet futureGet = p2pNode.getDomainProtectedData(locationKey, publicKey);
FutureGet futureGet = p2pNode.getDomainProtectedData(locationKey, publicKey);
futureGet.addListener(new BaseFutureAdapter<BaseFuture>() { futureGet.addListener(new BaseFutureAdapter<BaseFuture>() {
@Override @Override
public void operationComplete(BaseFuture baseFuture) throws Exception { public void operationComplete(BaseFuture baseFuture) throws Exception {
if (baseFuture.isSuccess() && futureGet.data() != null) { if (baseFuture.isSuccess() && futureGet.data() != null) {
final PeerAddress peerAddress = (PeerAddress) futureGet.data().object(); final PeerAddress peerAddress = (PeerAddress) futureGet.data().object();
Platform.runLater(() -> listener.onResult(peerAddress)); Platform.runLater(() -> listener.onResult(peerAddress));
}
else {
Platform.runLater(listener::onFailed);
}
} }
}); else {
} catch (IOException | ClassNotFoundException e) { Platform.runLater(listener::onFailed);
e.printStackTrace(); }
log.error(e.toString()); }
} });
} }
@ -213,7 +208,7 @@ public class MessageFacade implements MessageBroker {
}); });
} }
}); });
} catch (IOException | ClassNotFoundException e) { } catch (IOException e) {
Platform.runLater(() -> { Platform.runLater(() -> {
addOfferListener.onFailed("Add offer to DHT failed with an exception.", e); addOfferListener.onFailed("Add offer to DHT failed with an exception.", e);
log.error("Add offer to DHT failed with an exception: " + e.getMessage()); log.error("Add offer to DHT failed with an exception: " + e.getMessage());
@ -263,7 +258,7 @@ public class MessageFacade implements MessageBroker {
log.error("Remove offer from DHT failed. Error: " + t.getMessage()); log.error("Remove offer from DHT failed. Error: " + t.getMessage());
} }
}); });
} catch (IOException | ClassNotFoundException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error("Remove offer from DHT failed. Error: " + e.getMessage()); log.error("Remove offer from DHT failed. Error: " + e.getMessage());
} }
@ -364,12 +359,12 @@ public class MessageFacade implements MessageBroker {
} }
} }
}); });
} catch (IOException | ClassNotFoundException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public void removeArbitrator(Arbitrator arbitrator) throws IOException, ClassNotFoundException { public void removeArbitrator(Arbitrator arbitrator) throws IOException {
Number160 locationKey = Number160.createHash(ARBITRATORS_ROOT); Number160 locationKey = Number160.createHash(ARBITRATORS_ROOT);
final Data arbitratorData = new Data(arbitrator); final Data arbitratorData = new Data(arbitrator);
FutureRemove removeFuture = p2pNode.removeFromDataMap(locationKey, arbitratorData); FutureRemove removeFuture = p2pNode.removeFromDataMap(locationKey, arbitratorData);
@ -468,7 +463,7 @@ public class MessageFacade implements MessageBroker {
log.error("Update invalidationTimestamp to DHT failed with exception:" + t.getMessage()); log.error("Update invalidationTimestamp to DHT failed with exception:" + t.getMessage());
} }
}); });
} catch (IOException | ClassNotFoundException e) { } catch (IOException e) {
log.error("Update invalidationTimestamp to DHT failed with exception:" + e.getMessage()); log.error("Update invalidationTimestamp to DHT failed with exception:" + e.getMessage());
} }
} }
@ -479,45 +474,40 @@ public class MessageFacade implements MessageBroker {
public void requestInvalidationTimeStampFromDHT(String currencyCode) { public void requestInvalidationTimeStampFromDHT(String currencyCode) {
Number160 locationKey = Number160.createHash(currencyCode); Number160 locationKey = Number160.createHash(currencyCode);
try { FutureGet getFuture = p2pNode.getData(getInvalidatedLocationKey(locationKey));
FutureGet getFuture = p2pNode.getData(getInvalidatedLocationKey(locationKey)); getFuture.addListener(new BaseFutureListener<BaseFuture>() {
getFuture.addListener(new BaseFutureListener<BaseFuture>() { @Override
@Override public void operationComplete(BaseFuture future) throws Exception {
public void operationComplete(BaseFuture future) throws Exception { if (getFuture.isSuccess()) {
if (getFuture.isSuccess()) { Data data = getFuture.data();
Data data = getFuture.data(); if (data != null && data.object() instanceof Long) {
if (data != null && data.object() instanceof Long) { final Object object = data.object();
final Object object = data.object(); Platform.runLater(() -> {
Platform.runLater(() -> { Long timeStamp = (Long) object;
Long timeStamp = (Long) object; log.trace("Get invalidationTimestamp from DHT was successful. TimeStamp=" +
log.trace("Get invalidationTimestamp from DHT was successful. TimeStamp=" + timeStamp);
timeStamp); invalidationTimestamp.set(timeStamp);
invalidationTimestamp.set(timeStamp); });
});
}
else {
log.error("Get invalidationTimestamp from DHT failed. Data = " + data);
}
}
else if (getFuture.data() == null) {
// OK as nothing is set at the moment
log.trace("Get invalidationTimestamp from DHT returns null. That is ok for the startup.");
} }
else { else {
log.error("Get invalidationTimestamp from DHT failed with reason:" + getFuture.failedReason()); log.error("Get invalidationTimestamp from DHT failed. Data = " + data);
} }
} }
else if (getFuture.data() == null) {
@Override // OK as nothing is set at the moment
public void exceptionCaught(Throwable t) throws Exception { log.trace("Get invalidationTimestamp from DHT returns null. That is ok for the startup.");
log.error("Get invalidationTimestamp from DHT failed with exception:" + t.getMessage());
t.printStackTrace();
} }
}); else {
} catch (IOException | ClassNotFoundException e) { log.error("Get invalidationTimestamp from DHT failed with reason:" + getFuture.failedReason());
log.error("Get invalidationTimestamp from DHT failed with exception:" + e.getMessage()); }
e.printStackTrace(); }
}
@Override
public void exceptionCaught(Throwable t) throws Exception {
log.error("Get invalidationTimestamp from DHT failed with exception:" + t.getMessage());
t.printStackTrace();
}
});
} }
private Number160 getInvalidatedLocationKey(Number160 locationKey) { private Number160 getInvalidatedLocationKey(Number160 locationKey) {

View file

@ -139,39 +139,37 @@ public class P2PNode {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// The data and the domain are protected by that key pair. // The data and the domain are protected by that key pair.
public FuturePut putDomainProtectedData(Number160 locationKey, Data data) public FuturePut putDomainProtectedData(Number160 locationKey, Data data) {
throws IOException, ClassNotFoundException {
data.protectEntry(keyPair); data.protectEntry(keyPair);
final Number160 ownerKeyHash = Utils.makeSHAHash(keyPair.getPublic().getEncoded()); final Number160 ownerKeyHash = Utils.makeSHAHash(keyPair.getPublic().getEncoded());
return peerDHT.put(locationKey).data(data).keyPair(keyPair).domainKey(ownerKeyHash).protectDomain().start(); return peerDHT.put(locationKey).data(data).keyPair(keyPair).domainKey(ownerKeyHash).protectDomain().start();
} }
// No protection, everybody can write. // No protection, everybody can write.
public FuturePut putData(Number160 locationKey, Data data) throws IOException, ClassNotFoundException { public FuturePut putData(Number160 locationKey, Data data) {
return peerDHT.put(locationKey).data(data).start(); return peerDHT.put(locationKey).data(data).start();
} }
// Not public readable. Only users with the public key of the peer who stored the data can read that data // Not public readable. Only users with the public key of the peer who stored the data can read that data
public FutureGet getDomainProtectedData(Number160 locationKey, PublicKey publicKey) public FutureGet getDomainProtectedData(Number160 locationKey, PublicKey publicKey) {
throws IOException, ClassNotFoundException {
final Number160 ownerKeyHash = Utils.makeSHAHash(publicKey.getEncoded()); final Number160 ownerKeyHash = Utils.makeSHAHash(publicKey.getEncoded());
return peerDHT.get(locationKey).domainKey(ownerKeyHash).start(); return peerDHT.get(locationKey).domainKey(ownerKeyHash).start();
} }
// No protection, everybody can read. // No protection, everybody can read.
public FutureGet getData(Number160 locationKey) throws IOException, ClassNotFoundException { public FutureGet getData(Number160 locationKey) {
return peerDHT.get(locationKey).start(); return peerDHT.get(locationKey).start();
} }
// No domain protection, but entry protection // No domain protection, but entry protection
public FuturePut addProtectedData(Number160 locationKey, Data data) throws IOException, ClassNotFoundException { public FuturePut addProtectedData(Number160 locationKey, Data data) {
data.protectEntry(keyPair); data.protectEntry(keyPair);
log.trace("addProtectedData with contentKey " + data.hash().toString()); log.trace("addProtectedData with contentKey " + data.hash().toString());
return peerDHT.add(locationKey).data(data).keyPair(keyPair).start(); return peerDHT.add(locationKey).data(data).keyPair(keyPair).start();
} }
// No domain protection, but entry protection // No domain protection, but entry protection
public FutureRemove removeFromDataMap(Number160 locationKey, Data data) throws IOException, ClassNotFoundException { public FutureRemove removeFromDataMap(Number160 locationKey, Data data) {
Number160 contentKey = data.hash(); Number160 contentKey = data.hash();
log.trace("removeFromDataMap with contentKey " + contentKey.toString()); log.trace("removeFromDataMap with contentKey " + contentKey.toString());
return peerDHT.remove(locationKey).contentKey(contentKey).keyPair(keyPair).start(); return peerDHT.remove(locationKey).contentKey(contentKey).keyPair(keyPair).start();
@ -242,7 +240,7 @@ public class P2PNode {
else { else {
log.error("peerDHT is null"); log.error("peerDHT is null");
} }
} catch (IOException | ClassNotFoundException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.toString()); log.error(e.toString());
} }
@ -275,7 +273,7 @@ public class P2PNode {
if (peerDHT != null && !storedPeerAddress.equals(peerDHT.peerAddress())) { if (peerDHT != null && !storedPeerAddress.equals(peerDHT.peerAddress())) {
try { try {
storePeerAddress(); storePeerAddress();
} catch (IOException | ClassNotFoundException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.toString()); log.error(e.toString());
} }
@ -284,7 +282,7 @@ public class P2PNode {
}, checkIfIPChangedPeriod, checkIfIPChangedPeriod); }, checkIfIPChangedPeriod, checkIfIPChangedPeriod);
} }
private FuturePut storePeerAddress() throws IOException, ClassNotFoundException { private FuturePut storePeerAddress() throws IOException {
Number160 locationKey = Utils.makeSHAHash(keyPair.getPublic().getEncoded()); Number160 locationKey = Utils.makeSHAHash(keyPair.getPublic().getEncoded());
Data data = new Data(peerDHT.peerAddress()); Data data = new Data(peerDHT.peerAddress());
return putDomainProtectedData(locationKey, data); return putDomainProtectedData(locationKey, data);

View file

@ -65,7 +65,7 @@ public class Trade implements Serializable {
// When serialized those transient properties are not instantiated, so we instantiate them in the getters at first // When serialized those transient properties are not instantiated, so we instantiate them in the getters at first
// access. Only use the accessor not the private field. // access. Only use the accessor not the private field.
// TODO use ObjectPropertys instead of BooleanProperty // TODO use ObjectProperties instead of BooleanProperty
transient private BooleanProperty _payoutTxChanged; transient private BooleanProperty _payoutTxChanged;
transient private BooleanProperty _contractChanged; transient private BooleanProperty _contractChanged;
transient private ObjectProperty<Transaction> _depositTx; transient private ObjectProperty<Transaction> _depositTx;

View file

@ -45,13 +45,13 @@ import com.google.bitcoin.core.Coin;
import com.google.bitcoin.core.Transaction; import com.google.bitcoin.core.Transaction;
import com.google.bitcoin.utils.Fiat; import com.google.bitcoin.utils.Fiat;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableMap; import javafx.collections.ObservableMap;
@ -88,6 +88,7 @@ public class TradeManager {
// the latest pending trade // the latest pending trade
private Trade currentPendingTrade; private Trade currentPendingTrade;
final StringProperty featureNotImplementedWarning = new SimpleStringProperty();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -106,17 +107,17 @@ public class TradeManager {
this.cryptoFacade = cryptoFacade; this.cryptoFacade = cryptoFacade;
Object offersObject = persistence.read(this, "offers"); Object offersObject = persistence.read(this, "offers");
if (offersObject instanceof HashMap) { if (offersObject instanceof Map) {
offers.putAll((Map<String, Offer>) offersObject); offers.putAll((Map<String, Offer>) offersObject);
} }
Object pendingTradesObject = persistence.read(this, "pendingTrades"); Object pendingTradesObject = persistence.read(this, "pendingTrades");
if (pendingTradesObject instanceof HashMap) { if (pendingTradesObject instanceof Map) {
pendingTrades.putAll((Map<String, Trade>) pendingTradesObject); pendingTrades.putAll((Map<String, Trade>) pendingTradesObject);
} }
Object closedTradesObject = persistence.read(this, "closedTrades"); Object closedTradesObject = persistence.read(this, "closedTrades");
if (closedTradesObject instanceof HashMap) { if (closedTradesObject instanceof Map) {
closedTrades.putAll((Map<String, Trade>) closedTradesObject); closedTrades.putAll((Map<String, Trade>) closedTradesObject);
} }
@ -192,7 +193,7 @@ public class TradeManager {
} }
} }
private void addOffer(Offer offer) throws IOException { private void addOffer(Offer offer) {
if (offers.containsKey(offer.getId())) if (offers.containsKey(offer.getId()))
log.error("An offer with the id " + offer.getId() + " already exists. "); log.error("An offer with the id " + offer.getId() + " already exists. ");
@ -395,12 +396,9 @@ public class TradeManager {
persistPendingTrades(); persistPendingTrades();
} }
else { else {
// For usability tests we don't want to crash featureNotImplementedWarning.set("Sorry, you cannot continue. You have restarted the application in the " +
//TODO move to gui package "meantime. Interruption of the trade process is not supported yet. Will need more time to be " +
/* Popups.openWarningPopup("Sorry, you cannot continue. You have restarted the application in the meantime "implemented.");
. " +
"Interruption of the trade process is not supported yet. Will need more time to be implemented.");*/
} }
} }
@ -459,6 +457,15 @@ public class TradeManager {
} }
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
public void setFeatureNotImplementedWarning(String featureNotImplementedWarning) {
this.featureNotImplementedWarning.set(featureNotImplementedWarning);
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -479,6 +486,13 @@ public class TradeManager {
return currentPendingTrade; return currentPendingTrade;
} }
public String getFeatureNotImplementedWarning() {
return featureNotImplementedWarning.get();
}
public StringProperty featureNotImplementedWarningProperty() {
return featureNotImplementedWarning;
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Private // Private

View file

@ -21,7 +21,6 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.trade.handlers.FaultHandler; import io.bitsquare.trade.handlers.FaultHandler;
import io.bitsquare.trade.handlers.ResultHandler; import io.bitsquare.trade.handlers.ResultHandler;
import com.google.bitcoin.core.InsufficientMoneyException;
import com.google.bitcoin.core.Transaction; import com.google.bitcoin.core.Transaction;
import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.FutureCallback;
@ -59,9 +58,6 @@ public class BroadCastOfferFeeTx {
faultHandler.onFault("Offer fee payment failed with an exception.", t); faultHandler.onFault("Offer fee payment failed with an exception.", t);
} }
}); });
} catch (InsufficientMoneyException e) {
faultHandler.onFault(
"Offer fee payment failed because there is insufficient money in the trade wallet.", e);
} catch (Throwable t) { } catch (Throwable t) {
faultHandler.onFault("Offer fee payment failed because an exception occurred.", t); faultHandler.onFault("Offer fee payment failed because an exception occurred.", t);
} }

View file

@ -347,7 +347,7 @@ public class BuyerAcceptsOfferProtocol {
state = State.SetupListenerForBlockChainConfirmation; state = State.SetupListenerForBlockChainConfirmation;
SetupListenerForBlockChainConfirmation.run(this::onResultSetupListenerForBlockChainConfirmation, SetupListenerForBlockChainConfirmation.run(this::onResultSetupListenerForBlockChainConfirmation,
this::onFault, trade.getDepositTx(), listener); trade.getDepositTx(), listener);
} }
public void onResultSetupListenerForBlockChainConfirmation() { public void onResultSetupListenerForBlockChainConfirmation() {

View file

@ -51,7 +51,7 @@ public class SendSignedPayoutTx {
log.trace("Run task"); log.trace("Run task");
try { try {
Coin offererPaybackAmount = tradeAmount.add(collateral); Coin offererPaybackAmount = tradeAmount.add(collateral);
Coin takerPaybackAmount = collateral; @SuppressWarnings("UnnecessaryLocalVariable") Coin takerPaybackAmount = collateral;
Pair<ECKey.ECDSASignature, String> result = walletFacade.offererCreatesAndSignsPayoutTx( Pair<ECKey.ECDSASignature, String> result = walletFacade.offererCreatesAndSignsPayoutTx(
depositTransactionId, offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, tradeId); depositTransactionId, offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, tradeId);

View file

@ -17,7 +17,6 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.trade.handlers.ExceptionHandler;
import io.bitsquare.trade.handlers.ResultHandler; import io.bitsquare.trade.handlers.ResultHandler;
import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocolListener; import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocolListener;
@ -30,7 +29,7 @@ import org.slf4j.LoggerFactory;
public class SetupListenerForBlockChainConfirmation { public class SetupListenerForBlockChainConfirmation {
private static final Logger log = LoggerFactory.getLogger(SetupListenerForBlockChainConfirmation.class); private static final Logger log = LoggerFactory.getLogger(SetupListenerForBlockChainConfirmation.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, public static void run(ResultHandler resultHandler,
Transaction depositTransaction, BuyerAcceptsOfferProtocolListener listener) { Transaction depositTransaction, BuyerAcceptsOfferProtocolListener listener) {
log.trace("Run task"); log.trace("Run task");
//TODO //TODO

View file

@ -24,6 +24,8 @@ import com.google.bitcoin.core.Transaction;
import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.FutureCallback;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -55,7 +57,7 @@ public class SignAndPublishDepositTx {
} }
@Override @Override
public void onFailure(Throwable t) { public void onFailure(@NotNull Throwable t) {
log.error("offererSignAndPublishTx faultHandler.onFault:" + t); log.error("offererSignAndPublishTx faultHandler.onFault:" + t);
exceptionHandler.onError(t); exceptionHandler.onError(t);
} }

View file

@ -25,6 +25,8 @@ import com.google.bitcoin.core.Transaction;
import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.FutureCallback;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -43,7 +45,7 @@ public class PayTakeOfferFee {
} }
@Override @Override
public void onFailure(Throwable t) { public void onFailure(@NotNull Throwable t) {
log.error("Take offer fee paid faultHandler.onFault with exception: " + t); log.error("Take offer fee paid faultHandler.onFault with exception: " + t);
exceptionHandler.onError( exceptionHandler.onError(
new Exception("Take offer fee paid faultHandler.onFault with exception: " + t)); new Exception("Take offer fee paid faultHandler.onFault with exception: " + t));

View file

@ -26,6 +26,8 @@ import com.google.bitcoin.core.Utils;
import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.FutureCallback;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -61,7 +63,7 @@ public class SignAndPublishPayoutTx {
} }
@Override @Override
public void onFailure(Throwable t) { public void onFailure(@NotNull Throwable t) {
log.error("Exception at takerSignsAndSendsTx " + t); log.error("Exception at takerSignsAndSendsTx " + t);
exceptionHandler.onError(t); exceptionHandler.onError(t);
} }

View file

@ -40,8 +40,7 @@ public class DSAKeyUtil {
try { try {
final KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA"); final KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
keyGen.initialize(1024); keyGen.initialize(1024);
KeyPair generatedKeyPair = keyGen.genKeyPair(); return keyGen.genKeyPair();
return generatedKeyPair;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
log.error(e.toString()); log.error(e.toString());
} }