error handling, popups, code cleanup

This commit is contained in:
Manfred Karrer 2014-06-27 15:36:03 +02:00
parent 828b5ad9f2
commit 7abbe21329
107 changed files with 1911 additions and 2283 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "libs/bitcoinj"]
path = libs/bitcoinj
url = git://github.com/bitcoinj/bitcoinj

View file

@ -1,19 +1,25 @@
package io.bitsquare; package io.bitsquare;
import com.google.common.base.Throwables;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletFacade;
import io.bitsquare.di.BitSquareModule; import io.bitsquare.di.BitSquareModule;
import io.bitsquare.di.GuiceFXMLLoader; import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.NavigationViewURL;
import io.bitsquare.gui.popups.Popups;
import io.bitsquare.locale.Localisation; import io.bitsquare.locale.Localisation;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageFacade;
import io.bitsquare.settings.Settings; import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -34,14 +40,26 @@ public class BitSquare extends Application
launch(args); launch(args);
} }
public static Stage getStage()
{
return stage;
}
@Override @Override
public void start(Stage stage) throws Exception public void start(Stage stage)
{
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
init(stage);
}
private void init(Stage stage)
{ {
BitSquare.stage = stage; BitSquare.stage = stage;
log.debug("Startup: start"); log.debug("Startup: start");
final Injector injector = Guice.createInjector(new BitSquareModule()); final Injector injector = Guice.createInjector(new BitSquareModule());
walletFacade = injector.getInstance(WalletFacade.class);
walletFacade = injector.getInstance(WalletFacade.class);
messageFacade = injector.getInstance(MessageFacade.class); messageFacade = injector.getInstance(MessageFacade.class);
log.debug("Startup: messageFacade, walletFacade inited"); log.debug("Startup: messageFacade, walletFacade inited");
@ -60,22 +78,31 @@ public class BitSquare extends Application
GuiceFXMLLoader.setInjector(injector); GuiceFXMLLoader.setInjector(injector);
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource("/io/bitsquare/gui/MainView.fxml"), Localisation.getResourceBundle());
final Parent mainView = loader.load();
final Scene scene = new Scene(mainView, 800, 600);
stage.setScene(scene);
final String bitsquare = getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm();
scene.getStylesheets().setAll(bitsquare);
stage.setMinWidth(800); stage.setMinWidth(800);
stage.setMinHeight(400); stage.setMinHeight(400);
stage.setWidth(800); stage.setWidth(800);
stage.setHeight(600); stage.setHeight(600);
stage.show(); try
log.debug("Startup: stage displayed"); {
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationViewURL.MAIN), Localisation.getResourceBundle());
final Parent mainView = loader.load();
final Scene scene = new Scene(mainView, 800, 600);
stage.setScene(scene);
final String bitsquare = getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm();
scene.getStylesheets().setAll(bitsquare);
stage.show();
log.debug("Startup: stage displayed");
} catch (Exception e)
{
stage.show();
Action response = Popups.openExceptionPopup(e);
if (response == Dialog.Actions.OK)
Platform.exit();
}
} }
@Override @Override
@ -86,9 +113,4 @@ public class BitSquare extends Application
super.stop(); super.stop();
} }
public static Stage getStage()
{
return stage;
}
} }

View file

