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

View File

@ -33,7 +33,6 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
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
* "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 final NetworkParameters params;
private final AddressEntry addressEntry;
@ -63,31 +62,28 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector {
@VisibleForTesting
static void sortOutputs(ArrayList<TransactionOutput> outputs) {
Collections.sort(outputs, new Comparator<TransactionOutput>() {
@Override
public int compare(TransactionOutput a, TransactionOutput b) {
int depth1 = 0;
int depth2 = 0;
TransactionConfidence conf1 = a.getParentTransaction().getConfidence();
TransactionConfidence conf2 = b.getParentTransaction().getConfidence();
if (conf1.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
depth1 = conf1.getDepthInBlocks();
if (conf2.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
depth2 = conf2.getDepthInBlocks();
Coin aValue = a.getValue();
Coin bValue = b.getValue();
BigInteger aCoinDepth = BigInteger.valueOf(aValue.value).multiply(BigInteger.valueOf(depth1));
BigInteger bCoinDepth = BigInteger.valueOf(bValue.value).multiply(BigInteger.valueOf(depth2));
int c1 = bCoinDepth.compareTo(aCoinDepth);
if (c1 != 0) return c1;
// The "coin*days" destroyed are equal, sort by value alone to get the lowest transaction size.
int c2 = bValue.compareTo(aValue);
if (c2 != 0) return c2;
// They are entirely equivalent (possibly pending) so sort by hash to ensure a total ordering.
BigInteger aHash = a.getParentTransaction().getHash().toBigInteger();
BigInteger bHash = b.getParentTransaction().getHash().toBigInteger();
return aHash.compareTo(bHash);
}
Collections.sort(outputs, (a, b) -> {
int depth1 = 0;
int depth2 = 0;
TransactionConfidence conf1 = a.getParentTransaction().getConfidence();
TransactionConfidence conf2 = b.getParentTransaction().getConfidence();
if (conf1.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
depth1 = conf1.getDepthInBlocks();
if (conf2.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
depth2 = conf2.getDepthInBlocks();
Coin aValue = a.getValue();
Coin bValue = b.getValue();
BigInteger aCoinDepth = BigInteger.valueOf(aValue.value).multiply(BigInteger.valueOf(depth1));
BigInteger bCoinDepth = BigInteger.valueOf(bValue.value).multiply(BigInteger.valueOf(depth2));
int c1 = bCoinDepth.compareTo(aCoinDepth);
if (c1 != 0) return c1;
// The "coin*days" destroyed are equal, sort by value alone to get the lowest transaction size.
int c2 = bValue.compareTo(aValue);
if (c2 != 0) return c2;
// They are entirely equivalent (possibly pending) so sort by hash to ensure a total ordering.
BigInteger aHash = a.getParentTransaction().getHash().toBigInteger();
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
()) {
Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params);

View File

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

View File

@ -88,8 +88,8 @@ public class BitSquareModule extends AbstractModule {
bind(NetworkParameters.class).toProvider(NetworkParametersProvider.class).asEagerSingleton();
// 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(new Boolean(false));
// bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(true);
bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(false);
// might be better in a config file?
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
// modification
private List<Listener> listeners = new CopyOnWriteArrayList<>();
private Persistence persistence;
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
private final Persistence persistence;
private Item[] currentItems;
// Used for returning to the last important view

View File

@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
public class OverlayManager {
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() {
listeners.stream().forEach((e) -> e.onBlurContentRequested());
listeners.stream().forEach(OverlayListener::onBlurContentRequested);
}
public void removeBlurContent() {
listeners.stream().forEach((e) -> e.onRemoveBlurContentRequested());
listeners.stream().forEach(OverlayListener::onRemoveBlurContentRequested);
}
public void addListener(OverlayListener listener) {

View File

@ -27,11 +27,11 @@ public class ViewCB<T extends PresentationModel> implements Initializable {
@FXML protected Parent root;
public ViewCB(T presentationModel) {
protected ViewCB(T 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 paymentLabel = new SimpleStringProperty();
public final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>();
private final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>();
private OverlayManager overlayManager;
@ -81,9 +81,7 @@ public class AddressTextField extends AnchorPane {
}
});
addressLabel.focusTraversableProperty().set(focusTraversableProperty().get());
focusedProperty().addListener((ov, oldValue, newValue) -> {
addressLabel.requestFocus();
});
focusedProperty().addListener((ov, oldValue, newValue) -> addressLabel.requestFocus());
Label copyIcon = new Label();
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());
}
}
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.setLeftAnchor(txIdLabel, 0.0);
txIdLabel.focusTraversableProperty().set(focusTraversableProperty().get());
focusedProperty().addListener((ov, oldValue, newValue) -> {
txIdLabel.requestFocus();
});
focusedProperty().addListener((ov, oldValue, newValue) -> txIdLabel.requestFocus());
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 final Label label;
private StringProperty text = new SimpleStringProperty();
private final StringProperty text = new SimpleStringProperty();
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor

View File

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

View File

@ -79,9 +79,7 @@ public class TxIdTextField extends AnchorPane {
AnchorPane.setRightAnchor(txIdLabel, 55.0);
AnchorPane.setLeftAnchor(txIdLabel, 0.0);
txIdLabel.focusTraversableProperty().set(focusTraversableProperty().get());
focusedProperty().addListener((ov, oldValue, newValue) -> {
txIdLabel.requestFocus();
});
focusedProperty().addListener((ov, oldValue, newValue) -> txIdLabel.requestFocus());
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 {
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 LabelWithBorder currentLabelWithBorder;
private LabelWithBorder prevLabelWithBorder;
private int index;
private final List<LabelWithBorder> labelWithBorders = new ArrayList<>();
///////////////////////////////////////////////////////////////////////////////////////////
@ -66,8 +65,8 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
public void reset() {
prevLabelWithBorder = null;
for (int i = 0; i < labelWithBorders.size(); i++) {
currentLabelWithBorder = labelWithBorders.get(i);
for (LabelWithBorder labelWithBorder : labelWithBorders) {
currentLabelWithBorder = labelWithBorder;
currentLabelWithBorder.open();
}
}
@ -97,8 +96,6 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
}
public void setSelectedIndex(int index) {
this.index = index;
if (index < labelWithBorders.size()) {
for (int i = 0; i <= index; i++) {

View File

@ -46,7 +46,7 @@
/* naviagtion buttons */
/* navigation buttons */
#image-nav-home {
-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.util.Profiler;
import io.bitsquare.gui.util.Transitions;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.util.ViewLoader;
import java.io.IOException;
@ -76,11 +77,18 @@ public class MainViewCB extends ViewCB<MainPM> {
@Inject
private MainViewCB(MainPM presentationModel, Navigation navigation,
OverlayManager overlayManager) {
OverlayManager overlayManager, TradeManager tradeManager) {
super(presentationModel);
this.navigation = navigation;
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();
}
@SuppressWarnings("EmptyMethod")
@Override
public void activate() {
super.activate();

View File

@ -48,6 +48,7 @@ class AccountPM extends PresentationModel<AccountModel> {
super.initialize();
}
@SuppressWarnings("EmptyMethod")
@Override
public void 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 Navigation navigation;
private final Navigation navigation;
private Navigation.Listener listener;
@FXML Tab tab;

View File

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

View File

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

View File

@ -36,13 +36,13 @@ import javafx.scene.layout.*;
import org.slf4j.Logger;
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);
@FXML HBox buttonsHBox;
@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();
}
@SuppressWarnings("EmptyMethod")
@Override
public void activate() {
super.activate();

View File

@ -67,6 +67,7 @@ class PasswordPM extends PresentationModel<PasswordModel> {
super.initialize();
}
@SuppressWarnings("EmptyMethod")
@Override
public void 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 OverlayManager overlayManager;
private final OverlayManager overlayManager;
@FXML TextField feeTextField;
@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);
@FXML ListView languagesListView, countriesListView, arbitratorsListView;
@FXML ListView<Locale> languagesListView;
@FXML ListView<Country> countriesListView;
@FXML ListView<Arbitrator> arbitratorsListView;
@FXML ComboBox<Locale> languageComboBox;
@FXML ComboBox<Region> regionComboBox;
@FXML ComboBox<Country> countryComboBox;

View File

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

View File

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

View File

@ -51,7 +51,7 @@ public class AccountSettingsViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(AccountSettingsViewCB.class);
private MenuItem seedWords, password, restrictions, fiatAccount, registration;
private Navigation navigation;
private final Navigation navigation;
private Navigation.Listener listener;
@FXML VBox leftVBox;
@ -117,8 +117,7 @@ public class AccountSettingsViewCB extends CachedViewCB {
Navigation.Item.ACCOUNT_SETTINGS, Navigation.Item.SEED_WORDS);
}
else {
if (items != null &&
items.length == 4 &&
if (items.length == 4 &&
items[2] == Navigation.Item.ACCOUNT_SETTINGS) {
loadView(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 WizardItem seedWords, password, fiatAccount, restrictions, registration;
private Navigation navigation;
private final Navigation navigation;
private Navigation.Listener listener;
@FXML VBox leftVBox;
@ -83,8 +83,6 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
if (navigationItems != null &&
navigationItems.length == 4 &&
navigationItems[2] == Navigation.Item.ACCOUNT_SETUP) {
log.debug("### " + navigationItems[3]);
//loadView(navigationItems[3]);
switch (navigationItems[3]) {
case SEED_WORDS:
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);
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);
restrictions = new WizardItem(navigation, this, "Setup your preferences",
restrictions = new WizardItem(this, "Setup your preferences",
"Define your preferences with whom you want to trade",
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",
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",
Navigation.Item.REGISTRATION);
@ -134,7 +132,6 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
super.initialize(url, rb);
navigation.addListener(listener);
childController = seedWords.show();
}
@ -209,13 +206,11 @@ class WizardItem extends HBox {
private final ImageView imageView;
private final Label titleLabel;
private final Label subTitleLabel;
private AccountSetupViewCB host;
private final AccountSetupViewCB host;
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) {
this.navigation = navigation;
this.host = host;
this.navigationItem = navigationItem;

View File

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

View File

@ -47,9 +47,8 @@ public class TransactionsController extends CachedViewController {
private ObservableList<TransactionsListItem> transactionsListItems;
@FXML TableView<TransactionsListItem> tableView;
@FXML TableColumn<String, TransactionsListItem> dateColumn, addressColumn, amountColumn, typeColumn,
@FXML TableColumn<TransactionsListItem, TransactionsListItem> dateColumn, addressColumn, amountColumn, typeColumn,
confidenceColumn;
@FXML Button addNewAddressButton;
///////////////////////////////////////////////////////////////////////////////////////////
@ -112,14 +111,15 @@ public class TransactionsController extends CachedViewController {
///////////////////////////////////////////////////////////////////////////////////////////
private void setAddressColumnCellFactory() {
addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
addressColumn.setCellFactory(
new Callback<TableColumn<String, TransactionsListItem>, TableCell<String, TransactionsListItem>>() {
new Callback<TableColumn<TransactionsListItem, TransactionsListItem>, TableCell<TransactionsListItem,
TransactionsListItem>>() {
@Override
public TableCell<String, TransactionsListItem> call(TableColumn<String,
public TableCell<TransactionsListItem, TransactionsListItem> call(TableColumn<TransactionsListItem,
TransactionsListItem> column) {
return new TableCell<String, TransactionsListItem>() {
return new TableCell<TransactionsListItem, TransactionsListItem>() {
Hyperlink hyperlink;
@Override
@ -145,14 +145,15 @@ public class TransactionsController extends CachedViewController {
private void setConfidenceColumnCellFactory() {
confidenceColumn.setCellValueFactory((addressListItem) ->
new ReadOnlyObjectWrapper(addressListItem.getValue()));
new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
confidenceColumn.setCellFactory(
new Callback<TableColumn<String, TransactionsListItem>, TableCell<String, TransactionsListItem>>() {
new Callback<TableColumn<TransactionsListItem, TransactionsListItem>, TableCell<TransactionsListItem,
TransactionsListItem>>() {
@Override
public TableCell<String, TransactionsListItem> call(TableColumn<String,
public TableCell<TransactionsListItem, TransactionsListItem> call(TableColumn<TransactionsListItem,
TransactionsListItem> column) {
return new TableCell<String, TransactionsListItem>() {
return new TableCell<TransactionsListItem, TransactionsListItem>() {
@Override
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.dialog.Dialog;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -66,7 +68,7 @@ public class WithdrawalController extends CachedViewController {
private ObservableList<WithdrawalListItem> addressList;
@FXML TableView<WithdrawalListItem> tableView;
@FXML TableColumn<String, WithdrawalListItem> labelColumn, addressColumn, balanceColumn, copyColumn,
@FXML TableColumn<WithdrawalListItem, WithdrawalListItem> labelColumn, addressColumn, balanceColumn, copyColumn,
confidenceColumn;
@FXML Button addNewAddressButton;
@FXML TextField withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField;
@ -156,12 +158,12 @@ public class WithdrawalController extends CachedViewController {
BitSquareValidator.resetTextFields(
withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField);
if (transaction != null) {
log.info("onWithdraw onSuccess txid:" + transaction.getHashAsString());
log.info("onWithdraw onSuccess tx ID:" + transaction.getHashAsString());
}
}
@Override
public void onFailure(Throwable t) {
public void onFailure(@NotNull Throwable t) {
log.debug("onWithdraw onFailure");
}
};
@ -213,13 +215,15 @@ public class WithdrawalController extends CachedViewController {
///////////////////////////////////////////////////////////////////////////////////////////
private void setLabelColumnCellFactory() {
labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
labelColumn.setCellFactory(new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String,
WithdrawalListItem>>() {
labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
labelColumn.setCellFactory(new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>,
TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) {
return new TableCell<String, WithdrawalListItem>() {
public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
Hyperlink hyperlink;
@ -250,13 +254,15 @@ public class WithdrawalController extends CachedViewController {
}
private void setBalanceColumnCellFactory() {
balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
balanceColumn.setCellFactory(
new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>() {
new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) {
return new TableCell<String, WithdrawalListItem>() {
public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
@Override
public void updateItem(final WithdrawalListItem item, boolean empty) {
super.updateItem(item, empty);
@ -268,13 +274,15 @@ public class WithdrawalController extends CachedViewController {
}
private void setCopyColumnCellFactory() {
copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
copyColumn.setCellFactory(
new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>() {
new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) {
return new TableCell<String, WithdrawalListItem>() {
public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
final Label copyIcon = new Label();
{
@ -308,13 +316,15 @@ public class WithdrawalController extends CachedViewController {
private void setConfidenceColumnCellFactory() {
confidenceColumn.setCellValueFactory((addressListItem) ->
new ReadOnlyObjectWrapper(addressListItem.getValue()));
new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
confidenceColumn.setCellFactory(
new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>() {
new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem,
WithdrawalListItem>>() {
@Override
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column) {
return new TableCell<String, WithdrawalListItem>() {
public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
@Override
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
public class MsgController extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(MsgController.class);
@ -49,22 +50,25 @@ public class MsgController extends CachedViewCB {
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb);
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void activate() {
super.activate();

View File

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

View File

@ -22,7 +22,10 @@ import io.bitsquare.trade.Trade;
import org.slf4j.Logger;
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 final Trade trade;

View File

@ -30,12 +30,12 @@ import javafx.collections.ObservableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ClosedTradesModel extends UIModel {
class ClosedTradesModel extends UIModel {
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;

View File

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

View File

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

View File

@ -17,61 +17,20 @@
package io.bitsquare.gui.main.orders.offer;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.trade.Offer;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public 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();
/**
* We could remove that wrapper if it is not needed for additional UI only fields.
*/
class OfferListItem {
private final Offer offer;
private final String offerId;
public OfferListItem(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() {
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.LoggerFactory;
public class OffersModel extends UIModel {
class OffersModel extends UIModel {
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;
@ -61,7 +61,7 @@ public class OffersModel extends UIModel {
if (change.wasAdded())
list.add(new OfferListItem(change.getValueAdded()));
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();

View File

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

View File

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

View File

@ -89,9 +89,6 @@ class PendingTradesModel extends UIModel {
faultChangeListener = (ov, oldValue, newValue) -> fault.set(newValue);
mapChangeListener = change -> {
log.debug("######## " + change);
log.debug("######## " + change.getValueAdded());
log.debug("######## " + change.getValueRemoved());
if (change.wasAdded())
list.add(new PendingTradesListItem(change.getValueAdded()));
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> takerStateChangeListener;
private ChangeListener<Throwable> faultChangeListener;
private ChangeListener<PendingTradesListItem> listItemChangeListener;
///////////////////////////////////////////////////////////////////////////////////////////
@ -416,7 +415,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
///////////////////////////////////////////////////////////////////////////////////////////
private void setTradeIdColumnCellFactory() {
tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue()));
tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
tradeIdColumn.setCellFactory(
new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>,
TableCell<PendingTradesListItem, PendingTradesListItem>>() {

View File

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

View File

@ -260,6 +260,7 @@ class CreateOfferModel extends UIModel {
}
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isMinAmountLessOrEqualAmount() {
//noinspection SimplifiableIfStatement
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 Navigation navigation;
private OverlayManager overlayManager;
private final Navigation navigation;
private final OverlayManager overlayManager;
private CloseListener closeListener;
private boolean detailsVisible;

View File

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

View File

@ -70,7 +70,6 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
private final OptionalBtcValidator optionalBtcValidator;
private final OptionalFiatValidator optionalFiatValidator;
private Navigation.Item navigationItem;
private boolean detailsVisible;
private boolean advancedScreenInited;
@ -175,8 +174,6 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
public void setDirection(Direction 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() {
//noinspection SimplifiableIfStatement
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> {
private static final Logger log = LoggerFactory.getLogger(TakeOfferViewCB.class);
private Navigation navigation;
private OverlayManager overlayManager;
private final Navigation navigation;
private final OverlayManager overlayManager;
private CloseListener closeListener;
private boolean detailsVisible;

View File

@ -284,11 +284,11 @@ public class BSFormatter {
}
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) {
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) {
@ -334,6 +334,7 @@ public class BSFormatter {
input = input.replace(",", ".");
// don't use String.valueOf(Double.parseDouble(input)) as return value as it gives scientific
// notation (1.0E-6) which screw up coinFormat.parse
//noinspection ResultOfMethodCallIgnored
Double.parseDouble(input);
return input;
}

View File

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

View File

@ -33,23 +33,13 @@ public class Profiler {
private static final Stopwatch globalStopwatch = Stopwatch.createStarted();
private static final ThreadLocal<Stopwatch> threadStopwatch = ThreadLocal.withInitial(Stopwatch::createStarted);
private static final ThreadLocal<Long> last = ThreadLocal.withInitial(() -> 0L);
private static long lastCurrentTimeMillis = System.currentTimeMillis();
private static long lastFPSTime = System.currentTimeMillis();
private static long counter = 0;
public static void printMsgWithTime(String msg) {
final long elapsed = threadStopwatch.get().elapsed(TimeUnit.MILLISECONDS);
log.trace("\n\nCalled by: {} \nElapsed time: {}ms \nTotal time: {}ms\n\n",
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);
}
@ -57,7 +47,6 @@ public class Profiler {
AnimationTimer fpsTimer = new AnimationTimer() {
@Override
public void handle(long l) {
counter++;
long elapsed = (System.currentTimeMillis() - lastFPSTime);
if (elapsed > 19)
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) {
try {
//noinspection ResultOfMethodCallIgnored
Double.parseDouble(input);
return new ValidationResult(true);
} catch (Exception e) {

View File

@ -88,8 +88,8 @@ public class CountryUtil {
List<Country> allEuroCountries = new ArrayList<>();
String[] code = {"BE", "DE", "EE", "FI", "FR", "GR", "IE", "IT", "LV", "LU", "MT", "NL", "PT", "SK", "SI",
"ES", "AT", "CY"};
for (int i = 0; i < code.length; i++) {
Locale locale = new Locale("", code[i], "");
for (String aCode : code) {
Locale locale = new Locale("", aCode, "");
String regionCode = getRegionCode(locale.getCountry());
final Region region = new Region(regionCode, getRegionName(regionCode));
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.");
futureRelay.relays().forEach(e -> log.debug("remotePeer = " + e.remotePeer()));
findNeighbors2(peerDHT, nodeBehindNat, bootstrapAddress);
findNeighbors2(peerDHT, bootstrapAddress);
}
else {
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
FutureBootstrap futureBootstrap2 = peerDHT.peer().bootstrap().peerAddress(bootstrapAddress).start();
BootstrappedPeerFactory ref = this;

View File

@ -135,25 +135,20 @@ public class MessageFacade implements MessageBroker {
public void getPeerAddress(PublicKey publicKey, GetPeerAddressListener listener) {
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>() {
@Override
public void operationComplete(BaseFuture baseFuture) throws Exception {
if (baseFuture.isSuccess() && futureGet.data() != null) {
final PeerAddress peerAddress = (PeerAddress) futureGet.data().object();
Platform.runLater(() -> listener.onResult(peerAddress));
}
else {
Platform.runLater(listener::onFailed);
}
futureGet.addListener(new BaseFutureAdapter<BaseFuture>() {
@Override
public void operationComplete(BaseFuture baseFuture) throws Exception {
if (baseFuture.isSuccess() && futureGet.data() != null) {
final PeerAddress peerAddress = (PeerAddress) futureGet.data().object();
Platform.runLater(() -> listener.onResult(peerAddress));
}
});
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
log.error(e.toString());
}
else {
Platform.runLater(listener::onFailed);
}
}
});
}
@ -213,7 +208,7 @@ public class MessageFacade implements MessageBroker {
});
}
});
} catch (IOException | ClassNotFoundException e) {
} catch (IOException e) {
Platform.runLater(() -> {
addOfferListener.onFailed("Add offer to DHT failed with an exception.", e);
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());
}
});
} catch (IOException | ClassNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
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();
}
}
public void removeArbitrator(Arbitrator arbitrator) throws IOException, ClassNotFoundException {
public void removeArbitrator(Arbitrator arbitrator) throws IOException {
Number160 locationKey = Number160.createHash(ARBITRATORS_ROOT);
final Data arbitratorData = new Data(arbitrator);
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());
}
});
} catch (IOException | ClassNotFoundException e) {
} catch (IOException e) {
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) {
Number160 locationKey = Number160.createHash(currencyCode);
try {
FutureGet getFuture = p2pNode.getData(getInvalidatedLocationKey(locationKey));
getFuture.addListener(new BaseFutureListener<BaseFuture>() {
@Override
public void operationComplete(BaseFuture future) throws Exception {
if (getFuture.isSuccess()) {
Data data = getFuture.data();
if (data != null && data.object() instanceof Long) {
final Object object = data.object();
Platform.runLater(() -> {
Long timeStamp = (Long) object;
log.trace("Get invalidationTimestamp from DHT was successful. TimeStamp=" +
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.");
FutureGet getFuture = p2pNode.getData(getInvalidatedLocationKey(locationKey));
getFuture.addListener(new BaseFutureListener<BaseFuture>() {
@Override
public void operationComplete(BaseFuture future) throws Exception {
if (getFuture.isSuccess()) {
Data data = getFuture.data();
if (data != null && data.object() instanceof Long) {
final Object object = data.object();
Platform.runLater(() -> {
Long timeStamp = (Long) object;
log.trace("Get invalidationTimestamp from DHT was successful. TimeStamp=" +
timeStamp);
invalidationTimestamp.set(timeStamp);
});
}
else {
log.error("Get invalidationTimestamp from DHT failed with reason:" + getFuture.failedReason());
log.error("Get invalidationTimestamp from DHT failed. Data = " + data);
}
}
@Override
public void exceptionCaught(Throwable t) throws Exception {
log.error("Get invalidationTimestamp from DHT failed with exception:" + t.getMessage());
t.printStackTrace();
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.");
}
});
} catch (IOException | ClassNotFoundException e) {
log.error("Get invalidationTimestamp from DHT failed with exception:" + e.getMessage());
e.printStackTrace();
}
else {
log.error("Get invalidationTimestamp from DHT failed with reason:" + getFuture.failedReason());
}
}
@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) {

View File

@ -139,39 +139,37 @@ public class P2PNode {
///////////////////////////////////////////////////////////////////////////////////////////
// The data and the domain are protected by that key pair.
public FuturePut putDomainProtectedData(Number160 locationKey, Data data)
throws IOException, ClassNotFoundException {
public FuturePut putDomainProtectedData(Number160 locationKey, Data data) {
data.protectEntry(keyPair);
final Number160 ownerKeyHash = Utils.makeSHAHash(keyPair.getPublic().getEncoded());
return peerDHT.put(locationKey).data(data).keyPair(keyPair).domainKey(ownerKeyHash).protectDomain().start();
}
// 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();
}
// 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)
throws IOException, ClassNotFoundException {
public FutureGet getDomainProtectedData(Number160 locationKey, PublicKey publicKey) {
final Number160 ownerKeyHash = Utils.makeSHAHash(publicKey.getEncoded());
return peerDHT.get(locationKey).domainKey(ownerKeyHash).start();
}
// No protection, everybody can read.
public FutureGet getData(Number160 locationKey) throws IOException, ClassNotFoundException {
public FutureGet getData(Number160 locationKey) {
return peerDHT.get(locationKey).start();
}
// 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);
log.trace("addProtectedData with contentKey " + data.hash().toString());
return peerDHT.add(locationKey).data(data).keyPair(keyPair).start();
}
// 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();
log.trace("removeFromDataMap with contentKey " + contentKey.toString());
return peerDHT.remove(locationKey).contentKey(contentKey).keyPair(keyPair).start();
@ -242,7 +240,7 @@ public class P2PNode {
else {
log.error("peerDHT is null");
}
} catch (IOException | ClassNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
log.error(e.toString());
}
@ -275,7 +273,7 @@ public class P2PNode {
if (peerDHT != null && !storedPeerAddress.equals(peerDHT.peerAddress())) {
try {
storePeerAddress();
} catch (IOException | ClassNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
log.error(e.toString());
}
@ -284,7 +282,7 @@ public class P2PNode {
}, checkIfIPChangedPeriod, checkIfIPChangedPeriod);
}
private FuturePut storePeerAddress() throws IOException, ClassNotFoundException {
private FuturePut storePeerAddress() throws IOException {
Number160 locationKey = Utils.makeSHAHash(keyPair.getPublic().getEncoded());
Data data = new Data(peerDHT.peerAddress());
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
// 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 _contractChanged;
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.utils.Fiat;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableMap;
@ -88,6 +88,7 @@ public class TradeManager {
// the latest pending trade
private Trade currentPendingTrade;
final StringProperty featureNotImplementedWarning = new SimpleStringProperty();
///////////////////////////////////////////////////////////////////////////////////////////
@ -106,17 +107,17 @@ public class TradeManager {
this.cryptoFacade = cryptoFacade;
Object offersObject = persistence.read(this, "offers");
if (offersObject instanceof HashMap) {
if (offersObject instanceof Map) {
offers.putAll((Map<String, Offer>) offersObject);
}
Object pendingTradesObject = persistence.read(this, "pendingTrades");
if (pendingTradesObject instanceof HashMap) {
if (pendingTradesObject instanceof Map) {
pendingTrades.putAll((Map<String, Trade>) pendingTradesObject);
}
Object closedTradesObject = persistence.read(this, "closedTrades");
if (closedTradesObject instanceof HashMap) {
if (closedTradesObject instanceof Map) {
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()))
log.error("An offer with the id " + offer.getId() + " already exists. ");
@ -395,12 +396,9 @@ public class TradeManager {
persistPendingTrades();
}
else {
// For usability tests we don't want to crash
//TODO move to gui package
/* Popups.openWarningPopup("Sorry, you cannot continue. You have restarted the application in the meantime
. " +
"Interruption of the trade process is not supported yet. Will need more time to be implemented.");*/
featureNotImplementedWarning.set("Sorry, you cannot continue. You have restarted the application in the " +
"meantime. 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
///////////////////////////////////////////////////////////////////////////////////////////
@ -479,6 +486,13 @@ public class TradeManager {
return currentPendingTrade;
}
public String getFeatureNotImplementedWarning() {
return featureNotImplementedWarning.get();
}
public StringProperty featureNotImplementedWarningProperty() {
return featureNotImplementedWarning;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private

View File

@ -21,7 +21,6 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.trade.handlers.FaultHandler;
import io.bitsquare.trade.handlers.ResultHandler;
import com.google.bitcoin.core.InsufficientMoneyException;
import com.google.bitcoin.core.Transaction;
import com.google.common.util.concurrent.FutureCallback;
@ -59,9 +58,6 @@ public class BroadCastOfferFeeTx {
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) {
faultHandler.onFault("Offer fee payment failed because an exception occurred.", t);
}

View File

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

View File

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

View File

@ -17,7 +17,6 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.trade.handlers.ExceptionHandler;
import io.bitsquare.trade.handlers.ResultHandler;
import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocolListener;
@ -30,7 +29,7 @@ import org.slf4j.LoggerFactory;
public class SetupListenerForBlockChainConfirmation {
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) {
log.trace("Run task");
//TODO

View File

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

View File

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

View File

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