@ -9,8 +9,8 @@ import net.tomp2p.peers.Number160;
*/ */
public class RelayNode public class RelayNode
{ {
public static final Number160 ID = Number160.createHash(1);
private static Peer masterPeer = null; private static Peer masterPeer = null;
public static Number160 ID = Number160.createHash(1);
public static void main(String[] args) throws Exception public static void main(String[] args) throws Exception
{ {

View file

@ -1,7 +1,6 @@
package io.bitsquare.bank; package io.bitsquare.bank;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import java.io.Serializable; import java.io.Serializable;
import java.util.Currency; import java.util.Currency;
import java.util.Objects; import java.util.Objects;
@ -10,14 +9,14 @@ public class BankAccount implements Serializable
{ {
private static final long serialVersionUID = 1792577576443221268L; private static final long serialVersionUID = 1792577576443221268L;
private BankAccountTypeInfo bankAccountTypeInfo; private final BankAccountTypeInfo bankAccountTypeInfo;
private String accountPrimaryID; private final String accountPrimaryID;
private String accountSecondaryID; private final String accountSecondaryID;
private String accountHolderName; private final String accountHolderName;
private Country country; private final Country country;
private Currency currency; private final Currency currency;
private String uid; private final String uid;
private String accountTitle; private final String accountTitle;
public BankAccount(BankAccountTypeInfo bankAccountTypeInfo, public BankAccount(BankAccountTypeInfo bankAccountTypeInfo,
Currency currency, Currency currency,

View file

@ -7,10 +7,15 @@ import java.util.Objects;
public class BankAccountTypeInfo implements Serializable public class BankAccountTypeInfo implements Serializable
{ {
private static final long serialVersionUID = -8772708150197835288L; private static final long serialVersionUID = -8772708150197835288L;
private final BankAccountType type;
private final String primaryIDName;
private final String secondaryIDName;
public static enum BankAccountType public BankAccountTypeInfo(BankAccountType type, String primaryIDName, String secondaryIDName)
{ {
SEPA, WIRE, INTERNATIONAL, OK_PAY, NET_TELLER, PERFECT_MONEY, OTHER this.type = type;
this.primaryIDName = primaryIDName;
this.secondaryIDName = secondaryIDName;
} }
public static ArrayList<BankAccountTypeInfo> getAllBankAccountTypeInfoObjects() public static ArrayList<BankAccountTypeInfo> getAllBankAccountTypeInfoObjects()
@ -26,17 +31,6 @@ public class BankAccountTypeInfo implements Serializable
return bankTransferTypes; return bankTransferTypes;
} }
private BankAccountType type;
private String primaryIDName;
private String secondaryIDName;
public BankAccountTypeInfo(BankAccountType type, String primaryIDName, String secondaryIDName)
{
this.type = type;
this.primaryIDName = primaryIDName;
this.secondaryIDName = secondaryIDName;
}
public int hashCode() public int hashCode()
{ {
return Objects.hashCode(type); return Objects.hashCode(type);
@ -67,4 +61,9 @@ public class BankAccountTypeInfo implements Serializable
{ {
return secondaryIDName; return secondaryIDName;
} }
public static enum BankAccountType
{
SEPA, WIRE, INTERNATIONAL, OK_PAY, NET_TELLER, PERFECT_MONEY, OTHER
}
} }

View file

@ -5,12 +5,14 @@ import com.google.bitcoin.params.RegTestParams;
import com.google.bitcoin.wallet.CoinSelection; import com.google.bitcoin.wallet.CoinSelection;
import com.google.bitcoin.wallet.DefaultCoinSelector; import com.google.bitcoin.wallet.DefaultCoinSelector;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.util.*;
/** /**
* This class implements a {@link com.google.bitcoin.wallet.CoinSelector} which attempts to get the highest priority * This class implements a {@link com.google.bitcoin.wallet.CoinSelector} which attempts to get the highest priority
* 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
@ -19,9 +21,9 @@ import java.util.*;
public class AddressBasedCoinSelector extends DefaultCoinSelector public class AddressBasedCoinSelector extends DefaultCoinSelector
{ {
private static final Logger log = LoggerFactory.getLogger(AddressBasedCoinSelector.class); private static final Logger log = LoggerFactory.getLogger(AddressBasedCoinSelector.class);
private NetworkParameters params; private final NetworkParameters params;
private AddressEntry addressEntry; private final AddressEntry addressEntry;
private boolean includePending; private final boolean includePending;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -39,6 +41,53 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector
this.includePending = includePending; this.includePending = includePending;
} }
@VisibleForTesting
static void sortOutputs(ArrayList<TransactionOutput> outputs)
{
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();
BigInteger aValue = a.getValue();
BigInteger bValue = b.getValue();
BigInteger aCoinDepth = aValue.multiply(BigInteger.valueOf(depth1));
BigInteger bCoinDepth = bValue.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);
});
}
private static boolean isInBlockChainOrPending(Transaction tx)
{
// Pick chain-included transactions and transactions that are pending.
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||
type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
// In regtest mode we expect to have only one peer, so we won't see transactions propagate.
// TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
(confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get());
}
private static boolean isInBlockChain(Transaction tx)
{
// Only pick chain-included transactions.
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
return type.equals(TransactionConfidence.ConfidenceType.BUILDING);
}
/** /**
* Sub-classes can override this to just customize whether transactions are usable, but keep age sorting. * Sub-classes can override this to just customize whether transactions are usable, but keep age sorting.
@ -67,10 +116,10 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector
public CoinSelection select(BigInteger biTarget, LinkedList<TransactionOutput> candidates) public CoinSelection select(BigInteger biTarget, LinkedList<TransactionOutput> candidates)
{ {
long target = biTarget.longValue(); long target = biTarget.longValue();
HashSet<TransactionOutput> selected = new HashSet<TransactionOutput>(); HashSet<TransactionOutput> selected = new HashSet<>();
// Sort the inputs by age*value so we get the highest "coindays" spent. // Sort the inputs by age*value so we get the highest "coindays" spent.
// TODO: Consider changing the wallets internal format to track just outputs and keep them ordered. // TODO: Consider changing the wallets internal format to track just outputs and keep them ordered.
ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<>(candidates);
// When calculating the wallet balance, we may be asked to select all possible coins, if so, avoid sorting // When calculating the wallet balance, we may be asked to select all possible coins, if so, avoid sorting
// them in order to improve performance. // them in order to improve performance.
if (!biTarget.equals(NetworkParameters.MAX_MONEY)) if (!biTarget.equals(NetworkParameters.MAX_MONEY))
@ -96,59 +145,6 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector
return new CoinSelection(BigInteger.valueOf(total), selected); return new CoinSelection(BigInteger.valueOf(total), selected);
} }
@VisibleForTesting
static void sortOutputs(ArrayList<TransactionOutput> outputs)
{
Collections.sort(outputs, new Comparator<TransactionOutput>()
{
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();
BigInteger aValue = a.getValue();
BigInteger bValue = b.getValue();
BigInteger aCoinDepth = aValue.multiply(BigInteger.valueOf(depth1));
BigInteger bCoinDepth = bValue.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);
}
});
}
private static boolean isInBlockChainOrPending(Transaction tx)
{
// Pick chain-included transactions and transactions that are pending.
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||
type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
// In regtest mode we expect to have only one peer, so we won't see transactions propagate.
// TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
(confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get());
}
private static boolean isInBlockChain(Transaction tx)
{
// Only pick chain-included transactions.
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
return type.equals(TransactionConfidence.ConfidenceType.BUILDING);
}
/* /*
public static boolean isSelectable(Transaction tx) public static boolean isSelectable(Transaction tx)
{ {

View file

@ -4,26 +4,16 @@ import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.ECKey; import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.NetworkParameters; import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.Utils; import com.google.bitcoin.core.Utils;
import java.io.Serializable; import java.io.Serializable;
public class AddressEntry implements Serializable public class AddressEntry implements Serializable
{ {
private static final long serialVersionUID = 5501603992599920416L; private static final long serialVersionUID = 5501603992599920416L;
private final ECKey key;
public static enum AddressContext private final NetworkParameters params;
{ private final AddressContext addressContext;
REGISTRATION_FEE,
TRADE,
ARBITRATOR_DEPOSIT
}
private ECKey key;
private NetworkParameters params;
private String tradeId = null; private String tradeId = null;
private AddressContext addressContext;
public AddressEntry(ECKey key, NetworkParameters params, AddressContext addressContext) public AddressEntry(ECKey key, NetworkParameters params, AddressContext addressContext)
{ {
this.key = key; this.key = key;
@ -31,16 +21,16 @@ public class AddressEntry implements Serializable
this.addressContext = addressContext; this.addressContext = addressContext;
} }
public void setTradeId(String tradeId)
{
this.tradeId = tradeId;
}
public String getTradeId() public String getTradeId()
{ {
return tradeId; return tradeId;
} }
public void setTradeId(String tradeId)
{
this.tradeId = tradeId;
}
public AddressContext getAddressContext() public AddressContext getAddressContext()
{ {
return addressContext; return addressContext;
@ -65,4 +55,11 @@ public class AddressEntry implements Serializable
{ {
return key.toAddress(params); return key.toAddress(params);
} }
public static enum AddressContext
{
REGISTRATION_FEE,
TRADE,
ARBITRATOR_DEPOSIT
}
} }

View file

@ -3,11 +3,10 @@ package io.bitsquare.btc;
import com.google.bitcoin.core.NetworkParameters; import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.Wallet; import com.google.bitcoin.core.Wallet;
import com.google.bitcoin.crypto.KeyCrypter; import com.google.bitcoin.crypto.KeyCrypter;
import java.io.Serializable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.Serializable;
public class BitSquareWallet extends Wallet implements Serializable public class BitSquareWallet extends Wallet implements Serializable
{ {
private static final Logger log = LoggerFactory.getLogger(BitSquareWallet.class); private static final Logger log = LoggerFactory.getLogger(BitSquareWallet.class);

View file

@ -8,7 +8,6 @@ import com.google.bitcoin.store.SPVBlockStore;
import com.google.bitcoin.store.WalletProtobufSerializer; import com.google.bitcoin.store.WalletProtobufSerializer;
import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -98,7 +97,8 @@ public class BitSquareWalletAppKit extends WalletAppKit
if (blockingStartup) if (blockingStartup)
{ {
vPeerGroup.startAndWait(); vPeerGroup.startAsync();
vPeerGroup.awaitRunning();
// Make sure we shut down cleanly. // Make sure we shut down cleanly.
installShutdownHook(); installShutdownHook();
// TODO: Be able to use the provided download listener when doing a blocking startup. // TODO: Be able to use the provided download listener when doing a blocking startup.
@ -142,7 +142,9 @@ public class BitSquareWalletAppKit extends WalletAppKit
{ {
try try
{ {
BitSquareWalletAppKit.this.stopAndWait(); BitSquareWalletAppKit.this.stopAsync();
BitSquareWalletAppKit.this.awaitTerminated();
} catch (Exception e) } catch (Exception e)
{ {
throw new RuntimeException(e); throw new RuntimeException(e);

View file

@ -3,19 +3,17 @@ package io.bitsquare.btc;
import com.google.bitcoin.core.Utils; import com.google.bitcoin.core.Utils;
import io.bitsquare.gui.util.BitSquareConverter; import io.bitsquare.gui.util.BitSquareConverter;
import io.bitsquare.gui.util.BitSquareFormatter; import io.bitsquare.gui.util.BitSquareFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Locale; import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO // TODO
public class BtcFormatter public class BtcFormatter
{ {
public static final BigInteger BTC = new BigInteger("100000000");
private static final Logger log = LoggerFactory.getLogger(BtcFormatter.class); private static final Logger log = LoggerFactory.getLogger(BtcFormatter.class);
public static BigInteger BTC = new BigInteger("100000000");
public static BigInteger mBTC = new BigInteger("100000"); public static BigInteger mBTC = new BigInteger("100000");

View file

@ -5,7 +5,6 @@ import com.google.bitcoin.core.AddressFormatException;
import com.google.bitcoin.core.NetworkParameters; import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.Transaction; import com.google.bitcoin.core.Transaction;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.math.BigInteger; import java.math.BigInteger;
public class BtcValidator public class BtcValidator

View file

@ -2,20 +2,17 @@ package io.bitsquare.btc;
import com.google.bitcoin.core.*; import com.google.bitcoin.core.*;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.math.BigInteger;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.math.BigInteger;
public class FeePolicy public class FeePolicy
{ {
public static final BigInteger TX_FEE = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
public static final BigInteger ACCOUNT_REGISTRATION_FEE = Utils.toNanoCoins("0.01");
public static final BigInteger CREATE_OFFER_FEE = Utils.toNanoCoins("0.001");
public static final BigInteger TAKE_OFFER_FEE = CREATE_OFFER_FEE;
private static final Logger log = LoggerFactory.getLogger(FeePolicy.class); private static final Logger log = LoggerFactory.getLogger(FeePolicy.class);
public static BigInteger TX_FEE = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
public static BigInteger ACCOUNT_REGISTRATION_FEE = Utils.toNanoCoins("0.01");
public static BigInteger CREATE_OFFER_FEE = Utils.toNanoCoins("0.001");
public static BigInteger TAKE_OFFER_FEE = CREATE_OFFER_FEE;
private static final String registrationFeeAddress = "mvkDXt4QmN4Nq9dRUsRigBCaovde9nLkZR"; private static final String registrationFeeAddress = "mvkDXt4QmN4Nq9dRUsRigBCaovde9nLkZR";
private static final String createOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg"; private static final String createOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
private static final String takeOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg"; private static final String takeOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";

View file

@ -7,7 +7,6 @@ import com.google.bitcoin.params.RegTestParams;
import com.google.bitcoin.script.Script; import com.google.bitcoin.script.Script;
import com.google.bitcoin.script.ScriptBuilder; import com.google.bitcoin.script.ScriptBuilder;
import com.google.bitcoin.utils.Threading; import com.google.bitcoin.utils.Threading;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -20,17 +19,15 @@ import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.btc.listeners.ConfidenceListener; import io.bitsquare.btc.listeners.ConfidenceListener;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoFacade;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import javafx.application.Platform;
import javafx.util.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import javafx.application.Platform;
import javafx.util.Pair;
import javax.annotation.concurrent.GuardedBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.bitcoin.script.ScriptOpCodes.OP_RETURN; import static com.google.bitcoin.script.ScriptOpCodes.OP_RETURN;
@ -43,23 +40,23 @@ public class WalletFacade
public static final String TEST_NET = "TEST_NET"; public static final String TEST_NET = "TEST_NET";
public static final String REG_TEST_NET = "REG_TEST_NET"; public static final String REG_TEST_NET = "REG_TEST_NET";
public static String WALLET_PREFIX = BitSquare.ID; public static final String WALLET_PREFIX = BitSquare.ID;
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class); private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
private final ReentrantLock lock = Threading.lock("lock"); private final ReentrantLock lock = Threading.lock("lock");
private String saveAddressEntryListId; private final String saveAddressEntryListId;
private NetworkParameters params; private final NetworkParameters params;
private BitSquareWalletAppKit walletAppKit; private final BitSquareWalletAppKit walletAppKit;
private FeePolicy feePolicy; private final FeePolicy feePolicy;
private CryptoFacade cryptoFacade; private final CryptoFacade cryptoFacade;
private Storage storage; private final Storage storage;
private final List<DownloadListener> downloadListeners = new ArrayList<>();
private final List<ConfidenceListener> confidenceListeners = new ArrayList<>();
private final List<BalanceListener> balanceListeners = new ArrayList<>();
private BitSquareWallet wallet; private BitSquareWallet wallet;
private WalletEventListener walletEventListener; private WalletEventListener walletEventListener;
private List<DownloadListener> downloadListeners = new ArrayList<>();
private List<ConfidenceListener> confidenceListeners = new ArrayList<>();
private List<BalanceListener> balanceListeners = new ArrayList<>();
@GuardedBy("lock") @GuardedBy("lock")
private List<AddressEntry> addressEntryList = new ArrayList<>(); private List<AddressEntry> addressEntryList = new ArrayList<>();
@ -171,26 +168,30 @@ public class WalletFacade
}; };
wallet.addEventListener(walletEventListener); wallet.addEventListener(walletEventListener);
List<AddressEntry> savedAddressEntryList = (List<AddressEntry>) storage.read(saveAddressEntryListId); Object object = storage.read(saveAddressEntryListId);
if (savedAddressEntryList != null) if (object instanceof List)
{ {
addressEntryList = savedAddressEntryList; List<AddressEntry> savedAddressEntryList = (List<AddressEntry>) object;
} if (savedAddressEntryList != null)
else
{
lock.lock();
try
{ {
ECKey registrationKey = wallet.getKeys().get(0); addressEntryList = savedAddressEntryList;
AddressEntry registrationAddressEntry = new AddressEntry(registrationKey, params, AddressEntry.AddressContext.REGISTRATION_FEE);
addressEntryList.add(registrationAddressEntry);
} finally
{
lock.unlock();
} }
else
{
lock.lock();
try
{
ECKey registrationKey = wallet.getKeys().get(0);
AddressEntry registrationAddressEntry = new AddressEntry(registrationKey, params, AddressEntry.AddressContext.REGISTRATION_FEE);
addressEntryList.add(registrationAddressEntry);
} finally
{
lock.unlock();
}
saveAddressInfoList(); saveAddressInfoList();
getNewTradeAddressEntry(); getNewTradeAddressEntry();
}
} }
} }
@ -272,14 +273,7 @@ public class WalletFacade
public AddressEntry getUnusedTradeAddressInfo() public AddressEntry getUnusedTradeAddressInfo()
{ {
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), new Predicate<AddressEntry>() List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), addressInfo -> (addressInfo != null && addressInfo.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && addressInfo.getTradeId() == null)));
{
@Override
public boolean apply(@Nullable AddressEntry addressInfo)
{
return (addressInfo != null && addressInfo.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && addressInfo.getTradeId() == null);
}
}));
if (filteredList != null && filteredList.size() > 0) if (filteredList != null && filteredList.size() > 0)
return filteredList.get(0); return filteredList.get(0);
@ -289,14 +283,7 @@ public class WalletFacade
private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext) private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext)
{ {
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), new Predicate<AddressEntry>() List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), addressInfo -> (addressInfo != null && addressContext != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext().equals(addressContext))));
{
@Override
public boolean apply(@Nullable AddressEntry addressInfo)
{
return (addressInfo != null && addressContext != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext().equals(addressContext));
}
}));
if (filteredList != null && filteredList.size() > 0) if (filteredList != null && filteredList.size() > 0)
return filteredList.get(0); return filteredList.get(0);
@ -374,20 +361,22 @@ public class WalletFacade
Set<Transaction> transactions = wallet.getTransactions(true); Set<Transaction> transactions = wallet.getTransactions(true);
if (transactions != null) if (transactions != null)
{ {
for (Transaction tx : transactions) transactionConfidenceList.addAll(transactions.stream().map(tx -> getTransactionConfidence(tx, address)).collect(Collectors.toList()));
/* same as:
for (Transaction tx : transactions)
{ {
transactionConfidenceList.add(getTransactionConfidence(tx, address)); transactionConfidenceList.add(getTransactionConfidence(tx, address));
} }
*/
} }
return getMostRecentConfidence(transactionConfidenceList); return getMostRecentConfidence(transactionConfidenceList);
} }
private void notifyConfidenceListeners(Transaction tx) private void notifyConfidenceListeners(Transaction tx)
{ {
for (int i = 0; i < confidenceListeners.size(); i++) for (ConfidenceListener confidenceListener : confidenceListeners)
{ {
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>(); List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
ConfidenceListener confidenceListener = confidenceListeners.get(i);
transactionConfidenceList.add(getTransactionConfidence(tx, confidenceListener.getAddress())); transactionConfidenceList.add(getTransactionConfidence(tx, confidenceListener.getAddress()));
TransactionConfidence transactionConfidence = getMostRecentConfidence(transactionConfidenceList); TransactionConfidence transactionConfidence = getMostRecentConfidence(transactionConfidenceList);
@ -400,9 +389,17 @@ public class WalletFacade
List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx); List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx);
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>(); List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
for (int i = 0; i < mergedOutputs.size(); i++) mergedOutputs.stream().filter(transactionOutput -> transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH()).forEach(transactionOutput -> {
Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params);
if (address.equals(outputAddress))
{
transactionConfidenceList.add(tx.getConfidence());
}
});
/*
same as:
for (TransactionOutput transactionOutput : mergedOutputs)
{ {
TransactionOutput transactionOutput = mergedOutputs.get(i);
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH()) if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH())
{ {
Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params); Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params);
@ -412,6 +409,7 @@ public class WalletFacade
} }
} }
} }
*/
return getMostRecentConfidence(transactionConfidenceList); return getMostRecentConfidence(transactionConfidenceList);
} }
@ -422,9 +420,8 @@ public class WalletFacade
// add all connected outputs from any inputs as well // add all connected outputs from any inputs as well
List<TransactionInput> transactionInputs = tx.getInputs(); List<TransactionInput> transactionInputs = tx.getInputs();
for (int i = 0; i < transactionInputs.size(); i++) for (TransactionInput transactionInput : transactionInputs)
{ {
TransactionInput transactionInput = transactionInputs.get(i);
TransactionOutput transactionOutput = transactionInput.getConnectedOutput(); TransactionOutput transactionOutput = transactionInput.getConnectedOutput();
if (transactionOutput != null) if (transactionOutput != null)
connectedOutputs.add(transactionOutput); connectedOutputs.add(transactionOutput);
@ -439,9 +436,8 @@ public class WalletFacade
private TransactionConfidence getMostRecentConfidence(List<TransactionConfidence> transactionConfidenceList) private TransactionConfidence getMostRecentConfidence(List<TransactionConfidence> transactionConfidenceList)
{ {
TransactionConfidence transactionConfidence = null; TransactionConfidence transactionConfidence = null;
for (int i = 0; i < transactionConfidenceList.size(); i++) for (TransactionConfidence confidence : transactionConfidenceList)
{ {
TransactionConfidence confidence = transactionConfidenceList.get(i);
if (confidence != null) if (confidence != null)
{ {
if (transactionConfidence == null || if (transactionConfidence == null ||
@ -494,10 +490,8 @@ public class WalletFacade
private void notifyBalanceListeners(Transaction tx) private void notifyBalanceListeners(Transaction tx)
{ {
for (int i = 0; i < balanceListeners.size(); i++) for (BalanceListener balanceListener : balanceListeners)
{ {
BalanceListener balanceListener = balanceListeners.get(i);
BigInteger balance; BigInteger balance;
if (balanceListener.getAddress() != null) if (balanceListener.getAddress() != null)
balance = getBalanceForAddress(balanceListener.getAddress()); balance = getBalanceForAddress(balanceListener.getAddress());
@ -723,7 +717,7 @@ public class WalletFacade
String arbitratorPubKey, String arbitratorPubKey,
String offerersPartialDepositTxAsHex, String offerersPartialDepositTxAsHex,
String tradeId String tradeId
) throws InsufficientMoneyException, ExecutionException, InterruptedException, AddressFormatException ) throws InsufficientMoneyException
{ {
log.debug("takerAddPaymentAndSignTx"); log.debug("takerAddPaymentAndSignTx");
log.trace("inputs: "); log.trace("inputs: ");
@ -837,7 +831,7 @@ public class WalletFacade
String takersSignedScriptSigAsHex, String takersSignedScriptSigAsHex,
long offererTxOutIndex, long offererTxOutIndex,
long takerTxOutIndex, long takerTxOutIndex,
FutureCallback<Transaction> callback) throws Exception FutureCallback<Transaction> callback)
{ {
log.debug("offererSignAndPublishTx"); log.debug("offererSignAndPublishTx");
log.trace("inputs: "); log.trace("inputs: ");
@ -859,7 +853,7 @@ public class WalletFacade
// add input // add input
Transaction offerersFirstTxConnOut = wallet.getTransaction(offerersFirstTx.getInput(0).getOutpoint().getHash()); // pass that around! Transaction offerersFirstTxConnOut = wallet.getTransaction(offerersFirstTx.getInput(0).getOutpoint().getHash()); // pass that around!
TransactionOutPoint offerersFirstTxOutPoint = new TransactionOutPoint(params, offererTxOutIndex, offerersFirstTxConnOut); TransactionOutPoint offerersFirstTxOutPoint = new TransactionOutPoint(params, offererTxOutIndex, offerersFirstTxConnOut);
//TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, offerersFirstTx.getInput(0).getScriptBytes(), offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes aray //TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, offerersFirstTx.getInput(0).getScriptBytes(), offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes array
TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, new byte[]{}, offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes array TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, new byte[]{}, offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes array
offerersFirstTxInput.setParent(tx); offerersFirstTxInput.setParent(tx);
tx.addInput(offerersFirstTxInput); tx.addInput(offerersFirstTxInput);
@ -971,7 +965,7 @@ public class WalletFacade
BigInteger offererPaybackAmount, BigInteger offererPaybackAmount,
BigInteger takerPaybackAmount, BigInteger takerPaybackAmount,
String takerAddress, String takerAddress,
String tradeID) throws InsufficientMoneyException, AddressFormatException String tradeID) throws AddressFormatException
{ {
log.debug("offererCreatesAndSignsPayoutTx"); log.debug("offererCreatesAndSignsPayoutTx");
log.trace("inputs: "); log.trace("inputs: ");
@ -1009,7 +1003,7 @@ public class WalletFacade
BigInteger takerPaybackAmount, BigInteger takerPaybackAmount,
String offererAddress, String offererAddress,
String tradeID, String tradeID,
FutureCallback<Transaction> callback) throws InsufficientMoneyException, AddressFormatException FutureCallback<Transaction> callback) throws AddressFormatException
{ {
log.debug("takerSignsAndSendsTx"); log.debug("takerSignsAndSendsTx");
log.trace("inputs: "); log.trace("inputs: ");
@ -1125,6 +1119,13 @@ public class WalletFacade
// Inner classes // Inner classes
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public static interface DownloadListener
{
void progress(double percent, int blocksSoFar, Date date);
void doneDownload();
}
private class BlockChainDownloadListener extends com.google.bitcoin.core.DownloadListener private class BlockChainDownloadListener extends com.google.bitcoin.core.DownloadListener
{ {
@Override @Override
@ -1138,7 +1139,7 @@ public class WalletFacade
protected void doneDownload() protected void doneDownload()
{ {
super.doneDownload(); super.doneDownload();
Platform.runLater(() -> onDoneDownloadInUserThread()); Platform.runLater(this::onDoneDownloadInUserThread);
} }
private void onProgressInUserThread(double percent, int blocksSoFar, final Date date) private void onProgressInUserThread(double percent, int blocksSoFar, final Date date)
@ -1154,11 +1155,4 @@ public class WalletFacade
} }
} }
public static interface DownloadListener
{
void progress(double percent, int blocksSoFar, Date date);
void doneDownload();
}
} }

View file

@ -1,7 +1,6 @@
package io.bitsquare.btc.listeners; package io.bitsquare.btc.listeners;
import com.google.bitcoin.core.Address; import com.google.bitcoin.core.Address;
import java.math.BigInteger; import java.math.BigInteger;
public class BalanceListener public class BalanceListener

View file

@ -5,7 +5,7 @@ import com.google.bitcoin.core.TransactionConfidence;
public class ConfidenceListener public class ConfidenceListener
{ {
private Address address; private final Address address;
public ConfidenceListener(Address address) public ConfidenceListener(Address address)
{ {

View file

@ -4,11 +4,10 @@ import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.Utils; import com.google.bitcoin.core.Utils;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.security.SignatureException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.security.SignatureException;
/** /**
* That facade delivers crypto functionality from the bitcoinJ library * That facade delivers crypto functionality from the bitcoinJ library
*/ */

View file

@ -23,7 +23,6 @@ import io.bitsquare.trade.orderbook.OrderBook;
import io.bitsquare.trade.orderbook.OrderBookFilter; import io.bitsquare.trade.orderbook.OrderBookFilter;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
import java.io.File; import java.io.File;
public class BitSquareModule extends AbstractModule public class BitSquareModule extends AbstractModule
@ -59,7 +58,7 @@ public class BitSquareModule extends AbstractModule
class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit> class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit>
{ {
private NetworkParameters networkParameters; private final NetworkParameters networkParameters;
@Inject @Inject
public BitSquareWalletAppKitProvider(NetworkParameters networkParameters) public BitSquareWalletAppKitProvider(NetworkParameters networkParameters)
@ -75,7 +74,7 @@ class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit>
class NetworkParametersProvider implements Provider<NetworkParameters> class NetworkParametersProvider implements Provider<NetworkParameters>
{ {
private String networkType; private final String networkType;
@Inject @Inject
public NetworkParametersProvider(@Named("networkType") String networkType) public NetworkParametersProvider(@Named("networkType") String networkType)

View file

@ -7,14 +7,14 @@ import javafx.util.Callback;
* A JavaFX controller factory for constructing controllers via Guice DI. To * A JavaFX controller factory for constructing controllers via Guice DI. To
* install this in the {@link javafx.fxml.FXMLLoader}, pass it as a parameter to * install this in the {@link javafx.fxml.FXMLLoader}, pass it as a parameter to
* {@link javafx.fxml.FXMLLoader#setControllerFactory(Callback)}. * {@link javafx.fxml.FXMLLoader#setControllerFactory(Callback)}.
* <p/> * <p>
* Once set, make sure you do <b>not</b> use the static methods on * Once set, make sure you do <b>not</b> use the static methods on
* {@link javafx.fxml.FXMLLoader} when creating your JavaFX node. * {@link javafx.fxml.FXMLLoader} when creating your JavaFX node.
*/ */
public class GuiceControllerFactory implements Callback<Class<?>, Object> public class GuiceControllerFactory implements Callback<Class<?>, Object>
{ {
private Injector injector; private final Injector injector;
public GuiceControllerFactory(Injector injector) public GuiceControllerFactory(Injector injector)
{ {

View file

@ -1,11 +1,10 @@
package io.bitsquare.di; package io.bitsquare.di;
import com.google.inject.Injector; import com.google.inject.Injector;
import javafx.fxml.FXMLLoader;
import javafx.util.BuilderFactory;
import java.net.URL; import java.net.URL;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javafx.fxml.FXMLLoader;
import javafx.util.BuilderFactory;
/** /**
* Guice support for fxml controllers * Guice support for fxml controllers
@ -15,11 +14,6 @@ public class GuiceFXMLLoader extends FXMLLoader
private static Injector injector = null; private static Injector injector = null;
public static void setInjector(Injector injector)
{
GuiceFXMLLoader.injector = injector;
}
public GuiceFXMLLoader() public GuiceFXMLLoader()
{ {
super(); super();
@ -44,6 +38,11 @@ public class GuiceFXMLLoader extends FXMLLoader
setupControllerFactory(); setupControllerFactory();
} }
public static void setInjector(Injector injector)
{
GuiceFXMLLoader.injector = injector;
}
private void setupControllerFactory() private void setupControllerFactory()
{ {
if (GuiceFXMLLoader.injector != null) if (GuiceFXMLLoader.injector != null)

View file

@ -16,8 +16,12 @@ import io.bitsquare.storage.Storage;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
import io.bitsquare.trade.Trading; import io.bitsquare.trade.Trading;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import javafx.beans.value.ChangeListener; import java.io.IOException;
import javafx.beans.value.ObservableValue; import java.math.BigInteger;
import java.net.URL;
import java.util.Date;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
@ -35,41 +39,40 @@ import net.tomp2p.peers.PeerAddress;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URL;
import java.util.Date;
import java.util.ResourceBundle;
public class MainController implements Initializable, NavigationController public class MainController implements Initializable, NavigationController
{ {
private static final Logger log = LoggerFactory.getLogger(MainController.class); private static final Logger log = LoggerFactory.getLogger(MainController.class);
private static MainController mainController; private static MainController mainController;
private User user; private final User user;
private WalletFacade walletFacade; private final WalletFacade walletFacade;
private MessageFacade messageFacade; private final MessageFacade messageFacade;
private Trading trading; private final Trading trading;
private final Storage storage;
private final String selectedNavigationItemStorageId;
private final ToggleGroup toggleGroup = new ToggleGroup();
private ChildController childController; private ChildController childController;
private Storage storage;
private String selectedNavigationItemStorageId;
private NavigationItem selectedNavigationItem; private NavigationItem selectedNavigationItem;
private NetworkSyncPane networkSyncPane; private NetworkSyncPane networkSyncPane;
private ToggleGroup toggleGroup = new ToggleGroup();
private ToggleButton prevToggleButton; private ToggleButton prevToggleButton;
private Image prevToggleButtonIcon; private Image prevToggleButtonIcon;
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton; private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton;
private Pane msgButtonHolder, ordersButtonButtonHolder; private Pane msgButtonHolder, ordersButtonButtonHolder;
private TextField balanceTextField; private TextField balanceTextField;
@FXML
private Pane contentPane;
@FXML
private HBox leftNavPane, rightNavPane;
@FXML
private ProgressBar loadingBar;
@FXML
private AnchorPane rootPane;
@FXML
private Label loadingLabel;
@FXML
public Pane contentPane;
@FXML
public HBox leftNavPane, rightNavPane;
@FXML
public AnchorPane anchorPane;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -101,6 +104,11 @@ public class MainController implements Initializable, NavigationController
@Override @Override
public void initialize(URL url, ResourceBundle rb) public void initialize(URL url, ResourceBundle rb)
{
Platform.runLater(this::init);
}
public void init()
{ {
networkSyncPane = new NetworkSyncPane(); networkSyncPane = new NetworkSyncPane();
networkSyncPane.setSpacing(10); networkSyncPane.setSpacing(10);
@ -137,7 +145,14 @@ public class MainController implements Initializable, NavigationController
AnchorPane.setBottomAnchor(networkSyncPane, 0.0); AnchorPane.setBottomAnchor(networkSyncPane, 0.0);
AnchorPane.setLeftAnchor(networkSyncPane, 0.0); AnchorPane.setLeftAnchor(networkSyncPane, 0.0);
messageFacade.addTakeOfferRequestListener((tradingMessage, sender) -> showTakeOfferRequest(tradingMessage, sender)); messageFacade.addTakeOfferRequestListener(this::showTakeOfferRequest);
loadingBar.setProgress(-1);
rootPane.getChildren().removeAll(loadingLabel, loadingBar);
leftNavPane.setVisible(true);
rightNavPane.setVisible(true);
contentPane.setVisible(true);
} }
@ -152,9 +167,7 @@ public class MainController implements Initializable, NavigationController
alertButton.relocate(36, 19); alertButton.relocate(36, 19);
Tooltip.install(alertButton, new Tooltip("Someone accepted your offer")); Tooltip.install(alertButton, new Tooltip("Someone accepted your offer"));
alertButton.setOnAction((e) -> { alertButton.setOnAction((e) -> ordersButton.fire());
ordersButton.fire();
});
ordersButtonButtonHolder.getChildren().add(alertButton); ordersButtonButtonHolder.getChildren().add(alertButton);
} catch (NullPointerException e) } catch (NullPointerException e)
@ -331,7 +344,7 @@ public class MainController implements Initializable, NavigationController
{ {
if (user.getBankAccounts().size() > 1) if (user.getBankAccounts().size() > 1)
{ {
ComboBox accountComboBox = new ComboBox(FXCollections.observableArrayList(user.getBankAccounts())); ComboBox<BankAccount> accountComboBox = new ComboBox(FXCollections.observableArrayList(user.getBankAccounts()));
accountComboBox.setLayoutY(12); accountComboBox.setLayoutY(12);
accountComboBox.setValue(user.getCurrentBankAccount()); accountComboBox.setValue(user.getCurrentBankAccount());
accountComboBox.setConverter(new StringConverter<BankAccount>() accountComboBox.setConverter(new StringConverter<BankAccount>()
@ -360,14 +373,7 @@ public class MainController implements Initializable, NavigationController
vBox.getChildren().setAll(accountComboBox, titleLabel); vBox.getChildren().setAll(accountComboBox, titleLabel);
parent.getChildren().add(vBox); parent.getChildren().add(vBox);
accountComboBox.valueProperty().addListener(new ChangeListener<BankAccount>() accountComboBox.valueProperty().addListener((ov, oldValue, newValue) -> user.setCurrentBankAccount(newValue));
{
@Override
public void changed(ObservableValue ov, BankAccount oldValue, BankAccount newValue)
{
user.setCurrentBankAccount(newValue);
}
});
} }
} }

View file

@ -1,9 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="anchorPane" id="root-pane" fx:controller="io.bitsquare.gui.MainController" stylesheets="/io/bitsquare/gui/bitsquare.css" xmlns:fx="http://javafx.com/fxml/1" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="rootPane" id="root-pane" fx:controller="io.bitsquare.gui.MainController"
xmlns="http://javafx.com/javafx/8"> stylesheets="/io/bitsquare/gui/bitsquare.css" xmlns="http://javafx.com/javafx/8">
<HBox fx:id="leftNavPane" spacing="10" AnchorPane.leftAnchor="0" AnchorPane.topAnchor="0"/> <HBox fx:id="leftNavPane" visible="false" spacing="10" AnchorPane.leftAnchor="0" AnchorPane.topAnchor="0"/>
<HBox fx:id="rightNavPane" spacing="10" AnchorPane.rightAnchor="10" AnchorPane.topAnchor="0"/> <HBox fx:id="rightNavPane" visible="false" spacing="10" AnchorPane.rightAnchor="10" AnchorPane.topAnchor="0"/>
<AnchorPane fx:id="contentPane" id="content-pane" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="60"/> <AnchorPane fx:id="contentPane" id="content-pane" visible="false" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="60"/>
<ProgressBar fx:id="loadingBar" prefHeight="20" prefWidth="200" AnchorPane.topAnchor="250" AnchorPane.leftAnchor="300"/>
<Label fx:id="loadingLabel" text="Loading..." textAlignment="CENTER" alignment="CENTER" prefHeight="20" prefWidth="200" AnchorPane.topAnchor="280" AnchorPane.leftAnchor="300"/>
</AnchorPane> </AnchorPane>

View file

@ -2,24 +2,30 @@ package io.bitsquare.gui;
public class NavigationViewURL public class NavigationViewURL
{ {
public static final String MAIN = "/io/bitsquare/gui/MainView.fxml";
public static final String HOME = "/io/bitsquare/gui/home/HomeView.fxml"; public static final String HOME = "/io/bitsquare/gui/home/HomeView.fxml";
public static final String MARKET = "/io/bitsquare/gui/market/MarketView.fxml"; public static final String MARKET = "/io/bitsquare/gui/market/MarketView.fxml";
public static final String ORDERS = "/io/bitsquare/gui/orders/OrdersView.fxml"; public static final String ORDERS = "/io/bitsquare/gui/orders/OrdersView.fxml";
public static final String FUNDS = "/io/bitsquare/gui/funds/FundsView.fxml"; public static final String FUNDS = "/io/bitsquare/gui/funds/FundsView.fxml";
public static final String MSG = "/io/bitsquare/gui/msg/MsgView.fxml"; public static final String MSG = "/io/bitsquare/gui/msg/MsgView.fxml";
public static final String SETTINGS = "/io/bitsquare/gui/settings/SettingsView.fxml"; public static final String SETTINGS = "/io/bitsquare/gui/settings/SettingsView.fxml";
public static final String ORDER_BOOK = "/io/bitsquare/gui/market/orderbook/OrderBookView.fxml"; public static final String ORDER_BOOK = "/io/bitsquare/gui/market/orderbook/OrderBookView.fxml";
public static final String TAKER_TRADE = "/io/bitsquare/gui/market/trade/TakerTradeView.fxml"; public static final String TAKER_TRADE = "/io/bitsquare/gui/market/trade/TakerTradeView.fxml";
public static final String OFFERER_TRADE = "/io/bitsquare/gui/orders/OffererTradeView.fxml"; public static final String OFFERER_TRADE = "/io/bitsquare/gui/orders/OffererTradeView.fxml";
public static final String CREATE_OFFER = "/io/bitsquare/gui/market/createOffer/CreateOfferView.fxml"; public static final String CREATE_OFFER = "/io/bitsquare/gui/market/createOffer/CreateOfferView.fxml";
public static final String ARBITRATOR_PROFILE = "/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileView.fxml";
public static final String ARBITRATOR_OVERVIEW = "/io/bitsquare/gui/arbitrators/overview/ArbitratorOverviewView.fxml";
public static final String ARBITRATOR_REGISTRATION = "/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationView.fxml";
public static final String CLOSED_TRADE = "/io/bitsquare/gui/orders/closed/ClosedTradeView.fxml"; public static final String CLOSED_TRADE = "/io/bitsquare/gui/orders/closed/ClosedTradeView.fxml";
public static final String OFFER = "/io/bitsquare/gui/orders/offer/OfferView.fxml"; public static final String OFFER = "/io/bitsquare/gui/orders/offer/OfferView.fxml";
public static final String PENDING_TRADE = "/io/bitsquare/gui/orders/pending/PendingTradeView.fxml"; public static final String PENDING_TRADE = "/io/bitsquare/gui/orders/pending/PendingTradeView.fxml";
public static final String DEPOSIT = "/io/bitsquare/gui/funds/deposit/DepositView.fxml"; public static final String DEPOSIT = "/io/bitsquare/gui/funds/deposit/DepositView.fxml";
public static final String WITHDRAWAL = "/io/bitsquare/gui/funds/withdrawal/WithdrawalView.fxml"; public static final String WITHDRAWAL = "/io/bitsquare/gui/funds/withdrawal/WithdrawalView.fxml";
public static final String TRANSACTIONS = "/io/bitsquare/gui/funds/transactions/TransactionsView.fxml"; public static final String TRANSACTIONS = "/io/bitsquare/gui/funds/transactions/TransactionsView.fxml";
public static final String ARBITRATOR_PROFILE = "/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileView.fxml";
public static final String ARBITRATOR_OVERVIEW = "/io/bitsquare/gui/arbitrators/overview/ArbitratorOverviewView.fxml";
public static final String ARBITRATOR_REGISTRATION = "/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationView.fxml";
} }

View file

@ -14,6 +14,12 @@ import io.bitsquare.msg.listeners.ArbitratorListener;
import io.bitsquare.settings.Settings; import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
@ -25,26 +31,19 @@ import javafx.stage.Stage;
import net.tomp2p.peers.Number160; import net.tomp2p.peers.Number160;
import net.tomp2p.storage.Data; import net.tomp2p.storage.Data;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
public class ArbitratorOverviewController implements Initializable, ChildController, NavigationController, ArbitratorListener public class ArbitratorOverviewController implements Initializable, ChildController, NavigationController, ArbitratorListener
{ {
private Settings settings; private final Settings settings;
private Storage storage; private final Storage storage;
private MessageFacade messageFacade; private final MessageFacade messageFacade;
private final List<Arbitrator> allArbitrators = new ArrayList<>();
private Arbitrator currentArbitrator; private Arbitrator currentArbitrator;
private NavigationController navigationController; private NavigationController navigationController;
private ArbitratorProfileController arbitratorProfileController; private ArbitratorProfileController arbitratorProfileController;
private List<Arbitrator> allArbitrators = new ArrayList<>();
private int index = -1; private int index = -1;
@FXML @FXML
private Button prevButton, nextButton, selectButton; private Button prevButton, nextButton, selectButton, closeButton;
@FXML @FXML
private AnchorPane rootContainer; private AnchorPane rootContainer;
@FXML @FXML

View file

@ -2,13 +2,11 @@
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="rootContainer" prefHeight="600" prefWidth="800" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="rootContainer" prefHeight="600" prefWidth="800" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.arbitrators.overview.ArbitratorOverviewController"> AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.arbitrators.overview.ArbitratorOverviewController">
<children> <Pane fx:id="arbitratorProfile"/>
<Pane fx:id="arbitratorProfile"/> <Button fx:id="prevButton" text="Previous" onAction="#onPrevious" AnchorPane.bottomAnchor="45.0" AnchorPane.leftAnchor="10.0"/>
<Button fx:id="prevButton" text="Previous" onAction="#onPrevious" AnchorPane.bottomAnchor="45.0" AnchorPane.leftAnchor="10.0"/> <Button fx:id="nextButton" text="Next" onAction="#onNext" AnchorPane.bottomAnchor="45.0" AnchorPane.rightAnchor="10.0"/>
<Button fx:id="nextButton" text="Next" onAction="#onNext" AnchorPane.bottomAnchor="45.0" AnchorPane.rightAnchor="10.0"/> <Button fx:id="selectButton" text="Select" onAction="#onSelect" AnchorPane.bottomAnchor="45.0" AnchorPane.leftAnchor="350.0"/>
<Button fx:id="selectButton" text="Select" onAction="#onSelect" AnchorPane.bottomAnchor="45.0" AnchorPane.leftAnchor="350.0"/> <Button fx:id="closeButton" text="close" onAction="#onClose" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0"/>
<Button fx:id="closeButton" text="close" onAction="#onClose" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0"/>
</children>
</AnchorPane> </AnchorPane>

View file

@ -7,19 +7,18 @@ import io.bitsquare.gui.util.BitSquareFormatter;
import io.bitsquare.settings.Settings; import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import java.net.URL;
import java.util.ResourceBundle;
public class ArbitratorProfileController implements Initializable, ChildController public class ArbitratorProfileController implements Initializable, ChildController
{ {
private Settings settings; private final Settings settings;
private Storage storage; private final Storage storage;
private Arbitrator arbitrator; private Arbitrator arbitrator;
private NavigationController navigationController; private NavigationController navigationController;

View file

@ -3,44 +3,41 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane hgap="5.0" vgap="5.0" AnchorPane.bottomAnchor="80.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" <GridPane xmlns:fx="http://javafx.com/fxml/1" hgap="5.0" vgap="5.0" AnchorPane.bottomAnchor="80.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.arbitrators.profile.ArbitratorProfileController"> xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.arbitrators.profile.ArbitratorProfileController">
<children> <Label fx:id="nameLabel" text="Name:"/>
<Label fx:id="nameLabel" text="Name:"/> <TextField fx:id="nameTextField" editable="false" GridPane.columnIndex="1"/>
<TextField fx:id="nameTextField" editable="false" GridPane.columnIndex="1"/> <Label text="Languages:" GridPane.rowIndex="1"/>
<Label text="Languages:" GridPane.rowIndex="1"/> <TextField fx:id="languagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<TextField fx:id="languagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label text="Reputation:" GridPane.rowIndex="2"/> <Label text="Reputation:" GridPane.rowIndex="2"/>
<TextField fx:id="reputationTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="2"/> <TextField fx:id="reputationTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label text="Max. trade volume:" GridPane.rowIndex="3"/> <Label text="Max. trade volume:" GridPane.rowIndex="3"/>
<TextField fx:id="maxTradeVolumeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="3"/> <TextField fx:id="maxTradeVolumeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Label text="Passive service fee:" GridPane.rowIndex="4"/> <Label text="Passive service fee:" GridPane.rowIndex="4"/>
<TextField fx:id="passiveServiceFeeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="4"/> <TextField fx:id="passiveServiceFeeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
<Label text="Arbitration fee:" GridPane.rowIndex="5"/> <Label text="Arbitration fee:" GridPane.rowIndex="5"/>
<TextField fx:id="arbitrationFeeTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="5"/> <TextField fx:id="arbitrationFeeTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="5"/>
<Label text="Methods of arbitration:" GridPane.rowIndex="6"/> <Label text="Methods of arbitration:" GridPane.rowIndex="6"/>
<TextField fx:id="methodsTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="6"/> <TextField fx:id="methodsTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="6"/>
<Label text="ID verifications:" GridPane.rowIndex="7"/> <Label text="ID verifications:" GridPane.rowIndex="7"/>
<TextField fx:id="idVerificationsTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="7"/> <TextField fx:id="idVerificationsTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="7"/>
<Label text="Web page:" GridPane.rowIndex="9"/> <Label text="Web page:" GridPane.rowIndex="9"/>
<TextField fx:id="webPageTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="9"/> <TextField fx:id="webPageTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="9"/>
<Label text="Description:" GridPane.rowIndex="10" GridPane.valignment="TOP"> <Label text="Description:" GridPane.rowIndex="10" GridPane.valignment="TOP">
<GridPane.margin> <GridPane.margin>
<Insets top="10.0"/> <Insets top="10.0"/>
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<TextArea fx:id="descriptionTextArea" editable="false" prefHeight="150.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="10"/> <TextArea fx:id="descriptionTextArea" editable="false" prefHeight="150.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="10"/>
</children>
<columnConstraints> <columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/> <ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/>

View file

@ -24,6 +24,10 @@ import io.bitsquare.storage.Storage;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.Reputation; import io.bitsquare.user.Reputation;
import io.bitsquare.util.DSAKeyUtil; import io.bitsquare.util.DSAKeyUtil;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URL;
import java.util.*;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -37,18 +41,13 @@ import javafx.util.StringConverter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URL;
import java.util.*;
public class ArbitratorRegistrationController implements Initializable, ChildController public class ArbitratorRegistrationController implements Initializable, ChildController
{ {
private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationController.class); private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationController.class);
private Storage storage; private final Storage storage;
private WalletFacade walletFacade; private final WalletFacade walletFacade;
private MessageFacade messageFacade; private final MessageFacade messageFacade;
private Arbitrator arbitrator; private Arbitrator arbitrator;
private ArbitratorProfileController arbitratorProfileController; private ArbitratorProfileController arbitratorProfileController;
private boolean isEditMode; private boolean isEditMode;

View file

@ -4,158 +4,144 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="rootContainer" prefHeight="600" prefWidth="800" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="rootContainer" prefHeight="600" prefWidth="800" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.arbitrators.registration.ArbitratorRegistrationController"> AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.arbitrators.registration.ArbitratorRegistrationController">
<children>
<Accordion fx:id="accordion" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"> <Accordion fx:id="accordion" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
<panes> <panes>
<TitledPane fx:id="profileTitledPane" text="Profile" expanded="true"> <TitledPane fx:id="profileTitledPane" text="Profile" expanded="true">
<content>
<GridPane hgap="5.0" vgap="5.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"> <GridPane hgap="5.0" vgap="5.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
<children> <Label fx:id="nameLabel" text="Name:"/>
<Label fx:id="nameLabel" text="Name:"/> <TextField fx:id="nameTextField" GridPane.columnIndex="1" GridPane.columnSpan="3"/>
<TextField fx:id="nameTextField" GridPane.columnIndex="1" GridPane.columnSpan="3"/>
<Label text="ID type:" GridPane.rowIndex="1"/> <Label text="ID type:" GridPane.rowIndex="1"/>
<TextField fx:id="idTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/> <TextField fx:id="idTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<ComboBox fx:id="idTypeComboBox" onAction="#onSelectIDType" promptText="Select ID type" prefWidth="150.0" GridPane.columnIndex="3" GridPane.rowIndex="1"/> <ComboBox fx:id="idTypeComboBox" onAction="#onSelectIDType" promptText="Select ID type" prefWidth="150.0" GridPane.columnIndex="3" GridPane.rowIndex="1"/>
<Label text="Supported language(s):" GridPane.rowIndex="2"/> <Label text="Supported language(s):" GridPane.rowIndex="2"/>
<TextField fx:id="languagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="2"/> <TextField fx:id="languagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Button onAction="#onClearLanguages" text="Clear" GridPane.columnIndex="2" GridPane.rowIndex="2"/> <Button onAction="#onClearLanguages" text="Clear" GridPane.columnIndex="2" GridPane.rowIndex="2"/>
<ComboBox fx:id="languageComboBox" onAction="#onAddLanguage" prefWidth="150.0" promptText="Add language" GridPane.columnIndex="3" GridPane.rowIndex="2"/> <ComboBox fx:id="languageComboBox" onAction="#onAddLanguage" prefWidth="150.0" promptText="Add language" GridPane.columnIndex="3" GridPane.rowIndex="2"/>
<Label text="Max. trade volume (BTC):" GridPane.rowIndex="3"/> <Label text="Max. trade volume (BTC):" GridPane.rowIndex="3"/>
<TextField fx:id="maxTradeVolumeTextField" promptText="Recommended: 0.1 - 2 BTC" GridPane.columnIndex="1" GridPane.rowIndex="3" GridPane.columnSpan="3"/> <TextField fx:id="maxTradeVolumeTextField" promptText="Recommended: 0.1 - 2 BTC" GridPane.columnIndex="1" GridPane.rowIndex="3" GridPane.columnSpan="3"/>
<Label text="Passive service fee (%):" GridPane.rowIndex="4"/> <Label text="Passive service fee (%):" GridPane.rowIndex="4"/>
<TextField fx:id="passiveServiceFeeTextField" promptText="Recommended: 0.1 - 1%" GridPane.columnIndex="1" GridPane.rowIndex="4" GridPane.columnSpan="3"/> <TextField fx:id="passiveServiceFeeTextField" promptText="Recommended: 0.1 - 1%" GridPane.columnIndex="1" GridPane.rowIndex="4" GridPane.columnSpan="3"/>
<Label text="Min. passive service fee (BTC)" GridPane.rowIndex="5"/> <Label text="Min. passive service fee (BTC)" GridPane.rowIndex="5"/>
<TextField fx:id="minPassiveServiceFeeTextField" promptText="Recommended: 0.0001 - 0.005 BTC" GridPane.columnIndex="1" GridPane.rowIndex="5" GridPane.columnSpan="3"/> <TextField fx:id="minPassiveServiceFeeTextField" promptText="Recommended: 0.0001 - 0.005 BTC" GridPane.columnIndex="1" GridPane.rowIndex="5" GridPane.columnSpan="3"/>
<Label text="Arbitration fee (%):" GridPane.rowIndex="6"/> <Label text="Arbitration fee (%):" GridPane.rowIndex="6"/>
<TextField fx:id="arbitrationFeeTextField" promptText="Recommended: 5 - 20 %" GridPane.columnIndex="1" GridPane.rowIndex="6" GridPane.columnSpan="3"/> <TextField fx:id="arbitrationFeeTextField" promptText="Recommended: 5 - 20 %" GridPane.columnIndex="1" GridPane.rowIndex="6" GridPane.columnSpan="3"/>
<Label text="Min. arbitration fee (BTC):" GridPane.rowIndex="7"/> <Label text="Min. arbitration fee (BTC):" GridPane.rowIndex="7"/>
<TextField fx:id="minArbitrationFeeTextField" promptText="Recommended: 0.1 - 0.2 BTC" GridPane.columnIndex="1" GridPane.rowIndex="7" GridPane.columnSpan="3"/> <TextField fx:id="minArbitrationFeeTextField" promptText="Recommended: 0.1 - 0.2 BTC" GridPane.columnIndex="1" GridPane.rowIndex="7" GridPane.columnSpan="3"/>
<Label text="Method(s) used for arbitration:" GridPane.rowIndex="8"/> <Label text="Method(s) used for arbitration:" GridPane.rowIndex="8"/>
<TextField fx:id="methodsTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8"/> <TextField fx:id="methodsTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8"/>
<Button onAction="#onClearMethods" text="Clear" GridPane.columnIndex="2" GridPane.rowIndex="8"/> <Button onAction="#onClearMethods" text="Clear" GridPane.columnIndex="2" GridPane.rowIndex="8"/>
<ComboBox fx:id="methodsComboBox" onAction="#onAddMethod" prefWidth="150.0" promptText="Add method" GridPane.columnIndex="3" GridPane.rowIndex="8"/> <ComboBox fx:id="methodsComboBox" onAction="#onAddMethod" prefWidth="150.0" promptText="Add method" GridPane.columnIndex="3" GridPane.rowIndex="8"/>
<Label text="Offer ID verification(s):" GridPane.rowIndex="9"/> <Label text="Offer ID verification(s):" GridPane.rowIndex="9"/>
<TextField fx:id="idVerificationsTextField" promptText="Optional" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9"/> <TextField fx:id="idVerificationsTextField" promptText="Optional" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
<Button onAction="#onClearIDVerifications" text="Clear" GridPane.columnIndex="2" GridPane.rowIndex="9"/> <Button onAction="#onClearIDVerifications" text="Clear" GridPane.columnIndex="2" GridPane.rowIndex="9"/>
<ComboBox fx:id="idVerificationsComboBox" onAction="#onAddIDVerification" prefWidth="150.0" promptText="Add verification" GridPane.columnIndex="3" <ComboBox fx:id="idVerificationsComboBox" onAction="#onAddIDVerification" prefWidth="150.0" promptText="Add verification" GridPane.columnIndex="3"
GridPane.rowIndex="9"/> GridPane.rowIndex="9"/>
<Label text="Web page:" GridPane.rowIndex="10"/> <Label text="Web page:" GridPane.rowIndex="10"/>
<TextField fx:id="webPageTextField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="10"/> <TextField fx:id="webPageTextField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="10"/>
<Label text="Description:" GridPane.rowIndex="11" GridPane.valignment="TOP"> <Label text="Description:" GridPane.rowIndex="11" GridPane.valignment="TOP">
<GridPane.margin> <GridPane.margin>
<Insets top="10.0"/> <Insets top="10.0"/>
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<TextArea fx:id="descriptionTextArea" prefHeight="150.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="11"/> <TextArea fx:id="descriptionTextArea" prefHeight="150.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="11"/>
<Button fx:id="saveProfileButton" defaultButton="true" onAction="#onSaveProfile" text="Next" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="150.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="ALWAYS"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
</GridPane>
</TitledPane>
<TitledPane fx:id="payCollateralTitledPane" text="Pay collateral">
<AnchorPane>
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<Label fx:id="infoLabel"/>
<GridPane hgap="5.0" vgap="5.0">
<Label text="Collateral address:"/>
<TextField fx:id="collateralAddressTextField" editable="false" GridPane.columnIndex="1"/>
<Label fx:id="copyIcon" id="copy-icon" GridPane.columnIndex="2">
<padding>
<Insets bottom="0.0" left="0.0" right="0.0" top="-1.0"/>
</padding>
<tooltip>
<Tooltip text="Copy address to clipboard"/>
</tooltip>
</Label>
<Label text="Balance:" GridPane.rowIndex="1"/>
<TextField fx:id="balanceTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<ConfidenceProgressIndicator fx:id="progressIndicator" GridPane.columnIndex="2" GridPane.halignment="LEFT"
GridPane.rowIndex="1" GridPane.rowSpan="2" GridPane.valignment="TOP">
<GridPane.margin>
<Insets top="2.0"/>
</GridPane.margin>
</ConfidenceProgressIndicator>
<Label fx:id="confirmationLabel" text="Checking confirmations..." GridPane.columnIndex="3" GridPane.rowIndex="1"/>
<Button fx:id="paymentDoneButton" defaultButton="true" onAction="#onPaymentDone" text="Payment done" disable="true" GridPane.columnIndex="1"
GridPane.rowIndex="2"/>
<Button fx:id="saveProfileButton" defaultButton="true" onAction="#onSaveProfile" text="Next" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
</children>
<columnConstraints> <columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/> <ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"/> <ColumnConstraints hgrow="ALWAYS"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0"/> <ColumnConstraints hgrow="SOMETIMES" prefWidth="20.0" minWidth="20"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="150.0"/> <ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/> <RowConstraints vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/> <RowConstraints vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/> <RowConstraints vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/> <RowConstraints vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="ALWAYS"/>
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints> </rowConstraints>
</GridPane> </GridPane>
</content> </VBox>
</TitledPane> </AnchorPane>
</TitledPane>
<TitledPane fx:id="payCollateralTitledPane" text="Pay collateral"> </panes>
<content> </Accordion>
<AnchorPane>
<children>
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label fx:id="infoLabel"/>
<GridPane hgap="5.0" vgap="5.0">
<children>
<Label text="Collateral address:"/>
<TextField fx:id="collateralAddressTextField" editable="false" GridPane.columnIndex="1"/>
<Label fx:id="copyIcon" id="copy-icon" GridPane.columnIndex="2">
<padding>
<Insets bottom="0.0" left="0.0" right="0.0" top="-1.0"/>
</padding>
<tooltip>
<Tooltip text="Copy address to clipboard"/>
</tooltip>
</Label>
<Label text="Balance:" GridPane.rowIndex="1"/>
<TextField fx:id="balanceTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<ConfidenceProgressIndicator fx:id="progressIndicator" GridPane.columnIndex="2" GridPane.halignment="LEFT"
GridPane.rowIndex="1" GridPane.rowSpan="2" GridPane.valignment="TOP">
<GridPane.margin>
<Insets top="2.0"/>
</GridPane.margin>
</ConfidenceProgressIndicator>
<Label fx:id="confirmationLabel" text="Checking confirmations..." GridPane.columnIndex="3" GridPane.rowIndex="1"/>
<Button fx:id="paymentDoneButton" defaultButton="true" onAction="#onPaymentDone" text="Payment done" disable="true" GridPane.columnIndex="1"
GridPane.rowIndex="2"/>
</children>
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS"/>
<ColumnConstraints hgrow="SOMETIMES" prefWidth="20.0" minWidth="20"/>
<ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
</rowConstraints>
</GridPane>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children>
</AnchorPane> </AnchorPane>

View file

@ -180,7 +180,7 @@
-fx-background-color: transparent; -fx-background-color: transparent;
} }
/* scrollpane */ /* scroll-pane */
.scroll-pane { .scroll-pane {
-fx-background-insets: 0; -fx-background-insets: 0;

View file

@ -6,29 +6,25 @@ import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import io.bitsquare.locale.Localisation; import io.bitsquare.locale.Localisation;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import javafx.beans.value.ChangeListener; import java.io.IOException;
import javafx.beans.value.ObservableValue; import java.util.HashMap;
import java.util.Map;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.SingleSelectionModel; import javafx.scene.control.SingleSelectionModel;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.control.TabPane; import javafx.scene.control.TabPane;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class LazyLoadingTabPane extends TabPane public class LazyLoadingTabPane extends TabPane
{ {
private final Map<Integer, Node> views = new HashMap<>();
private final Map<Integer, ChildController> controllers = new HashMap<>();
SingleSelectionModel<Tab> selectionModel;
private String storageId; private String storageId;
private NavigationController navigationController; private NavigationController navigationController;
private String[] tabContentFXMLUrls; private String[] tabContentFXMLUrls;
private Storage storage; private Storage storage;
SingleSelectionModel<Tab> selectionModel;
private ChildController childController; private ChildController childController;
private Map<Integer, Node> views = new HashMap<>();
private Map<Integer, ChildController> controllers = new HashMap<>();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -52,14 +48,7 @@ public class LazyLoadingTabPane extends TabPane
storageId = navigationController.getClass().getName() + ".selectedTabIndex"; storageId = navigationController.getClass().getName() + ".selectedTabIndex";
selectionModel = getSelectionModel(); selectionModel = getSelectionModel();
selectionModel.selectedItemProperty().addListener(new ChangeListener<Tab>() selectionModel.selectedItemProperty().addListener((observableValue, oldTab, newTab) -> onTabSelectedIndexChanged());
{
@Override
public void changed(ObservableValue<? extends Tab> observableValue, Tab oldTab, Tab newTab)
{
onTabSelectedIndexChanged();
}
});
Object indexObject = storage.read(storageId); Object indexObject = storage.read(storageId);
if (indexObject != null) if (indexObject != null)

View file

@ -9,8 +9,8 @@ import javafx.util.Duration;
public class NetworkSyncPane extends HBox public class NetworkSyncPane extends HBox
{ {
private ProgressBar networkSyncProgressBar; private final ProgressBar networkSyncProgressBar;
private Label networkSyncInfoLabel; private final Label networkSyncInfoLabel;
public NetworkSyncPane() public NetworkSyncPane()
{ {

View file

@ -43,22 +43,22 @@ import javafx.scene.control.Skin;
* <p> * <p>
* ProgressIndicator sets focusTraversable to false. * ProgressIndicator sets focusTraversable to false.
* </p> * </p>
* <p/> * <p>
* <p/> * <p>
* This first example creates a ProgressIndicator with an indeterminate value : * This first example creates a ProgressIndicator with an indeterminate value :
* <pre><code> * <pre><code>
* import javafx.scene.control.ProgressIndicator; * import javafx.scene.control.ProgressIndicator;
* ProgressIndicator p1 = new ProgressIndicator(); * ProgressIndicator p1 = new ProgressIndicator();
* </code></pre> * </code></pre>
* <p/> * <p>
* <p/> * <p>
* This next example creates a ProgressIndicator which is 25% complete : * This next example creates a ProgressIndicator which is 25% complete :
* <pre><code> * <pre><code>
* import javafx.scene.control.ProgressIndicator; * import javafx.scene.control.ProgressIndicator;
* ProgressIndicator p2 = new ProgressIndicator(); * ProgressIndicator p2 = new ProgressIndicator();
* p2.setProgress(0.25F); * p2.setProgress(0.25F);
* </code></pre> * </code></pre>
* <p/> * <p>
* Implementation of ProgressIndicator According to JavaFX UI Control API Specification * Implementation of ProgressIndicator According to JavaFX UI Control API Specification
* *
* @since JavaFX 2.0 * @since JavaFX 2.0
@ -79,6 +79,44 @@ public class ConfidenceProgressIndicator extends Control
* Constructors * * Constructors *
* * * *
**************************************************************************/ **************************************************************************/
/**
* Initialize the style class to 'progress-indicator'.
* <p>
* This is the selector class from which CSS can be used to style
* this control.
*/
private static final String DEFAULT_STYLE_CLASS = "progress-indicator";
/**
* Pseudoclass indicating this is a determinate (i.e., progress can be
* determined) progress indicator.
*/
private static final PseudoClass PSEUDO_CLASS_DETERMINATE =
PseudoClass.getPseudoClass("determinate");
/***************************************************************************
* *
* Properties *
* *
**************************************************************************/
/**
* Pseudoclass indicating this is an indeterminate (i.e., progress cannot
* be determined) progress indicator.
*/
private static final PseudoClass PSEUDO_CLASS_INDETERMINATE =
PseudoClass.getPseudoClass("indeterminate");
/**
* A flag indicating whether it is possible to determine the progress
* of the ProgressIndicator. Typically indeterminate progress bars are
* rendered with some form of animation indicating potentially "infinite"
* progress.
*/
private ReadOnlyBooleanWrapper indeterminate;
/**
* The actual progress of the ProgressIndicator. A negative value for
* progress indicates that the progress is indeterminate. A positive value
* between 0 and 1 indicates the percentage of progress where 0 is 0% and 1
* is 100%. Any value greater than 1 is interpreted as 100%.
*/
private DoubleProperty progress;
/** /**
* Creates a new indeterminate ProgressIndicator. * Creates a new indeterminate ProgressIndicator.
@ -91,10 +129,11 @@ public class ConfidenceProgressIndicator extends Control
/** /**
* Creates a new ProgressIndicator with the given progress value. * Creates a new ProgressIndicator with the given progress value.
*/ */
@SuppressWarnings("unchecked")
public ConfidenceProgressIndicator(double progress) public ConfidenceProgressIndicator(double progress)
{ {
// focusTraversable is styleable through css. Calling setFocusTraversable // focusTraversable is styleable through css. Calling setFocusTraversable
// makes it look to css like the user set the value and css will not // makes it look to css like the user set the value and css will not
// override. Initializing focusTraversable by calling applyStyle with null // override. Initializing focusTraversable by calling applyStyle with null
// StyleOrigin ensures that css will be able to override the value. // StyleOrigin ensures that css will be able to override the value.
((StyleableProperty) focusTraversableProperty()).applyStyle(null, Boolean.FALSE); ((StyleableProperty) focusTraversableProperty()).applyStyle(null, Boolean.FALSE);
@ -106,29 +145,17 @@ public class ConfidenceProgressIndicator extends Control
pseudoClassStateChanged(PSEUDO_CLASS_INDETERMINATE, c == 0); pseudoClassStateChanged(PSEUDO_CLASS_INDETERMINATE, c == 0);
pseudoClassStateChanged(PSEUDO_CLASS_DETERMINATE, c != 0); pseudoClassStateChanged(PSEUDO_CLASS_DETERMINATE, c != 0);
} }
/***************************************************************************
* * public final boolean isIndeterminate()
* Properties * {
* * return indeterminate == null || indeterminate.get();
**************************************************************************/ }
/**
* A flag indicating whether it is possible to determine the progress
* of the ProgressIndicator. Typically indeterminate progress bars are
* rendered with some form of animation indicating potentially "infinite"
* progress.
*/
private ReadOnlyBooleanWrapper indeterminate;
private void setIndeterminate(boolean value) private void setIndeterminate(boolean value)
{ {
indeterminatePropertyImpl().set(value); indeterminatePropertyImpl().set(value);
} }
public final boolean isIndeterminate()
{
return indeterminate == null ? true : indeterminate.get();
}
public final ReadOnlyBooleanProperty indeterminateProperty() public final ReadOnlyBooleanProperty indeterminateProperty()
{ {
return indeterminatePropertyImpl().getReadOnlyProperty(); return indeterminatePropertyImpl().getReadOnlyProperty();
@ -165,23 +192,31 @@ public class ConfidenceProgressIndicator extends Control
} }
/** /**
* The actual progress of the ProgressIndicator. A negative value for * ************************************************************************
* progress indicates that the progress is indeterminate. A positive value * *
* between 0 and 1 indicates the percentage of progress where 0 is 0% and 1 * Methods *
* is 100%. Any value greater than 1 is interpreted as 100%. * *
* ************************************************************************
*/ */
private DoubleProperty progress;
public final void setProgress(double value)
{
progressProperty().set(value);
}
public final double getProgress() public final double getProgress()
{ {
return progress == null ? INDETERMINATE_PROGRESS : progress.get(); return progress == null ? INDETERMINATE_PROGRESS : progress.get();
} }
/**
* ************************************************************************
* *
* Stylesheet Handling *
* *
* ************************************************************************
*/
public final void setProgress(double value)
{
progressProperty().set(value);
}
public final DoubleProperty progressProperty() public final DoubleProperty progressProperty()
{ {
if (progress == null) if (progress == null)
@ -210,12 +245,6 @@ public class ConfidenceProgressIndicator extends Control
return progress; return progress;
} }
/***************************************************************************
* *
* Methods *
* *
**************************************************************************/
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -225,34 +254,6 @@ public class ConfidenceProgressIndicator extends Control
return new ConfidenceProgressIndicatorSkin(this); return new ConfidenceProgressIndicatorSkin(this);
} }
/***************************************************************************
* *
* Stylesheet Handling *
* *
**************************************************************************/
/**
* Initialize the style class to 'progress-indicator'.
* <p/>
* This is the selector class from which CSS can be used to style
* this control.
*/
private static final String DEFAULT_STYLE_CLASS = "progress-indicator";
/**
* Pseudoclass indicating this is a determinate (i.e., progress can be
* determined) progress indicator.
*/
private static final PseudoClass PSEUDO_CLASS_DETERMINATE =
PseudoClass.getPseudoClass("determinate");
/**
* Pseudoclass indicating this is an indeterminate (i.e., progress cannot
* be determined) progress indicator.
*/
private static final PseudoClass PSEUDO_CLASS_INDETERMINATE =
PseudoClass.getPseudoClass("indeterminate");
/** /**
* Most Controls return true for focusTraversable, so Control overrides * Most Controls return true for focusTraversable, so Control overrides
* this method to return true, but ProgressIndicator returns false for * this method to return true, but ProgressIndicator returns false for
@ -263,6 +264,7 @@ public class ConfidenceProgressIndicator extends Control
*/ */
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings("deprecation")
protected /*do not make final*/ Boolean impl_cssGetFocusTraversableInitialValue() protected /*do not make final*/ Boolean impl_cssGetFocusTraversableInitialValue()
{ {
return Boolean.FALSE; return Boolean.FALSE;

View file

@ -26,7 +26,6 @@ package io.bitsquare.gui.components.confidence.behavior;
import com.sun.javafx.scene.control.behavior.BehaviorBase; import com.sun.javafx.scene.control.behavior.BehaviorBase;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import java.util.Collections; import java.util.Collections;
public class ConfidenceProgressIndicatorBehavior<C extends ConfidenceProgressIndicator> extends BehaviorBase<C> public class ConfidenceProgressIndicatorBehavior<C extends ConfidenceProgressIndicator> extends BehaviorBase<C>

View file

@ -31,6 +31,9 @@ import com.sun.javafx.css.converters.SizeConverter;
import com.sun.javafx.scene.control.skin.BehaviorSkinBase; import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.components.confidence.behavior.ConfidenceProgressIndicatorBehavior; import io.bitsquare.gui.components.confidence.behavior.ConfidenceProgressIndicatorBehavior;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javafx.animation.KeyFrame; import javafx.animation.KeyFrame;
import javafx.animation.KeyValue; import javafx.animation.KeyValue;
import javafx.animation.Timeline; import javafx.animation.Timeline;
@ -42,8 +45,6 @@ import javafx.beans.property.ObjectProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.css.*; import javafx.css.*;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.NodeOrientation; import javafx.geometry.NodeOrientation;
import javafx.scene.Node; import javafx.scene.Node;
@ -59,10 +60,6 @@ import javafx.scene.shape.Circle;
import javafx.scene.transform.Scale; import javafx.scene.transform.Scale;
import javafx.util.Duration; import javafx.util.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<ConfidenceProgressIndicator, ConfidenceProgressIndicatorBehavior<ConfidenceProgressIndicator>> public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<ConfidenceProgressIndicator, ConfidenceProgressIndicatorBehavior<ConfidenceProgressIndicator>>
{ {
@ -85,7 +82,108 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
} */ } */
private IndeterminateSpinner spinner; private IndeterminateSpinner spinner;
/**
* The number of segments in the spinner.
*/
private final IntegerProperty indeterminateSegmentCount =
new StyleableIntegerProperty(8)
{
@Override
protected void invalidated()
{
if (spinner != null) spinner.rebuild();
}
@Override
public Object getBean()
{
return ConfidenceProgressIndicatorSkin.this;
}
@Override
public String getName()
{
return "indeterminateSegmentCount";
}
@Override
public CssMetaData<ConfidenceProgressIndicator, Number> getCssMetaData()
{
return StyleableProperties.INDETERMINATE_SEGMENT_COUNT;
}
};
/**
* True if the progress indicator should rotate as well as animate opacity.
*/
private final BooleanProperty spinEnabled = new StyleableBooleanProperty(false)
{
@Override
protected void invalidated()
{
if (spinner != null) spinner.setSpinEnabled(get());
}
@Override
public CssMetaData<ConfidenceProgressIndicator, Boolean> getCssMetaData()
{
return StyleableProperties.SPIN_ENABLED;
}
@Override
public Object getBean()
{
return ConfidenceProgressIndicatorSkin.this;
}
@Override
public String getName()
{
return "spinEnabled";
}
};
private DeterminateIndicator determinateIndicator; private DeterminateIndicator determinateIndicator;
/**
* The colour of the progress segment.
*/
private final ObjectProperty<Paint> progressColor =
new StyleableObjectProperty<Paint>(null)
{
@Override
public void set(Paint newProgressColor)
{
final Paint color = (newProgressColor instanceof Color)
? newProgressColor
: null;
super.set(color);
}
@Override
protected void invalidated()
{
if (spinner != null) spinner.setFillOverride(get());
if (determinateIndicator != null) determinateIndicator.setFillOverride(get());
}
@Override
public Object getBean()
{
return ConfidenceProgressIndicatorSkin.this;
}
@Override
public String getName()
{
return "progressColorProperty";
}
@Override
public CssMetaData<ConfidenceProgressIndicator, Paint> getCssMetaData()
{
return StyleableProperties.PROGRESS_COLOR;
}
};
private boolean timelineNulled = false; private boolean timelineNulled = false;
/** /**
@ -95,19 +193,12 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
* * * *
* ************************************************************************ * ************************************************************************
*/ */
@SuppressWarnings("deprecation")
public ConfidenceProgressIndicatorSkin(ConfidenceProgressIndicator control) public ConfidenceProgressIndicatorSkin(ConfidenceProgressIndicator control)
{ {
super(control, new ConfidenceProgressIndicatorBehavior<ConfidenceProgressIndicator>(control)); super(control, new ConfidenceProgressIndicatorBehavior<>(control));
InvalidationListener indeterminateListener = new InvalidationListener() InvalidationListener indeterminateListener = valueModel -> initialize();
{
@Override
public void invalidated(Observable valueModel)
{
initialize();
}
};
control.indeterminateProperty().addListener(indeterminateListener); control.indeterminateProperty().addListener(indeterminateListener);
InvalidationListener visibilityListener = new InvalidationListener() InvalidationListener visibilityListener = new InvalidationListener()
@ -178,6 +269,16 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
getSkinnable().requestLayout(); getSkinnable().requestLayout();
} }
/**
* @return The CssMetaData associated with this class, which may include the
* CssMetaData of its super classes.
*/
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()
{
return StyleableProperties.STYLEABLES;
}
@SuppressWarnings("deprecation")
private void initialize() private void initialize()
{ {
ConfidenceProgressIndicator control = getSkinnable(); ConfidenceProgressIndicator control = getSkinnable();
@ -237,6 +338,22 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
} }
} }
public Paint getProgressColor()
{
return progressColor.get();
}
/**
* {@inheritDoc}
*/
@Override
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()
{
return getClassCssMetaData();
}
// *********** Stylesheet Handling *****************************************
/** /**
* ************************************************************************ * ************************************************************************
* * * *
@ -249,18 +366,17 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
{ {
//private double textGap = 2.0F; //private double textGap = 2.0F;
private final ConfidenceProgressIndicator control;
//private Text text;
private final StackPane indicator;
private final StackPane progress;
private final StackPane tick;
private final Arc arcShape;
private final Circle indicatorCircle;
// only update progress text on whole percentages // only update progress text on whole percentages
private int intProgress; private int intProgress;
// only update pie arc to nearest degree // only update pie arc to nearest degree
private int degProgress; private int degProgress;
private ConfidenceProgressIndicator control;
//private Text text;
private StackPane indicator;
private StackPane progress;
private StackPane tick;
private Arc arcShape;
private Circle indicatorCircle;
public DeterminateIndicator(ConfidenceProgressIndicator control, ConfidenceProgressIndicatorSkin s, Paint fillOverride) public DeterminateIndicator(ConfidenceProgressIndicator control, ConfidenceProgressIndicatorSkin s, Paint fillOverride)
{ {
@ -271,14 +387,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
intProgress = (int) Math.round(control.getProgress() * 100.0); intProgress = (int) Math.round(control.getProgress() * 100.0);
degProgress = (int) (360 * control.getProgress()); degProgress = (int) (360 * control.getProgress());
InvalidationListener progressListener = new InvalidationListener() InvalidationListener progressListener = valueModel -> updateProgress();
{
@Override
public void invalidated(Observable valueModel)
{
updateProgress();
}
};
control.progressProperty().addListener(progressListener); control.progressProperty().addListener(progressListener);
getChildren().clear(); getChildren().clear();
@ -495,11 +604,11 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
static class IndeterminateSpinner extends Region static class IndeterminateSpinner extends Region
{ {
private ConfidenceProgressIndicator control; private final ConfidenceProgressIndicator control;
private ConfidenceProgressIndicatorSkin skin; private final ConfidenceProgressIndicatorSkin skin;
private IndicatorPaths pathsG; private final IndicatorPaths pathsG;
private Timeline indeterminateTimeline; private final Timeline indeterminateTimeline;
private final List<Double> opacities = new ArrayList<Double>(); private final List<Double> opacities = new ArrayList<>();
private boolean spinEnabled = false; private boolean spinEnabled = false;
private Paint fillOverride = null; private Paint fillOverride = null;
@ -547,14 +656,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
{ {
keyFrames.add( keyFrames.add(
new KeyFrame( new KeyFrame(
Duration.millis(i), new EventHandler<ActionEvent>() Duration.millis(i), event -> shiftColors()));
{
@Override
public void handle(ActionEvent event)
{
shiftColors();
}
}));
} }
indeterminateTimeline.getKeyFrames().setAll(keyFrames); indeterminateTimeline.getKeyFrames().setAll(keyFrames);
} }
@ -574,103 +676,6 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
} }
} }
private class IndicatorPaths extends Pane
{
IndeterminateSpinner piSkin;
IndicatorPaths(IndeterminateSpinner pi)
{
super();
piSkin = pi;
InvalidationListener treeVisibilityListener = new InvalidationListener()
{
@Override
public void invalidated(Observable valueModel)
{
if (piSkin.skin.getSkinnable().impl_isTreeVisible())
{
piSkin.pauseIndicator(false);
}
else
{
piSkin.pauseIndicator(true);
}
}
};
impl_treeVisibleProperty().addListener(treeVisibilityListener);
}
@Override
protected double computePrefWidth(double height)
{
double w = 0;
for (Node child : getChildren())
{
if (child instanceof Region)
{
Region region = (Region) child;
if (region.getShape() != null)
{
w = Math.max(w, region.getShape().getLayoutBounds().getMaxX());
}
else
{
w = Math.max(w, region.prefWidth(height));
}
}
}
return w;
}
@Override
protected double computePrefHeight(double width)
{
double h = 0;
for (Node child : getChildren())
{
if (child instanceof Region)
{
Region region = (Region) child;
if (region.getShape() != null)
{
h = Math.max(h, region.getShape().getLayoutBounds().getMaxY());
}
else
{
h = Math.max(h, region.prefHeight(width));
}
}
}
return h;
}
@Override
protected void layoutChildren()
{
// calculate scale
double scale = getWidth() / computePrefWidth(-1);
for (Node child : getChildren())
{
if (child instanceof Region)
{
Region region = (Region) child;
if (region.getShape() != null)
{
region.resize(
region.getShape().getLayoutBounds().getMaxX(),
region.getShape().getLayoutBounds().getMaxY()
);
region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
}
else
{
region.autosize();
}
}
}
}
}
@Override @Override
protected void layoutChildren() protected void layoutChildren()
{ {
@ -727,126 +732,106 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
pathsG.getChildren().get(i).setOpacity(opacities.get(i)); pathsG.getChildren().get(i).setOpacity(opacities.get(i));
} }
} }
}
public Paint getProgressColor() @SuppressWarnings("deprecation")
{ private class IndicatorPaths extends Pane
return progressColor.get(); {
} final IndeterminateSpinner piSkin;
/** IndicatorPaths(IndeterminateSpinner pi)
* The colour of the progress segment.
*/
private ObjectProperty<Paint> progressColor =
new StyleableObjectProperty<Paint>(null)
{ {
super();
piSkin = pi;
InvalidationListener treeVisibilityListener = valueModel -> {
if (piSkin.skin.getSkinnable().impl_isTreeVisible())
{
piSkin.pauseIndicator(false);
}
else
{
piSkin.pauseIndicator(true);
}
};
impl_treeVisibleProperty().addListener(treeVisibilityListener);
}
@Override @Override
public void set(Paint newProgressColor) protected double computePrefWidth(double height)
{
final Paint color = (newProgressColor instanceof Color)
? newProgressColor
: null;
super.set(color);
}
@Override
protected void invalidated()
{
if (spinner != null) spinner.setFillOverride(get());
if (determinateIndicator != null) determinateIndicator.setFillOverride(get());
}
@Override
public Object getBean()
{
return ConfidenceProgressIndicatorSkin.this;
}
@Override
public String getName()
{
return "progressColorProperty";
}
@Override
public CssMetaData<ConfidenceProgressIndicator, Paint> getCssMetaData()
{
return StyleableProperties.PROGRESS_COLOR;
}
};
/**
* The number of segments in the spinner.
*/
private IntegerProperty indeterminateSegmentCount =
new StyleableIntegerProperty(8)
{ {
double w = 0;
@Override for (Node child : getChildren())
protected void invalidated()
{ {
if (spinner != null) spinner.rebuild(); if (child instanceof Region)
{
Region region = (Region) child;
if (region.getShape() != null)
{
w = Math.max(w, region.getShape().getLayoutBounds().getMaxX());
}
else
{
w = Math.max(w, region.prefWidth(height));
}
}
} }
return w;
}
@Override @Override
public Object getBean() protected double computePrefHeight(double width)
{
double h = 0;
for (Node child : getChildren())
{ {
return ConfidenceProgressIndicatorSkin.this; if (child instanceof Region)
{
Region region = (Region) child;
if (region.getShape() != null)
{
h = Math.max(h, region.getShape().getLayoutBounds().getMaxY());
}
else
{
h = Math.max(h, region.prefHeight(width));
}
}
} }
return h;
}
@Override @Override
public String getName() protected void layoutChildren()
{ {
return "indeterminateSegmentCount"; // calculate scale
} double scale = getWidth() / computePrefWidth(-1);
getChildren().stream().filter(child -> child instanceof Region).forEach(child -> {
@Override Region region = (Region) child;
public CssMetaData<ConfidenceProgressIndicator, Number> getCssMetaData() if (region.getShape() != null)
{ {
return StyleableProperties.INDETERMINATE_SEGMENT_COUNT; region.resize(
} region.getShape().getLayoutBounds().getMaxX(),
}; region.getShape().getLayoutBounds().getMaxY()
);
/** region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
* True if the progress indicator should rotate as well as animate opacity. }
*/ else
private final BooleanProperty spinEnabled = new StyleableBooleanProperty(false) {
{ region.autosize();
@Override }
protected void invalidated() });
{ }
if (spinner != null) spinner.setSpinEnabled(get());
} }
}
@Override
public CssMetaData<ConfidenceProgressIndicator, Boolean> getCssMetaData()
{
return StyleableProperties.SPIN_ENABLED;
}
@Override
public Object getBean()
{
return ConfidenceProgressIndicatorSkin.this;
}
@Override
public String getName()
{
return "spinEnabled";
}
};
// *********** Stylesheet Handling *****************************************
/** /**
* Super-lazy instantiation pattern from Bill Pugh. * Super-lazy instantiation pattern from Bill Pugh.
* *
* @treatAsPrivate implementation detail * @treatAsPrivate implementation detail
*/ */
@SuppressWarnings({"deprecation", "unchecked"})
private static class StyleableProperties private static class StyleableProperties
{ {
public static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
private static final CssMetaData<ConfidenceProgressIndicator, Paint> PROGRESS_COLOR = private static final CssMetaData<ConfidenceProgressIndicator, Paint> PROGRESS_COLOR =
new CssMetaData<ConfidenceProgressIndicator, Paint>("-fx-progress-color", new CssMetaData<ConfidenceProgressIndicator, Paint>("-fx-progress-color",
PaintConverter.getInstance(), null) PaintConverter.getInstance(), null)
@ -867,6 +852,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
return (StyleableProperty<Paint>) skin.progressColor; return (StyleableProperty<Paint>) skin.progressColor;
} }
}; };
private static final CssMetaData<ConfidenceProgressIndicator, Number> INDETERMINATE_SEGMENT_COUNT = private static final CssMetaData<ConfidenceProgressIndicator, Number> INDETERMINATE_SEGMENT_COUNT =
new CssMetaData<ConfidenceProgressIndicator, Number>("-fx-indeterminate-segment-count", new CssMetaData<ConfidenceProgressIndicator, Number>("-fx-indeterminate-segment-count",
SizeConverter.getInstance(), 8) SizeConverter.getInstance(), 8)
@ -913,12 +899,9 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
} }
}; };
public static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
static static
{ {
final List<CssMetaData<? extends Styleable, ?>> styleables = final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(SkinBase.getClassCssMetaData());
new ArrayList<CssMetaData<? extends Styleable, ?>>(SkinBase.getClassCssMetaData());
styleables.add(PROGRESS_COLOR); styleables.add(PROGRESS_COLOR);
styleables.add(INDETERMINATE_SEGMENT_COUNT); styleables.add(INDETERMINATE_SEGMENT_COUNT);
styleables.add(SPIN_ENABLED); styleables.add(SPIN_ENABLED);
@ -926,22 +909,4 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
} }
} }
/**
* @return The CssMetaData associated with this class, which may include the
* CssMetaData of its super classes.
*/
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()
{
return StyleableProperties.STYLEABLES;
}
/**
* {@inheritDoc}
*/
@Override
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()
{
return getClassCssMetaData();
}
} }

View file

@ -1,10 +1,9 @@
package io.bitsquare.gui.components.processbar; package io.bitsquare.gui.components.processbar;
import java.util.List;
import javafx.scene.control.Control; import javafx.scene.control.Control;
import javafx.scene.control.Skin; import javafx.scene.control.Skin;
import java.util.List;
public class ProcessStepBar<T> extends Control public class ProcessStepBar<T> extends Control
{ {
@ -27,6 +26,11 @@ public class ProcessStepBar<T> extends Control
return new ProcessStepBarSkin<>(this); return new ProcessStepBarSkin<>(this);
} }
List<ProcessStepItem> getProcessStepItems()
{
return processStepItems;
}
public void setProcessStepItems(List<ProcessStepItem> processStepItems) public void setProcessStepItems(List<ProcessStepItem> processStepItems)
{ {
this.processStepItems = processStepItems; this.processStepItems = processStepItems;
@ -34,11 +38,6 @@ public class ProcessStepBar<T> extends Control
((ProcessStepBarSkin) getSkin()).dataChanged(); ((ProcessStepBarSkin) getSkin()).dataChanged();
} }
List<ProcessStepItem> getProcessStepItems()
{
return processStepItems;
}
public void next() public void next()
{ {
((ProcessStepBarSkin) getSkin()).next(); ((ProcessStepBarSkin) getSkin()).next();

View file

@ -3,6 +3,9 @@ package io.bitsquare.gui.components.processbar;
import com.sun.javafx.scene.control.behavior.BehaviorBase; import com.sun.javafx.scene.control.behavior.BehaviorBase;
import com.sun.javafx.scene.control.behavior.KeyBinding; import com.sun.javafx.scene.control.behavior.KeyBinding;
import com.sun.javafx.scene.control.skin.BehaviorSkinBase; import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Node; import javafx.scene.Node;
@ -14,17 +17,12 @@ import javafx.scene.layout.BorderWidths;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.*; import javafx.scene.shape.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, BehaviorBase<ProcessStepBar<T>>> public class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, BehaviorBase<ProcessStepBar<T>>>
{ {
final ProcessStepBar<T> controller;
LabelWithBorder currentLabelWithBorder; LabelWithBorder currentLabelWithBorder;
LabelWithBorder prevLabelWithBorder; LabelWithBorder prevLabelWithBorder;
final ProcessStepBar<T> controller;
int index; int index;
List<LabelWithBorder> labelWithBorders; List<LabelWithBorder> labelWithBorders;
@ -49,9 +47,8 @@ public class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, B
int i = 0; int i = 0;
labelWithBorders = new ArrayList<>(); labelWithBorders = new ArrayList<>();
int size = controller.getProcessStepItems().size(); int size = controller.getProcessStepItems().size();
for (Iterator<ProcessStepItem> iterator = controller.getProcessStepItems().iterator(); iterator.hasNext(); ) for (ProcessStepItem processStepItem : controller.getProcessStepItems())
{ {
ProcessStepItem processStepItem = iterator.next();
LabelWithBorder labelWithBorder = new LabelWithBorder(processStepItem, i == 0, i == size - 1); LabelWithBorder labelWithBorder = new LabelWithBorder(processStepItem, i == 0, i == size - 1);
getChildren().add(labelWithBorder); getChildren().add(labelWithBorder);
labelWithBorders.add(labelWithBorder); labelWithBorders.add(labelWithBorder);
@ -105,12 +102,12 @@ public class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, B
public static class LabelWithBorder extends Label public static class LabelWithBorder extends Label
{ {
final double borderWidth = 1;
private final double arrowWidth = 10; private final double arrowWidth = 10;
private final double arrowHeight = 30; private final double arrowHeight = 30;
private ProcessStepItem processStepItem; private final ProcessStepItem processStepItem;
private boolean isFirst; private final boolean isFirst;
private boolean isLast; private final boolean isLast;
double borderWidth = 1;
public LabelWithBorder(ProcessStepItem processStepItem, boolean isFirst, boolean isLast) public LabelWithBorder(ProcessStepItem processStepItem, boolean isFirst, boolean isLast)
{ {

View file

@ -5,9 +5,9 @@ import javafx.scene.paint.Paint;
public class ProcessStepItem public class ProcessStepItem
{ {
private String label; private final String label;
private Paint color; private final Paint color;
private boolean progressIndicator; private final boolean progressIndicator;
public ProcessStepItem(String label) public ProcessStepItem(String label)
{ {

View file

@ -7,18 +7,17 @@ import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.NavigationViewURL; import io.bitsquare.gui.NavigationViewURL;
import io.bitsquare.gui.components.LazyLoadingTabPane; import io.bitsquare.gui.components.LazyLoadingTabPane;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class FundsController implements Initializable, ChildController, NavigationController public class FundsController implements Initializable, ChildController, NavigationController
{ {
private static final Logger log = LoggerFactory.getLogger(FundsController.class); private static final Logger log = LoggerFactory.getLogger(FundsController.class);
private Storage storage; private final Storage storage;
@FXML @FXML
private LazyLoadingTabPane tabPane; private LazyLoadingTabPane tabPane;

View file

@ -3,8 +3,8 @@
<?import io.bitsquare.gui.components.LazyLoadingTabPane?> <?import io.bitsquare.gui.components.LazyLoadingTabPane?>
<?import javafx.scene.control.Tab?> <?import javafx.scene.control.Tab?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<LazyLoadingTabPane fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" <LazyLoadingTabPane xmlns:fx="http://javafx.com/fxml/1" fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.funds.FundsController"> xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.funds.FundsController">
<Tab text="Deposit" closable="false"/> <Tab text="Deposit" closable="false"/>
<Tab text="Withdrawal" closable="false"/> <Tab text="Withdrawal" closable="false"/>

View file

@ -8,11 +8,13 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.ChildController; import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.Hibernate; import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
@ -22,19 +24,15 @@ import javafx.util.Callback;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
public class DepositController implements Initializable, ChildController, Hibernate public class DepositController implements Initializable, ChildController, Hibernate
{ {
private static final Logger log = LoggerFactory.getLogger(DepositController.class); private static final Logger log = LoggerFactory.getLogger(DepositController.class);
private WalletFacade walletFacade; private final WalletFacade walletFacade;
protected ObservableList<DepositListItem> addressList; protected ObservableList<DepositListItem> addressList;
@FXML @FXML
private TableView tableView; private TableView<DepositListItem> tableView;
@FXML @FXML
private TableColumn<String, DepositListItem> labelColumn, addressColumn, balanceColumn, copyColumn, confidenceColumn; private TableColumn<String, DepositListItem> labelColumn, addressColumn, balanceColumn, copyColumn, confidenceColumn;
@FXML @FXML
@ -81,9 +79,9 @@ public class DepositController implements Initializable, ChildController, Hibern
@Override @Override
public void cleanup() public void cleanup()
{ {
for (int i = 0; i < addressList.size(); i++) for (DepositListItem anAddressList : addressList)
{ {
addressList.get(i).cleanup(); anAddressList.cleanup();
} }
} }
@ -103,9 +101,9 @@ public class DepositController implements Initializable, ChildController, Hibern
{ {
List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList(); List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList();
addressList = FXCollections.observableArrayList(); addressList = FXCollections.observableArrayList();
for (int i = 0; i < addressEntryList.size(); i++) for (AddressEntry anAddressEntryList : addressEntryList)
{ {
addressList.add(new DepositListItem(addressEntryList.get(i), walletFacade)); addressList.add(new DepositListItem(anAddressEntryList, walletFacade));
} }
tableView.setItems(addressList); tableView.setItems(addressList);
@ -158,14 +156,7 @@ public class DepositController implements Initializable, ChildController, Hibern
Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId()); Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId());
Tooltip.install(hyperlink, tooltip); Tooltip.install(hyperlink, tooltip);
hyperlink.setOnAction(new EventHandler<ActionEvent>() hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressEntry().getTradeId()));
{
@Override
public void handle(ActionEvent event)
{
log.info("Show trade details " + item.getAddressEntry().getTradeId());
}
});
} }
setGraphic(hyperlink); setGraphic(hyperlink);
} }
@ -219,7 +210,7 @@ public class DepositController implements Initializable, ChildController, Hibern
{ {
return new TableCell<String, DepositListItem>() return new TableCell<String, DepositListItem>()
{ {
Label copyIcon = new Label(); final Label copyIcon = new Label();
{ {
copyIcon.getStyleClass().add("copy-icon"); copyIcon.getStyleClass().add("copy-icon");

View file

@ -4,7 +4,7 @@ import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.funds.withdrawal.WithdrawalListItem; import io.bitsquare.gui.funds.withdrawal.WithdrawalListItem;
public class DepositListItem extends WithdrawalListItem class DepositListItem extends WithdrawalListItem
{ {
public DepositListItem(AddressEntry addressEntry, WalletFacade walletFacade) public DepositListItem(AddressEntry addressEntry, WalletFacade walletFacade)
{ {

View file

@ -4,8 +4,8 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.control.cell.PropertyValueFactory?> <?import javafx.scene.control.cell.PropertyValueFactory?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<VBox spacing="10" fx:controller="io.bitsquare.gui.funds.deposit.DepositController" xmlns="http://javafx.com/javafx/8" <VBox xmlns:fx="http://javafx.com/fxml/1" spacing="10" fx:controller="io.bitsquare.gui.funds.deposit.DepositController"
xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8">
<padding> <padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</padding> </padding>

View file

@ -6,11 +6,13 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.ChildController; import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.Hibernate; import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
@ -18,15 +20,11 @@ import javafx.util.Callback;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
public class TransactionsController implements Initializable, ChildController, Hibernate public class TransactionsController implements Initializable, ChildController, Hibernate
{ {
private static final Logger log = LoggerFactory.getLogger(TransactionsController.class); private static final Logger log = LoggerFactory.getLogger(TransactionsController.class);
private WalletFacade walletFacade; private final WalletFacade walletFacade;
protected ObservableList<TransactionsListItem> transactionsListItems; protected ObservableList<TransactionsListItem> transactionsListItems;
@FXML @FXML
@ -75,9 +73,9 @@ public class TransactionsController implements Initializable, ChildController, H
@Override @Override
public void cleanup() public void cleanup()
{ {
for (int i = 0; i < transactionsListItems.size(); i++) for (TransactionsListItem transactionsListItem : transactionsListItems)
{ {
transactionsListItems.get(i).cleanup(); transactionsListItem.cleanup();
} }
} }
@ -97,10 +95,7 @@ public class TransactionsController implements Initializable, ChildController, H
{ {
List<Transaction> transactions = walletFacade.getWallet().getRecentTransactions(10000, true); List<Transaction> transactions = walletFacade.getWallet().getRecentTransactions(10000, true);
transactionsListItems = FXCollections.observableArrayList(); transactionsListItems = FXCollections.observableArrayList();
for (int i = 0; i < transactions.size(); i++) transactionsListItems.addAll(transactions.stream().map(transaction -> new TransactionsListItem(transaction, walletFacade)).collect(Collectors.toList()));
{
transactionsListItems.add(new TransactionsListItem(transactions.get(i), walletFacade));
}
tableView.setItems(transactionsListItems); tableView.setItems(transactionsListItems);
} }
@ -141,14 +136,7 @@ public class TransactionsController implements Initializable, ChildController, H
{ {
hyperlink = new Hyperlink(item.getAddressString()); hyperlink = new Hyperlink(item.getAddressString());
hyperlink.setId("id-link"); hyperlink.setId("id-link");
hyperlink.setOnAction(new EventHandler<ActionEvent>() hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressString()));
{
@Override
public void handle(ActionEvent event)
{
log.info("Show trade details " + item.getAddressString());
}
});
setGraphic(hyperlink); setGraphic(hyperlink);
} }
else else

View file

@ -9,27 +9,25 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.listeners.ConfidenceListener; import io.bitsquare.btc.listeners.ConfidenceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.util.BitSquareFormatter; import io.bitsquare.gui.util.BitSquareFormatter;
import java.math.BigInteger;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.scene.control.Tooltip; import javafx.scene.control.Tooltip;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.math.BigInteger; class TransactionsListItem
public class TransactionsListItem
{ {
private static final Logger log = LoggerFactory.getLogger(TransactionsListItem.class); private static final Logger log = LoggerFactory.getLogger(TransactionsListItem.class);
private final StringProperty date = new SimpleStringProperty(); private final StringProperty date = new SimpleStringProperty();
private final StringProperty amount = new SimpleStringProperty(); private final StringProperty amount = new SimpleStringProperty();
private final StringProperty type = new SimpleStringProperty(); private final StringProperty type = new SimpleStringProperty();
private final Transaction transaction;
private final WalletFacade walletFacade;
private final ConfidenceProgressIndicator progressIndicator;
private final Tooltip tooltip;
private String addressString; private String addressString;
private Transaction transaction;
private WalletFacade walletFacade;
private ConfidenceListener confidenceListener; private ConfidenceListener confidenceListener;
private ConfidenceProgressIndicator progressIndicator;
private Tooltip tooltip;
public TransactionsListItem(Transaction transaction, WalletFacade walletFacade) public TransactionsListItem(Transaction transaction, WalletFacade walletFacade)
{ {

View file

@ -4,8 +4,8 @@
<?import javafx.scene.control.cell.PropertyValueFactory?> <?import javafx.scene.control.cell.PropertyValueFactory?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<VBox spacing="10" fx:controller="io.bitsquare.gui.funds.transactions.TransactionsController" xmlns="http://javafx.com/javafx/8" <VBox xmlns:fx="http://javafx.com/fxml/1" spacing="10" fx:controller="io.bitsquare.gui.funds.transactions.TransactionsController"
xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8">
<padding> <padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</padding> </padding>

View file

@ -11,15 +11,17 @@ import io.bitsquare.btc.*;
import io.bitsquare.gui.ChildController; import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.Hibernate; import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.popups.Popups;
import io.bitsquare.gui.util.BitSquareValidator; import io.bitsquare.gui.util.BitSquareValidator;
import io.bitsquare.gui.util.Popups; import java.math.BigInteger;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
@ -31,21 +33,16 @@ import org.controlsfx.dialog.Dialog;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
public class WithdrawalController implements Initializable, ChildController, Hibernate public class WithdrawalController implements Initializable, ChildController, Hibernate
{ {
private static final Logger log = LoggerFactory.getLogger(WithdrawalController.class); private static final Logger log = LoggerFactory.getLogger(WithdrawalController.class);
private WalletFacade walletFacade; private final WalletFacade walletFacade;
protected ObservableList<WithdrawalListItem> addressList; protected ObservableList<WithdrawalListItem> addressList;
@FXML @FXML
private TableView tableView; private TableView<WithdrawalListItem> tableView;
@FXML @FXML
private TableColumn<String, WithdrawalListItem> labelColumn, addressColumn, balanceColumn, copyColumn, confidenceColumn; private TableColumn<String, WithdrawalListItem> labelColumn, addressColumn, balanceColumn, copyColumn, confidenceColumn;
@FXML @FXML
@ -80,28 +77,23 @@ public class WithdrawalController implements Initializable, ChildController, Hib
setCopyColumnCellFactory(); setCopyColumnCellFactory();
setConfidenceColumnCellFactory(); setConfidenceColumnCellFactory();
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<WithdrawalListItem>() tableView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
{ if (newValue != null)
@Override
public void changed(ObservableValue<? extends WithdrawalListItem> observableValue, WithdrawalListItem oldValue, WithdrawalListItem newValue)
{ {
if (newValue != null) BitSquareValidator.resetTextFields(withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField);
{
BitSquareValidator.resetTextFields(withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField);
if (newValue.getBalance().compareTo(BigInteger.ZERO) > 0) if (newValue.getBalance().compareTo(BigInteger.ZERO) > 0)
{ {
amountTextField.setText(BtcFormatter.satoshiToString(newValue.getBalance())); amountTextField.setText(BtcFormatter.satoshiToString(newValue.getBalance()));
withdrawFromTextField.setText(newValue.getAddressEntry().getAddressString()); withdrawFromTextField.setText(newValue.getAddressEntry().getAddressString());
changeAddressTextField.setText(newValue.getAddressEntry().getAddressString()); changeAddressTextField.setText(newValue.getAddressEntry().getAddressString());
} }
else else
{ {
withdrawFromTextField.setText(""); withdrawFromTextField.setText("");
withdrawFromTextField.setPromptText("No fund to withdrawal on that address."); withdrawFromTextField.setPromptText("No fund to withdrawal on that address.");
amountTextField.setText(""); amountTextField.setText("");
amountTextField.setPromptText("Invalid amount"); amountTextField.setPromptText("Invalid amount");
}
} }
} }
}); });
@ -120,9 +112,9 @@ public class WithdrawalController implements Initializable, ChildController, Hib
@Override @Override
public void cleanup() public void cleanup()
{ {
for (int i = 0; i < addressList.size(); i++) for (WithdrawalListItem anAddressList : addressList)
{ {
addressList.get(i).cleanup(); anAddressList.cleanup();
} }
} }
@ -142,10 +134,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
{ {
List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList(); List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList();
addressList = FXCollections.observableArrayList(); addressList = FXCollections.observableArrayList();
for (int i = 0; i < addressEntryList.size(); i++) addressList.addAll(addressEntryList.stream().map(anAddressEntryList -> new WithdrawalListItem(anAddressEntryList, walletFacade)).collect(Collectors.toList()));
{
addressList.add(new WithdrawalListItem(addressEntryList.get(i), walletFacade));
}
tableView.setItems(addressList); tableView.setItems(addressList);
} }
@ -215,6 +204,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
} catch (BitSquareValidator.ValidationException e) } catch (BitSquareValidator.ValidationException e)
{ {
log.trace(e.toString());
} }
} }
@ -254,14 +244,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId()); Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId());
Tooltip.install(hyperlink, tooltip); Tooltip.install(hyperlink, tooltip);
hyperlink.setOnAction(new EventHandler<ActionEvent>() hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressEntry().getTradeId()));
{
@Override
public void handle(ActionEvent event)
{
log.info("Show trade details " + item.getAddressEntry().getTradeId());
}
});
} }
setGraphic(hyperlink); setGraphic(hyperlink);
} }
@ -315,7 +298,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
{ {
return new TableCell<String, WithdrawalListItem>() return new TableCell<String, WithdrawalListItem>()
{ {
Label copyIcon = new Label(); final Label copyIcon = new Label();
{ {
copyIcon.getStyleClass().add("copy-icon"); copyIcon.getStyleClass().add("copy-icon");

View file

@ -8,23 +8,22 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.btc.listeners.ConfidenceListener; import io.bitsquare.btc.listeners.ConfidenceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import java.math.BigInteger;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Tooltip; import javafx.scene.control.Tooltip;
import java.math.BigInteger;
public class WithdrawalListItem public class WithdrawalListItem
{ {
private final StringProperty addressString = new SimpleStringProperty(); private final StringProperty addressString = new SimpleStringProperty();
private final BalanceListener balanceListener; private final BalanceListener balanceListener;
private final Label balanceLabel; private final Label balanceLabel;
private AddressEntry addressEntry; private final AddressEntry addressEntry;
private WalletFacade walletFacade; private final WalletFacade walletFacade;
private ConfidenceListener confidenceListener; private final ConfidenceListener confidenceListener;
private ConfidenceProgressIndicator progressIndicator; private final ConfidenceProgressIndicator progressIndicator;
private Tooltip tooltip; private final Tooltip tooltip;
private BigInteger balance; private BigInteger balance;
public WithdrawalListItem(AddressEntry addressEntry, WalletFacade walletFacade) public WithdrawalListItem(AddressEntry addressEntry, WalletFacade walletFacade)

View file

@ -4,7 +4,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.control.cell.PropertyValueFactory?> <?import javafx.scene.control.cell.PropertyValueFactory?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<VBox spacing="10" fx:controller="io.bitsquare.gui.funds.withdrawal.WithdrawalController" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <VBox xmlns:fx="http://javafx.com/fxml/1" spacing="10" fx:controller="io.bitsquare.gui.funds.withdrawal.WithdrawalController" xmlns="http://javafx.com/javafx/8">
<padding> <padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</padding> </padding>
@ -27,22 +27,20 @@
<padding> <padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</padding> </padding>
<children>
<Label text="Amount (BTC):" GridPane.rowIndex="0"/> <Label text="Amount (BTC):" GridPane.rowIndex="0"/>
<TextField fx:id="amountTextField" GridPane.rowIndex="0" GridPane.columnIndex="1"/> <TextField fx:id="amountTextField" GridPane.rowIndex="0" GridPane.columnIndex="1"/>
<Label text="Withdraw from address:" GridPane.rowIndex="1"/> <Label text="Withdraw from address:" GridPane.rowIndex="1"/>
<TextField fx:id="withdrawFromTextField" promptText="Select a source address from the table" GridPane.rowIndex="1" GridPane.columnIndex="1"/> <TextField fx:id="withdrawFromTextField" promptText="Select a source address from the table" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
<Label text="Change address:" GridPane.rowIndex="2"/> <Label text="Change address:" GridPane.rowIndex="2"/>
<TextField fx:id="changeAddressTextField" GridPane.rowIndex="2" GridPane.columnIndex="1"/> <TextField fx:id="changeAddressTextField" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
<Label text="Withdraw to address:" GridPane.rowIndex="3"/> <Label text="Withdraw to address:" GridPane.rowIndex="3"/>
<TextField fx:id="withdrawToTextField" GridPane.rowIndex="3" GridPane.columnIndex="1"/> <TextField fx:id="withdrawToTextField" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
<Button text="Withdraw" defaultButton="true" onAction="#onWithdraw" GridPane.rowIndex="4" GridPane.columnIndex="1"/> <Button text="Withdraw" defaultButton="true" onAction="#onWithdraw" GridPane.rowIndex="4" GridPane.columnIndex="1"/>
</children>
<columnConstraints> <columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/> <ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>

View file

@ -8,6 +8,9 @@ import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.NavigationViewURL; import io.bitsquare.gui.NavigationViewURL;
import io.bitsquare.gui.arbitrators.registration.ArbitratorRegistrationController; import io.bitsquare.gui.arbitrators.registration.ArbitratorRegistrationController;
import io.bitsquare.locale.Localisation; import io.bitsquare.locale.Localisation;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
@ -18,16 +21,11 @@ import javafx.scene.layout.Pane;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
public class HomeController implements Initializable, ChildController, NavigationController public class HomeController implements Initializable, ChildController, NavigationController
{ {
private NavigationController navigationController;
@FXML @FXML
public Pane rootContainer; public Pane rootContainer;
private NavigationController navigationController;
private ArbitratorRegistrationController arbitratorRegistrationController; private ArbitratorRegistrationController arbitratorRegistrationController;
@Override @Override

View file

@ -1,19 +1,13 @@
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:controller="io.bitsquare.gui.home.HomeController" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" <AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="io.bitsquare.gui.home.HomeController" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0"
xmlns:fx="http://javafx.com/fxml"> AnchorPane.topAnchor="10.0">
<children> <VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <Label id="headline-label" text="Overview"/>
<children> <Label text="TODO"/>
<Label id="headline-label" text="Overview"/> <Button text="Register yourself as an arbitrator" onAction="#onArbitratorRegistration"/>
<Label text="TODO"/> <Button text="Edit my arbitrator details" onAction="#onArbitratorEdit"/>
</VBox>
<Button text="Register yourself as an arbitrator" onAction="#onArbitratorRegistration"/>
<Button text="Edit my arbitrator details" onAction="#onArbitratorEdit"/>
</children>
</VBox>
</children>
</AnchorPane> </AnchorPane>

View file

@ -8,16 +8,15 @@ import io.bitsquare.gui.NavigationViewURL;
import io.bitsquare.gui.market.orderbook.OrderBookController; import io.bitsquare.gui.market.orderbook.OrderBookController;
import io.bitsquare.locale.Localisation; import io.bitsquare.locale.Localisation;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.control.TabPane; import javafx.scene.control.TabPane;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
public class MarketController implements Initializable, NavigationController, ChildController public class MarketController implements Initializable, NavigationController, ChildController
{ {
private ChildController childController; private ChildController childController;

View file

@ -2,6 +2,6 @@
<?import javafx.scene.control.TabPane?> <?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<TabPane fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" <TabPane xmlns:fx="http://javafx.com/fxml/1" fx:id="tabPane" AnchorPane.bottomAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns:fx="http://javafx.com/fxml/1" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
fx:controller="io.bitsquare.gui.market.MarketController"/> fx:controller="io.bitsquare.gui.market.MarketController"/>

View file

@ -12,10 +12,10 @@ import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.NavigationViewURL; import io.bitsquare.gui.NavigationViewURL;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.popups.Popups;
import io.bitsquare.gui.util.BitSquareConverter; import io.bitsquare.gui.util.BitSquareConverter;
import io.bitsquare.gui.util.BitSquareFormatter; import io.bitsquare.gui.util.BitSquareFormatter;
import io.bitsquare.gui.util.ConfidenceDisplay; import io.bitsquare.gui.util.ConfidenceDisplay;
import io.bitsquare.gui.util.Popups;
import io.bitsquare.locale.Localisation; import io.bitsquare.locale.Localisation;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageFacade;
import io.bitsquare.settings.Settings; import io.bitsquare.settings.Settings;
@ -25,8 +25,11 @@ import io.bitsquare.trade.Trading;
import io.bitsquare.trade.orderbook.OrderBookFilter; import io.bitsquare.trade.orderbook.OrderBookFilter;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import javafx.beans.value.ChangeListener; import java.io.IOException;
import javafx.beans.value.ObservableValue; import java.math.BigInteger;
import java.net.URL;
import java.util.Random;
import java.util.ResourceBundle;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
@ -38,22 +41,15 @@ import javafx.scene.layout.AnchorPane;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URL;
import java.util.Random;
import java.util.ResourceBundle;
public class CreateOfferController implements Initializable, ChildController, Hibernate public class CreateOfferController implements Initializable, ChildController, Hibernate
{ {
private static final Logger log = LoggerFactory.getLogger(CreateOfferController.class); private static final Logger log = LoggerFactory.getLogger(CreateOfferController.class);
private final Trading trading;
private final WalletFacade walletFacade;
private final MessageFacade messageFacade;
private final Settings settings;
private final User user;
private NavigationController navigationController; private NavigationController navigationController;
private Trading trading;
private WalletFacade walletFacade;
private MessageFacade messageFacade;
private Settings settings;
private User user;
private Direction direction; private Direction direction;
private Offer offer; private Offer offer;
private ConfidenceDisplay confidenceDisplay; private ConfidenceDisplay confidenceDisplay;
@ -111,22 +107,8 @@ public class CreateOfferController implements Initializable, ChildController, Hi
collateralTextField.setText("10"); collateralTextField.setText("10");
updateVolume(); updateVolume();
amountTextField.textProperty().addListener(new ChangeListener<String>() amountTextField.textProperty().addListener((observable, oldValue, newValue) -> updateVolume());
{ priceTextField.textProperty().addListener((observable, oldValue, newValue) -> updateVolume());
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
{
updateVolume();
}
});
priceTextField.textProperty().addListener(new ChangeListener<String>()
{
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
{
updateVolume();
}
});
} }

View file

@ -4,105 +4,100 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="rootContainer" prefHeight="500" prefWidth="800" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="rootContainer" prefHeight="500" prefWidth="800" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0"
xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.market.createOffer.CreateOfferController"> AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.market.createOffer.CreateOfferController">
<children>
<GridPane hgap="5.0" vgap="5.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"> <GridPane hgap="5.0" vgap="5.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
<children> <Label id="form-header-text" text="Create new offer" GridPane.rowIndex="0"/>
<Label id="form-header-text" text="Create new offer" GridPane.rowIndex="0"/>
<Label fx:id="buyLabel" GridPane.rowIndex="1"/> <Label fx:id="buyLabel" GridPane.rowIndex="1"/>
<HBox spacing="5" GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="NEVER" alignment="CENTER_LEFT"> <HBox spacing="5" GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="NEVER" alignment="CENTER_LEFT">
<TextField fx:id="amountTextField" prefWidth="70.0" alignment="CENTER_RIGHT"/> <TextField fx:id="amountTextField" prefWidth="70.0" alignment="CENTER_RIGHT"/>
<Label text="BTC for:"/> <Label text="BTC for:"/>
<TextField fx:id="priceTextField" prefWidth="70.0" alignment="CENTER_RIGHT"/> <TextField fx:id="priceTextField" prefWidth="70.0" alignment="CENTER_RIGHT"/>
<Label text="EUR ="/> <Label text="EUR ="/>
<TextField fx:id="volumeTextField" prefWidth="70.0" alignment="CENTER_RIGHT" editable="false"/> <TextField fx:id="volumeTextField" prefWidth="70.0" alignment="CENTER_RIGHT" editable="false"/>
<Label text="EUR in total"/> <Label text="EUR in total"/>
</HBox> </HBox>
<Label text="Min. Amount:" GridPane.rowIndex="2"/> <Label text="Min. Amount:" GridPane.rowIndex="2"/>
<TextField fx:id="minAmountTextField" GridPane.columnIndex="1" GridPane.rowIndex="2"/> <TextField fx:id="minAmountTextField" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label text="Collateral (%):" GridPane.rowIndex="3"/> <Label text="Collateral (%):" GridPane.rowIndex="3"/>
<TextField fx:id="collateralTextField" GridPane.columnIndex="1" GridPane.rowIndex="3"/> <TextField fx:id="collateralTextField" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Label id="form-header-text" text="Offer details" GridPane.rowIndex="4"> <Label id="form-header-text" text="Offer details" GridPane.rowIndex="4">
<GridPane.margin> <GridPane.margin>
<Insets top="10.0"/> <Insets top="10.0"/>
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<Label text="Bank account type:" GridPane.rowIndex="5"/> <Label text="Bank account type:" GridPane.rowIndex="5"/>
<TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5"/> <TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
<Label text="Bank account currency:" GridPane.rowIndex="6"/> <Label text="Bank account currency:" GridPane.rowIndex="6"/>
<TextField fx:id="bankAccountCurrencyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="6"/> <TextField fx:id="bankAccountCurrencyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
<Label text="Bank account county:" GridPane.rowIndex="7"/> <Label text="Bank account county:" GridPane.rowIndex="7"/>
<TextField fx:id="bankAccountCountyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="7"/> <TextField fx:id="bankAccountCountyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="7"/>
<Label text="Accepted countries:" GridPane.rowIndex="8"/> <Label text="Accepted countries:" GridPane.rowIndex="8"/>
<TextField fx:id="acceptedCountriesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8"/> <TextField fx:id="acceptedCountriesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8"/>
<Label text="Accepted languages:" GridPane.rowIndex="9"/> <Label text="Accepted languages:" GridPane.rowIndex="9"/>
<TextField fx:id="acceptedLanguagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9"/> <TextField fx:id="acceptedLanguagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
<Label id="form-header-text" fx:id="placeOfferTitle" text="Place offer:" GridPane.rowIndex="10"> <Label id="form-header-text" fx:id="placeOfferTitle" text="Place offer:" GridPane.rowIndex="10">
<GridPane.margin> <GridPane.margin>
<Insets top="10.0"/> <Insets top="10.0"/>
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<Label text="Offer fee:" GridPane.rowIndex="11"/> <Label text="Offer fee:" GridPane.rowIndex="11"/>
<TextField fx:id="feeLabel" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="11"/> <TextField fx:id="feeLabel" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="11"/>
<Button fx:id="placeOfferButton" defaultButton="true" onAction="#onPlaceOffer" text="Place offer" GridPane.columnIndex="1" GridPane.rowIndex="12"/> <Button fx:id="placeOfferButton" defaultButton="true" onAction="#onPlaceOffer" text="Place offer" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
<Label fx:id="txTitleLabel" text="Transaction ID:" visible="false" GridPane.rowIndex="12"/> <Label fx:id="txTitleLabel" text="Transaction ID:" visible="false" GridPane.rowIndex="12"/>
<TextField fx:id="txTextField" visible="false" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="12"/> <TextField fx:id="txTextField" visible="false" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
<ConfidenceProgressIndicator fx:id="progressIndicator" visible="false" progress="0" GridPane.columnIndex="2" GridPane.halignment="LEFT" <ConfidenceProgressIndicator fx:id="progressIndicator" visible="false" progress="0" GridPane.columnIndex="2" GridPane.halignment="LEFT"
GridPane.rowIndex="12" GridPane.rowSpan="2" GridPane.valignment="TOP"> GridPane.rowIndex="12" GridPane.rowSpan="2" GridPane.valignment="TOP">
<GridPane.margin> <GridPane.margin>
<Insets top="2.0"/> <Insets top="2.0"/>
</GridPane.margin> </GridPane.margin>
</ConfidenceProgressIndicator> </ConfidenceProgressIndicator>
<Label fx:id="confirmationLabel" text="Checking confirmations..." visible="false" GridPane.columnIndex="3" GridPane.rowIndex="12"/> <Label fx:id="confirmationLabel" text="Checking confirmations..." visible="false" GridPane.columnIndex="3" GridPane.rowIndex="12"/>
<Button fx:id="closeButton" visible="false" defaultButton="true" onAction="#onClose" text="Close" GridPane.columnIndex="1" GridPane.rowIndex="13"/> <Button fx:id="closeButton" visible="false" defaultButton="true" onAction="#onClose" text="Close" GridPane.columnIndex="1" GridPane.rowIndex="13"/>
</children> <columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS" minWidth="400"/>
<ColumnConstraints hgrow="SOMETIMES" prefWidth="20.0" minWidth="20"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
</rowConstraints>
<opaqueInsets>
<Insets/>
</opaqueInsets>
<columnConstraints> </GridPane>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS" minWidth="400"/>
<ColumnConstraints hgrow="SOMETIMES" prefWidth="20.0" minWidth="20"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
</rowConstraints>
<opaqueInsets>
<Insets/>
</opaqueInsets>
</GridPane>
</children>
</AnchorPane> </AnchorPane>

View file

@ -11,10 +11,10 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.*; import io.bitsquare.gui.*;
import io.bitsquare.gui.market.createOffer.CreateOfferController; import io.bitsquare.gui.market.createOffer.CreateOfferController;
import io.bitsquare.gui.market.trade.TakerTradeController; import io.bitsquare.gui.market.trade.TakerTradeController;
import io.bitsquare.gui.popups.Popups;
import io.bitsquare.gui.util.BitSquareConverter; import io.bitsquare.gui.util.BitSquareConverter;
import io.bitsquare.gui.util.BitSquareFormatter; import io.bitsquare.gui.util.BitSquareFormatter;
import io.bitsquare.gui.util.Icons; import io.bitsquare.gui.util.Icons;
import io.bitsquare.gui.util.Popups;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.CurrencyUtil; import io.bitsquare.locale.CurrencyUtil;
import io.bitsquare.locale.Localisation; import io.bitsquare.locale.Localisation;
@ -28,10 +28,16 @@ import io.bitsquare.trade.orderbook.OrderBookFilter;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil; import io.bitsquare.util.DSAKeyUtil;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
import java.math.BigInteger;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import javafx.animation.AnimationTimer; import javafx.animation.AnimationTimer;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.transformation.SortedList; import javafx.collections.transformation.SortedList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
@ -48,32 +54,18 @@ import org.controlsfx.dialog.Dialogs;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
public class OrderBookController implements Initializable, ChildController public class OrderBookController implements Initializable, ChildController
{ {
private static final Logger log = LoggerFactory.getLogger(OrderBookController.class); private static final Logger log = LoggerFactory.getLogger(OrderBookController.class);
private NavigationController navigationController; private final OrderBook orderBook;
private OrderBook orderBook;
private SortedList<OrderBookListItem> offerList;
private final OrderBookFilter orderBookFilter; private final OrderBookFilter orderBookFilter;
private User user; private final User user;
private MessageFacade messageFacade; private final MessageFacade messageFacade;
private WalletFacade walletFacade; private final WalletFacade walletFacade;
private Settings settings; private final Settings settings;
private Storage storage; private final Storage storage;
private AnimationTimer pollingTimer; private final Image buyIcon = Icons.getIconImage(Icons.BUY);
private Image buyIcon = Icons.getIconImage(Icons.BUY); private final Image sellIcon = Icons.getIconImage(Icons.SELL);
private Image sellIcon = Icons.getIconImage(Icons.SELL);
@FXML @FXML
public AnchorPane holderPane; public AnchorPane holderPane;
@FXML @FXML
@ -83,11 +75,14 @@ public class OrderBookController implements Initializable, ChildController
@FXML @FXML
public TableView<OrderBookListItem> orderBookTable; public TableView<OrderBookListItem> orderBookTable;
@FXML @FXML
public TableColumn priceColumn, amountColumn, volumeColumn; public TableColumn<OrderBookListItem, String> priceColumn, amountColumn, volumeColumn;
@FXML
private TableColumn<String, OrderBookListItem> directionColumn, countryColumn, bankAccountTypeColumn;
@FXML @FXML
public Button createOfferButton; public Button createOfferButton;
private NavigationController navigationController;
private SortedList<OrderBookListItem> offerList;
private AnimationTimer pollingTimer;
@FXML
private TableColumn<String, OrderBookListItem> directionColumn, countryColumn, bankAccountTypeColumn;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -129,43 +124,19 @@ public class OrderBookController implements Initializable, ChildController
orderBook.loadOffers(); orderBook.loadOffers();
// handlers // handlers
amount.textProperty().addListener(new ChangeListener<String>() amount.textProperty().addListener((observable, oldValue, newValue) -> {
{ orderBookFilter.setAmount(textInputToNumber(oldValue, newValue));
@Override updateVolume();
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
{
orderBookFilter.setAmount(textInputToNumber(oldValue, newValue));
updateVolume();
}
}); });
price.textProperty().addListener(new ChangeListener<String>() price.textProperty().addListener((observable, oldValue, newValue) -> {
{ orderBookFilter.setPrice(textInputToNumber(oldValue, newValue));
@Override updateVolume();
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
{
orderBookFilter.setPrice(textInputToNumber(oldValue, newValue));
updateVolume();
}
}); });
orderBookFilter.getDirectionChangedProperty().addListener(new ChangeListener<Boolean>() orderBookFilter.getDirectionChangedProperty().addListener((observable, oldValue, newValue) -> applyOffers());
{
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue)
{
applyOffers();
}
});
user.getBankAccountChangedProperty().addListener(new ChangeListener<Boolean>() user.getBankAccountChangedProperty().addListener((observable, oldValue, newValue) -> orderBook.loadOffers());
{
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue)
{
orderBook.loadOffers();
}
});
createOfferButton.setOnAction(e -> createOffer()); createOfferButton.setOnAction(e -> createOffer());
@ -369,13 +340,7 @@ public class OrderBookController implements Initializable, ChildController
private void removeOffer(Offer offer) private void removeOffer(Offer offer)
{ {
try orderBook.removeOffer(offer);
{
orderBook.removeOffer(offer);
} catch (IOException e)
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
} }
private void applyOffers() private void applyOffers()
@ -393,28 +358,13 @@ public class OrderBookController implements Initializable, ChildController
{ {
pollingTimer = Utilities.setInterval(1000, (AnimationTimer animationTimer) -> { pollingTimer = Utilities.setInterval(1000, (AnimationTimer animationTimer) -> {
try if (user.getCurrentBankAccount() != null)
{ messageFacade.getDirtyFlag(user.getCurrentBankAccount().getCurrency());
if (user.getCurrentBankAccount() != null) else
messageFacade.getDirtyFlag(user.getCurrentBankAccount().getCurrency()); messageFacade.getDirtyFlag(CurrencyUtil.getDefaultCurrency());
else
messageFacade.getDirtyFlag(CurrencyUtil.getDefaultCurrency());
} catch (IOException e)
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return null; return null;
}); });
messageFacade.getIsDirtyProperty().addListener(new ChangeListener<Boolean>() messageFacade.getIsDirtyProperty().addListener((observableValue, oldValue, newValue) -> orderBook.loadOffers());
{
@Override
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue)
{
//log.info("getIsDirtyProperty changed " + oldValue + "/" + newValue);
orderBook.loadOffers();
}
});
} }

View file

@ -12,7 +12,7 @@ public class OrderBookListItem
protected final StringProperty amount = new SimpleStringProperty(); protected final StringProperty amount = new SimpleStringProperty();
protected final StringProperty volume = new SimpleStringProperty(); protected final StringProperty volume = new SimpleStringProperty();
protected Offer offer; protected final Offer offer;
public OrderBookListItem(Offer offer) public OrderBookListItem(Offer offer)

View file

@ -4,69 +4,65 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.control.cell.PropertyValueFactory?> <?import javafx.scene.control.cell.PropertyValueFactory?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="holderPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="holderPane" AnchorPane.bottomAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns:fx="http://javafx.com/fxml/1" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
fx:controller="io.bitsquare.gui.market.orderbook.OrderBookController"> fx:controller="io.bitsquare.gui.market.orderbook.OrderBookController">
<children>
<HBox fx:id="topHBox" prefHeight="22.0" AnchorPane.topAnchor="10.0" AnchorPane.leftAnchor="10.0" <HBox fx:id="topHBox" prefHeight="22.0" AnchorPane.topAnchor="10.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0"> AnchorPane.rightAnchor="10.0">
<children> <TextField fx:id="amount" prefHeight="26.0" prefWidth="60.0" alignment="CENTER_RIGHT">
<TextField fx:id="amount" prefHeight="26.0" prefWidth="60.0" alignment="CENTER_RIGHT"> <HBox.margin>
<HBox.margin> <Insets left="0.0"/>
<Insets left="0.0"/> </HBox.margin>
</HBox.margin> </TextField>
</TextField> <Label text="BTC for">
<Label text="BTC for"> <padding>
<padding> <Insets left="4.0" right="4.0" top="5.0"/>
<Insets left="4.0" right="4.0" top="5.0"/> </padding>
</padding> </Label>
</Label> <TextField fx:id="price" prefHeight="26.0" prefWidth="70.0" alignment="CENTER_RIGHT"/>
<TextField fx:id="price" prefHeight="26.0" prefWidth="70.0" alignment="CENTER_RIGHT"/> <Label text="EUR/BTC =">
<Label text="EUR/BTC ="> <padding>
<padding> <Insets left="4.0" right="4.0" top="5.0"/>
<Insets left="4.0" right="4.0" top="5.0"/> </padding>
</padding> </Label>
</Label> <TextField fx:id="volume" prefHeight="26.0" prefWidth="70.0" alignment="CENTER_RIGHT" editable="false"/>
<TextField fx:id="volume" prefHeight="26.0" prefWidth="70.0" alignment="CENTER_RIGHT" editable="false"/> <Label prefHeight="21.0" prefWidth="100.0" text="EUR in total">
<Label prefHeight="21.0" prefWidth="100.0" text="EUR in total"> <padding>
<padding> <Insets left="4.0" right="4.0" top="5.0"/>
<Insets left="4.0" right="4.0" top="5.0"/> </padding>
</padding> <HBox.margin>
<HBox.margin> <Insets/>
<Insets/> </HBox.margin>
</HBox.margin> </Label>
</Label> </HBox>
</children>
</HBox>
<Button fx:id="createOfferButton" text="Create new offer" AnchorPane.topAnchor="10.0" <Button fx:id="createOfferButton" text="Create new offer" AnchorPane.topAnchor="10.0"
AnchorPane.rightAnchor="10.0"/> AnchorPane.rightAnchor="10.0"/>
<TableView fx:id="orderBookTable" AnchorPane.leftAnchor="10.0" <TableView fx:id="orderBookTable" AnchorPane.leftAnchor="10.0"
AnchorPane.topAnchor="45.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0"> AnchorPane.topAnchor="45.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0">
<columns> <columns>
<TableColumn text="Amount (Min.)" fx:id="amountColumn" minWidth="120"> <TableColumn text="Amount (Min.)" fx:id="amountColumn" minWidth="120">
<cellValueFactory> <cellValueFactory>
<PropertyValueFactory property="amount"/> <PropertyValueFactory property="amount"/>
</cellValueFactory> </cellValueFactory>
</TableColumn> </TableColumn>
<TableColumn text="Price" fx:id="priceColumn" minWidth="70"> <TableColumn text="Price" fx:id="priceColumn" minWidth="70">
<cellValueFactory> <cellValueFactory>
<PropertyValueFactory property="price"/> <PropertyValueFactory property="price"/>
</cellValueFactory> </cellValueFactory>
</TableColumn> </TableColumn>
<TableColumn text="Volume (Min.)" fx:id="volumeColumn" minWidth="130"> <TableColumn text="Volume (Min.)" fx:id="volumeColumn" minWidth="130">
<cellValueFactory> <cellValueFactory>
<PropertyValueFactory property="volume"/> <PropertyValueFactory property="volume"/>
</cellValueFactory> </cellValueFactory>
</TableColumn> </TableColumn>
<TableColumn text="Country" fx:id="countryColumn" minWidth="60"/> <TableColumn text="Country" fx:id="countryColumn" minWidth="60"/>
<TableColumn text="Bank transfer type" fx:id="bankAccountTypeColumn" minWidth="140"/> <TableColumn text="Bank transfer type" fx:id="bankAccountTypeColumn" minWidth="140"/>
<TableColumn text="" fx:id="directionColumn" minWidth="80" sortable="false"/> <TableColumn text="" fx:id="directionColumn" minWidth="80" sortable="false"/>
</columns> </columns>
</TableView> </TableView>
</children>
</AnchorPane> </AnchorPane>

View file

@ -9,10 +9,10 @@ import io.bitsquare.gui.NavigationViewURL;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.components.processbar.ProcessStepBar; import io.bitsquare.gui.components.processbar.ProcessStepBar;
import io.bitsquare.gui.components.processbar.ProcessStepItem; import io.bitsquare.gui.components.processbar.ProcessStepItem;
import io.bitsquare.gui.popups.Popups;
import io.bitsquare.gui.util.BitSquareConverter; import io.bitsquare.gui.util.BitSquareConverter;
import io.bitsquare.gui.util.BitSquareFormatter; import io.bitsquare.gui.util.BitSquareFormatter;
import io.bitsquare.gui.util.FormBuilder; import io.bitsquare.gui.util.FormBuilder;
import io.bitsquare.gui.util.Popups;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.TradeMessage; import io.bitsquare.msg.TradeMessage;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
@ -22,6 +22,11 @@ import io.bitsquare.trade.Trading;
import io.bitsquare.trade.payment.taker.TakerPaymentProtocol; import io.bitsquare.trade.payment.taker.TakerPaymentProtocol;
import io.bitsquare.trade.payment.taker.TakerPaymentProtocolListener; import io.bitsquare.trade.payment.taker.TakerPaymentProtocolListener;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
import java.math.BigInteger;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import javafx.animation.AnimationTimer; import javafx.animation.AnimationTimer;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
@ -32,26 +37,20 @@ import javafx.scene.layout.Pane;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
public class TakerTradeController implements Initializable, ChildController public class TakerTradeController implements Initializable, ChildController
{ {
private static final Logger log = LoggerFactory.getLogger(TakerTradeController.class); private static final Logger log = LoggerFactory.getLogger(TakerTradeController.class);
private Trading trading; private final Trading trading;
private WalletFacade walletFacade; private final WalletFacade walletFacade;
private BlockChainFacade blockChainFacade; private final BlockChainFacade blockChainFacade;
private MessageFacade messageFacade; private final MessageFacade messageFacade;
private final List<ProcessStepItem> processStepItems = new ArrayList<>();
private Offer offer; private Offer offer;
private Trade trade; private Trade trade;
private BigInteger requestedAmount; private BigInteger requestedAmount;
private boolean offererIsOnline; private boolean offererIsOnline;
private int row; private int row;
private List<ProcessStepItem> processStepItems = new ArrayList();
private NavigationController navigationController; private NavigationController navigationController;
private TextField amountTextField, totalToPayLabel, totalLabel, collateralTextField, isOnlineTextField; private TextField amountTextField, totalToPayLabel, totalLabel, collateralTextField, isOnlineTextField;
private Label statusTextField, infoLabel; private Label statusTextField, infoLabel;
@ -474,8 +473,7 @@ public class TakerTradeController implements Initializable, ChildController
{ {
double amount = BitSquareConverter.stringToDouble2(amountTextField.getText()); double amount = BitSquareConverter.stringToDouble2(amountTextField.getText());
double resultDouble = amount * (double) offer.getCollateral() / 100.0; double resultDouble = amount * (double) offer.getCollateral() / 100.0;
BigInteger result = BtcFormatter.doubleValueToSatoshis(resultDouble); return BtcFormatter.doubleValueToSatoshis(resultDouble);
return result;
} }
private BigInteger getAmountInSatoshis() private BigInteger getAmountInSatoshis()

View file

@ -5,29 +5,27 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.ScrollPane?> <?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="rootContainer" fx:controller="io.bitsquare.gui.market.trade.TakerTradeController" <AnchorPane xmlns:fx="http://javafx.com/fxml" fx:id="rootContainer"
xmlns:fx="http://javafx.com/fxml"> fx:controller="io.bitsquare.gui.market.trade.TakerTradeController">
<ScrollPane fitToWidth="true" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" <ScrollPane fitToWidth="true" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
AnchorPane.bottomAnchor="0"> AnchorPane.bottomAnchor="0">
<content> <VBox spacing="10">
<VBox spacing="10"> <padding>
<Insets left="10" right="10" top="10" bottom="10"/>
</padding>
<ProcessStepBar fx:id="processStepBar"/>
<VSpacer prefHeight="5"/>
<GridPane fx:id="gridPane" vgap="5" hgap="5">
<padding> <padding>
<Insets left="10" right="10" top="10" bottom="10"/> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding> </padding>
<ProcessStepBar fx:id="processStepBar"/> <columnConstraints>
<VSpacer prefHeight="5"/> <ColumnConstraints halignment="RIGHT"/>
<GridPane fx:id="gridPane" vgap="5" hgap="5"> <ColumnConstraints halignment="LEFT" prefWidth="400"/>
<padding> <ColumnConstraints halignment="LEFT"/>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/> </columnConstraints>
</padding> </GridPane>
<columnConstraints> </VBox>
<ColumnConstraints halignment="RIGHT"/>
<ColumnConstraints halignment="LEFT" prefWidth="400"/>
<ColumnConstraints halignment="LEFT"/>
</columnConstraints>
</GridPane>
</VBox>
</content>
</ScrollPane> </ScrollPane>
</AnchorPane> </AnchorPane>

View file

@ -3,13 +3,12 @@ package io.bitsquare.gui.msg;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.bitsquare.gui.ChildController; import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class MsgController implements Initializable, ChildController public class MsgController implements Initializable, ChildController
{ {
private static final Logger log = LoggerFactory.getLogger(MsgController.class); private static final Logger log = LoggerFactory.getLogger(MsgController.class);

View file

@ -2,16 +2,12 @@
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:controller="io.bitsquare.gui.msg.MsgController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.msg.MsgController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8">
<children> <VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label id="headline-label" text="Message"/> <Label id="headline-label" text="Message"/>
</children> </VBox>
</VBox>
</children>
</AnchorPane> </AnchorPane>

View file

@ -7,18 +7,17 @@ import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.NavigationViewURL; import io.bitsquare.gui.NavigationViewURL;
import io.bitsquare.gui.components.LazyLoadingTabPane; import io.bitsquare.gui.components.LazyLoadingTabPane;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class OrdersController implements Initializable, ChildController, NavigationController public class OrdersController implements Initializable, ChildController, NavigationController
{ {
private static final Logger log = LoggerFactory.getLogger(OrdersController.class); private static final Logger log = LoggerFactory.getLogger(OrdersController.class);
private Storage storage; private final Storage storage;
@FXML @FXML
private LazyLoadingTabPane tabPane; private LazyLoadingTabPane tabPane;

View file

@ -3,8 +3,8 @@
<?import io.bitsquare.gui.components.LazyLoadingTabPane?> <?import io.bitsquare.gui.components.LazyLoadingTabPane?>
<?import javafx.scene.control.Tab?> <?import javafx.scene.control.Tab?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<LazyLoadingTabPane fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" <LazyLoadingTabPane xmlns:fx="http://javafx.com/fxml/1" fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.orders.OrdersController"> xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.orders.OrdersController">
<Tab text="Open offers" closable="false"/> <Tab text="Open offers" closable="false"/>
<Tab text="Pending trades" closable="false"/> <Tab text="Pending trades" closable="false"/>

View file

@ -4,13 +4,12 @@ import com.google.inject.Inject;
import io.bitsquare.gui.ChildController; import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.Hibernate; import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class ClosedTradeController implements Initializable, ChildController, Hibernate public class ClosedTradeController implements Initializable, ChildController, Hibernate
{ {
private static final Logger log = LoggerFactory.getLogger(ClosedTradeController.class); private static final Logger log = LoggerFactory.getLogger(ClosedTradeController.class);

View file

@ -2,16 +2,12 @@
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:controller="io.bitsquare.gui.orders.closed.ClosedTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.orders.closed.ClosedTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8">
<children> <VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label id="headline-label" text="Closed"/> <Label id="headline-label" text="Closed"/>
</children> </VBox>
</VBox>
</children>
</AnchorPane> </AnchorPane>

View file

@ -7,11 +7,15 @@ import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.util.Icons; import io.bitsquare.gui.util.Icons;
import io.bitsquare.trade.Offer; import io.bitsquare.trade.Offer;
import io.bitsquare.trade.Trading; import io.bitsquare.trade.Trading;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
@ -20,23 +24,15 @@ import javafx.util.Callback;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
public class OfferController implements Initializable, ChildController, Hibernate public class OfferController implements Initializable, ChildController, Hibernate
{ {
private static final Logger log = LoggerFactory.getLogger(OfferController.class); private static final Logger log = LoggerFactory.getLogger(OfferController.class);
private final Trading trading;
protected ObservableList<OfferListItem> offerListItems; protected ObservableList<OfferListItem> offerListItems;
@FXML @FXML
private TableColumn<String, OfferListItem> offerIdColumn, dateColumn, amountColumn, priceColumn, volumeColumn, removeColumn; private TableColumn<String, OfferListItem> offerIdColumn, dateColumn, amountColumn, priceColumn, volumeColumn, removeColumn;
@FXML @FXML
private TableView offerTable; private TableView<OfferListItem> offerTable;
private Trading trading;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -96,10 +92,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
offerListItems = FXCollections.observableArrayList(); offerListItems = FXCollections.observableArrayList();
Map<String, Offer> offerMap = trading.getOffers(); Map<String, Offer> offerMap = trading.getOffers();
List<Offer> offerList = new ArrayList<>(offerMap.values()); List<Offer> offerList = new ArrayList<>(offerMap.values());
for (int i = 0; i < offerList.size(); i++) offerListItems.addAll(offerList.stream().map(OfferListItem::new).collect(Collectors.toList()));
{
offerListItems.add(new OfferListItem(offerList.get(i)));
}
offerTable.setItems(offerListItems); offerTable.setItems(offerListItems);
} }
@ -116,14 +109,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
private void removeOffer(OfferListItem offerListItem) private void removeOffer(OfferListItem offerListItem)
{ {
try trading.removeOffer(offerListItem.getOffer());
{
trading.removeOffer(offerListItem.getOffer());
} catch (IOException e)
{
e.printStackTrace();
}
offerListItems.remove(offerListItem); offerListItems.remove(offerListItem);
} }
@ -161,14 +147,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
{ {
Tooltip tooltip = new Tooltip(item.getOfferId()); Tooltip tooltip = new Tooltip(item.getOfferId());
Tooltip.install(hyperlink, tooltip); Tooltip.install(hyperlink, tooltip);
hyperlink.setOnAction(new EventHandler<ActionEvent>() hyperlink.setOnAction(event -> openOfferDetails(item));
{
@Override
public void handle(ActionEvent event)
{
openOfferDetails(item);
}
});
} }
setGraphic(hyperlink); setGraphic(hyperlink);
} }

View file

@ -12,8 +12,8 @@ public class OfferListItem
protected final StringProperty amount = new SimpleStringProperty(); protected final StringProperty amount = new SimpleStringProperty();
protected final StringProperty date = new SimpleStringProperty(); protected final StringProperty date = new SimpleStringProperty();
protected final StringProperty volume = new SimpleStringProperty(); protected final StringProperty volume = new SimpleStringProperty();
protected final Offer offer;
private final String offerId; private final String offerId;
protected Offer offer;
public OfferListItem(Offer offer) public OfferListItem(Offer offer)
{ {

View file

@ -4,8 +4,8 @@
<?import javafx.scene.control.cell.*?> <?import javafx.scene.control.cell.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<VBox spacing="10" fx:controller="io.bitsquare.gui.orders.offer.OfferController" xmlns="http://javafx.com/javafx/8" <VBox xmlns:fx="http://javafx.com/fxml/1" spacing="10" fx:controller="io.bitsquare.gui.orders.offer.OfferController"
xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8">
<padding> <padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</padding> </padding>

View file

@ -4,13 +4,12 @@ import com.google.inject.Inject;
import io.bitsquare.gui.ChildController; import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.Hibernate; import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class PendingTradeController implements Initializable, ChildController, Hibernate public class PendingTradeController implements Initializable, ChildController, Hibernate
{ {
private static final Logger log = LoggerFactory.getLogger(PendingTradeController.class); private static final Logger log = LoggerFactory.getLogger(PendingTradeController.class);

View file

@ -2,16 +2,12 @@
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8">
<children> <VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label id="headline-label" text="Pending"/> <Label id="headline-label" text="Pending"/>
</children> </VBox>
</VBox>
</children>
</AnchorPane> </AnchorPane>

View file

@ -9,7 +9,7 @@ public class TradesTableItem extends OrderBookListItem
{ {
private static final Logger log = LoggerFactory.getLogger(TradesTableItem.class); private static final Logger log = LoggerFactory.getLogger(TradesTableItem.class);
private Trade trade; private final Trade trade;
public TradesTableItem(Trade trade) public TradesTableItem(Trade trade)
{ {

View file

@ -0,0 +1,155 @@
package io.bitsquare.gui.popups;
import com.google.bitcoin.store.BlockStoreException;
import com.google.common.base.Throwables;
import io.bitsquare.BitSquare;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Platform;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
import org.controlsfx.dialog.Dialogs;
public class Popups
{
// Information
public static void openInformationPopup(String title, String message)
{
openInformationPopup(title, message, null);
}
public static void openInformationPopup(String title, String message, String masthead)
{
Dialogs.create()
.owner(BitSquare.getStage())
.title(title)
.message(message)
.masthead(masthead)
.showInformation();
}
// Confirm
public static void openConfirmPopup(String title, String message)
{
openConfirmPopup(title, message, null);
}
public static Action openConfirmPopup(String title, String message, String masthead)
{
List<Action> actions = new ArrayList<>();
actions.add(Dialog.Actions.OK);
actions.add(Dialog.Actions.CANCEL);
return Dialogs.create()
.owner(BitSquare.getStage())
.title(title)
.message(message)
.masthead(masthead)
.actions(actions)
.showConfirm();
}
// Warning
public static void openWarningPopup(String message)
{
openWarningPopup("Warning", message, null);
}
public static void openWarningPopup(String title, String message)
{
openWarningPopup(title, message, null);
}
public static void openWarningPopup(String title, String message, String masthead)
{
Dialogs.create()
.owner(BitSquare.getStage())
.title(title)
.message(message)
.masthead(masthead)
.showWarning();
}
// Error
public static Action openErrorPopup(String message)
{
return openErrorPopup("Error", message);
}
public static Action openErrorPopup(String title, String message)
{
return openErrorPopup(title, message, null);
}
public static Action openErrorPopup(String title, String message, String masthead)
{
return Dialogs.create()
.owner(BitSquare.getStage())
.title(title)
.message(message)
.masthead(masthead)
.showError();
}
// Exception
public static Action openExceptionPopup(Throwable throwable)
{
return openExceptionPopup(throwable, "Exception", "That should not have happened...");
}
public static Action openExceptionPopup(Throwable throwable, String title, String message)
{
return openExceptionPopup(throwable, title, message, null);
}
public static Action openExceptionPopup(Throwable throwable, String title, String message, String masthead)
{
return Dialogs.create()
.owner(BitSquare.getStage())
.title(title)
.message(message)
.masthead(masthead)
.showException(throwable);
}
// Support handling of uncaught exception from any thread (also non gui thread)
public static void handleUncaughtExceptions(Throwable throwable)
{
Runnable runnable = () ->
{
if (Throwables.getRootCause(throwable) instanceof BlockStoreException)
{
Action response = Popups.openErrorPopup("Application already running", "This application is already running and cannot be started twice.", "");
if (response == Dialog.Actions.OK)
Platform.exit();
}
else
{
Action response = Popups.openExceptionPopup(throwable, "Exception", "", "A critical error has occurred.\nPlease copy the exception details and send a bug report to bugs@bitsquare.io.");
if (response == Dialog.Actions.OK)
Platform.exit();
}
};
if (Platform.isFxApplicationThread())
runnable.run();
else
Platform.runLater(runnable);
}
// custom
public static void openInsufficientMoneyPopup()
{
openWarningPopup("Not enough money available", "There is not enough money available. Please pay in first to your wallet.", null);
}
public static Action openRegistrationMissingPopup(String title, String message, String masthead, List<Dialogs.CommandLink> commandLinks, int selectedIndex)
{
return Dialogs.create()
.owner(BitSquare.getStage())
.title(title)
.message(message)
.masthead(masthead)
.showCommandLinks(commandLinks.get(selectedIndex), commandLinks);
}
}

View file

@ -22,10 +22,12 @@ import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.Reputation; import io.bitsquare.user.Reputation;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil; import io.bitsquare.util.DSAKeyUtil;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.geometry.Pos; import javafx.geometry.Pos;
@ -37,26 +39,21 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.util.Callback; import javafx.util.Callback;
import javafx.util.StringConverter; import javafx.util.StringConverter;
import java.io.IOException;
import java.net.URL;
import java.util.*;
// TODO separate in 2 view/controllers // TODO separate in 2 view/controllers
public class SettingsController implements Initializable, ChildController, NavigationController public class SettingsController implements Initializable, ChildController, NavigationController
{ {
private User user; private final User user;
private Settings settings; private final Settings settings;
private Storage storage; private final Storage storage;
private WalletFacade walletFacade; private final WalletFacade walletFacade;
private MessageFacade messageFacade; private final MessageFacade messageFacade;
private final ObservableList<Locale> languageList;
private final ObservableList<Country> countryList;
private NavigationController navigationController; private NavigationController navigationController;
private ChildController childController; private ChildController childController;
private ObservableList<Locale> languageList;
private ObservableList<Country> countryList;
private List<String> regionList; private List<String> regionList;
private ObservableList<Arbitrator> arbitratorList; private ObservableList<Arbitrator> arbitratorList;
private Region selectedRegion, selectedBankAccountRegion; private Region selectedRegion, selectedBankAccountRegion;
@ -240,14 +237,9 @@ public class SettingsController implements Initializable, ChildController, Navig
stage.initOwner(rootStage); stage.initOwner(rootStage);
Scene scene = new Scene((Parent) view, 800, 600); Scene scene = new Scene((Parent) view, 800, 600);
stage.setScene(scene); stage.setScene(scene);
stage.setOnHidden(new EventHandler<WindowEvent>() stage.setOnHidden(windowEvent -> {
{ if (fxmlView.equals(NavigationViewURL.ARBITRATOR_OVERVIEW))
@Override updateArbitrators();
public void handle(WindowEvent windowEvent)
{
if (fxmlView.equals(NavigationViewURL.ARBITRATOR_OVERVIEW))
updateArbitrators();
}
}); });
stage.show(); stage.show();
@ -399,15 +391,7 @@ public class SettingsController implements Initializable, ChildController, Navig
{ {
label.setText(item.getDisplayName()); label.setText(item.getDisplayName());
removeButton.setOnAction(new EventHandler<ActionEvent>() removeButton.setOnAction(actionEvent -> removeLanguage(item));
{
@Override
public void handle(ActionEvent actionEvent)
{
removeLanguage(item);
}
});
setGraphic(hBox); setGraphic(hBox);
} }
@ -491,15 +475,7 @@ public class SettingsController implements Initializable, ChildController, Navig
{ {
label.setText(item.getName()); label.setText(item.getName());
removeButton.setOnAction(new EventHandler<ActionEvent>() removeButton.setOnAction(actionEvent -> removeCountry(item));
{
@Override
public void handle(ActionEvent actionEvent)
{
removeCountry(item);
}
});
setGraphic(hBox); setGraphic(hBox);
} }
@ -567,15 +543,7 @@ public class SettingsController implements Initializable, ChildController, Navig
{ {
label.setText(item.getName()); label.setText(item.getName());
removeButton.setOnAction(new EventHandler<ActionEvent>() removeButton.setOnAction(actionEvent -> removeArbitrator(item));
{
@Override
public void handle(ActionEvent actionEvent)
{
removeArbitrator(item);
}
});
setGraphic(hBox); setGraphic(hBox);
} }

View file

@ -3,30 +3,28 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<TabPane fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" <TabPane xmlns:fx="http://javafx.com/fxml/1" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.settings.SettingsController"> xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.settings.SettingsController">
<Tab text="General" closable="false"> <Tab text="General" closable="false">
<GridPane hgap="5.0" vgap="5.0"> <GridPane hgap="5.0" vgap="5.0">
<padding> <padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</padding> </padding>
<children> <Label text="Accepted languages:"/>
<Label text="Accepted languages:"/> <ListView fx:id="languagesListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1"/>
<ListView fx:id="languagesListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1"/> <Label text="Accepted countries:" GridPane.rowIndex="2"/>
<Label text="Accepted countries:" GridPane.rowIndex="2"/> <Label text="Accepted arbitrators:" GridPane.rowIndex="4"/>
<Label text="Accepted arbitrators:" GridPane.rowIndex="4"/> <ListView fx:id="countriesListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<ListView fx:id="countriesListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1" GridPane.rowIndex="2"/> <ListView fx:id="arbitratorsListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
<ListView fx:id="arbitratorsListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1" GridPane.rowIndex="4"/> <ComboBox fx:id="languageComboBox" onAction="#onAddLanguage" prefWidth="150.0" promptText="Add language" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<ComboBox fx:id="languageComboBox" onAction="#onAddLanguage" prefWidth="150.0" promptText="Add language" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<HBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="3"> <HBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="3">
<ComboBox fx:id="regionComboBox" onAction="#onSelectRegion" prefWidth="150.0" promptText="Select region"/> <ComboBox fx:id="regionComboBox" onAction="#onSelectRegion" prefWidth="150.0" promptText="Select region"/>
<ComboBox fx:id="countryComboBox" onAction="#onAddCountry" visible="false" prefWidth="150.0" promptText="Add country"/> <ComboBox fx:id="countryComboBox" onAction="#onAddCountry" visible="false" prefWidth="150.0" promptText="Add country"/>
</HBox> </HBox>
<Button onAction="#onAddArbitrator" text="Add arbitrator" GridPane.columnIndex="1" GridPane.rowIndex="5"/> <Button onAction="#onAddArbitrator" text="Add arbitrator" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
</children>
<columnConstraints> <columnConstraints>
<ColumnConstraints/> <ColumnConstraints/>
@ -82,7 +80,7 @@
<HBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="8"> <HBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="8">
<Button fx:id="saveBankAccountButton" defaultButton="true" onAction="#onSaveBankAccount" text="Save bank account"/> <Button fx:id="saveBankAccountButton" defaultButton="true" onAction="#onSaveBankAccount" text="Save bank account"/>
<Button fx:id="addBankAccountButton" onAction="#onAddBankAccount" text="Add new bank account"/> <Button fx:id="addBankAccountButton" onAction="#onAddBankAccount" text="Add new bank account"/>
<Button fx:id="removeBankAccountButton" onAction="#onRemoveBankAccount" text="Remove bank account"/> <Button onAction="#onRemoveBankAccount" text="Remove bank account"/>
</HBox> </HBox>

View file

@ -4,7 +4,6 @@ import io.bitsquare.locale.Country;
import io.bitsquare.locale.Localisation; import io.bitsquare.locale.Localisation;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Currency; import java.util.Currency;

View file

@ -9,12 +9,8 @@ import javafx.scene.paint.Color;
public class BitSquareValidator public class BitSquareValidator
{ {
private static Effect invalidEffect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.0, 0, 0); private static final Effect invalidEffect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.0, 0, 0);
private static String invalidStyle = "-fx-border-color: red"; private static final String invalidStyle = "-fx-border-color: red";
public static class ValidationException extends Exception
{
}
public static void textFieldsNotEmptyWithReset(TextField... textFields) throws ValidationException public static void textFieldsNotEmptyWithReset(TextField... textFields) throws ValidationException
{ {
@ -24,9 +20,8 @@ public class BitSquareValidator
public static void resetTextFields(TextField... textFields) public static void resetTextFields(TextField... textFields)
{ {
for (int i = 0; i < textFields.length; i++) for (TextField textField : textFields)
{ {
TextField textField = textFields[i];
textField.setStyle("-fx-border-color: null"); textField.setStyle("-fx-border-color: null");
textField.setEffect(null); textField.setEffect(null);
} }
@ -34,9 +29,8 @@ public class BitSquareValidator
public static void textFieldsNotEmpty(TextField... textFields) throws ValidationException public static void textFieldsNotEmpty(TextField... textFields) throws ValidationException
{ {
for (int i = 0; i < textFields.length; i++) for (TextField textField : textFields)
{ {
TextField textField = textFields[i];
textFieldNotEmpty(textField); textFieldNotEmpty(textField);
} }
} }
@ -59,9 +53,8 @@ public class BitSquareValidator
public static void textFieldsHasDoubleValue(TextField... textFields) throws ValidationException public static void textFieldsHasDoubleValue(TextField... textFields) throws ValidationException
{ {
for (int i = 0; i < textFields.length; i++) for (TextField textField : textFields)
{ {
TextField textField = textFields[i];
textFieldHasDoubleValue(textField); textFieldHasDoubleValue(textField);
} }
} }
@ -101,9 +94,8 @@ public class BitSquareValidator
public static boolean validateStringsAsDouble(String... inputs) public static boolean validateStringsAsDouble(String... inputs)
{ {
boolean result = true; boolean result = true;
for (int i = 0; i < inputs.length; i++) for (String input : inputs)
{ {
String input = inputs[i];
result &= validateStringAsDouble(input); result &= validateStringAsDouble(input);
} }
return result; return result;
@ -125,9 +117,8 @@ public class BitSquareValidator
public static boolean validateStringsNotEmpty(String... inputs) public static boolean validateStringsNotEmpty(String... inputs)
{ {
boolean result = true; boolean result = true;
for (int i = 0; i < inputs.length; i++) for (String input : inputs)
{ {
String input = inputs[i];
result &= validateStringNotEmpty(input); result &= validateStringNotEmpty(input);
} }
return result; return result;
@ -138,4 +129,8 @@ public class BitSquareValidator
return input != null && input.length() > 0 && !input.equals(" "); return input != null && input.length() > 0 && !input.equals(" ");
} }
public static class ValidationException extends Exception
{
}
} }

View file

@ -4,16 +4,14 @@ import com.google.bitcoin.core.*;
import com.google.bitcoin.script.Script; import com.google.bitcoin.script.Script;
import io.bitsquare.btc.BtcFormatter; import io.bitsquare.btc.BtcFormatter;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import java.math.BigInteger;
import java.util.List;
import java.util.Set;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class ConfidenceDisplay public class ConfidenceDisplay
{ {
private static final Logger log = LoggerFactory.getLogger(ConfidenceDisplay.class); private static final Logger log = LoggerFactory.getLogger(ConfidenceDisplay.class);
@ -186,9 +184,8 @@ public class ConfidenceDisplay
Set<Transaction> transactions = wallet.getTransactions(false); Set<Transaction> transactions = wallet.getTransactions(false);
Transaction latestTransaction = null; Transaction latestTransaction = null;
for (Iterator<Transaction> iterator = transactions.iterator(); iterator.hasNext(); ) for (Transaction transaction : transactions)
{ {
Transaction transaction = iterator.next();
if (latestTransaction != null) if (latestTransaction != null)
{ {
if (transaction.getUpdateTime().compareTo(latestTransaction.getUpdateTime()) > 0) if (transaction.getUpdateTime().compareTo(latestTransaction.getUpdateTime()) > 0)

View file

@ -2,6 +2,9 @@ package io.bitsquare.gui.util;
import io.bitsquare.bank.BankAccountTypeInfo; import io.bitsquare.bank.BankAccountTypeInfo;
import io.bitsquare.gui.components.VSpacer; import io.bitsquare.gui.components.VSpacer;
import java.util.Currency;
import java.util.List;
import java.util.Locale;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
@ -9,10 +12,6 @@ import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import java.util.Currency;
import java.util.List;
import java.util.Locale;
//TODO to be removed //TODO to be removed
public class FormBuilder public class FormBuilder
{ {

View file

@ -13,8 +13,6 @@ public class Icons
public static final String NAV_SELL_ACTIVE = "/images/nav/nav_sell_active.png"; public static final String NAV_SELL_ACTIVE = "/images/nav/nav_sell_active.png";
public static final String ORDERS = "/images/nav/orders.png"; public static final String ORDERS = "/images/nav/orders.png";
public static final String ORDERS_ACTIVE = "/images/nav/orders_active.png"; public static final String ORDERS_ACTIVE = "/images/nav/orders_active.png";
public static final String HISTORY = "/images/unused/history.png";
public static final String HISTORY_ACTIVE = "/images/unused/history_active.png";
public static final String FUNDS = "/images/nav/funds.png"; public static final String FUNDS = "/images/nav/funds.png";
public static final String FUNDS_ACTIVE = "/images/nav/funds_active.png"; public static final String FUNDS_ACTIVE = "/images/nav/funds_active.png";
public static final String MSG = "/images/nav/msg.png"; public static final String MSG = "/images/nav/msg.png";
@ -28,20 +26,6 @@ public class Icons
public static final String SELL = "/images/sell.png"; public static final String SELL = "/images/sell.png";
public static final String REMOVE = "/images/removeOffer.png"; public static final String REMOVE = "/images/removeOffer.png";
public static final String PROGRESS_0_ICON_FILE = "/images/tx/circleProgress0.png";
public static final String PROGRESS_1_ICON_FILE = "/images/tx/circleProgress1.png";
public static final String PROGRESS_2_ICON_FILE = "/images/tx/circleProgress2.png";
public static final String PROGRESS_3_ICON_FILE = "/images/tx/circleProgress3.png";
public static final String PROGRESS_4_ICON_FILE = "/images/tx/circleProgress4.png";
public static final String PROGRESS_5_ICON_FILE = "/images/tx/circleProgress5.png";
public static final String FULL_CONFIRMED = "/images/tx/fullConfirmed.png";
public static final String SHAPE_TRIANGLE_ICON_FILE = "/images/tx/shapeTriangle.png";
public static final String SHAPE_SQUARE_ICON_FILE = "/images/tx/shapeSquare.png";
public static final String SHAPE_PENTAGON_ICON_FILE = "/images/tx/shapePentagon.png";
public static final String SHAPE_HEXAGON_ICON_FILE = "/images/tx/shapeHexagon.png";
public static Image getIconImage(String iconName) public static Image getIconImage(String iconName)
{ {
return new Image(Icons.class.getResourceAsStream(iconName)); return new Image(Icons.class.getResourceAsStream(iconName));
@ -51,44 +35,4 @@ public class Icons
{ {
return new ImageView(new Image(Icons.class.getResourceAsStream(iconName))); return new ImageView(new Image(Icons.class.getResourceAsStream(iconName)));
} }
public static String getIconIDForConfirmations(int confirmations)
{
switch (confirmations)
{
case 0:
return Icons.PROGRESS_0_ICON_FILE;
case 1:
return Icons.PROGRESS_1_ICON_FILE;
case 2:
return Icons.PROGRESS_2_ICON_FILE;
case 3:
return Icons.PROGRESS_3_ICON_FILE;
case 4:
return Icons.PROGRESS_4_ICON_FILE;
case 5:
return Icons.PROGRESS_5_ICON_FILE;
case 6:
default:
return Icons.FULL_CONFIRMED;
}
}
public static String getIconIDForPeersSeenTx(int numberOfPeersSeenTx)
{
switch (numberOfPeersSeenTx)
{
case 0:
return Icons.PROGRESS_0_ICON_FILE;
case 1:
return Icons.SHAPE_TRIANGLE_ICON_FILE;
case 2:
return Icons.SHAPE_SQUARE_ICON_FILE;
case 3:
return Icons.SHAPE_PENTAGON_ICON_FILE;
case 4:
default:
return Icons.SHAPE_HEXAGON_ICON_FILE;
}
}
} }

View file

@ -1,66 +0,0 @@
package io.bitsquare.gui.util;
import io.bitsquare.BitSquare;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
import org.controlsfx.dialog.Dialogs;
import java.util.ArrayList;
import java.util.List;
public class Popups
{
public static Action openErrorPopup(String title, String message)
{
return Dialogs.create()
.title(title)
.message(message)
.nativeTitleBar()
.lightweight()
.showError();
}
public static Action openInsufficientMoneyPopup()
{
return openErrorPopup("Not enough money available", "There is not enough money available. Please pay in first to your wallet.");
}
public static Action openWarningPopup(String title, String message)
{
return Dialogs.create()
.title(title)
.message(message)
.nativeTitleBar()
.lightweight()
.showWarning();
}
public static Action openRegistrationMissingPopup(String title, String message, String masthead, List<Dialogs.CommandLink> commandLinks, int selectedIndex)
{
return Dialogs.create()
.title(title)
.message(message)
.masthead(masthead)
.nativeTitleBar()
.lightweight()
.showCommandLinks(commandLinks.get(selectedIndex), commandLinks);
}
public static Action openConfirmPopup(String title, String masthead, String message)
{
List<Action> actions = new ArrayList<>();
actions.add(Dialog.Actions.OK);
actions.add(Dialog.Actions.CANCEL);
return Dialogs.create()
.owner(BitSquare.getStage())
.title(title)
.message(message)
.masthead(masthead)
.nativeTitleBar()
.lightweight()
.actions(actions)
.showConfirm();
}
}

View file

@ -7,9 +7,9 @@ public class Country implements Serializable
{ {
private static final long serialVersionUID = -5930294199097793187L; private static final long serialVersionUID = -5930294199097793187L;
private String code; private final String code;
private String name; private final String name;
private Region region; private final Region region;
public Country(String code, String name, Region region) public Country(String code, String name, Region region)
{ {

View file

@ -1,136 +1,13 @@
package io.bitsquare.locale; package io.bitsquare.locale;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class CountryUtil public class CountryUtil
{ {
public static List<Region> getAllRegions() private static final String[] countryCodes = new String[]{"AE",
{
List<Region> allRegions = new ArrayList<>();
String regionCode = "NA";
Region region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "SA";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "AF";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "EU";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "AS";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "OC";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
return allRegions;
}
public static List<Country> getAllCountriesFor(Region selectedRegion)
{
List<Country> allCountries = getAllCountries();
List<Country> filteredList = Lists.newArrayList(Collections2.filter(allCountries, new Predicate<Country>()
{
@Override
public boolean apply(@Nullable Country country)
{
return selectedRegion != null && country != null && country.getRegion().equals(selectedRegion);
}
}));
return filteredList;
}
public static List<Country> getAllCountries()
{
List<Locale> allCountryLocales = getAllCountryLocales();
List<Country> allCountries = new ArrayList<>();
for (int i = 0; i < allCountryLocales.size(); i++)
{
Locale locale = allCountryLocales.get(i);
String regionCode = getRegionCode(locale.getCountry());
Region region = new Region(regionCode, getRegionName(regionCode));
Country country = new Country(locale.getCountry(), locale.getDisplayCountry(), region);
allCountries.add(country);
}
return allCountries;
}
public static Country getDefaultCountry()
{
Locale locale = new Locale("", Locale.getDefault().getCountry());
String regionCode = getRegionCode(locale.getCountry());
Region region = new Region(regionCode, getRegionName(regionCode));
return new Country(locale.getCountry(), locale.getDisplayCountry(), region);
}
public static String getRegionName(String regionCode)
{
for (String[] regionName : regionCodeToName)
{
if (regionName[0].equals(regionCode))
{
return regionName[1];
}
}
return regionCode;
}
private static List<Locale> getAllCountryLocales()
{
List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
Set<Locale> allLocalesAsSet = new HashSet<>();
for (int i = 0; i < allLocales.size(); i++)
{
Locale locale = allLocales.get(i);
if (!locale.getCountry().equals(""))
{
allLocalesAsSet.add(new Locale("", locale.getCountry(), ""));
}
}
allLocales = new ArrayList<>();
allLocales.addAll(allLocalesAsSet);
allLocales.sort(new Comparator<Locale>()
{
@Override
public int compare(Locale locale1, Locale locale2)
{
return locale1.getDisplayCountry().compareTo(locale2.getDisplayCountry());
}
});
return allLocales;
}
private static String getRegionCode(String countryCode)
{
if (countryCode.length() > 0 && countryCodeList.contains(countryCode))
{
int index = countryCodeList.indexOf(countryCode);
return regionCodeList.get(index).toString();
}
else
{
return "Undefined";
}
}
private static String[] countryCodes = new String[]{"AE",
"AL", "AL",
"AR", "AR",
"AT", "AT",
@ -227,8 +104,8 @@ public class CountryUtil
"YE", "YE",
"ZA" "ZA"
}; };
private static final List<String> regionCodeList = Arrays.asList(countryCodes);
private static String[] regionCodes = new String[]{ private static final String[] regionCodes = new String[]{
"AS", "AS",
"EU", "EU",
"SA", "SA",
@ -326,23 +203,8 @@ public class CountryUtil
"AS", "AS",
"AF" "AF"
}; };
private static final List<String> countryCodeList = Arrays.asList(regionCodes);
private static List<String> regionCodeList; private static final String[][] regionCodeToName = new String[][]{
private static List<String> countryCodeList;
static
{
if (countryCodeList == null)
{
countryCodeList = Arrays.asList(countryCodes);
}
if (regionCodeList == null)
{
regionCodeList = Arrays.asList(regionCodes);
}
}
private static String[][] regionCodeToName = new String[][]{
{"NA", "North America"}, {"NA", "North America"},
{"SA", "South America"}, {"SA", "South America"},
{"AF", "Africa"}, {"AF", "Africa"},
@ -351,4 +213,122 @@ public class CountryUtil
{"OC", "Oceania"} {"OC", "Oceania"}
}; };
public static List<Region> getAllRegions()
{
List<Region> allRegions = new ArrayList<>();
String regionCode = "NA";
Region region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "SA";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "AF";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "EU";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "AS";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
regionCode = "OC";
region = new Region(regionCode, getRegionName(regionCode));
allRegions.add(region);
return allRegions;
}
public static List<Country> getAllCountriesFor(Region selectedRegion)
{
List<Country> allCountries = getAllCountries();
return Lists.newArrayList(Collections2.filter(allCountries, country -> selectedRegion != null && country != null && country.getRegion().equals(selectedRegion)));
}
public static List<Country> getAllCountries()
{
List<Locale> allCountryLocales = getAllCountryLocales();
List<Country> allCountries = new ArrayList<>();
for (Locale locale : allCountryLocales)
{
String regionCode = getRegionCode(locale.getCountry());
Region region = new Region(regionCode, getRegionName(regionCode));
Country country = new Country(locale.getCountry(), locale.getDisplayCountry(), region);
allCountries.add(country);
}
return allCountries;
}
public static Country getDefaultCountry()
{
Locale locale = new Locale("", Locale.getDefault().getCountry());
String regionCode = getRegionCode(locale.getCountry());
Region region = new Region(regionCode, getRegionName(regionCode));
return new Country(locale.getCountry(), locale.getDisplayCountry(), region);
}
public static String getRegionName(String regionCode)
{
for (String[] regionName : regionCodeToName)
{
if (regionName[0].equals(regionCode))
{
return regionName[1];
}
}
return regionCode;
}
private static List<Locale> getAllCountryLocales()
{
List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
Set<Locale> allLocalesAsSet = allLocales.stream().filter(locale -> !locale.getCountry().equals("")).map(locale -> new Locale("", locale.getCountry(), "")).collect(Collectors.toSet());
/*
same as:
Set<Locale> allLocalesAsSet = new HashSet<>();
for (Locale locale : allLocales)
{
if (!locale.getCountry().equals(""))
{
allLocalesAsSet.add(new Locale("", locale.getCountry(), ""));
}
} */
allLocales = new ArrayList<>();
allLocales.addAll(allLocalesAsSet);
allLocales.sort((locale1, locale2) -> locale1.getDisplayCountry().compareTo(locale2.getDisplayCountry()));
/*
allLocales.sort(new Comparator<Locale>()
{
@Override
public int compare(Locale locale1, Locale locale2)
{
return locale1.getDisplayCountry().compareTo(locale2.getDisplayCountry());
}
});
*/
return allLocales;
}
private static String getRegionCode(String countryCode)
{
if (countryCode.length() > 0 && countryCodeList.contains(countryCode))
{
int index = countryCodeList.indexOf(countryCode);
return regionCodeList.get(index);
}
else
{
return "Undefined";
}
}
} }

View file

@ -23,14 +23,7 @@ public class CurrencyUtil
allCurrenciesSet.removeAll(mainCurrencies); allCurrenciesSet.removeAll(mainCurrencies);
List<Currency> allCurrenciesList = new ArrayList<>(allCurrenciesSet); List<Currency> allCurrenciesList = new ArrayList<>(allCurrenciesSet);
allCurrenciesList.sort(new Comparator<Currency>() allCurrenciesList.sort((a, b) -> a.getCurrencyCode().compareTo(b.getCurrencyCode()));
{
@Override
public int compare(Currency a, Currency b)
{
return a.getCurrencyCode().compareTo(b.getCurrencyCode());
}
});
List<Currency> resultList = new ArrayList<>(mainCurrencies); List<Currency> resultList = new ArrayList<>(mainCurrencies);
resultList.addAll(allCurrenciesList); resultList.addAll(allCurrenciesList);

View file

@ -1,6 +1,7 @@
package io.bitsquare.locale; package io.bitsquare.locale;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class LanguageUtil public class LanguageUtil
{ {
@ -24,25 +25,10 @@ public class LanguageUtil
public static List<Locale> getAllLanguageLocales() public static List<Locale> getAllLanguageLocales()
{ {
List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales()); List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
Set<Locale> allLocalesAsSet = new HashSet<>(); Set<Locale> allLocalesAsSet = allLocales.stream().filter(locale -> !locale.getLanguage().equals("")).map(locale -> new Locale(locale.getLanguage(), "")).collect(Collectors.toSet());
for (int i = 0; i < allLocales.size(); i++)
{
Locale locale = allLocales.get(i);
if (!locale.getLanguage().equals(""))
{
allLocalesAsSet.add(new Locale(locale.getLanguage(), ""));
}
}
allLocales = new ArrayList<>(); allLocales = new ArrayList<>();
allLocales.addAll(allLocalesAsSet); allLocales.addAll(allLocalesAsSet);
allLocales.sort(new Comparator<Locale>() allLocales.sort((locale1, locale2) -> locale1.getDisplayLanguage().compareTo(locale2.getDisplayLanguage()));
{
@Override
public int compare(Locale locale1, Locale locale2)
{
return locale1.getDisplayLanguage().compareTo(locale2.getDisplayLanguage());
}
});
return allLocales; return allLocales;
} }

View file

@ -1,8 +1,5 @@
package io.bitsquare.locale; package io.bitsquare.locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -13,6 +10,8 @@ import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.PropertyResourceBundle; import java.util.PropertyResourceBundle;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Localisation public class Localisation
{ {

View file

@ -7,8 +7,8 @@ public class Region implements Serializable
{ {
private static final long serialVersionUID = -5930294199097793187L; private static final long serialVersionUID = -5930294199097793187L;
private String code; private final String code;
private String name; private final String name;
public Region(String code, String name) public Region(String code, String name)
{ {

View file

@ -9,6 +9,11 @@ import io.bitsquare.trade.payment.taker.TakerPaymentProtocol;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import io.bitsquare.util.DSAKeyUtil; import io.bitsquare.util.DSAKeyUtil;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
import java.io.File;
import java.io.IOException;
import java.security.KeyPair;
import java.security.PublicKey;
import java.util.*;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
@ -19,19 +24,12 @@ import net.tomp2p.p2p.Peer;
import net.tomp2p.p2p.PeerMaker; import net.tomp2p.p2p.PeerMaker;
import net.tomp2p.peers.Number160; import net.tomp2p.peers.Number160;
import net.tomp2p.peers.PeerAddress; import net.tomp2p.peers.PeerAddress;
import net.tomp2p.rpc.ObjectDataReply;
import net.tomp2p.storage.Data; import net.tomp2p.storage.Data;
import net.tomp2p.storage.StorageDisk; import net.tomp2p.storage.StorageDisk;
import net.tomp2p.utils.Utils; import net.tomp2p.utils.Utils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.security.KeyPair;
import java.security.PublicKey;
import java.util.*;
/** /**
* That facade delivers messaging functionality from the TomP2P library * That facade delivers messaging functionality from the TomP2P library
* The TomP2P library codebase shall not be used outside that facade. * The TomP2P library codebase shall not be used outside that facade.
@ -39,33 +37,26 @@ import java.util.*;
*/ */
public class MessageFacade public class MessageFacade
{ {
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
public static final String PING = "ping"; public static final String PING = "ping";
public static final String PONG = "pong"; public static final String PONG = "pong";
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
private static final int MASTER_PEER_PORT = 5000; private static final int MASTER_PEER_PORT = 5000;
private static String MASTER_PEER_IP = "192.168.1.33"; private static String MASTER_PEER_IP = "192.168.1.33";
private final List<OrderBookListener> orderBookListeners = new ArrayList<>();
private final List<TakeOfferRequestListener> takeOfferRequestListeners = new ArrayList<>();
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
// //TODO change to map (key: offerID) instead of list (offererPaymentProtocols, takerPaymentProtocols)
private final List<TakerPaymentProtocol> takerPaymentProtocols = new ArrayList<>();
private final List<OffererPaymentProtocol> offererPaymentProtocols = new ArrayList<>();
private final List<PingPeerListener> pingPeerListeners = new ArrayList<>();
private final BooleanProperty isDirty = new SimpleBooleanProperty(false);
private Peer myPeer; private Peer myPeer;
private int port; private int port;
private KeyPair keyPair; private KeyPair keyPair;
private Peer masterPeer; private Peer masterPeer;
private List<OrderBookListener> orderBookListeners = new ArrayList<>();
private List<TakeOfferRequestListener> takeOfferRequestListeners = new ArrayList<>();
private List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
// //TODO change to map (key: offerID) instead of list (offererPaymentProtocols, takerPaymentProtocols)
private List<TakerPaymentProtocol> takerPaymentProtocols = new ArrayList<>();
private List<OffererPaymentProtocol> offererPaymentProtocols = new ArrayList<>();
private List<PingPeerListener> pingPeerListeners = new ArrayList<>();
private Long lastTimeStamp = -3L; private Long lastTimeStamp = -3L;
private BooleanProperty isDirty = new SimpleBooleanProperty(false);
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -264,7 +255,7 @@ public class MessageFacade
// Remove offer // Remove offer
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void removeOffer(Offer offer) throws IOException public void removeOffer(Offer offer)
{ {
Number160 locationKey = Number160.createHash(offer.getCurrency().getCurrencyCode()); Number160 locationKey = Number160.createHash(offer.getCurrency().getCurrencyCode());
Number160 contentKey = Number160.createHash(offer.getId()); Number160 contentKey = Number160.createHash(offer.getId());
@ -300,7 +291,7 @@ public class MessageFacade
return isDirty; return isDirty;
} }
public void getDirtyFlag(Currency currency) throws IOException public void getDirtyFlag(Currency currency)
{ {
Number160 locationKey = Number160.createHash(currency.getCurrencyCode()); Number160 locationKey = Number160.createHash(currency.getCurrencyCode());
FutureDHT getFuture = myPeer.get(getDirtyLocationKey(locationKey)).start(); FutureDHT getFuture = myPeer.get(getDirtyLocationKey(locationKey)).start();
@ -343,7 +334,7 @@ public class MessageFacade
lastTimeStamp++; lastTimeStamp++;
} }
private Number160 getDirtyLocationKey(Number160 locationKey) throws IOException private Number160 getDirtyLocationKey(Number160 locationKey)
{ {
return Number160.createHash(locationKey.toString() + "Dirty"); return Number160.createHash(locationKey.toString() + "Dirty");
} }
@ -352,28 +343,27 @@ public class MessageFacade
{ {
// we don't want to get an update from dirty for own changes, so update the lastTimeStamp to omit a change trigger // we don't want to get an update from dirty for own changes, so update the lastTimeStamp to omit a change trigger
lastTimeStamp = System.currentTimeMillis(); lastTimeStamp = System.currentTimeMillis();
FutureDHT putFuture = null;
try try
{ {
putFuture = myPeer.put(getDirtyLocationKey(locationKey)).setData(new Data(lastTimeStamp)).start(); FutureDHT putFuture = myPeer.put(getDirtyLocationKey(locationKey)).setData(new Data(lastTimeStamp)).start();
putFuture.addListener(new BaseFutureListener<BaseFuture>()
{
@Override
public void operationComplete(BaseFuture future) throws Exception
{
//System.out.println("operationComplete");
}
@Override
public void exceptionCaught(Throwable t) throws Exception
{
System.err.println("exceptionCaught");
}
});
} catch (IOException e) } catch (IOException e)
{ {
log.warn("Error at writing dirty flag (timeStamp) " + e.getMessage()); log.warn("Error at writing dirty flag (timeStamp) " + e.getMessage());
} }
putFuture.addListener(new BaseFutureListener<BaseFuture>()
{
@Override
public void operationComplete(BaseFuture future) throws Exception
{
//System.out.println("operationComplete");
}
@Override
public void exceptionCaught(Throwable t) throws Exception
{
System.err.println("exceptionCaught");
}
});
} }
@ -475,20 +465,20 @@ public class MessageFacade
final PeerConnection peerConnection = myPeer.createPeerConnection(peerAddress, 10); final PeerConnection peerConnection = myPeer.createPeerConnection(peerAddress, 10);
final FutureResponse sendFuture = myPeer.sendDirect(peerConnection).setObject(tradeMessage).start(); final FutureResponse sendFuture = myPeer.sendDirect(peerConnection).setObject(tradeMessage).start();
sendFuture.addListener(new BaseFutureAdapter<BaseFuture>() sendFuture.addListener(new BaseFutureAdapter<BaseFuture>()
{ {
@Override @Override
public void operationComplete(BaseFuture baseFuture) throws Exception public void operationComplete(BaseFuture baseFuture) throws Exception
{ {
if (sendFuture.isSuccess()) if (sendFuture.isSuccess())
{ {
Platform.runLater(() -> onSendTradingMessageResult(listener)); Platform.runLater(() -> onSendTradingMessageResult(listener));
} }
else else
{ {
Platform.runLater(() -> onSendTradingMessageFailed(listener)); Platform.runLater(() -> onSendTradingMessageFailed(listener));
} }
} }
} }
); );
} }
@ -591,23 +581,23 @@ public class MessageFacade
{ {
FutureResponse sendFuture = myPeer.sendDirect(peerConnection).setObject(PING).start(); FutureResponse sendFuture = myPeer.sendDirect(peerConnection).setObject(PING).start();
sendFuture.addListener(new BaseFutureAdapter<BaseFuture>() sendFuture.addListener(new BaseFutureAdapter<BaseFuture>()
{ {
@Override @Override
public void operationComplete(BaseFuture baseFuture) throws Exception public void operationComplete(BaseFuture baseFuture) throws Exception
{ {
if (sendFuture.isSuccess()) if (sendFuture.isSuccess())
{ {
final String pong = (String) sendFuture.getObject(); final String pong = (String) sendFuture.getObject();
if (pong != null) if (pong != null)
Platform.runLater(() -> onResponseFromPing(pong.equals(PONG))); Platform.runLater(() -> onResponseFromPing(pong.equals(PONG)));
} }
else else
{ {
peerConnection.close(); peerConnection.close();
Platform.runLater(() -> onResponseFromPing(false)); Platform.runLater(() -> onResponseFromPing(false));
} }
} }
} }
); );
} }
} catch (Exception e) } catch (Exception e)
@ -736,7 +726,7 @@ public class MessageFacade
}); });
} }
private void setupStorage() throws IOException private void setupStorage()
{ {
//TODO BitSquare.ID just temp... //TODO BitSquare.ID just temp...
String dirPath = Utilities.getRootDir() + BitSquare.ID + "_tomP2P"; String dirPath = Utilities.getRootDir() + BitSquare.ID + "_tomP2P";
@ -765,17 +755,12 @@ public class MessageFacade
private void setupReplyHandler() private void setupReplyHandler()
{ {
myPeer.setObjectDataReply(new ObjectDataReply() myPeer.setObjectDataReply((sender, request) -> {
{ if (!sender.equals(myPeer.getPeerAddress()))
@Override
public Object reply(PeerAddress sender, Object request) throws Exception
{ {
if (!sender.equals(myPeer.getPeerAddress())) Platform.runLater(() -> onMessage(request, sender));
{
Platform.runLater(() -> onMessage(request, sender));
}
return null;
} }
return null;
}); });
} }

View file

@ -1,7 +1,6 @@
package io.bitsquare.msg; package io.bitsquare.msg;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.UUID; import java.util.UUID;
@ -12,8 +11,9 @@ public class TradeMessage implements Serializable
private static final long serialVersionUID = 7916445031849763995L; private static final long serialVersionUID = 7916445031849763995L;
private String uid; private final String uid;
private final TradeMessageType type;
private final String offerUID;
private String takerMessagePubKey; private String takerMessagePubKey;
private String signedTakerDepositTxAsHex; private String signedTakerDepositTxAsHex;
private String txScriptSigAsHex; private String txScriptSigAsHex;
@ -21,10 +21,8 @@ public class TradeMessage implements Serializable
private String contractAsJson; private String contractAsJson;
private String takerContractSignature; private String takerContractSignature;
private String takerPayoutAddress; private String takerPayoutAddress;
private TradeMessageType type;
private String depositTxID; private String depositTxID;
private String depositTxAsHex; private String depositTxAsHex;
private String offererSignatureR; private String offererSignatureR;
private String offererSignatureS; private String offererSignatureS;
private BigInteger offererPaybackAmount; private BigInteger offererPaybackAmount;
@ -33,7 +31,6 @@ public class TradeMessage implements Serializable
private BigInteger tradeAmount; private BigInteger tradeAmount;
private String takeOfferFeeTxID; private String takeOfferFeeTxID;
private String takerMultiSigPubKey; private String takerMultiSigPubKey;
private String offerUID;
private BankAccount bankAccount; private BankAccount bankAccount;
private String accountID; private String accountID;
private String offererPubKey; private String offererPubKey;
@ -257,16 +254,16 @@ public class TradeMessage implements Serializable
return depositTxAsHex; return depositTxAsHex;
} }
public void setPayoutTxAsHex(String payoutTxAsHex)
{
this.payoutTxAsHex = payoutTxAsHex;
}
public String getPayoutTxAsHex() public String getPayoutTxAsHex()
{ {
return payoutTxAsHex; return payoutTxAsHex;
} }
public void setPayoutTxAsHex(String payoutTxAsHex)
{
this.payoutTxAsHex = payoutTxAsHex;
}
public long getOffererTxOutIndex() public long getOffererTxOutIndex()
{ {
return offererTxOutIndex; return offererTxOutIndex;

View file

@ -1,10 +1,9 @@
package io.bitsquare.msg.listeners; package io.bitsquare.msg.listeners;
import java.util.Map;
import net.tomp2p.peers.Number160; import net.tomp2p.peers.Number160;
import net.tomp2p.storage.Data; import net.tomp2p.storage.Data;
import java.util.Map;
public interface ArbitratorListener public interface ArbitratorListener
{ {
void onArbitratorAdded(Data offerData, boolean success); void onArbitratorAdded(Data offerData, boolean success);

View file

@ -1,10 +1,9 @@
package io.bitsquare.msg.listeners; package io.bitsquare.msg.listeners;
import java.util.Map;
import net.tomp2p.peers.Number160; import net.tomp2p.peers.Number160;
import net.tomp2p.storage.Data; import net.tomp2p.storage.Data;
import java.util.Map;
public interface OrderBookListener public interface OrderBookListener
{ {
void onOfferAdded(Data offerData, boolean success); void onOfferAdded(Data offerData, boolean success);

View file

@ -3,7 +3,6 @@ package io.bitsquare.settings;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
@ -79,20 +78,6 @@ public class Settings implements Serializable
acceptedArbitrators.remove(item); acceptedArbitrators.remove(item);
} }
public void setMaxCollateral(int maxCollateral)
{
this.maxCollateral = maxCollateral;
}
public void setMinCollateral(int minCollateral)
{
this.minCollateral = minCollateral;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public List<Arbitrator> getAcceptedArbitrators() public List<Arbitrator> getAcceptedArbitrators()
{ {
return acceptedArbitrators; return acceptedArbitrators;
@ -103,6 +88,10 @@ public class Settings implements Serializable
return acceptedLanguageLocales; return acceptedLanguageLocales;
} }
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public List<Country> getAcceptedCountries() public List<Country> getAcceptedCountries()
{ {
return acceptedCountryLocales; return acceptedCountryLocales;
@ -128,9 +117,19 @@ public class Settings implements Serializable
return maxCollateral; return maxCollateral;
} }
public void setMaxCollateral(int maxCollateral)
{
this.maxCollateral = maxCollateral;
}
public int getMinCollateral() public int getMinCollateral()
{ {
return minCollateral; return minCollateral;
} }
public void setMinCollateral(int minCollateral)
{
this.minCollateral = minCollateral;
}
} }

View file

@ -2,12 +2,11 @@ package io.bitsquare.storage;
import io.bitsquare.BitSquare; import io.bitsquare.BitSquare;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*; import java.io.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Simple storage solution for serialized data * Simple storage solution for serialized data
@ -53,9 +52,7 @@ public class Storage
public Object read(String key) public Object read(String key)
{ {
dict = readDataVO(); dict = readDataVO();
Object result = dict.get(key); return dict.get(key);
//log.info("Read object with key = " + key + " result = " + result);
return result;
} }
@ -88,15 +85,14 @@ public class Storage
{ {
FileInputStream fileIn = new FileInputStream(file); FileInputStream fileIn = new FileInputStream(file);
ObjectInputStream in = new ObjectInputStream(fileIn); ObjectInputStream in = new ObjectInputStream(fileIn);
dict = (Map<String, Object>) in.readObject(); Object object = in.readObject();
if (object instanceof Map)
dict = (Map<String, Object>) object;
in.close(); in.close();
fileIn.close(); fileIn.close();
} catch (IOException i) } catch (IOException | ClassNotFoundException i)
{ {
i.printStackTrace(); i.printStackTrace();
} catch (ClassNotFoundException c)
{
c.printStackTrace();
} }
} }
return dict; return dict;

View file

@ -1,7 +1,6 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigInteger; import java.math.BigInteger;
@ -9,15 +8,15 @@ public class Contract implements Serializable
{ {
private static final long serialVersionUID = 71472356206100158L; private static final long serialVersionUID = 71472356206100158L;
private Offer offer; private final Offer offer;
private String takeOfferFeeTxID; private final String takeOfferFeeTxID;
private BigInteger tradeAmount; private final BigInteger tradeAmount;
private String offererAccountID; private final String offererAccountID;
private String takerAccountID; private final String takerAccountID;
private BankAccount offererBankAccount; private final BankAccount offererBankAccount;
private BankAccount takerBankAccount; private final BankAccount takerBankAccount;
private String offererMessagePubKeyAsHex; private final String offererMessagePubKeyAsHex;
private String takerMessagePubKeyAsHex; private final String takerMessagePubKeyAsHex;
public Contract(Offer offer, public Contract(Offer offer,
BigInteger tradeAmount, BigInteger tradeAmount,

View file

@ -4,7 +4,6 @@ import io.bitsquare.bank.BankAccountTypeInfo;
import io.bitsquare.btc.BtcFormatter; import io.bitsquare.btc.BtcFormatter;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.*;
@ -20,7 +19,7 @@ public class Offer implements Serializable
private final String id; private final String id;
private final Date creationDate; private final Date creationDate;
private double price; private final double price;
private final BigInteger amount; private final BigInteger amount;
private final BigInteger minAmount; private final BigInteger minAmount;
private final String messagePubKeyAsHex; private final String messagePubKeyAsHex;
@ -30,9 +29,9 @@ public class Offer implements Serializable
private final int collateral; private final int collateral;
private final List<Country> acceptedCountries; private final List<Country> acceptedCountries;
private final List<Locale> acceptedLanguageLocales; private final List<Locale> acceptedLanguageLocales;
private String offerFeePaymentTxID;
private final String bankAccountUID; private final String bankAccountUID;
private final Arbitrator arbitrator; private final Arbitrator arbitrator;
private String offerFeePaymentTxID;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -77,9 +76,9 @@ public class Offer implements Serializable
// Setters // Setters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void setOfferFeePaymentTxID(String offerFeePaymentTxID) public String getMessagePubKeyAsHex()
{ {
this.offerFeePaymentTxID = offerFeePaymentTxID; return messagePubKeyAsHex;
} }
@ -87,11 +86,6 @@ public class Offer implements Serializable
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public String getMessagePubKeyAsHex()
{
return messagePubKeyAsHex;
}
public String getId() public String getId()
{ {
return id; return id;
@ -157,6 +151,11 @@ public class Offer implements Serializable
return offerFeePaymentTxID; return offerFeePaymentTxID;
} }
public void setOfferFeePaymentTxID(String offerFeePaymentTxID)
{
this.offerFeePaymentTxID = offerFeePaymentTxID;
}
public Arbitrator getArbitrator() public Arbitrator getArbitrator()
{ {
return arbitrator; return arbitrator;

View file

@ -1,29 +1,19 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import com.google.bitcoin.core.Transaction; import com.google.bitcoin.core.Transaction;
import java.io.Serializable;
import java.math.BigInteger;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import java.io.Serializable;
import java.math.BigInteger;
public class Trade implements Serializable public class Trade implements Serializable
{ {
public static enum State
{
NONE,
ACCEPTED,
COMPLETED
}
private static final long serialVersionUID = -8275323072940974077L; private static final long serialVersionUID = -8275323072940974077L;
transient private final SimpleBooleanProperty depositTxChangedProperty = new SimpleBooleanProperty(); transient private final SimpleBooleanProperty depositTxChangedProperty = new SimpleBooleanProperty();
transient private final SimpleBooleanProperty payoutTxChangedProperty = new SimpleBooleanProperty(); transient private final SimpleBooleanProperty payoutTxChangedProperty = new SimpleBooleanProperty();
transient private final SimpleBooleanProperty contractChangedProperty = new SimpleBooleanProperty(); transient private final SimpleBooleanProperty contractChangedProperty = new SimpleBooleanProperty();
transient private final SimpleStringProperty stateChangedProperty = new SimpleStringProperty(); transient private final SimpleStringProperty stateChangedProperty = new SimpleStringProperty();
private final Offer offer;
private Offer offer;
private String takeOfferFeeTxID; private String takeOfferFeeTxID;
private BigInteger tradeAmount; private BigInteger tradeAmount;
private Contract contract; private Contract contract;
@ -38,59 +28,13 @@ public class Trade implements Serializable
this.offer = offer; this.offer = offer;
} }
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
public void setTakeOfferFeeTxID(String takeOfferFeeTxID)
{
this.takeOfferFeeTxID = takeOfferFeeTxID;
}
public void setTradeAmount(BigInteger tradeAmount)
{
this.tradeAmount = tradeAmount;
}
public void setContract(Contract contract)
{
this.contract = contract;
contractChangedProperty.set(!contractChangedProperty.get());
}
public void setContractAsJson(String contractAsJson)
{
this.contractAsJson = contractAsJson;
}
public void setContractTakerSignature(String takerSignature) public void setContractTakerSignature(String takerSignature)
{ {
this.takerSignature = takerSignature; this.takerSignature = takerSignature;
} }
public void setDepositTransaction(Transaction depositTransaction)
{
this.depositTransaction = depositTransaction;
depositTxChangedProperty.set(!depositTxChangedProperty.get());
}
public void setState(State state)
{
this.state = state;
stateChangedProperty.set(state.toString());
}
public void setPayoutTransaction(Transaction payoutTransaction)
{
this.payoutTransaction = payoutTransaction;
payoutTxChangedProperty.set(!payoutTxChangedProperty.get());
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Getters // Setters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public String getId() public String getId()
@ -108,21 +52,47 @@ public class Trade implements Serializable
return takeOfferFeeTxID; return takeOfferFeeTxID;
} }
public void setTakeOfferFeeTxID(String takeOfferFeeTxID)
{
this.takeOfferFeeTxID = takeOfferFeeTxID;
}
public BigInteger getTradeAmount() public BigInteger getTradeAmount()
{ {
return tradeAmount; return tradeAmount;
} }
public void setTradeAmount(BigInteger tradeAmount)
{
this.tradeAmount = tradeAmount;
}
public Contract getContract() public Contract getContract()
{ {
return contract; return contract;
} }
public void setContract(Contract contract)
{
this.contract = contract;
contractChangedProperty.set(!contractChangedProperty.get());
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public String getContractAsJson() public String getContractAsJson()
{ {
return contractAsJson; return contractAsJson;
} }
public void setContractAsJson(String contractAsJson)
{
this.contractAsJson = contractAsJson;
}
public String getTakerSignature() public String getTakerSignature()
{ {
return takerSignature; return takerSignature;
@ -133,16 +103,33 @@ public class Trade implements Serializable
return depositTransaction; return depositTransaction;
} }
public void setDepositTransaction(Transaction depositTransaction)
{
this.depositTransaction = depositTransaction;
depositTxChangedProperty.set(!depositTxChangedProperty.get());
}
public Transaction getPayoutTransaction() public Transaction getPayoutTransaction()
{ {
return payoutTransaction; return payoutTransaction;
} }
public void setPayoutTransaction(Transaction payoutTransaction)
{
this.payoutTransaction = payoutTransaction;
payoutTxChangedProperty.set(!payoutTxChangedProperty.get());
}
public State getState() public State getState()
{ {
return state; return state;
} }
public void setState(State state)
{
this.state = state;
stateChangedProperty.set(state.toString());
}
public SimpleBooleanProperty getDepositTxChangedProperty() public SimpleBooleanProperty getDepositTxChangedProperty()
{ {
@ -169,11 +156,6 @@ public class Trade implements Serializable
return getTradeAmount().multiply(BigInteger.valueOf(getOffer().getCollateral())).divide(BigInteger.valueOf(100)); return getTradeAmount().multiply(BigInteger.valueOf(getOffer().getCollateral())).divide(BigInteger.valueOf(100));
} }
///////////////////////////////////////////////////////////////////////////////////////////
// toString
///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public String toString() public String toString()
{ {
@ -188,4 +170,16 @@ public class Trade implements Serializable
", state=" + state + ", state=" + state +
'}'; '}';
} }
///////////////////////////////////////////////////////////////////////////////////////////
// toString
///////////////////////////////////////////////////////////////////////////////////////////
public static enum State
{
NONE,
ACCEPTED,
COMPLETED
}
} }

View file

@ -16,36 +16,34 @@ import io.bitsquare.trade.payment.offerer.OffererPaymentProtocolListener;
import io.bitsquare.trade.payment.taker.TakerPaymentProtocol; import io.bitsquare.trade.payment.taker.TakerPaymentProtocol;
import io.bitsquare.trade.payment.taker.TakerPaymentProtocolListener; import io.bitsquare.trade.payment.taker.TakerPaymentProtocolListener;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import net.tomp2p.peers.PeerAddress; import net.tomp2p.peers.PeerAddress;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/** /**
* Represents trade domain. Keeps complexity of process apart from view controller * Represents trade domain. Keeps complexity of process apart from view controller
*/ */
public class Trading public class Trading
{ {
private static final Logger log = LoggerFactory.getLogger(Trading.class); private static final Logger log = LoggerFactory.getLogger(Trading.class);
private Map<String, Offer> myOffers = new HashMap<>();
private Map<String, Trade> trades = new HashMap<>();
private final Map<String, TakerPaymentProtocol> takerPaymentProtocols = new HashMap<>(); private final Map<String, TakerPaymentProtocol> takerPaymentProtocols = new HashMap<>();
private final Map<String, OffererPaymentProtocol> offererPaymentProtocols = new HashMap<>(); private final Map<String, OffererPaymentProtocol> offererPaymentProtocols = new HashMap<>();
private final String storageKey; private final String storageKey;
private User user; private final User user;
private Storage storage; private final Storage storage;
private MessageFacade messageFacade; private final MessageFacade messageFacade;
private BlockChainFacade blockChainFacade; private final BlockChainFacade blockChainFacade;
private WalletFacade walletFacade; private final WalletFacade walletFacade;
private CryptoFacade cryptoFacade; private final CryptoFacade cryptoFacade;
private Settings settings; private final Settings settings;
private final StringProperty newTradeProperty = new SimpleStringProperty(); private final StringProperty newTradeProperty = new SimpleStringProperty();
private Map<String, Offer> myOffers = new HashMap<>();
private Map<String, Trade> trades = new HashMap<>();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -73,11 +71,11 @@ public class Trading
Object offersObject = storage.read(storageKey + ".offers"); Object offersObject = storage.read(storageKey + ".offers");
if (offersObject != null && offersObject instanceof HashMap) if (offersObject != null && offersObject instanceof HashMap)
myOffers = (Map) offersObject; myOffers = (Map<String, Offer>) offersObject;
Object tradesObject = storage.read(storageKey + ".trades"); Object tradesObject = storage.read(storageKey + ".trades");
if (tradesObject != null && tradesObject instanceof HashMap) if (tradesObject != null && tradesObject instanceof HashMap)
trades = (Map) tradesObject; trades = (Map<String, Trade>) tradesObject;
} }
@ -105,7 +103,7 @@ public class Trading
messageFacade.addOffer(offer); messageFacade.addOffer(offer);
} }
public void removeOffer(Offer offer) throws IOException public void removeOffer(Offer offer)
{ {
myOffers.remove(offer.getId()); myOffers.remove(offer.getId());
saveOffers(); saveOffers();
@ -128,7 +126,7 @@ public class Trading
return trade; return trade;
} }
public void removeTrade(Trade trade) throws IOException public void removeTrade(Trade trade)
{ {
trades.remove(trade.getId()); trades.remove(trade.getId());
storage.write(storageKey + ".trades", trades); storage.write(storageKey + ".trades", trades);
@ -200,7 +198,7 @@ public class Trading
}); });
// the handler was not called there because the obejct was not created when the event occurred (and therefor no listener) // the handler was not called there because the object was not created when the event occurred (and therefor no listener)
// will probably created earlier, so let it for the moment like that.... // will probably created earlier, so let it for the moment like that....
offererPaymentProtocol.onTakeOfferRequested(sender); offererPaymentProtocol.onTakeOfferRequested(sender);
} }
@ -237,8 +235,8 @@ public class Trading
return myOffers; return myOffers;
} }
public Offer getOffer(String offerUID) public Offer getOffer(String offerId)
{ {
return myOffers.get(offerUID.toString()); return myOffers.get(offerId);
} }
} }

View file

@ -13,6 +13,10 @@ import io.bitsquare.trade.Offer;
import io.bitsquare.trade.Trading; import io.bitsquare.trade.Trading;
import io.bitsquare.user.Arbitrator; import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.FilteredList;
@ -22,25 +26,17 @@ import net.tomp2p.storage.Data;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Predicate;
public class OrderBook implements OrderBookListener public class OrderBook implements OrderBookListener
{ {
private static final Logger log = LoggerFactory.getLogger(OrderBook.class); private static final Logger log = LoggerFactory.getLogger(OrderBook.class);
protected final ObservableList<OrderBookListItem> allOffers = FXCollections.observableArrayList();
private Settings settings; private final FilteredList<OrderBookListItem> filteredList = new FilteredList<>(allOffers);
private User user;
private MessageFacade messageFacade;
private Trading trading;
protected ObservableList<OrderBookListItem> allOffers = FXCollections.observableArrayList();
private FilteredList<OrderBookListItem> filteredList = new FilteredList<>(allOffers);
// FilteredList does not support sorting, so we need to wrap it to a SortedList // FilteredList does not support sorting, so we need to wrap it to a SortedList
private SortedList<OrderBookListItem> offerList = new SortedList<>(filteredList); private final SortedList<OrderBookListItem> offerList = new SortedList<>(filteredList);
private final Settings settings;
private final User user;
private final MessageFacade messageFacade;
private final Trading trading;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -79,7 +75,7 @@ public class OrderBook implements OrderBookListener
messageFacade.getOffers(CurrencyUtil.getDefaultCurrency().getCurrencyCode()); messageFacade.getOffers(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
} }
public void removeOffer(Offer offer) throws IOException public void removeOffer(Offer offer)
{ {
trading.removeOffer(offer); trading.removeOffer(offer);
messageFacade.removeOffer(offer); messageFacade.removeOffer(offer);
@ -87,90 +83,85 @@ public class OrderBook implements OrderBookListener
public void applyFilter(OrderBookFilter orderBookFilter) public void applyFilter(OrderBookFilter orderBookFilter)
{ {
filteredList.setPredicate(new Predicate<OrderBookListItem>() filteredList.setPredicate(orderBookListItem -> {
{ Offer offer = orderBookListItem.getOffer();
@Override BankAccount currentBankAccount = user.getCurrentBankAccount();
public boolean test(OrderBookListItem orderBookListItem)
if (orderBookFilter == null
|| offer == null
|| currentBankAccount == null
|| orderBookFilter.getDirection() == null)
return false;
// The users current bank account currency must match the offer currency (1 to 1)
boolean currencyResult = currentBankAccount.getCurrency().equals(offer.getCurrency());
// The offer bank account country must match one of the accepted countries defined in the settings (1 to n)
boolean countryResult = countryInList(offer.getBankAccountCountry(), settings.getAcceptedCountries());
// One of the supported languages from the settings must match one of the offer languages (n to n)
boolean languageResult = languagesInList(settings.getAcceptedLanguageLocales(), offer.getAcceptedLanguageLocales());
// Apply applyFilter only if there is a valid value set
// The requested amount must be lower or equal then the offer amount
boolean amountResult = true;
if (orderBookFilter.getAmount() > 0)
amountResult = orderBookFilter.getAmount() <= offer.getAmount().doubleValue();
// The requested trade direction must be opposite of the offerList trade direction
boolean directionResult = !orderBookFilter.getDirection().equals(offer.getDirection());
// Apply applyFilter only if there is a valid value set
boolean priceResult = true;
if (orderBookFilter.getPrice() > 0)
{ {
Offer offer = orderBookListItem.getOffer(); if (offer.getDirection() == Direction.SELL)
BankAccount currentBankAccount = user.getCurrentBankAccount(); priceResult = orderBookFilter.getPrice() >= offer.getPrice();
else
if (orderBookFilter == null priceResult = orderBookFilter.getPrice() <= offer.getPrice();
|| offer == null
|| currentBankAccount == null
|| orderBookFilter.getDirection() == null)
return false;
// The users current bank account currency must match the offer currency (1 to 1)
boolean currencyResult = currentBankAccount.getCurrency().equals(offer.getCurrency());
// The offer bank account country must match one of the accepted countries defined in the settings (1 to n)
boolean countryResult = countryInList(offer.getBankAccountCountry(), settings.getAcceptedCountries());
// One of the supported languages from the settings must match one of the offer languages (n to n)
boolean languageResult = languagesInList(settings.getAcceptedLanguageLocales(), offer.getAcceptedLanguageLocales());
// Apply applyFilter only if there is a valid value set
// The requested amount must be lower or equal then the offer amount
boolean amountResult = true;
if (orderBookFilter.getAmount() > 0)
amountResult = orderBookFilter.getAmount() <= offer.getAmount().doubleValue();
// The requested trade direction must be opposite of the offerList trade direction
boolean directionResult = !orderBookFilter.getDirection().equals(offer.getDirection());
// Apply applyFilter only if there is a valid value set
boolean priceResult = true;
if (orderBookFilter.getPrice() > 0)
{
if (offer.getDirection() == Direction.SELL)
priceResult = orderBookFilter.getPrice() >= offer.getPrice();
else
priceResult = orderBookFilter.getPrice() <= offer.getPrice();
}
// The arbitrator defined in the offer must match one of the accepted arbitrators defined in the settings (1 to n)
boolean arbitratorResult = arbitratorInList(offer.getArbitrator(), settings.getAcceptedArbitrators());
boolean result = currencyResult
&& countryResult
&& languageResult
&& amountResult
&& directionResult
&& priceResult
&& arbitratorResult;
/*
log.debug("result = " + result +
", currencyResult = " + currencyResult +
", countryResult = " + countryResult +
", languageResult = " + languageResult +
", amountResult = " + amountResult +
", directionResult = " + directionResult +
", priceResult = " + priceResult +
", arbitratorResult = " + arbitratorResult
);
log.debug("currentBankAccount.getCurrency() = " + currentBankAccount.getCurrency() +
", offer.getCurrency() = " + offer.getCurrency());
log.debug("offer.getCountryLocale() = " + offer.getBankAccountCountryLocale() +
", settings.getAcceptedCountries() = " + settings.getAcceptedCountries().toString());
log.debug("settings.getAcceptedLanguageLocales() = " + settings.getAcceptedLanguageLocales() +
", offer.getAcceptedLanguageLocales() = " + offer.getAcceptedLanguageLocales());
log.debug("currentBankAccount.getBankAccountType().getType() = " + currentBankAccount.getBankAccountType().getType() +
", offer.getBankAccountTypeEnum() = " + offer.getBankAccountTypeEnum());
log.debug("orderBookFilter.getAmount() = " + orderBookFilter.getAmount() +
", offer.getAmount() = " + offer.getAmount());
log.debug("orderBookFilter.getDirection() = " + orderBookFilter.getDirection() +
", offer.getDirection() = " + offer.getDirection());
log.debug("orderBookFilter.getPrice() = " + orderBookFilter.getPrice() +
", offer.getPrice() = " + offer.getPrice());
log.debug("offer.getArbitrator() = " + offer.getArbitrator() +
", settings.getAcceptedArbitrators() = " + settings.getAcceptedArbitrators());
*/
return result;
} }
// The arbitrator defined in the offer must match one of the accepted arbitrators defined in the settings (1 to n)
boolean arbitratorResult = arbitratorInList(offer.getArbitrator(), settings.getAcceptedArbitrators());
boolean result = currencyResult
&& countryResult
&& languageResult
&& amountResult
&& directionResult
&& priceResult
&& arbitratorResult;
/*
log.debug("result = " + result +
", currencyResult = " + currencyResult +
", countryResult = " + countryResult +
", languageResult = " + languageResult +
", amountResult = " + amountResult +
", directionResult = " + directionResult +
", priceResult = " + priceResult +
", arbitratorResult = " + arbitratorResult
);
log.debug("currentBankAccount.getCurrency() = " + currentBankAccount.getCurrency() +
", offer.getCurrency() = " + offer.getCurrency());
log.debug("offer.getCountryLocale() = " + offer.getBankAccountCountryLocale() +
", settings.getAcceptedCountries() = " + settings.getAcceptedCountries().toString());
log.debug("settings.getAcceptedLanguageLocales() = " + settings.getAcceptedLanguageLocales() +
", offer.getAcceptedLanguageLocales() = " + offer.getAcceptedLanguageLocales());
log.debug("currentBankAccount.getBankAccountType().getType() = " + currentBankAccount.getBankAccountType().getType() +
", offer.getBankAccountTypeEnum() = " + offer.getBankAccountTypeEnum());
log.debug("orderBookFilter.getAmount() = " + orderBookFilter.getAmount() +
", offer.getAmount() = " + offer.getAmount());
log.debug("orderBookFilter.getDirection() = " + orderBookFilter.getDirection() +
", offer.getDirection() = " + offer.getDirection());
log.debug("orderBookFilter.getPrice() = " + orderBookFilter.getPrice() +
", offer.getPrice() = " + offer.getPrice());
log.debug("offer.getArbitrator() = " + offer.getArbitrator() +
", settings.getAcceptedArbitrators() = " + settings.getAcceptedArbitrators());
*/
return result;
}); });
} }
@ -184,7 +175,7 @@ public class OrderBook implements OrderBookListener
try try
{ {
Object offerDataObject = offerData.getObject(); Object offerDataObject = offerData.getObject();
if (offerDataObject instanceof Offer && offerDataObject != null) if (offerDataObject instanceof Offer)
{ {
Offer offer = (Offer) offerDataObject; Offer offer = (Offer) offerDataObject;
allOffers.add(new OrderBookListItem(offer)); allOffers.add(new OrderBookListItem(offer));
@ -207,7 +198,7 @@ public class OrderBook implements OrderBookListener
try try
{ {
Object offerDataObject = offerData.getObject(); Object offerDataObject = offerData.getObject();
if (offerDataObject instanceof Offer && offerDataObject != null) if (offerDataObject instanceof Offer)
{ {
Offer offer = (Offer) offerDataObject; Offer offer = (Offer) offerDataObject;
OrderBookListItem orderBookListItem = new OrderBookListItem(offer); OrderBookListItem orderBookListItem = new OrderBookListItem(offer);
@ -233,17 +224,10 @@ public class OrderBook implements OrderBookListener
try try
{ {
Object offerDataObject = offerData.getObject(); Object offerDataObject = offerData.getObject();
if (offerDataObject instanceof Offer && offerDataObject != null) if (offerDataObject instanceof Offer)
{ {
Offer offer = (Offer) offerDataObject; Offer offer = (Offer) offerDataObject;
allOffers.removeIf(new Predicate<OrderBookListItem>() allOffers.removeIf(orderBookListItem -> orderBookListItem.getOffer().getId().equals(offer.getId()));
{
@Override
public boolean test(OrderBookListItem orderBookListItem)
{
return orderBookListItem.getOffer().getId().equals(offer.getId());
}
});
} }
} catch (ClassNotFoundException | IOException e) } catch (ClassNotFoundException | IOException e)
{ {

View file

@ -16,42 +16,42 @@ public class OrderBookFilter
// Setters // Setters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void setAmount(double amount)
{
this.amount = amount;
}
public void setPrice(double price)
{
this.price = price;
}
public void setDirection(Direction direction)
{
this.direction = direction;
directionChangedProperty.set(!directionChangedProperty.get());
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public double getAmount() public double getAmount()
{ {
return amount; return amount;
} }
public void setAmount(double amount)
{
this.amount = amount;
}
public Direction getDirection() public Direction getDirection()
{ {
return direction; return direction;
} }
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public void setDirection(Direction direction)
{
this.direction = direction;
directionChangedProperty.set(!directionChangedProperty.get());
}
public double getPrice() public double getPrice()
{ {
return price; return price;
} }
public void setPrice(double price)
{
this.price = price;
}
public SimpleBooleanProperty getDirectionChangedProperty() public SimpleBooleanProperty getDirectionChangedProperty()
{ {
return directionChangedProperty; return directionChangedProperty;

View file

@ -16,14 +16,12 @@ import io.bitsquare.trade.Offer;
import io.bitsquare.trade.Trade; import io.bitsquare.trade.Trade;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
import java.math.BigInteger;
import javafx.util.Pair; import javafx.util.Pair;
import net.tomp2p.peers.PeerAddress; import net.tomp2p.peers.PeerAddress;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigInteger;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
//TODO refactor to process based pattern //TODO refactor to process based pattern
@ -32,18 +30,18 @@ public class OffererPaymentProtocol
private static final Logger log = LoggerFactory.getLogger(OffererPaymentProtocol.class); private static final Logger log = LoggerFactory.getLogger(OffererPaymentProtocol.class);
private Trade trade; private final Trade trade;
private Offer offer; private final Offer offer;
private final OffererPaymentProtocolListener offererPaymentProtocolListener;
private final MessageFacade messageFacade;
private final WalletFacade walletFacade;
private final BlockChainFacade blockChainFacade;
private final CryptoFacade cryptoFacade;
private final User user;
private final int numberOfSteps = 10;//TODO
private Contract contract; private Contract contract;
private OffererPaymentProtocolListener offererPaymentProtocolListener;
private MessageFacade messageFacade;
private WalletFacade walletFacade;
private BlockChainFacade blockChainFacade;
private CryptoFacade cryptoFacade;
private User user;
private PeerAddress peerAddress; private PeerAddress peerAddress;
private boolean isTakeOfferRequested; private boolean isTakeOfferRequested;
private int numberOfSteps = 10;//TODO
private int currentStep = 0; private int currentStep = 0;
private String preparedOffererDepositTxAsHex; private String preparedOffererDepositTxAsHex;
private Transaction depositTransaction; private Transaction depositTransaction;
@ -117,15 +115,8 @@ public class OffererPaymentProtocol
offererPaymentProtocolListener.onProgress(getProgress()); offererPaymentProtocolListener.onProgress(getProgress());
isTakeOfferRequested = true; isTakeOfferRequested = true;
try log.debug("1.3 messageFacade.removeOffer");
{ messageFacade.removeOffer(offer);
log.debug("1.3 messageFacade.removeOffer");
messageFacade.removeOffer(offer);
} catch (IOException e)
{
log.error("1.3 messageFacade.removeOffer failed " + e.getMessage());
offererPaymentProtocolListener.onFailure("removeOffer failed " + e.getMessage());
}
// It's the takers turn again, so we are in wait mode.... // It's the takers turn again, so we are in wait mode....
} }
@ -470,29 +461,29 @@ public class OffererPaymentProtocol
onDepositTxConfirmedInBlockchain(); onDepositTxConfirmedInBlockchain();
transaction.getConfidence().addEventListener(new TransactionConfidence.Listener() transaction.getConfidence().addEventListener(new TransactionConfidence.Listener()
{ {
@Override @Override
public void onConfidenceChanged(Transaction tx, ChangeReason reason) public void onConfidenceChanged(Transaction tx, ChangeReason reason)
{ {
if (reason == ChangeReason.SEEN_PEERS) if (reason == ChangeReason.SEEN_PEERS)
{ {
updateConfirmation(tx.getConfidence()); updateConfirmation(tx.getConfidence());
//todo just for testing now, dont like to wait so long... //todo just for testing now, dont like to wait so long...
/* if (tx.getConfidenceForAddress().numBroadcastPeers() > 3) /* if (tx.getConfidenceForAddress().numBroadcastPeers() > 3)
{ {
onDepositTxConfirmedInBlockchain(); onDepositTxConfirmedInBlockchain();
transaction.getConfidenceForAddress().removeEventListener(this); transaction.getConfidenceForAddress().removeEventListener(this);
} */ } */
} }
if (reason == ChangeReason.TYPE && tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) if (reason == ChangeReason.TYPE && tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
{ {
onDepositTxConfirmedInBlockchain(); onDepositTxConfirmedInBlockchain();
transaction.getConfidence().removeEventListener(this); transaction.getConfidence().removeEventListener(this);
} }
} }
} }
); );
} }
@ -583,9 +574,6 @@ public class OffererPaymentProtocol
log.debug("3.10 sendTradingMessage BANK_TX_INITED"); log.debug("3.10 sendTradingMessage BANK_TX_INITED");
messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener); messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener);
} catch (InsufficientMoneyException e)
{
log.error("3.10 offererCreatesAndSignsPayoutTx onFailed InsufficientMoneyException " + e.getMessage());
} catch (AddressFormatException e) } catch (AddressFormatException e)
{ {
log.error("3.10 offererCreatesAndSignsPayoutTx onFailed AddressFormatException " + e.getMessage()); log.error("3.10 offererCreatesAndSignsPayoutTx onFailed AddressFormatException " + e.getMessage());

View file

@ -11,22 +11,19 @@ import org.slf4j.LoggerFactory;
public class PaymentProcess public class PaymentProcess
{ {
private static final Logger log = LoggerFactory.getLogger(PaymentProcess.class); private static final Logger log = LoggerFactory.getLogger(PaymentProcess.class);
private MessageFacade messageService;
private BlockChainFacade bitcoinServices;
protected String offererDepositPubKey; protected String offererDepositPubKey;
protected String offererPayoutAddress; protected String offererPayoutAddress;
protected String offererChangeAddress; protected String offererChangeAddress;
protected String offererTotalInputPayment; protected String offererTotalInputPayment;
protected String offererOutputPayment; protected String offererOutputPayment;
protected String takerDepositPubKey; protected String takerDepositPubKey;
protected String takerPayoutAddress; protected String takerPayoutAddress;
protected String takerChangeAddress; protected String takerChangeAddress;
protected String takerTotalInputPayment; protected String takerTotalInputPayment;
protected String takerOutputPayment; protected String takerOutputPayment;
protected String multiSigAddress; protected String multiSigAddress;
private MessageFacade messageService;
private BlockChainFacade bitcoinServices;
private WalletFacade wallet; private WalletFacade wallet;
public PaymentProcess() public PaymentProcess()

Some files were not shown because too many files have changed in this diff Show more