mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 07:15:54 -04:00
error handling, popups, code cleanup
This commit is contained in:
parent
828b5ad9f2
commit
7abbe21329
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "libs/bitcoinj"]
|
||||
path = libs/bitcoinj
|
||||
url = git://github.com/bitcoinj/bitcoinj
|
@ -1,19 +1,25 @@
|
||||
package io.bitsquare;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.di.BitSquareModule;
|
||||
import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.gui.NavigationViewURL;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -34,14 +40,26 @@ public class BitSquare extends Application
|
||||
launch(args);
|
||||
}
|
||||
|
||||
public static Stage getStage()
|
||||
{
|
||||
return stage;
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
log.debug("Startup: start");
|
||||
final Injector injector = Guice.createInjector(new BitSquareModule());
|
||||
walletFacade = injector.getInstance(WalletFacade.class);
|
||||
|
||||
walletFacade = injector.getInstance(WalletFacade.class);
|
||||
messageFacade = injector.getInstance(MessageFacade.class);
|
||||
log.debug("Startup: messageFacade, walletFacade inited");
|
||||
|
||||
@ -60,22 +78,31 @@ public class BitSquare extends Application
|
||||
|
||||
|
||||
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.setMinHeight(400);
|
||||
stage.setWidth(800);
|
||||
stage.setHeight(600);
|
||||
|
||||
stage.show();
|
||||
log.debug("Startup: stage displayed");
|
||||
try
|
||||
{
|
||||
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
|
||||
@ -86,9 +113,4 @@ public class BitSquare extends Application
|
||||
|
||||
super.stop();
|
||||
}
|
||||
|
||||
public static Stage getStage()
|
||||
{
|
||||
return stage;
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import net.tomp2p.peers.Number160;
|
||||
*/
|
||||
public class RelayNode
|
||||
{
|
||||
public static final Number160 ID = Number160.createHash(1);
|
||||
private static Peer masterPeer = null;
|
||||
public static Number160 ID = Number160.createHash(1);
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.bitsquare.bank;
|
||||
|
||||
import io.bitsquare.locale.Country;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Currency;
|
||||
import java.util.Objects;
|
||||
@ -10,14 +9,14 @@ public class BankAccount implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1792577576443221268L;
|
||||
|
||||
private BankAccountTypeInfo bankAccountTypeInfo;
|
||||
private String accountPrimaryID;
|
||||
private String accountSecondaryID;
|
||||
private String accountHolderName;
|
||||
private Country country;
|
||||
private Currency currency;
|
||||
private String uid;
|
||||
private String accountTitle;
|
||||
private final BankAccountTypeInfo bankAccountTypeInfo;
|
||||
private final String accountPrimaryID;
|
||||
private final String accountSecondaryID;
|
||||
private final String accountHolderName;
|
||||
private final Country country;
|
||||
private final Currency currency;
|
||||
private final String uid;
|
||||
private final String accountTitle;
|
||||
|
||||
public BankAccount(BankAccountTypeInfo bankAccountTypeInfo,
|
||||
Currency currency,
|
||||
|
@ -7,10 +7,15 @@ import java.util.Objects;
|
||||
public class BankAccountTypeInfo implements Serializable
|
||||
{
|
||||
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()
|
||||
@ -26,17 +31,6 @@ public class BankAccountTypeInfo implements Serializable
|
||||
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()
|
||||
{
|
||||
return Objects.hashCode(type);
|
||||
@ -67,4 +61,9 @@ public class BankAccountTypeInfo implements Serializable
|
||||
{
|
||||
return secondaryIDName;
|
||||
}
|
||||
|
||||
public static enum BankAccountType
|
||||
{
|
||||
SEPA, WIRE, INTERNATIONAL, OK_PAY, NET_TELLER, PERFECT_MONEY, OTHER
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,14 @@ import com.google.bitcoin.params.RegTestParams;
|
||||
import com.google.bitcoin.wallet.CoinSelection;
|
||||
import com.google.bitcoin.wallet.DefaultCoinSelector;
|
||||
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.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
|
||||
* 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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(AddressBasedCoinSelector.class);
|
||||
private NetworkParameters params;
|
||||
private AddressEntry addressEntry;
|
||||
private boolean includePending;
|
||||
private final NetworkParameters params;
|
||||
private final AddressEntry addressEntry;
|
||||
private final boolean includePending;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -39,6 +41,53 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
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.
|
||||
@ -67,10 +116,10 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
public CoinSelection select(BigInteger biTarget, LinkedList<TransactionOutput> candidates)
|
||||
{
|
||||
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.
|
||||
// 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
|
||||
// them in order to improve performance.
|
||||
if (!biTarget.equals(NetworkParameters.MAX_MONEY))
|
||||
@ -96,59 +145,6 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
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)
|
||||
{
|
||||
|
@ -4,26 +4,16 @@ import com.google.bitcoin.core.Address;
|
||||
import com.google.bitcoin.core.ECKey;
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.core.Utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AddressEntry implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 5501603992599920416L;
|
||||
|
||||
public static enum AddressContext
|
||||
{
|
||||
REGISTRATION_FEE,
|
||||
TRADE,
|
||||
ARBITRATOR_DEPOSIT
|
||||
}
|
||||
|
||||
private ECKey key;
|
||||
private NetworkParameters params;
|
||||
private final ECKey key;
|
||||
private final NetworkParameters params;
|
||||
private final AddressContext addressContext;
|
||||
private String tradeId = null;
|
||||
|
||||
private AddressContext addressContext;
|
||||
|
||||
public AddressEntry(ECKey key, NetworkParameters params, AddressContext addressContext)
|
||||
{
|
||||
this.key = key;
|
||||
@ -31,16 +21,16 @@ public class AddressEntry implements Serializable
|
||||
this.addressContext = addressContext;
|
||||
}
|
||||
|
||||
public void setTradeId(String tradeId)
|
||||
{
|
||||
this.tradeId = tradeId;
|
||||
}
|
||||
|
||||
public String getTradeId()
|
||||
{
|
||||
return tradeId;
|
||||
}
|
||||
|
||||
public void setTradeId(String tradeId)
|
||||
{
|
||||
this.tradeId = tradeId;
|
||||
}
|
||||
|
||||
public AddressContext getAddressContext()
|
||||
{
|
||||
return addressContext;
|
||||
@ -65,4 +55,11 @@ public class AddressEntry implements Serializable
|
||||
{
|
||||
return key.toAddress(params);
|
||||
}
|
||||
|
||||
public static enum AddressContext
|
||||
{
|
||||
REGISTRATION_FEE,
|
||||
TRADE,
|
||||
ARBITRATOR_DEPOSIT
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,10 @@ package io.bitsquare.btc;
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.core.Wallet;
|
||||
import com.google.bitcoin.crypto.KeyCrypter;
|
||||
import java.io.Serializable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class BitSquareWallet extends Wallet implements Serializable
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(BitSquareWallet.class);
|
||||
|
@ -8,7 +8,6 @@ import com.google.bitcoin.store.SPVBlockStore;
|
||||
import com.google.bitcoin.store.WalletProtobufSerializer;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -98,7 +97,8 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||
|
||||
if (blockingStartup)
|
||||
{
|
||||
vPeerGroup.startAndWait();
|
||||
vPeerGroup.startAsync();
|
||||
vPeerGroup.awaitRunning();
|
||||
// Make sure we shut down cleanly.
|
||||
installShutdownHook();
|
||||
// TODO: Be able to use the provided download listener when doing a blocking startup.
|
||||
@ -142,7 +142,9 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||
{
|
||||
try
|
||||
{
|
||||
BitSquareWalletAppKit.this.stopAndWait();
|
||||
BitSquareWalletAppKit.this.stopAsync();
|
||||
BitSquareWalletAppKit.this.awaitTerminated();
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
|
@ -3,19 +3,17 @@ package io.bitsquare.btc;
|
||||
import com.google.bitcoin.core.Utils;
|
||||
import io.bitsquare.gui.util.BitSquareConverter;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Locale;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
// TODO
|
||||
public class BtcFormatter
|
||||
{
|
||||
public static final BigInteger BTC = new BigInteger("100000000");
|
||||
private static final Logger log = LoggerFactory.getLogger(BtcFormatter.class);
|
||||
|
||||
public static BigInteger BTC = new BigInteger("100000000");
|
||||
public static BigInteger mBTC = new BigInteger("100000");
|
||||
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.google.bitcoin.core.AddressFormatException;
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class BtcValidator
|
||||
|
@ -2,20 +2,17 @@ package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.*;
|
||||
import com.google.inject.Inject;
|
||||
import java.math.BigInteger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
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);
|
||||
|
||||
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 createOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
|
||||
private static final String takeOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
|
||||
|
@ -7,7 +7,6 @@ import com.google.bitcoin.params.RegTestParams;
|
||||
import com.google.bitcoin.script.Script;
|
||||
import com.google.bitcoin.script.ScriptBuilder;
|
||||
import com.google.bitcoin.utils.Threading;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.crypto.CryptoFacade;
|
||||
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.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
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;
|
||||
|
||||
@ -43,23 +40,23 @@ public class WalletFacade
|
||||
public static final String TEST_NET = "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 final ReentrantLock lock = Threading.lock("lock");
|
||||
|
||||
private String saveAddressEntryListId;
|
||||
private NetworkParameters params;
|
||||
private BitSquareWalletAppKit walletAppKit;
|
||||
private FeePolicy feePolicy;
|
||||
private CryptoFacade cryptoFacade;
|
||||
private Storage storage;
|
||||
private final String saveAddressEntryListId;
|
||||
private final NetworkParameters params;
|
||||
private final BitSquareWalletAppKit walletAppKit;
|
||||
private final FeePolicy feePolicy;
|
||||
private final CryptoFacade cryptoFacade;
|
||||
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 WalletEventListener walletEventListener;
|
||||
private List<DownloadListener> downloadListeners = new ArrayList<>();
|
||||
private List<ConfidenceListener> confidenceListeners = new ArrayList<>();
|
||||
private List<BalanceListener> balanceListeners = new ArrayList<>();
|
||||
@GuardedBy("lock")
|
||||
private List<AddressEntry> addressEntryList = new ArrayList<>();
|
||||
|
||||
@ -171,26 +168,30 @@ public class WalletFacade
|
||||
};
|
||||
wallet.addEventListener(walletEventListener);
|
||||
|
||||
List<AddressEntry> savedAddressEntryList = (List<AddressEntry>) storage.read(saveAddressEntryListId);
|
||||
if (savedAddressEntryList != null)
|
||||
Object object = storage.read(saveAddressEntryListId);
|
||||
if (object instanceof List)
|
||||
{
|
||||
addressEntryList = savedAddressEntryList;
|
||||
}
|
||||
else
|
||||
{
|
||||
lock.lock();
|
||||
try
|
||||
List<AddressEntry> savedAddressEntryList = (List<AddressEntry>) object;
|
||||
if (savedAddressEntryList != null)
|
||||
{
|
||||
ECKey registrationKey = wallet.getKeys().get(0);
|
||||
AddressEntry registrationAddressEntry = new AddressEntry(registrationKey, params, AddressEntry.AddressContext.REGISTRATION_FEE);
|
||||
addressEntryList.add(registrationAddressEntry);
|
||||
} finally
|
||||
{
|
||||
lock.unlock();
|
||||
addressEntryList = savedAddressEntryList;
|
||||
}
|
||||
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();
|
||||
getNewTradeAddressEntry();
|
||||
saveAddressInfoList();
|
||||
getNewTradeAddressEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,14 +273,7 @@ public class WalletFacade
|
||||
|
||||
public AddressEntry getUnusedTradeAddressInfo()
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), new Predicate<AddressEntry>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(@Nullable AddressEntry addressInfo)
|
||||
{
|
||||
return (addressInfo != null && addressInfo.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && addressInfo.getTradeId() == null);
|
||||
}
|
||||
}));
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), addressInfo -> (addressInfo != null && addressInfo.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && addressInfo.getTradeId() == null)));
|
||||
|
||||
if (filteredList != null && filteredList.size() > 0)
|
||||
return filteredList.get(0);
|
||||
@ -289,14 +283,7 @@ public class WalletFacade
|
||||
|
||||
private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext)
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), new Predicate<AddressEntry>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(@Nullable AddressEntry addressInfo)
|
||||
{
|
||||
return (addressInfo != null && addressContext != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext().equals(addressContext));
|
||||
}
|
||||
}));
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), addressInfo -> (addressInfo != null && addressContext != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext().equals(addressContext))));
|
||||
|
||||
if (filteredList != null && filteredList.size() > 0)
|
||||
return filteredList.get(0);
|
||||
@ -374,20 +361,22 @@ public class WalletFacade
|
||||
Set<Transaction> transactions = wallet.getTransactions(true);
|
||||
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));
|
||||
}
|
||||
*/
|
||||
}
|
||||
return getMostRecentConfidence(transactionConfidenceList);
|
||||
}
|
||||
|
||||
private void notifyConfidenceListeners(Transaction tx)
|
||||
{
|
||||
for (int i = 0; i < confidenceListeners.size(); i++)
|
||||
for (ConfidenceListener confidenceListener : confidenceListeners)
|
||||
{
|
||||
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
ConfidenceListener confidenceListener = confidenceListeners.get(i);
|
||||
transactionConfidenceList.add(getTransactionConfidence(tx, confidenceListener.getAddress()));
|
||||
|
||||
TransactionConfidence transactionConfidence = getMostRecentConfidence(transactionConfidenceList);
|
||||
@ -400,9 +389,17 @@ public class WalletFacade
|
||||
List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx);
|
||||
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())
|
||||
{
|
||||
Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params);
|
||||
@ -412,6 +409,7 @@ public class WalletFacade
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return getMostRecentConfidence(transactionConfidenceList);
|
||||
}
|
||||
|
||||
@ -422,9 +420,8 @@ public class WalletFacade
|
||||
|
||||
// add all connected outputs from any inputs as well
|
||||
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();
|
||||
if (transactionOutput != null)
|
||||
connectedOutputs.add(transactionOutput);
|
||||
@ -439,9 +436,8 @@ public class WalletFacade
|
||||
private TransactionConfidence getMostRecentConfidence(List<TransactionConfidence> transactionConfidenceList)
|
||||
{
|
||||
TransactionConfidence transactionConfidence = null;
|
||||
for (int i = 0; i < transactionConfidenceList.size(); i++)
|
||||
for (TransactionConfidence confidence : transactionConfidenceList)
|
||||
{
|
||||
TransactionConfidence confidence = transactionConfidenceList.get(i);
|
||||
if (confidence != null)
|
||||
{
|
||||
if (transactionConfidence == null ||
|
||||
@ -494,10 +490,8 @@ public class WalletFacade
|
||||
|
||||
private void notifyBalanceListeners(Transaction tx)
|
||||
{
|
||||
for (int i = 0; i < balanceListeners.size(); i++)
|
||||
for (BalanceListener balanceListener : balanceListeners)
|
||||
{
|
||||
BalanceListener balanceListener = balanceListeners.get(i);
|
||||
|
||||
BigInteger balance;
|
||||
if (balanceListener.getAddress() != null)
|
||||
balance = getBalanceForAddress(balanceListener.getAddress());
|
||||
@ -723,7 +717,7 @@ public class WalletFacade
|
||||
String arbitratorPubKey,
|
||||
String offerersPartialDepositTxAsHex,
|
||||
String tradeId
|
||||
) throws InsufficientMoneyException, ExecutionException, InterruptedException, AddressFormatException
|
||||
) throws InsufficientMoneyException
|
||||
{
|
||||
log.debug("takerAddPaymentAndSignTx");
|
||||
log.trace("inputs: ");
|
||||
@ -837,7 +831,7 @@ public class WalletFacade
|
||||
String takersSignedScriptSigAsHex,
|
||||
long offererTxOutIndex,
|
||||
long takerTxOutIndex,
|
||||
FutureCallback<Transaction> callback) throws Exception
|
||||
FutureCallback<Transaction> callback)
|
||||
{
|
||||
log.debug("offererSignAndPublishTx");
|
||||
log.trace("inputs: ");
|
||||
@ -859,7 +853,7 @@ public class WalletFacade
|
||||
// add input
|
||||
Transaction offerersFirstTxConnOut = wallet.getTransaction(offerersFirstTx.getInput(0).getOutpoint().getHash()); // pass that around!
|
||||
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
|
||||
offerersFirstTxInput.setParent(tx);
|
||||
tx.addInput(offerersFirstTxInput);
|
||||
@ -971,7 +965,7 @@ public class WalletFacade
|
||||
BigInteger offererPaybackAmount,
|
||||
BigInteger takerPaybackAmount,
|
||||
String takerAddress,
|
||||
String tradeID) throws InsufficientMoneyException, AddressFormatException
|
||||
String tradeID) throws AddressFormatException
|
||||
{
|
||||
log.debug("offererCreatesAndSignsPayoutTx");
|
||||
log.trace("inputs: ");
|
||||
@ -1009,7 +1003,7 @@ public class WalletFacade
|
||||
BigInteger takerPaybackAmount,
|
||||
String offererAddress,
|
||||
String tradeID,
|
||||
FutureCallback<Transaction> callback) throws InsufficientMoneyException, AddressFormatException
|
||||
FutureCallback<Transaction> callback) throws AddressFormatException
|
||||
{
|
||||
log.debug("takerSignsAndSendsTx");
|
||||
log.trace("inputs: ");
|
||||
@ -1125,6 +1119,13 @@ public class WalletFacade
|
||||
// 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
|
||||
{
|
||||
@Override
|
||||
@ -1138,7 +1139,7 @@ public class WalletFacade
|
||||
protected void doneDownload()
|
||||
{
|
||||
super.doneDownload();
|
||||
Platform.runLater(() -> onDoneDownloadInUserThread());
|
||||
Platform.runLater(this::onDoneDownloadInUserThread);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package io.bitsquare.btc.listeners;
|
||||
|
||||
import com.google.bitcoin.core.Address;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class BalanceListener
|
||||
|
@ -5,7 +5,7 @@ import com.google.bitcoin.core.TransactionConfidence;
|
||||
|
||||
public class ConfidenceListener
|
||||
{
|
||||
private Address address;
|
||||
private final Address address;
|
||||
|
||||
public ConfidenceListener(Address address)
|
||||
{
|
||||
|
@ -4,11 +4,10 @@ import com.google.bitcoin.core.ECKey;
|
||||
import com.google.bitcoin.core.Utils;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.inject.Inject;
|
||||
import java.security.SignatureException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.security.SignatureException;
|
||||
|
||||
/**
|
||||
* That facade delivers crypto functionality from the bitcoinJ library
|
||||
*/
|
||||
|
@ -23,7 +23,6 @@ import io.bitsquare.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BitSquareModule extends AbstractModule
|
||||
@ -59,7 +58,7 @@ public class BitSquareModule extends AbstractModule
|
||||
|
||||
class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit>
|
||||
{
|
||||
private NetworkParameters networkParameters;
|
||||
private final NetworkParameters networkParameters;
|
||||
|
||||
@Inject
|
||||
public BitSquareWalletAppKitProvider(NetworkParameters networkParameters)
|
||||
@ -75,7 +74,7 @@ class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit>
|
||||
|
||||
class NetworkParametersProvider implements Provider<NetworkParameters>
|
||||
{
|
||||
private String networkType;
|
||||
private final String networkType;
|
||||
|
||||
@Inject
|
||||
public NetworkParametersProvider(@Named("networkType") String networkType)
|
||||
|
@ -7,14 +7,14 @@ import javafx.util.Callback;
|
||||
* 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
|
||||
* {@link javafx.fxml.FXMLLoader#setControllerFactory(Callback)}.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Once set, make sure you do <b>not</b> use the static methods on
|
||||
* {@link javafx.fxml.FXMLLoader} when creating your JavaFX node.
|
||||
*/
|
||||
public class GuiceControllerFactory implements Callback<Class<?>, Object>
|
||||
{
|
||||
|
||||
private Injector injector;
|
||||
private final Injector injector;
|
||||
|
||||
public GuiceControllerFactory(Injector injector)
|
||||
{
|
||||
|
@ -1,11 +1,10 @@
|
||||
package io.bitsquare.di;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.util.BuilderFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.util.BuilderFactory;
|
||||
|
||||
/**
|
||||
* Guice support for fxml controllers
|
||||
@ -15,11 +14,6 @@ public class GuiceFXMLLoader extends FXMLLoader
|
||||
|
||||
private static Injector injector = null;
|
||||
|
||||
public static void setInjector(Injector injector)
|
||||
{
|
||||
GuiceFXMLLoader.injector = injector;
|
||||
}
|
||||
|
||||
public GuiceFXMLLoader()
|
||||
{
|
||||
super();
|
||||
@ -44,6 +38,11 @@ public class GuiceFXMLLoader extends FXMLLoader
|
||||
setupControllerFactory();
|
||||
}
|
||||
|
||||
public static void setInjector(Injector injector)
|
||||
{
|
||||
GuiceFXMLLoader.injector = injector;
|
||||
}
|
||||
|
||||
private void setupControllerFactory()
|
||||
{
|
||||
if (GuiceFXMLLoader.injector != null)
|
||||
|
@ -16,8 +16,12 @@ import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import java.io.IOException;
|
||||
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.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -35,41 +39,40 @@ import net.tomp2p.peers.PeerAddress;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(MainController.class);
|
||||
private static MainController mainController;
|
||||
|
||||
|
||||
private User user;
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
private Trading trading;
|
||||
private final User user;
|
||||
private final WalletFacade walletFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private final Trading trading;
|
||||
private final Storage storage;
|
||||
private final String selectedNavigationItemStorageId;
|
||||
private final ToggleGroup toggleGroup = new ToggleGroup();
|
||||
|
||||
private ChildController childController;
|
||||
private Storage storage;
|
||||
private String selectedNavigationItemStorageId;
|
||||
private NavigationItem selectedNavigationItem;
|
||||
private NetworkSyncPane networkSyncPane;
|
||||
private ToggleGroup toggleGroup = new ToggleGroup();
|
||||
private ToggleButton prevToggleButton;
|
||||
private Image prevToggleButtonIcon;
|
||||
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton;
|
||||
private Pane msgButtonHolder, ordersButtonButtonHolder;
|
||||
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
|
||||
@ -101,6 +104,11 @@ public class MainController implements Initializable, NavigationController
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
Platform.runLater(this::init);
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
networkSyncPane = new NetworkSyncPane();
|
||||
networkSyncPane.setSpacing(10);
|
||||
@ -137,7 +145,14 @@ public class MainController implements Initializable, NavigationController
|
||||
AnchorPane.setBottomAnchor(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);
|
||||
Tooltip.install(alertButton, new Tooltip("Someone accepted your offer"));
|
||||
|
||||
alertButton.setOnAction((e) -> {
|
||||
ordersButton.fire();
|
||||
});
|
||||
alertButton.setOnAction((e) -> ordersButton.fire());
|
||||
ordersButtonButtonHolder.getChildren().add(alertButton);
|
||||
|
||||
} catch (NullPointerException e)
|
||||
@ -331,7 +344,7 @@ public class MainController implements Initializable, NavigationController
|
||||
{
|
||||
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.setValue(user.getCurrentBankAccount());
|
||||
accountComboBox.setConverter(new StringConverter<BankAccount>()
|
||||
@ -360,14 +373,7 @@ public class MainController implements Initializable, NavigationController
|
||||
vBox.getChildren().setAll(accountComboBox, titleLabel);
|
||||
parent.getChildren().add(vBox);
|
||||
|
||||
accountComboBox.valueProperty().addListener(new ChangeListener<BankAccount>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue ov, BankAccount oldValue, BankAccount newValue)
|
||||
{
|
||||
user.setCurrentBankAccount(newValue);
|
||||
}
|
||||
});
|
||||
accountComboBox.valueProperty().addListener((ov, oldValue, newValue) -> user.setCurrentBankAccount(newValue));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ProgressBar?>
|
||||
<?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"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<HBox fx:id="leftNavPane" spacing="10" AnchorPane.leftAnchor="0" AnchorPane.topAnchor="0"/>
|
||||
<HBox fx:id="rightNavPane" 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 xmlns:fx="http://javafx.com/fxml/1" fx:id="rootPane" id="root-pane" fx:controller="io.bitsquare.gui.MainController"
|
||||
stylesheets="/io/bitsquare/gui/bitsquare.css" xmlns="http://javafx.com/javafx/8">
|
||||
<HBox fx:id="leftNavPane" visible="false" spacing="10" AnchorPane.leftAnchor="0" AnchorPane.topAnchor="0"/>
|
||||
<HBox fx:id="rightNavPane" visible="false" spacing="10" AnchorPane.rightAnchor="10" AnchorPane.topAnchor="0"/>
|
||||
<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>
|
@ -2,24 +2,30 @@ package io.bitsquare.gui;
|
||||
|
||||
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 MARKET = "/io/bitsquare/gui/market/MarketView.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 MSG = "/io/bitsquare/gui/msg/MsgView.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 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 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 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 DEPOSIT = "/io/bitsquare/gui/funds/deposit/DepositView.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 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";
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,12 @@ import io.bitsquare.msg.listeners.ArbitratorListener;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
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.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -25,26 +31,19 @@ import javafx.stage.Stage;
|
||||
import net.tomp2p.peers.Number160;
|
||||
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
|
||||
{
|
||||
private Settings settings;
|
||||
private Storage storage;
|
||||
private MessageFacade messageFacade;
|
||||
private final Settings settings;
|
||||
private final Storage storage;
|
||||
private final MessageFacade messageFacade;
|
||||
private final List<Arbitrator> allArbitrators = new ArrayList<>();
|
||||
private Arbitrator currentArbitrator;
|
||||
private NavigationController navigationController;
|
||||
private ArbitratorProfileController arbitratorProfileController;
|
||||
private List<Arbitrator> allArbitrators = new ArrayList<>();
|
||||
private int index = -1;
|
||||
|
||||
@FXML
|
||||
private Button prevButton, nextButton, selectButton;
|
||||
private Button prevButton, nextButton, selectButton, closeButton;
|
||||
@FXML
|
||||
private AnchorPane rootContainer;
|
||||
@FXML
|
||||
|
@ -2,13 +2,11 @@
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?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"
|
||||
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.arbitrators.overview.ArbitratorOverviewController">
|
||||
<children>
|
||||
<Pane fx:id="arbitratorProfile"/>
|
||||
<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="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"/>
|
||||
</children>
|
||||
<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"
|
||||
AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.arbitrators.overview.ArbitratorOverviewController">
|
||||
<Pane fx:id="arbitratorProfile"/>
|
||||
<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="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"/>
|
||||
</AnchorPane>
|
||||
|
@ -7,19 +7,18 @@ import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ArbitratorProfileController implements Initializable, ChildController
|
||||
{
|
||||
private Settings settings;
|
||||
private Storage storage;
|
||||
private final Settings settings;
|
||||
private final Storage storage;
|
||||
private Arbitrator arbitrator;
|
||||
private NavigationController navigationController;
|
||||
|
||||
|
@ -3,44 +3,41 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.arbitrators.profile.ArbitratorProfileController">
|
||||
<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="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.arbitrators.profile.ArbitratorProfileController">
|
||||
|
||||
<children>
|
||||
<Label fx:id="nameLabel" text="Name:"/>
|
||||
<TextField fx:id="nameTextField" editable="false" GridPane.columnIndex="1"/>
|
||||
<Label text="Languages:" GridPane.rowIndex="1"/>
|
||||
<TextField fx:id="languagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
<Label fx:id="nameLabel" text="Name:"/>
|
||||
<TextField fx:id="nameTextField" editable="false" GridPane.columnIndex="1"/>
|
||||
<Label text="Languages:" GridPane.rowIndex="1"/>
|
||||
<TextField fx:id="languagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="Reputation:" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="reputationTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
<Label text="Reputation:" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="reputationTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Max. trade volume:" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="maxTradeVolumeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
<Label text="Max. trade volume:" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="maxTradeVolumeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<Label text="Passive service fee:" GridPane.rowIndex="4"/>
|
||||
<TextField fx:id="passiveServiceFeeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||
<Label text="Passive service fee:" GridPane.rowIndex="4"/>
|
||||
<TextField fx:id="passiveServiceFeeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||
|
||||
<Label text="Arbitration fee:" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="arbitrationFeeTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" 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"/>
|
||||
|
||||
<Label text="Methods of arbitration:" GridPane.rowIndex="6"/>
|
||||
<TextField fx:id="methodsTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" 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"/>
|
||||
|
||||
<Label text="ID verifications:" GridPane.rowIndex="7"/>
|
||||
<TextField fx:id="idVerificationsTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" 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"/>
|
||||
|
||||
<Label text="Web page:" GridPane.rowIndex="9"/>
|
||||
<TextField fx:id="webPageTextField" editable="false" GridPane.columnIndex="1" GridPane.columnSpan="2" 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"/>
|
||||
|
||||
<Label text="Description:" GridPane.rowIndex="10" GridPane.valignment="TOP">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<TextArea fx:id="descriptionTextArea" editable="false" prefHeight="150.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="10"/>
|
||||
|
||||
</children>
|
||||
<Label text="Description:" GridPane.rowIndex="10" GridPane.valignment="TOP">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<TextArea fx:id="descriptionTextArea" editable="false" prefHeight="150.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="10"/>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/>
|
||||
|
@ -24,6 +24,10 @@ import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import io.bitsquare.user.Reputation;
|
||||
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.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
@ -37,18 +41,13 @@ import javafx.util.StringConverter;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationController.class);
|
||||
|
||||
private Storage storage;
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
private final Storage storage;
|
||||
private final WalletFacade walletFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private Arbitrator arbitrator;
|
||||
private ArbitratorProfileController arbitratorProfileController;
|
||||
private boolean isEditMode;
|
||||
|
@ -4,158 +4,144 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?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"
|
||||
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.arbitrators.registration.ArbitratorRegistrationController">
|
||||
<children>
|
||||
<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"
|
||||
AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.arbitrators.registration.ArbitratorRegistrationController">
|
||||
|
||||
<Accordion fx:id="accordion" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
|
||||
<panes>
|
||||
<Accordion fx:id="accordion" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
|
||||
<panes>
|
||||
|
||||
<TitledPane fx:id="profileTitledPane" text="Profile" expanded="true">
|
||||
<content>
|
||||
<TitledPane fx:id="profileTitledPane" text="Profile" expanded="true">
|
||||
|
||||
<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:"/>
|
||||
<TextField fx:id="nameTextField" GridPane.columnIndex="1" GridPane.columnSpan="3"/>
|
||||
<Label fx:id="nameLabel" text="Name:"/>
|
||||
<TextField fx:id="nameTextField" GridPane.columnIndex="1" GridPane.columnSpan="3"/>
|
||||
|
||||
<Label text="ID type:" 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"/>
|
||||
<Label text="ID type:" 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"/>
|
||||
|
||||
<Label text="Supported language(s):" 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"/>
|
||||
<ComboBox fx:id="languageComboBox" onAction="#onAddLanguage" prefWidth="150.0" promptText="Add language" GridPane.columnIndex="3" GridPane.rowIndex="2"/>
|
||||
<Label text="Supported language(s):" 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"/>
|
||||
<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"/>
|
||||
<TextField fx:id="maxTradeVolumeTextField" promptText="Recommended: 0.1 - 2 BTC" GridPane.columnIndex="1" GridPane.rowIndex="3" GridPane.columnSpan="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"/>
|
||||
|
||||
<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"/>
|
||||
<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"/>
|
||||
|
||||
<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"/>
|
||||
<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"/>
|
||||
|
||||
<Label text="Arbitration fee (%):" GridPane.rowIndex="6"/>
|
||||
<TextField fx:id="arbitrationFeeTextField" promptText="Recommended: 5 - 20 %" GridPane.columnIndex="1" GridPane.rowIndex="6" GridPane.columnSpan="3"/>
|
||||
<Label text="Arbitration fee (%):" GridPane.rowIndex="6"/>
|
||||
<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"/>
|
||||
<TextField fx:id="minArbitrationFeeTextField" promptText="Recommended: 0.1 - 0.2 BTC" GridPane.columnIndex="1" GridPane.rowIndex="7" GridPane.columnSpan="3"/>
|
||||
<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"/>
|
||||
|
||||
<Label text="Method(s) used for arbitration:" 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"/>
|
||||
<ComboBox fx:id="methodsComboBox" onAction="#onAddMethod" prefWidth="150.0" promptText="Add method" GridPane.columnIndex="3" 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"/>
|
||||
<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"/>
|
||||
|
||||
<Label text="Offer ID verification(s):" 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"/>
|
||||
<ComboBox fx:id="idVerificationsComboBox" onAction="#onAddIDVerification" prefWidth="150.0" promptText="Add verification" GridPane.columnIndex="3"
|
||||
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"/>
|
||||
<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"
|
||||
GridPane.rowIndex="9"/>
|
||||
|
||||
<Label text="Web page:" GridPane.rowIndex="10"/>
|
||||
<TextField fx:id="webPageTextField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="10"/>
|
||||
<Label text="Web page:" 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">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<TextArea fx:id="descriptionTextArea" prefHeight="150.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="11"/>
|
||||
<Label text="Description:" GridPane.rowIndex="11" GridPane.valignment="TOP">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<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 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 halignment="RIGHT" hgrow="SOMETIMES"/>
|
||||
<ColumnConstraints hgrow="ALWAYS"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" prefWidth="20.0" minWidth="20"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES"/>
|
||||
</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 vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
|
||||
</GridPane>
|
||||
</content>
|
||||
</TitledPane>
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
</TitledPane>
|
||||
|
||||
<TitledPane fx:id="payCollateralTitledPane" text="Pay collateral">
|
||||
<content>
|
||||
<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>
|
||||
</panes>
|
||||
</Accordion>
|
||||
</AnchorPane>
|
||||
|
@ -180,7 +180,7 @@
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
/* scrollpane */
|
||||
/* scroll-pane */
|
||||
|
||||
.scroll-pane {
|
||||
-fx-background-insets: 0;
|
||||
|
@ -6,29 +6,25 @@ import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.SingleSelectionModel;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 NavigationController navigationController;
|
||||
private String[] tabContentFXMLUrls;
|
||||
private Storage storage;
|
||||
SingleSelectionModel<Tab> selectionModel;
|
||||
private ChildController childController;
|
||||
|
||||
private Map<Integer, Node> views = new HashMap<>();
|
||||
private Map<Integer, ChildController> controllers = new HashMap<>();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -52,14 +48,7 @@ public class LazyLoadingTabPane extends TabPane
|
||||
storageId = navigationController.getClass().getName() + ".selectedTabIndex";
|
||||
|
||||
selectionModel = getSelectionModel();
|
||||
selectionModel.selectedItemProperty().addListener(new ChangeListener<Tab>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Tab> observableValue, Tab oldTab, Tab newTab)
|
||||
{
|
||||
onTabSelectedIndexChanged();
|
||||
}
|
||||
});
|
||||
selectionModel.selectedItemProperty().addListener((observableValue, oldTab, newTab) -> onTabSelectedIndexChanged());
|
||||
|
||||
Object indexObject = storage.read(storageId);
|
||||
if (indexObject != null)
|
||||
|
@ -9,8 +9,8 @@ import javafx.util.Duration;
|
||||
|
||||
public class NetworkSyncPane extends HBox
|
||||
{
|
||||
private ProgressBar networkSyncProgressBar;
|
||||
private Label networkSyncInfoLabel;
|
||||
private final ProgressBar networkSyncProgressBar;
|
||||
private final Label networkSyncInfoLabel;
|
||||
|
||||
public NetworkSyncPane()
|
||||
{
|
||||
|
@ -43,22 +43,22 @@ import javafx.scene.control.Skin;
|
||||
* <p>
|
||||
* ProgressIndicator sets focusTraversable to false.
|
||||
* </p>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* This first example creates a ProgressIndicator with an indeterminate value :
|
||||
* <pre><code>
|
||||
* import javafx.scene.control.ProgressIndicator;
|
||||
* ProgressIndicator p1 = new ProgressIndicator();
|
||||
* </code></pre>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* This next example creates a ProgressIndicator which is 25% complete :
|
||||
* <pre><code>
|
||||
* import javafx.scene.control.ProgressIndicator;
|
||||
* ProgressIndicator p2 = new ProgressIndicator();
|
||||
* p2.setProgress(0.25F);
|
||||
* </code></pre>
|
||||
* <p/>
|
||||
* <p>
|
||||
* Implementation of ProgressIndicator According to JavaFX UI Control API Specification
|
||||
*
|
||||
* @since JavaFX 2.0
|
||||
@ -79,6 +79,44 @@ public class ConfidenceProgressIndicator extends Control
|
||||
* 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.
|
||||
@ -91,10 +129,11 @@ public class ConfidenceProgressIndicator extends Control
|
||||
/**
|
||||
* Creates a new ProgressIndicator with the given progress value.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ConfidenceProgressIndicator(double progress)
|
||||
{
|
||||
// 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
|
||||
// StyleOrigin ensures that css will be able to override the value.
|
||||
((StyleableProperty) focusTraversableProperty()).applyStyle(null, Boolean.FALSE);
|
||||
@ -106,29 +145,17 @@ public class ConfidenceProgressIndicator extends Control
|
||||
pseudoClassStateChanged(PSEUDO_CLASS_INDETERMINATE, c == 0);
|
||||
pseudoClassStateChanged(PSEUDO_CLASS_DETERMINATE, c != 0);
|
||||
}
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Properties *
|
||||
* *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public final boolean isIndeterminate()
|
||||
{
|
||||
return indeterminate == null || indeterminate.get();
|
||||
}
|
||||
|
||||
private void setIndeterminate(boolean value)
|
||||
{
|
||||
indeterminatePropertyImpl().set(value);
|
||||
}
|
||||
|
||||
public final boolean isIndeterminate()
|
||||
{
|
||||
return indeterminate == null ? true : indeterminate.get();
|
||||
}
|
||||
|
||||
public final ReadOnlyBooleanProperty indeterminateProperty()
|
||||
{
|
||||
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
|
||||
* is 100%. Any value greater than 1 is interpreted as 100%.
|
||||
* ************************************************************************
|
||||
* *
|
||||
* Methods *
|
||||
* *
|
||||
* ************************************************************************
|
||||
*/
|
||||
private DoubleProperty progress;
|
||||
|
||||
public final void setProgress(double value)
|
||||
{
|
||||
progressProperty().set(value);
|
||||
}
|
||||
|
||||
public final double getProgress()
|
||||
{
|
||||
return progress == null ? INDETERMINATE_PROGRESS : progress.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* ************************************************************************
|
||||
* *
|
||||
* Stylesheet Handling *
|
||||
* *
|
||||
* ************************************************************************
|
||||
*/
|
||||
|
||||
public final void setProgress(double value)
|
||||
{
|
||||
progressProperty().set(value);
|
||||
}
|
||||
|
||||
public final DoubleProperty progressProperty()
|
||||
{
|
||||
if (progress == null)
|
||||
@ -210,12 +245,6 @@ public class ConfidenceProgressIndicator extends Control
|
||||
return progress;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Methods *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -225,34 +254,6 @@ public class ConfidenceProgressIndicator extends Control
|
||||
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
|
||||
* this method to return true, but ProgressIndicator returns false for
|
||||
@ -263,6 +264,7 @@ public class ConfidenceProgressIndicator extends Control
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected /*do not make final*/ Boolean impl_cssGetFocusTraversableInitialValue()
|
||||
{
|
||||
return Boolean.FALSE;
|
||||
|
@ -26,7 +26,6 @@ package io.bitsquare.gui.components.confidence.behavior;
|
||||
|
||||
import com.sun.javafx.scene.control.behavior.BehaviorBase;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class ConfidenceProgressIndicatorBehavior<C extends ConfidenceProgressIndicator> extends BehaviorBase<C>
|
||||
|
@ -31,6 +31,9 @@ import com.sun.javafx.css.converters.SizeConverter;
|
||||
import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
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.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
@ -42,8 +45,6 @@ import javafx.beans.property.ObjectProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.css.*;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.NodeOrientation;
|
||||
import javafx.scene.Node;
|
||||
@ -59,10 +60,6 @@ import javafx.scene.shape.Circle;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<ConfidenceProgressIndicator, ConfidenceProgressIndicatorBehavior<ConfidenceProgressIndicator>>
|
||||
{
|
||||
|
||||
@ -85,7 +82,108 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
} */
|
||||
|
||||
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;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
@ -95,19 +193,12 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
* *
|
||||
* ************************************************************************
|
||||
*/
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ConfidenceProgressIndicatorSkin(ConfidenceProgressIndicator control)
|
||||
{
|
||||
super(control, new ConfidenceProgressIndicatorBehavior<ConfidenceProgressIndicator>(control));
|
||||
super(control, new ConfidenceProgressIndicatorBehavior<>(control));
|
||||
|
||||
InvalidationListener indeterminateListener = new InvalidationListener()
|
||||
{
|
||||
@Override
|
||||
public void invalidated(Observable valueModel)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
};
|
||||
InvalidationListener indeterminateListener = valueModel -> initialize();
|
||||
control.indeterminateProperty().addListener(indeterminateListener);
|
||||
|
||||
InvalidationListener visibilityListener = new InvalidationListener()
|
||||
@ -178,6 +269,16 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
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()
|
||||
{
|
||||
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 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
|
||||
private int intProgress;
|
||||
|
||||
// only update pie arc to nearest degree
|
||||
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)
|
||||
{
|
||||
@ -271,14 +387,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
intProgress = (int) Math.round(control.getProgress() * 100.0);
|
||||
degProgress = (int) (360 * control.getProgress());
|
||||
|
||||
InvalidationListener progressListener = new InvalidationListener()
|
||||
{
|
||||
@Override
|
||||
public void invalidated(Observable valueModel)
|
||||
{
|
||||
updateProgress();
|
||||
}
|
||||
};
|
||||
InvalidationListener progressListener = valueModel -> updateProgress();
|
||||
control.progressProperty().addListener(progressListener);
|
||||
|
||||
getChildren().clear();
|
||||
@ -495,11 +604,11 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
|
||||
static class IndeterminateSpinner extends Region
|
||||
{
|
||||
private ConfidenceProgressIndicator control;
|
||||
private ConfidenceProgressIndicatorSkin skin;
|
||||
private IndicatorPaths pathsG;
|
||||
private Timeline indeterminateTimeline;
|
||||
private final List<Double> opacities = new ArrayList<Double>();
|
||||
private final ConfidenceProgressIndicator control;
|
||||
private final ConfidenceProgressIndicatorSkin skin;
|
||||
private final IndicatorPaths pathsG;
|
||||
private final Timeline indeterminateTimeline;
|
||||
private final List<Double> opacities = new ArrayList<>();
|
||||
private boolean spinEnabled = false;
|
||||
private Paint fillOverride = null;
|
||||
|
||||
@ -547,14 +656,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
{
|
||||
keyFrames.add(
|
||||
new KeyFrame(
|
||||
Duration.millis(i), new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent event)
|
||||
{
|
||||
shiftColors();
|
||||
}
|
||||
}));
|
||||
Duration.millis(i), event -> shiftColors()));
|
||||
}
|
||||
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
|
||||
protected void layoutChildren()
|
||||
{
|
||||
@ -727,126 +732,106 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
pathsG.getChildren().get(i).setOpacity(opacities.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Paint getProgressColor()
|
||||
{
|
||||
return progressColor.get();
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
private class IndicatorPaths extends Pane
|
||||
{
|
||||
final IndeterminateSpinner piSkin;
|
||||
|
||||
/**
|
||||
* The colour of the progress segment.
|
||||
*/
|
||||
private ObjectProperty<Paint> progressColor =
|
||||
new StyleableObjectProperty<Paint>(null)
|
||||
IndicatorPaths(IndeterminateSpinner pi)
|
||||
{
|
||||
super();
|
||||
piSkin = pi;
|
||||
InvalidationListener treeVisibilityListener = valueModel -> {
|
||||
if (piSkin.skin.getSkinnable().impl_isTreeVisible())
|
||||
{
|
||||
piSkin.pauseIndicator(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
piSkin.pauseIndicator(true);
|
||||
}
|
||||
};
|
||||
impl_treeVisibleProperty().addListener(treeVisibilityListener);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The number of segments in the spinner.
|
||||
*/
|
||||
private IntegerProperty indeterminateSegmentCount =
|
||||
new StyleableIntegerProperty(8)
|
||||
@Override
|
||||
protected double computePrefWidth(double height)
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void invalidated()
|
||||
double w = 0;
|
||||
for (Node child : getChildren())
|
||||
{
|
||||
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
|
||||
public Object getBean()
|
||||
@Override
|
||||
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
|
||||
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
|
||||
protected void layoutChildren()
|
||||
{
|
||||
// calculate scale
|
||||
double scale = getWidth() / computePrefWidth(-1);
|
||||
getChildren().stream().filter(child -> child instanceof Region).forEach(child -> {
|
||||
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
|
||||
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.
|
||||
*
|
||||
* @treatAsPrivate implementation detail
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
private static class StyleableProperties
|
||||
{
|
||||
public static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
|
||||
private static final CssMetaData<ConfidenceProgressIndicator, Paint> PROGRESS_COLOR =
|
||||
new CssMetaData<ConfidenceProgressIndicator, Paint>("-fx-progress-color",
|
||||
PaintConverter.getInstance(), null)
|
||||
@ -867,6 +852,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
return (StyleableProperty<Paint>) skin.progressColor;
|
||||
}
|
||||
};
|
||||
|
||||
private static final CssMetaData<ConfidenceProgressIndicator, Number> INDETERMINATE_SEGMENT_COUNT =
|
||||
new CssMetaData<ConfidenceProgressIndicator, Number>("-fx-indeterminate-segment-count",
|
||||
SizeConverter.getInstance(), 8)
|
||||
@ -913,12 +899,9 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
}
|
||||
};
|
||||
|
||||
public static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
|
||||
|
||||
static
|
||||
{
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables =
|
||||
new ArrayList<CssMetaData<? extends Styleable, ?>>(SkinBase.getClassCssMetaData());
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(SkinBase.getClassCssMetaData());
|
||||
styleables.add(PROGRESS_COLOR);
|
||||
styleables.add(INDETERMINATE_SEGMENT_COUNT);
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package io.bitsquare.gui.components.processbar;
|
||||
|
||||
import java.util.List;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Skin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProcessStepBar<T> extends Control
|
||||
{
|
||||
|
||||
@ -27,6 +26,11 @@ public class ProcessStepBar<T> extends Control
|
||||
return new ProcessStepBarSkin<>(this);
|
||||
}
|
||||
|
||||
List<ProcessStepItem> getProcessStepItems()
|
||||
{
|
||||
return processStepItems;
|
||||
}
|
||||
|
||||
public void setProcessStepItems(List<ProcessStepItem> processStepItems)
|
||||
{
|
||||
this.processStepItems = processStepItems;
|
||||
@ -34,11 +38,6 @@ public class ProcessStepBar<T> extends Control
|
||||
((ProcessStepBarSkin) getSkin()).dataChanged();
|
||||
}
|
||||
|
||||
List<ProcessStepItem> getProcessStepItems()
|
||||
{
|
||||
return processStepItems;
|
||||
}
|
||||
|
||||
public void next()
|
||||
{
|
||||
((ProcessStepBarSkin) getSkin()).next();
|
||||
|
@ -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.KeyBinding;
|
||||
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.Pos;
|
||||
import javafx.scene.Node;
|
||||
@ -14,17 +17,12 @@ import javafx.scene.layout.BorderWidths;
|
||||
import javafx.scene.paint.Color;
|
||||
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>>>
|
||||
{
|
||||
final ProcessStepBar<T> controller;
|
||||
LabelWithBorder currentLabelWithBorder;
|
||||
LabelWithBorder prevLabelWithBorder;
|
||||
final ProcessStepBar<T> controller;
|
||||
int index;
|
||||
List<LabelWithBorder> labelWithBorders;
|
||||
|
||||
@ -49,9 +47,8 @@ public class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, B
|
||||
int i = 0;
|
||||
labelWithBorders = new ArrayList<>();
|
||||
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);
|
||||
getChildren().add(labelWithBorder);
|
||||
labelWithBorders.add(labelWithBorder);
|
||||
@ -105,12 +102,12 @@ public class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, B
|
||||
|
||||
public static class LabelWithBorder extends Label
|
||||
{
|
||||
final double borderWidth = 1;
|
||||
private final double arrowWidth = 10;
|
||||
private final double arrowHeight = 30;
|
||||
private ProcessStepItem processStepItem;
|
||||
private boolean isFirst;
|
||||
private boolean isLast;
|
||||
double borderWidth = 1;
|
||||
private final ProcessStepItem processStepItem;
|
||||
private final boolean isFirst;
|
||||
private final boolean isLast;
|
||||
|
||||
public LabelWithBorder(ProcessStepItem processStepItem, boolean isFirst, boolean isLast)
|
||||
{
|
||||
|
@ -5,9 +5,9 @@ import javafx.scene.paint.Paint;
|
||||
|
||||
public class ProcessStepItem
|
||||
{
|
||||
private String label;
|
||||
private Paint color;
|
||||
private boolean progressIndicator;
|
||||
private final String label;
|
||||
private final Paint color;
|
||||
private final boolean progressIndicator;
|
||||
|
||||
public ProcessStepItem(String label)
|
||||
{
|
||||
|
@ -7,18 +7,17 @@ import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationViewURL;
|
||||
import io.bitsquare.gui.components.LazyLoadingTabPane;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class FundsController implements Initializable, ChildController, NavigationController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(FundsController.class);
|
||||
private Storage storage;
|
||||
private final Storage storage;
|
||||
|
||||
@FXML
|
||||
private LazyLoadingTabPane tabPane;
|
||||
|
@ -3,8 +3,8 @@
|
||||
<?import io.bitsquare.gui.components.LazyLoadingTabPane?>
|
||||
<?import javafx.scene.control.Tab?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.funds.FundsController">
|
||||
<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="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.funds.FundsController">
|
||||
|
||||
<Tab text="Deposit" closable="false"/>
|
||||
<Tab text="Withdrawal" closable="false"/>
|
||||
|
@ -8,11 +8,13 @@ import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
@ -22,19 +24,15 @@ import javafx.util.Callback;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class DepositController implements Initializable, ChildController, Hibernate
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(DepositController.class);
|
||||
|
||||
private WalletFacade walletFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
protected ObservableList<DepositListItem> addressList;
|
||||
|
||||
@FXML
|
||||
private TableView tableView;
|
||||
private TableView<DepositListItem> tableView;
|
||||
@FXML
|
||||
private TableColumn<String, DepositListItem> labelColumn, addressColumn, balanceColumn, copyColumn, confidenceColumn;
|
||||
@FXML
|
||||
@ -81,9 +79,9 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
@Override
|
||||
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();
|
||||
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);
|
||||
@ -158,14 +156,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId());
|
||||
Tooltip.install(hyperlink, tooltip);
|
||||
|
||||
hyperlink.setOnAction(new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent event)
|
||||
{
|
||||
log.info("Show trade details " + item.getAddressEntry().getTradeId());
|
||||
}
|
||||
});
|
||||
hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressEntry().getTradeId()));
|
||||
}
|
||||
setGraphic(hyperlink);
|
||||
}
|
||||
@ -219,7 +210,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
{
|
||||
return new TableCell<String, DepositListItem>()
|
||||
{
|
||||
Label copyIcon = new Label();
|
||||
final Label copyIcon = new Label();
|
||||
|
||||
{
|
||||
copyIcon.getStyleClass().add("copy-icon");
|
||||
|
@ -4,7 +4,7 @@ import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.funds.withdrawal.WithdrawalListItem;
|
||||
|
||||
public class DepositListItem extends WithdrawalListItem
|
||||
class DepositListItem extends WithdrawalListItem
|
||||
{
|
||||
public DepositListItem(AddressEntry addressEntry, WalletFacade walletFacade)
|
||||
{
|
||||
|
@ -4,8 +4,8 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<VBox spacing="10" fx:controller="io.bitsquare.gui.funds.deposit.DepositController" 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.deposit.DepositController"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</padding>
|
||||
|
@ -6,11 +6,13 @@ import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
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.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
@ -18,15 +20,11 @@ import javafx.util.Callback;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class TransactionsController implements Initializable, ChildController, Hibernate
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TransactionsController.class);
|
||||
|
||||
private WalletFacade walletFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
protected ObservableList<TransactionsListItem> transactionsListItems;
|
||||
|
||||
@FXML
|
||||
@ -75,9 +73,9 @@ public class TransactionsController implements Initializable, ChildController, H
|
||||
@Override
|
||||
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);
|
||||
transactionsListItems = FXCollections.observableArrayList();
|
||||
for (int i = 0; i < transactions.size(); i++)
|
||||
{
|
||||
transactionsListItems.add(new TransactionsListItem(transactions.get(i), walletFacade));
|
||||
}
|
||||
transactionsListItems.addAll(transactions.stream().map(transaction -> new TransactionsListItem(transaction, walletFacade)).collect(Collectors.toList()));
|
||||
|
||||
tableView.setItems(transactionsListItems);
|
||||
}
|
||||
@ -141,14 +136,7 @@ public class TransactionsController implements Initializable, ChildController, H
|
||||
{
|
||||
hyperlink = new Hyperlink(item.getAddressString());
|
||||
hyperlink.setId("id-link");
|
||||
hyperlink.setOnAction(new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent event)
|
||||
{
|
||||
log.info("Show trade details " + item.getAddressString());
|
||||
}
|
||||
});
|
||||
hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressString()));
|
||||
setGraphic(hyperlink);
|
||||
}
|
||||
else
|
||||
|
@ -9,27 +9,25 @@ import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.btc.listeners.ConfidenceListener;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import java.math.BigInteger;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class TransactionsListItem
|
||||
class TransactionsListItem
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TransactionsListItem.class);
|
||||
private final StringProperty date = new SimpleStringProperty();
|
||||
private final StringProperty amount = 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 Transaction transaction;
|
||||
private WalletFacade walletFacade;
|
||||
private ConfidenceListener confidenceListener;
|
||||
private ConfidenceProgressIndicator progressIndicator;
|
||||
private Tooltip tooltip;
|
||||
|
||||
public TransactionsListItem(Transaction transaction, WalletFacade walletFacade)
|
||||
{
|
||||
|
@ -4,8 +4,8 @@
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<VBox spacing="10" fx:controller="io.bitsquare.gui.funds.transactions.TransactionsController" 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.transactions.TransactionsController"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</padding>
|
||||
|
@ -11,15 +11,17 @@ import io.bitsquare.btc.*;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
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.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
@ -31,21 +33,16 @@ import org.controlsfx.dialog.Dialog;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(WithdrawalController.class);
|
||||
|
||||
|
||||
private WalletFacade walletFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
protected ObservableList<WithdrawalListItem> addressList;
|
||||
|
||||
@FXML
|
||||
private TableView tableView;
|
||||
private TableView<WithdrawalListItem> tableView;
|
||||
@FXML
|
||||
private TableColumn<String, WithdrawalListItem> labelColumn, addressColumn, balanceColumn, copyColumn, confidenceColumn;
|
||||
@FXML
|
||||
@ -80,28 +77,23 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
setCopyColumnCellFactory();
|
||||
setConfidenceColumnCellFactory();
|
||||
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<WithdrawalListItem>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends WithdrawalListItem> observableValue, WithdrawalListItem oldValue, WithdrawalListItem newValue)
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||
if (newValue != null)
|
||||
{
|
||||
if (newValue != null)
|
||||
{
|
||||
BitSquareValidator.resetTextFields(withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField);
|
||||
BitSquareValidator.resetTextFields(withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField);
|
||||
|
||||
if (newValue.getBalance().compareTo(BigInteger.ZERO) > 0)
|
||||
{
|
||||
amountTextField.setText(BtcFormatter.satoshiToString(newValue.getBalance()));
|
||||
withdrawFromTextField.setText(newValue.getAddressEntry().getAddressString());
|
||||
changeAddressTextField.setText(newValue.getAddressEntry().getAddressString());
|
||||
}
|
||||
else
|
||||
{
|
||||
withdrawFromTextField.setText("");
|
||||
withdrawFromTextField.setPromptText("No fund to withdrawal on that address.");
|
||||
amountTextField.setText("");
|
||||
amountTextField.setPromptText("Invalid amount");
|
||||
}
|
||||
if (newValue.getBalance().compareTo(BigInteger.ZERO) > 0)
|
||||
{
|
||||
amountTextField.setText(BtcFormatter.satoshiToString(newValue.getBalance()));
|
||||
withdrawFromTextField.setText(newValue.getAddressEntry().getAddressString());
|
||||
changeAddressTextField.setText(newValue.getAddressEntry().getAddressString());
|
||||
}
|
||||
else
|
||||
{
|
||||
withdrawFromTextField.setText("");
|
||||
withdrawFromTextField.setPromptText("No fund to withdrawal on that address.");
|
||||
amountTextField.setText("");
|
||||
amountTextField.setPromptText("Invalid amount");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -120,9 +112,9 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
@Override
|
||||
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();
|
||||
addressList = FXCollections.observableArrayList();
|
||||
for (int i = 0; i < addressEntryList.size(); i++)
|
||||
{
|
||||
addressList.add(new WithdrawalListItem(addressEntryList.get(i), walletFacade));
|
||||
}
|
||||
addressList.addAll(addressEntryList.stream().map(anAddressEntryList -> new WithdrawalListItem(anAddressEntryList, walletFacade)).collect(Collectors.toList()));
|
||||
|
||||
tableView.setItems(addressList);
|
||||
}
|
||||
@ -215,6 +204,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
|
||||
} 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.install(hyperlink, tooltip);
|
||||
|
||||
hyperlink.setOnAction(new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent event)
|
||||
{
|
||||
log.info("Show trade details " + item.getAddressEntry().getTradeId());
|
||||
}
|
||||
});
|
||||
hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressEntry().getTradeId()));
|
||||
}
|
||||
setGraphic(hyperlink);
|
||||
}
|
||||
@ -315,7 +298,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
{
|
||||
return new TableCell<String, WithdrawalListItem>()
|
||||
{
|
||||
Label copyIcon = new Label();
|
||||
final Label copyIcon = new Label();
|
||||
|
||||
{
|
||||
copyIcon.getStyleClass().add("copy-icon");
|
||||
|
@ -8,23 +8,22 @@ import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.btc.listeners.BalanceListener;
|
||||
import io.bitsquare.btc.listeners.ConfidenceListener;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import java.math.BigInteger;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class WithdrawalListItem
|
||||
{
|
||||
private final StringProperty addressString = new SimpleStringProperty();
|
||||
private final BalanceListener balanceListener;
|
||||
private final Label balanceLabel;
|
||||
private AddressEntry addressEntry;
|
||||
private WalletFacade walletFacade;
|
||||
private ConfidenceListener confidenceListener;
|
||||
private ConfidenceProgressIndicator progressIndicator;
|
||||
private Tooltip tooltip;
|
||||
private final AddressEntry addressEntry;
|
||||
private final WalletFacade walletFacade;
|
||||
private final ConfidenceListener confidenceListener;
|
||||
private final ConfidenceProgressIndicator progressIndicator;
|
||||
private final Tooltip tooltip;
|
||||
private BigInteger balance;
|
||||
|
||||
public WithdrawalListItem(AddressEntry addressEntry, WalletFacade walletFacade)
|
||||
|
@ -4,7 +4,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
<?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>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</padding>
|
||||
@ -27,22 +27,20 @@
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</padding>
|
||||
<children>
|
||||
|
||||
<Label text="Amount (BTC):" GridPane.rowIndex="0"/>
|
||||
<TextField fx:id="amountTextField" GridPane.rowIndex="0" GridPane.columnIndex="1"/>
|
||||
<Label text="Amount (BTC):" GridPane.rowIndex="0"/>
|
||||
<TextField fx:id="amountTextField" GridPane.rowIndex="0" GridPane.columnIndex="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"/>
|
||||
<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"/>
|
||||
|
||||
<Label text="Change address:" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="changeAddressTextField" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
|
||||
<Label text="Change address:" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="changeAddressTextField" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Withdraw to address:" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="withdrawToTextField" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
|
||||
<Label text="Withdraw to address:" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="withdrawToTextField" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
|
||||
|
||||
<Button text="Withdraw" defaultButton="true" onAction="#onWithdraw" GridPane.rowIndex="4" GridPane.columnIndex="1"/>
|
||||
</children>
|
||||
<Button text="Withdraw" defaultButton="true" onAction="#onWithdraw" GridPane.rowIndex="4" GridPane.columnIndex="1"/>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
|
||||
|
@ -8,6 +8,9 @@ import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationViewURL;
|
||||
import io.bitsquare.gui.arbitrators.registration.ArbitratorRegistrationController;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -18,16 +21,11 @@ import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class HomeController implements Initializable, ChildController, NavigationController
|
||||
{
|
||||
private NavigationController navigationController;
|
||||
|
||||
@FXML
|
||||
public Pane rootContainer;
|
||||
private NavigationController navigationController;
|
||||
private ArbitratorRegistrationController arbitratorRegistrationController;
|
||||
|
||||
@Override
|
||||
|
@ -1,19 +1,13 @@
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<children>
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<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"
|
||||
AnchorPane.topAnchor="10.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"/>
|
||||
<Label text="TODO"/>
|
||||
|
||||
<Label id="headline-label" text="Overview"/>
|
||||
<Label text="TODO"/>
|
||||
|
||||
<Button text="Register yourself as an arbitrator" onAction="#onArbitratorRegistration"/>
|
||||
<Button text="Edit my arbitrator details" onAction="#onArbitratorEdit"/>
|
||||
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
<Button text="Register yourself as an arbitrator" onAction="#onArbitratorRegistration"/>
|
||||
<Button text="Edit my arbitrator details" onAction="#onArbitratorEdit"/>
|
||||
</VBox>
|
||||
</AnchorPane>
|
@ -8,16 +8,15 @@ import io.bitsquare.gui.NavigationViewURL;
|
||||
import io.bitsquare.gui.market.orderbook.OrderBookController;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class MarketController implements Initializable, NavigationController, ChildController
|
||||
{
|
||||
private ChildController childController;
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
<?import javafx.scene.control.TabPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<TabPane 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"
|
||||
<TabPane 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"
|
||||
fx:controller="io.bitsquare.gui.market.MarketController"/>
|
@ -12,10 +12,10 @@ import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationViewURL;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.gui.util.BitSquareConverter;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.gui.util.ConfidenceDisplay;
|
||||
import io.bitsquare.gui.util.Popups;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.settings.Settings;
|
||||
@ -25,8 +25,11 @@ import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.util.Random;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -38,22 +41,15 @@ import javafx.scene.layout.AnchorPane;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
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 Trading trading;
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
private Settings settings;
|
||||
private User user;
|
||||
private Direction direction;
|
||||
private Offer offer;
|
||||
private ConfidenceDisplay confidenceDisplay;
|
||||
@ -111,22 +107,8 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
collateralTextField.setText("10");
|
||||
updateVolume();
|
||||
|
||||
amountTextField.textProperty().addListener(new ChangeListener<String>()
|
||||
{
|
||||
@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();
|
||||
}
|
||||
});
|
||||
amountTextField.textProperty().addListener((observable, oldValue, newValue) -> updateVolume());
|
||||
priceTextField.textProperty().addListener((observable, oldValue, newValue) -> updateVolume());
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,105 +4,100 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.market.createOffer.CreateOfferController">
|
||||
<children>
|
||||
<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"
|
||||
AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.market.createOffer.CreateOfferController">
|
||||
|
||||
<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"/>
|
||||
<GridPane hgap="5.0" vgap="5.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.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">
|
||||
<TextField fx:id="amountTextField" prefWidth="70.0" alignment="CENTER_RIGHT"/>
|
||||
<Label text="BTC for:"/>
|
||||
<TextField fx:id="priceTextField" prefWidth="70.0" alignment="CENTER_RIGHT"/>
|
||||
<Label text="EUR ="/>
|
||||
<TextField fx:id="volumeTextField" prefWidth="70.0" alignment="CENTER_RIGHT" editable="false"/>
|
||||
<Label text="EUR in total"/>
|
||||
</HBox>
|
||||
<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"/>
|
||||
<Label text="BTC for:"/>
|
||||
<TextField fx:id="priceTextField" prefWidth="70.0" alignment="CENTER_RIGHT"/>
|
||||
<Label text="EUR ="/>
|
||||
<TextField fx:id="volumeTextField" prefWidth="70.0" alignment="CENTER_RIGHT" editable="false"/>
|
||||
<Label text="EUR in total"/>
|
||||
</HBox>
|
||||
|
||||
<Label text="Min. Amount:" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="minAmountTextField" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
<Label text="Min. Amount:" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="minAmountTextField" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Collateral (%):" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="collateralTextField" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
<Label text="Collateral (%):" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="collateralTextField" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<Label id="form-header-text" text="Offer details" GridPane.rowIndex="4">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label id="form-header-text" text="Offer details" GridPane.rowIndex="4">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
|
||||
<Label text="Bank account type:" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
<Label text="Bank account type:" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
|
||||
<Label text="Bank account currency:" GridPane.rowIndex="6"/>
|
||||
<TextField fx:id="bankAccountCurrencyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
|
||||
<Label text="Bank account currency:" GridPane.rowIndex="6"/>
|
||||
<TextField fx:id="bankAccountCurrencyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
|
||||
|
||||
<Label text="Bank account county:" GridPane.rowIndex="7"/>
|
||||
<TextField fx:id="bankAccountCountyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="7"/>
|
||||
<Label text="Bank account county:" GridPane.rowIndex="7"/>
|
||||
<TextField fx:id="bankAccountCountyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="7"/>
|
||||
|
||||
<Label text="Accepted countries:" GridPane.rowIndex="8"/>
|
||||
<TextField fx:id="acceptedCountriesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8"/>
|
||||
<Label text="Accepted countries:" GridPane.rowIndex="8"/>
|
||||
<TextField fx:id="acceptedCountriesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8"/>
|
||||
|
||||
<Label text="Accepted languages:" GridPane.rowIndex="9"/>
|
||||
<TextField fx:id="acceptedLanguagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
|
||||
<Label text="Accepted languages:" 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">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label id="form-header-text" fx:id="placeOfferTitle" text="Place offer:" GridPane.rowIndex="10">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
|
||||
<Label text="Offer fee:" GridPane.rowIndex="11"/>
|
||||
<TextField fx:id="feeLabel" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="11"/>
|
||||
<Label text="Offer fee:" 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"/>
|
||||
<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"
|
||||
GridPane.rowIndex="12" GridPane.rowSpan="2" GridPane.valignment="TOP">
|
||||
<GridPane.margin>
|
||||
<Insets top="2.0"/>
|
||||
</GridPane.margin>
|
||||
</ConfidenceProgressIndicator>
|
||||
<Label fx:id="confirmationLabel" text="Checking confirmations..." visible="false" GridPane.columnIndex="3" 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"/>
|
||||
<ConfidenceProgressIndicator fx:id="progressIndicator" visible="false" progress="0" GridPane.columnIndex="2" GridPane.halignment="LEFT"
|
||||
GridPane.rowIndex="12" GridPane.rowSpan="2" GridPane.valignment="TOP">
|
||||
<GridPane.margin>
|
||||
<Insets top="2.0"/>
|
||||
</GridPane.margin>
|
||||
</ConfidenceProgressIndicator>
|
||||
<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>
|
||||
<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>
|
||||
</GridPane>
|
||||
</AnchorPane>
|
||||
|
@ -11,10 +11,10 @@ import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.*;
|
||||
import io.bitsquare.gui.market.createOffer.CreateOfferController;
|
||||
import io.bitsquare.gui.market.trade.TakerTradeController;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.gui.util.BitSquareConverter;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.gui.util.Icons;
|
||||
import io.bitsquare.gui.util.Popups;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
@ -28,10 +28,16 @@ import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
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.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -48,32 +54,18 @@ import org.controlsfx.dialog.Dialogs;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderBookController.class);
|
||||
private NavigationController navigationController;
|
||||
private OrderBook orderBook;
|
||||
private SortedList<OrderBookListItem> offerList;
|
||||
private final OrderBook orderBook;
|
||||
private final OrderBookFilter orderBookFilter;
|
||||
private User user;
|
||||
private MessageFacade messageFacade;
|
||||
private WalletFacade walletFacade;
|
||||
private Settings settings;
|
||||
private Storage storage;
|
||||
private AnimationTimer pollingTimer;
|
||||
private Image buyIcon = Icons.getIconImage(Icons.BUY);
|
||||
private Image sellIcon = Icons.getIconImage(Icons.SELL);
|
||||
|
||||
private final User user;
|
||||
private final MessageFacade messageFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
private final Settings settings;
|
||||
private final Storage storage;
|
||||
private final Image buyIcon = Icons.getIconImage(Icons.BUY);
|
||||
private final Image sellIcon = Icons.getIconImage(Icons.SELL);
|
||||
@FXML
|
||||
public AnchorPane holderPane;
|
||||
@FXML
|
||||
@ -83,11 +75,14 @@ public class OrderBookController implements Initializable, ChildController
|
||||
@FXML
|
||||
public TableView<OrderBookListItem> orderBookTable;
|
||||
@FXML
|
||||
public TableColumn priceColumn, amountColumn, volumeColumn;
|
||||
@FXML
|
||||
private TableColumn<String, OrderBookListItem> directionColumn, countryColumn, bankAccountTypeColumn;
|
||||
public TableColumn<OrderBookListItem, String> priceColumn, amountColumn, volumeColumn;
|
||||
@FXML
|
||||
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();
|
||||
|
||||
// handlers
|
||||
amount.textProperty().addListener(new ChangeListener<String>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
|
||||
{
|
||||
orderBookFilter.setAmount(textInputToNumber(oldValue, newValue));
|
||||
updateVolume();
|
||||
}
|
||||
amount.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
orderBookFilter.setAmount(textInputToNumber(oldValue, newValue));
|
||||
updateVolume();
|
||||
});
|
||||
|
||||
price.textProperty().addListener(new ChangeListener<String>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
|
||||
{
|
||||
orderBookFilter.setPrice(textInputToNumber(oldValue, newValue));
|
||||
updateVolume();
|
||||
}
|
||||
price.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
orderBookFilter.setPrice(textInputToNumber(oldValue, newValue));
|
||||
updateVolume();
|
||||
});
|
||||
|
||||
orderBookFilter.getDirectionChangedProperty().addListener(new ChangeListener<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue)
|
||||
{
|
||||
applyOffers();
|
||||
}
|
||||
});
|
||||
orderBookFilter.getDirectionChangedProperty().addListener((observable, oldValue, newValue) -> applyOffers());
|
||||
|
||||
user.getBankAccountChangedProperty().addListener(new ChangeListener<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue)
|
||||
{
|
||||
orderBook.loadOffers();
|
||||
}
|
||||
});
|
||||
user.getBankAccountChangedProperty().addListener((observable, oldValue, newValue) -> orderBook.loadOffers());
|
||||
|
||||
createOfferButton.setOnAction(e -> createOffer());
|
||||
|
||||
@ -369,13 +340,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
|
||||
private void removeOffer(Offer offer)
|
||||
{
|
||||
try
|
||||
{
|
||||
orderBook.removeOffer(offer);
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
orderBook.removeOffer(offer);
|
||||
}
|
||||
|
||||
private void applyOffers()
|
||||
@ -393,28 +358,13 @@ public class OrderBookController implements Initializable, ChildController
|
||||
{
|
||||
|
||||
pollingTimer = Utilities.setInterval(1000, (AnimationTimer animationTimer) -> {
|
||||
try
|
||||
{
|
||||
if (user.getCurrentBankAccount() != null)
|
||||
messageFacade.getDirtyFlag(user.getCurrentBankAccount().getCurrency());
|
||||
else
|
||||
messageFacade.getDirtyFlag(CurrencyUtil.getDefaultCurrency());
|
||||
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
if (user.getCurrentBankAccount() != null)
|
||||
messageFacade.getDirtyFlag(user.getCurrentBankAccount().getCurrency());
|
||||
else
|
||||
messageFacade.getDirtyFlag(CurrencyUtil.getDefaultCurrency());
|
||||
return null;
|
||||
});
|
||||
messageFacade.getIsDirtyProperty().addListener(new ChangeListener<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue)
|
||||
{
|
||||
//log.info("getIsDirtyProperty changed " + oldValue + "/" + newValue);
|
||||
orderBook.loadOffers();
|
||||
}
|
||||
});
|
||||
messageFacade.getIsDirtyProperty().addListener((observableValue, oldValue, newValue) -> orderBook.loadOffers());
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class OrderBookListItem
|
||||
protected final StringProperty amount = new SimpleStringProperty();
|
||||
protected final StringProperty volume = new SimpleStringProperty();
|
||||
|
||||
protected Offer offer;
|
||||
protected final Offer offer;
|
||||
|
||||
|
||||
public OrderBookListItem(Offer offer)
|
||||
|
@ -4,69 +4,65 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane fx:id="holderPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="holderPane" AnchorPane.bottomAnchor="0.0"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
|
||||
fx:controller="io.bitsquare.gui.market.orderbook.OrderBookController">
|
||||
<children>
|
||||
|
||||
<HBox fx:id="topHBox" prefHeight="22.0" AnchorPane.topAnchor="10.0" AnchorPane.leftAnchor="10.0"
|
||||
AnchorPane.rightAnchor="10.0">
|
||||
<children>
|
||||
<TextField fx:id="amount" prefHeight="26.0" prefWidth="60.0" alignment="CENTER_RIGHT">
|
||||
<HBox.margin>
|
||||
<Insets left="0.0"/>
|
||||
</HBox.margin>
|
||||
</TextField>
|
||||
<Label text="BTC for">
|
||||
<padding>
|
||||
<Insets left="4.0" right="4.0" top="5.0"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<TextField fx:id="price" prefHeight="26.0" prefWidth="70.0" alignment="CENTER_RIGHT"/>
|
||||
<Label text="EUR/BTC =">
|
||||
<padding>
|
||||
<Insets left="4.0" right="4.0" top="5.0"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<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">
|
||||
<padding>
|
||||
<Insets left="4.0" right="4.0" top="5.0"/>
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets/>
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="topHBox" prefHeight="22.0" AnchorPane.topAnchor="10.0" AnchorPane.leftAnchor="10.0"
|
||||
AnchorPane.rightAnchor="10.0">
|
||||
<TextField fx:id="amount" prefHeight="26.0" prefWidth="60.0" alignment="CENTER_RIGHT">
|
||||
<HBox.margin>
|
||||
<Insets left="0.0"/>
|
||||
</HBox.margin>
|
||||
</TextField>
|
||||
<Label text="BTC for">
|
||||
<padding>
|
||||
<Insets left="4.0" right="4.0" top="5.0"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<TextField fx:id="price" prefHeight="26.0" prefWidth="70.0" alignment="CENTER_RIGHT"/>
|
||||
<Label text="EUR/BTC =">
|
||||
<padding>
|
||||
<Insets left="4.0" right="4.0" top="5.0"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<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">
|
||||
<padding>
|
||||
<Insets left="4.0" right="4.0" top="5.0"/>
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets/>
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
</HBox>
|
||||
|
||||
<Button fx:id="createOfferButton" text="Create new offer" AnchorPane.topAnchor="10.0"
|
||||
AnchorPane.rightAnchor="10.0"/>
|
||||
<Button fx:id="createOfferButton" text="Create new offer" AnchorPane.topAnchor="10.0"
|
||||
AnchorPane.rightAnchor="10.0"/>
|
||||
|
||||
<TableView fx:id="orderBookTable" AnchorPane.leftAnchor="10.0"
|
||||
AnchorPane.topAnchor="45.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0">
|
||||
<columns>
|
||||
<TableColumn text="Amount (Min.)" fx:id="amountColumn" minWidth="120">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="amount"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="Price" fx:id="priceColumn" minWidth="70">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="price"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="Volume (Min.)" fx:id="volumeColumn" minWidth="130">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="volume"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="Country" fx:id="countryColumn" minWidth="60"/>
|
||||
<TableColumn text="Bank transfer type" fx:id="bankAccountTypeColumn" minWidth="140"/>
|
||||
<TableColumn text="" fx:id="directionColumn" minWidth="80" sortable="false"/>
|
||||
<TableView fx:id="orderBookTable" AnchorPane.leftAnchor="10.0"
|
||||
AnchorPane.topAnchor="45.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0">
|
||||
<columns>
|
||||
<TableColumn text="Amount (Min.)" fx:id="amountColumn" minWidth="120">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="amount"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="Price" fx:id="priceColumn" minWidth="70">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="price"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="Volume (Min.)" fx:id="volumeColumn" minWidth="130">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="volume"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="Country" fx:id="countryColumn" minWidth="60"/>
|
||||
<TableColumn text="Bank transfer type" fx:id="bankAccountTypeColumn" minWidth="140"/>
|
||||
<TableColumn text="" fx:id="directionColumn" minWidth="80" sortable="false"/>
|
||||
|
||||
</columns>
|
||||
</TableView>
|
||||
</columns>
|
||||
</TableView>
|
||||
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
@ -9,10 +9,10 @@ import io.bitsquare.gui.NavigationViewURL;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.components.processbar.ProcessStepBar;
|
||||
import io.bitsquare.gui.components.processbar.ProcessStepItem;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.gui.util.BitSquareConverter;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.gui.util.FormBuilder;
|
||||
import io.bitsquare.gui.util.Popups;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.TradeMessage;
|
||||
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.TakerPaymentProtocolListener;
|
||||
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.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -32,26 +37,20 @@ import javafx.scene.layout.Pane;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerTradeController.class);
|
||||
|
||||
private Trading trading;
|
||||
private WalletFacade walletFacade;
|
||||
private BlockChainFacade blockChainFacade;
|
||||
private MessageFacade messageFacade;
|
||||
private final Trading trading;
|
||||
private final WalletFacade walletFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private final List<ProcessStepItem> processStepItems = new ArrayList<>();
|
||||
private Offer offer;
|
||||
private Trade trade;
|
||||
private BigInteger requestedAmount;
|
||||
private boolean offererIsOnline;
|
||||
private int row;
|
||||
private List<ProcessStepItem> processStepItems = new ArrayList();
|
||||
private NavigationController navigationController;
|
||||
private TextField amountTextField, totalToPayLabel, totalLabel, collateralTextField, isOnlineTextField;
|
||||
private Label statusTextField, infoLabel;
|
||||
@ -474,8 +473,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
{
|
||||
double amount = BitSquareConverter.stringToDouble2(amountTextField.getText());
|
||||
double resultDouble = amount * (double) offer.getCollateral() / 100.0;
|
||||
BigInteger result = BtcFormatter.doubleValueToSatoshis(resultDouble);
|
||||
return result;
|
||||
return BtcFormatter.doubleValueToSatoshis(resultDouble);
|
||||
}
|
||||
|
||||
private BigInteger getAmountInSatoshis()
|
||||
|
@ -5,29 +5,27 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane fx:id="rootContainer" fx:controller="io.bitsquare.gui.market.trade.TakerTradeController"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:id="rootContainer"
|
||||
fx:controller="io.bitsquare.gui.market.trade.TakerTradeController">
|
||||
<ScrollPane fitToWidth="true" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="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>
|
||||
<Insets left="10" right="10" top="10" bottom="10"/>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</padding>
|
||||
<ProcessStepBar fx:id="processStepBar"/>
|
||||
<VSpacer prefHeight="5"/>
|
||||
<GridPane fx:id="gridPane" vgap="5" hgap="5">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</padding>
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT"/>
|
||||
<ColumnConstraints halignment="LEFT" prefWidth="400"/>
|
||||
<ColumnConstraints halignment="LEFT"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
||||
</VBox>
|
||||
</content>
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT"/>
|
||||
<ColumnConstraints halignment="LEFT" prefWidth="400"/>
|
||||
<ColumnConstraints halignment="LEFT"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
||||
</VBox>
|
||||
</ScrollPane>
|
||||
</AnchorPane>
|
@ -3,13 +3,12 @@ package io.bitsquare.gui.msg;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class MsgController implements Initializable, ChildController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(MsgController.class);
|
||||
|
@ -2,16 +2,12 @@
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane fx:controller="io.bitsquare.gui.msg.MsgController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0"
|
||||
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8"
|
||||
xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.msg.MsgController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
<Label id="headline-label" text="Message"/>
|
||||
<Label id="headline-label" text="Message"/>
|
||||
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
|
@ -7,18 +7,17 @@ import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationViewURL;
|
||||
import io.bitsquare.gui.components.LazyLoadingTabPane;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class OrdersController implements Initializable, ChildController, NavigationController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(OrdersController.class);
|
||||
private Storage storage;
|
||||
private final Storage storage;
|
||||
|
||||
@FXML
|
||||
private LazyLoadingTabPane tabPane;
|
||||
|
@ -3,8 +3,8 @@
|
||||
<?import io.bitsquare.gui.components.LazyLoadingTabPane?>
|
||||
<?import javafx.scene.control.Tab?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.orders.OrdersController">
|
||||
<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="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.orders.OrdersController">
|
||||
|
||||
<Tab text="Open offers" closable="false"/>
|
||||
<Tab text="Pending trades" closable="false"/>
|
||||
|
@ -4,13 +4,12 @@ import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ClosedTradeController implements Initializable, ChildController, Hibernate
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ClosedTradeController.class);
|
||||
|
@ -2,16 +2,12 @@
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane fx:controller="io.bitsquare.gui.orders.closed.ClosedTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0"
|
||||
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8"
|
||||
xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.orders.closed.ClosedTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
<Label id="headline-label" text="Closed"/>
|
||||
<Label id="headline-label" text="Closed"/>
|
||||
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
|
@ -7,11 +7,15 @@ import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.util.Icons;
|
||||
import io.bitsquare.trade.Offer;
|
||||
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.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
@ -20,23 +24,15 @@ import javafx.util.Callback;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(OfferController.class);
|
||||
private final Trading trading;
|
||||
protected ObservableList<OfferListItem> offerListItems;
|
||||
|
||||
@FXML
|
||||
private TableColumn<String, OfferListItem> offerIdColumn, dateColumn, amountColumn, priceColumn, volumeColumn, removeColumn;
|
||||
@FXML
|
||||
private TableView offerTable;
|
||||
private Trading trading;
|
||||
private TableView<OfferListItem> offerTable;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -96,10 +92,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
offerListItems = FXCollections.observableArrayList();
|
||||
Map<String, Offer> offerMap = trading.getOffers();
|
||||
List<Offer> offerList = new ArrayList<>(offerMap.values());
|
||||
for (int i = 0; i < offerList.size(); i++)
|
||||
{
|
||||
offerListItems.add(new OfferListItem(offerList.get(i)));
|
||||
}
|
||||
offerListItems.addAll(offerList.stream().map(OfferListItem::new).collect(Collectors.toList()));
|
||||
offerTable.setItems(offerListItems);
|
||||
}
|
||||
|
||||
@ -116,14 +109,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
|
||||
private void removeOffer(OfferListItem offerListItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
trading.removeOffer(offerListItem.getOffer());
|
||||
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
trading.removeOffer(offerListItem.getOffer());
|
||||
offerListItems.remove(offerListItem);
|
||||
}
|
||||
|
||||
@ -161,14 +147,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
{
|
||||
Tooltip tooltip = new Tooltip(item.getOfferId());
|
||||
Tooltip.install(hyperlink, tooltip);
|
||||
hyperlink.setOnAction(new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent event)
|
||||
{
|
||||
openOfferDetails(item);
|
||||
}
|
||||
});
|
||||
hyperlink.setOnAction(event -> openOfferDetails(item));
|
||||
}
|
||||
setGraphic(hyperlink);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ public class OfferListItem
|
||||
protected final StringProperty amount = new SimpleStringProperty();
|
||||
protected final StringProperty date = new SimpleStringProperty();
|
||||
protected final StringProperty volume = new SimpleStringProperty();
|
||||
protected final Offer offer;
|
||||
private final String offerId;
|
||||
protected Offer offer;
|
||||
|
||||
public OfferListItem(Offer offer)
|
||||
{
|
||||
|
@ -4,8 +4,8 @@
|
||||
<?import javafx.scene.control.cell.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<VBox spacing="10" fx:controller="io.bitsquare.gui.orders.offer.OfferController" 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.orders.offer.OfferController"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</padding>
|
||||
|
@ -4,13 +4,12 @@ import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class PendingTradeController implements Initializable, ChildController, Hibernate
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(PendingTradeController.class);
|
||||
|
@ -2,16 +2,12 @@
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0"
|
||||
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8"
|
||||
xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
<Label id="headline-label" text="Pending"/>
|
||||
<Label id="headline-label" text="Pending"/>
|
||||
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
|
@ -9,7 +9,7 @@ public class TradesTableItem extends OrderBookListItem
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TradesTableItem.class);
|
||||
|
||||
private Trade trade;
|
||||
private final Trade trade;
|
||||
|
||||
public TradesTableItem(Trade trade)
|
||||
{
|
||||
|
155
src/main/java/io/bitsquare/gui/popups/Popups.java
Normal file
155
src/main/java/io/bitsquare/gui/popups/Popups.java
Normal 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);
|
||||
}
|
||||
}
|
@ -22,10 +22,12 @@ import io.bitsquare.user.Arbitrator;
|
||||
import io.bitsquare.user.Reputation;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Pos;
|
||||
@ -37,26 +39,21 @@ import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
// TODO separate in 2 view/controllers
|
||||
public class SettingsController implements Initializable, ChildController, NavigationController
|
||||
{
|
||||
private User user;
|
||||
private Settings settings;
|
||||
private Storage storage;
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
private final User user;
|
||||
private final Settings settings;
|
||||
private final Storage storage;
|
||||
private final WalletFacade walletFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private final ObservableList<Locale> languageList;
|
||||
private final ObservableList<Country> countryList;
|
||||
private NavigationController navigationController;
|
||||
private ChildController childController;
|
||||
private ObservableList<Locale> languageList;
|
||||
private ObservableList<Country> countryList;
|
||||
private List<String> regionList;
|
||||
private ObservableList<Arbitrator> arbitratorList;
|
||||
private Region selectedRegion, selectedBankAccountRegion;
|
||||
@ -240,14 +237,9 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
stage.initOwner(rootStage);
|
||||
Scene scene = new Scene((Parent) view, 800, 600);
|
||||
stage.setScene(scene);
|
||||
stage.setOnHidden(new EventHandler<WindowEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(WindowEvent windowEvent)
|
||||
{
|
||||
if (fxmlView.equals(NavigationViewURL.ARBITRATOR_OVERVIEW))
|
||||
updateArbitrators();
|
||||
}
|
||||
stage.setOnHidden(windowEvent -> {
|
||||
if (fxmlView.equals(NavigationViewURL.ARBITRATOR_OVERVIEW))
|
||||
updateArbitrators();
|
||||
});
|
||||
stage.show();
|
||||
|
||||
@ -399,15 +391,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
{
|
||||
label.setText(item.getDisplayName());
|
||||
|
||||
removeButton.setOnAction(new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent)
|
||||
{
|
||||
removeLanguage(item);
|
||||
}
|
||||
|
||||
});
|
||||
removeButton.setOnAction(actionEvent -> removeLanguage(item));
|
||||
|
||||
setGraphic(hBox);
|
||||
}
|
||||
@ -491,15 +475,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
{
|
||||
label.setText(item.getName());
|
||||
|
||||
removeButton.setOnAction(new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent)
|
||||
{
|
||||
removeCountry(item);
|
||||
}
|
||||
|
||||
});
|
||||
removeButton.setOnAction(actionEvent -> removeCountry(item));
|
||||
|
||||
setGraphic(hBox);
|
||||
}
|
||||
@ -567,15 +543,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
{
|
||||
label.setText(item.getName());
|
||||
|
||||
removeButton.setOnAction(new EventHandler<ActionEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent)
|
||||
{
|
||||
removeArbitrator(item);
|
||||
}
|
||||
|
||||
});
|
||||
removeButton.setOnAction(actionEvent -> removeArbitrator(item));
|
||||
|
||||
setGraphic(hBox);
|
||||
}
|
||||
|
@ -3,30 +3,28 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.settings.SettingsController">
|
||||
<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="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.settings.SettingsController">
|
||||
|
||||
<Tab text="General" closable="false">
|
||||
<GridPane hgap="5.0" vgap="5.0">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</padding>
|
||||
<children>
|
||||
<Label text="Accepted languages:"/>
|
||||
<ListView fx:id="languagesListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1"/>
|
||||
<Label text="Accepted countries:" GridPane.rowIndex="2"/>
|
||||
<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="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"/>
|
||||
<Label text="Accepted languages:"/>
|
||||
<ListView fx:id="languagesListView" prefHeight="300.0" prefWidth="400.0" GridPane.columnIndex="1"/>
|
||||
<Label text="Accepted countries:" GridPane.rowIndex="2"/>
|
||||
<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="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"/>
|
||||
|
||||
<HBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<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"/>
|
||||
</HBox>
|
||||
<HBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<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"/>
|
||||
</HBox>
|
||||
|
||||
<Button onAction="#onAddArbitrator" text="Add arbitrator" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
</children>
|
||||
<Button onAction="#onAddArbitrator" text="Add arbitrator" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints/>
|
||||
@ -82,7 +80,7 @@
|
||||
<HBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="8">
|
||||
<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="removeBankAccountButton" onAction="#onRemoveBankAccount" text="Remove bank account"/>
|
||||
<Button onAction="#onRemoveBankAccount" text="Remove bank account"/>
|
||||
</HBox>
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@ import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Currency;
|
||||
|
@ -9,12 +9,8 @@ import javafx.scene.paint.Color;
|
||||
|
||||
public class BitSquareValidator
|
||||
{
|
||||
private static Effect invalidEffect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.0, 0, 0);
|
||||
private static String invalidStyle = "-fx-border-color: red";
|
||||
|
||||
public static class ValidationException extends Exception
|
||||
{
|
||||
}
|
||||
private static final Effect invalidEffect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.0, 0, 0);
|
||||
private static final String invalidStyle = "-fx-border-color: red";
|
||||
|
||||
public static void textFieldsNotEmptyWithReset(TextField... textFields) throws ValidationException
|
||||
{
|
||||
@ -24,9 +20,8 @@ public class BitSquareValidator
|
||||
|
||||
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.setEffect(null);
|
||||
}
|
||||
@ -34,9 +29,8 @@ public class BitSquareValidator
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -59,9 +53,8 @@ public class BitSquareValidator
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -101,9 +94,8 @@ public class BitSquareValidator
|
||||
public static boolean validateStringsAsDouble(String... inputs)
|
||||
{
|
||||
boolean result = true;
|
||||
for (int i = 0; i < inputs.length; i++)
|
||||
for (String input : inputs)
|
||||
{
|
||||
String input = inputs[i];
|
||||
result &= validateStringAsDouble(input);
|
||||
}
|
||||
return result;
|
||||
@ -125,9 +117,8 @@ public class BitSquareValidator
|
||||
public static boolean validateStringsNotEmpty(String... inputs)
|
||||
{
|
||||
boolean result = true;
|
||||
for (int i = 0; i < inputs.length; i++)
|
||||
for (String input : inputs)
|
||||
{
|
||||
String input = inputs[i];
|
||||
result &= validateStringNotEmpty(input);
|
||||
}
|
||||
return result;
|
||||
@ -138,4 +129,8 @@ public class BitSquareValidator
|
||||
return input != null && input.length() > 0 && !input.equals(" ");
|
||||
}
|
||||
|
||||
public static class ValidationException extends Exception
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,16 +4,14 @@ import com.google.bitcoin.core.*;
|
||||
import com.google.bitcoin.script.Script;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
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.TextField;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfidenceDisplay
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ConfidenceDisplay.class);
|
||||
@ -186,9 +184,8 @@ public class ConfidenceDisplay
|
||||
|
||||
Set<Transaction> transactions = wallet.getTransactions(false);
|
||||
Transaction latestTransaction = null;
|
||||
for (Iterator<Transaction> iterator = transactions.iterator(); iterator.hasNext(); )
|
||||
for (Transaction transaction : transactions)
|
||||
{
|
||||
Transaction transaction = iterator.next();
|
||||
if (latestTransaction != null)
|
||||
{
|
||||
if (transaction.getUpdateTime().compareTo(latestTransaction.getUpdateTime()) > 0)
|
||||
|
@ -2,6 +2,9 @@ package io.bitsquare.gui.util;
|
||||
|
||||
import io.bitsquare.bank.BankAccountTypeInfo;
|
||||
import io.bitsquare.gui.components.VSpacer;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
@ -9,10 +12,6 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
//TODO to be removed
|
||||
public class FormBuilder
|
||||
{
|
||||
|
@ -13,8 +13,6 @@ public class Icons
|
||||
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_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_ACTIVE = "/images/nav/funds_active.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 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)
|
||||
{
|
||||
return new Image(Icons.class.getResourceAsStream(iconName));
|
||||
@ -51,44 +35,4 @@ public class Icons
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -7,9 +7,9 @@ public class Country implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -5930294199097793187L;
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private Region region;
|
||||
private final String code;
|
||||
private final String name;
|
||||
private final Region region;
|
||||
|
||||
public Country(String code, String name, Region region)
|
||||
{
|
||||
|
@ -1,136 +1,13 @@
|
||||
package io.bitsquare.locale;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CountryUtil
|
||||
{
|
||||
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();
|
||||
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",
|
||||
private static final String[] countryCodes = new String[]{"AE",
|
||||
"AL",
|
||||
"AR",
|
||||
"AT",
|
||||
@ -227,8 +104,8 @@ public class CountryUtil
|
||||
"YE",
|
||||
"ZA"
|
||||
};
|
||||
|
||||
private static String[] regionCodes = new String[]{
|
||||
private static final List<String> regionCodeList = Arrays.asList(countryCodes);
|
||||
private static final String[] regionCodes = new String[]{
|
||||
"AS",
|
||||
"EU",
|
||||
"SA",
|
||||
@ -326,23 +203,8 @@ public class CountryUtil
|
||||
"AS",
|
||||
"AF"
|
||||
};
|
||||
|
||||
private static List<String> regionCodeList;
|
||||
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[][]{
|
||||
private static final List<String> countryCodeList = Arrays.asList(regionCodes);
|
||||
private static final String[][] regionCodeToName = new String[][]{
|
||||
{"NA", "North America"},
|
||||
{"SA", "South America"},
|
||||
{"AF", "Africa"},
|
||||
@ -351,4 +213,122 @@ public class CountryUtil
|
||||
{"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";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,14 +23,7 @@ public class CurrencyUtil
|
||||
|
||||
allCurrenciesSet.removeAll(mainCurrencies);
|
||||
List<Currency> allCurrenciesList = new ArrayList<>(allCurrenciesSet);
|
||||
allCurrenciesList.sort(new Comparator<Currency>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Currency a, Currency b)
|
||||
{
|
||||
return a.getCurrencyCode().compareTo(b.getCurrencyCode());
|
||||
}
|
||||
});
|
||||
allCurrenciesList.sort((a, b) -> a.getCurrencyCode().compareTo(b.getCurrencyCode()));
|
||||
|
||||
List<Currency> resultList = new ArrayList<>(mainCurrencies);
|
||||
resultList.addAll(allCurrenciesList);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.bitsquare.locale;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LanguageUtil
|
||||
{
|
||||
@ -24,25 +25,10 @@ public class LanguageUtil
|
||||
public static List<Locale> getAllLanguageLocales()
|
||||
{
|
||||
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.getLanguage().equals(""))
|
||||
{
|
||||
allLocalesAsSet.add(new Locale(locale.getLanguage(), ""));
|
||||
}
|
||||
}
|
||||
Set<Locale> allLocalesAsSet = allLocales.stream().filter(locale -> !locale.getLanguage().equals("")).map(locale -> new Locale(locale.getLanguage(), "")).collect(Collectors.toSet());
|
||||
allLocales = new ArrayList<>();
|
||||
allLocales.addAll(allLocalesAsSet);
|
||||
allLocales.sort(new Comparator<Locale>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Locale locale1, Locale locale2)
|
||||
{
|
||||
return locale1.getDisplayLanguage().compareTo(locale2.getDisplayLanguage());
|
||||
}
|
||||
});
|
||||
allLocales.sort((locale1, locale2) -> locale1.getDisplayLanguage().compareTo(locale2.getDisplayLanguage()));
|
||||
|
||||
return allLocales;
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package io.bitsquare.locale;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@ -13,6 +10,8 @@ import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.PropertyResourceBundle;
|
||||
import java.util.ResourceBundle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Localisation
|
||||
{
|
||||
|
@ -7,8 +7,8 @@ public class Region implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -5930294199097793187L;
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
public Region(String code, String name)
|
||||
{
|
||||
|
@ -9,6 +9,11 @@ import io.bitsquare.trade.payment.taker.TakerPaymentProtocol;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
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.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
@ -19,19 +24,12 @@ import net.tomp2p.p2p.Peer;
|
||||
import net.tomp2p.p2p.PeerMaker;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import net.tomp2p.rpc.ObjectDataReply;
|
||||
import net.tomp2p.storage.Data;
|
||||
import net.tomp2p.storage.StorageDisk;
|
||||
import net.tomp2p.utils.Utils;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
* The TomP2P library codebase shall not be used outside that facade.
|
||||
@ -39,33 +37,26 @@ import java.util.*;
|
||||
*/
|
||||
public class MessageFacade
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
|
||||
|
||||
public static final String PING = "ping";
|
||||
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 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 int port;
|
||||
private KeyPair keyPair;
|
||||
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 BooleanProperty isDirty = new SimpleBooleanProperty(false);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -264,7 +255,7 @@ public class MessageFacade
|
||||
// Remove offer
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void removeOffer(Offer offer) throws IOException
|
||||
public void removeOffer(Offer offer)
|
||||
{
|
||||
Number160 locationKey = Number160.createHash(offer.getCurrency().getCurrencyCode());
|
||||
Number160 contentKey = Number160.createHash(offer.getId());
|
||||
@ -300,7 +291,7 @@ public class MessageFacade
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public void getDirtyFlag(Currency currency) throws IOException
|
||||
public void getDirtyFlag(Currency currency)
|
||||
{
|
||||
Number160 locationKey = Number160.createHash(currency.getCurrencyCode());
|
||||
FutureDHT getFuture = myPeer.get(getDirtyLocationKey(locationKey)).start();
|
||||
@ -343,7 +334,7 @@ public class MessageFacade
|
||||
lastTimeStamp++;
|
||||
}
|
||||
|
||||
private Number160 getDirtyLocationKey(Number160 locationKey) throws IOException
|
||||
private Number160 getDirtyLocationKey(Number160 locationKey)
|
||||
{
|
||||
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
|
||||
lastTimeStamp = System.currentTimeMillis();
|
||||
FutureDHT putFuture = null;
|
||||
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)
|
||||
{
|
||||
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 FutureResponse sendFuture = myPeer.sendDirect(peerConnection).setObject(tradeMessage).start();
|
||||
sendFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(BaseFuture baseFuture) throws Exception
|
||||
{
|
||||
if (sendFuture.isSuccess())
|
||||
{
|
||||
Platform.runLater(() -> onSendTradingMessageResult(listener));
|
||||
}
|
||||
else
|
||||
{
|
||||
Platform.runLater(() -> onSendTradingMessageFailed(listener));
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(BaseFuture baseFuture) throws Exception
|
||||
{
|
||||
if (sendFuture.isSuccess())
|
||||
{
|
||||
Platform.runLater(() -> onSendTradingMessageResult(listener));
|
||||
}
|
||||
else
|
||||
{
|
||||
Platform.runLater(() -> onSendTradingMessageFailed(listener));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -591,23 +581,23 @@ public class MessageFacade
|
||||
{
|
||||
FutureResponse sendFuture = myPeer.sendDirect(peerConnection).setObject(PING).start();
|
||||
sendFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(BaseFuture baseFuture) throws Exception
|
||||
{
|
||||
if (sendFuture.isSuccess())
|
||||
{
|
||||
final String pong = (String) sendFuture.getObject();
|
||||
if (pong != null)
|
||||
Platform.runLater(() -> onResponseFromPing(pong.equals(PONG)));
|
||||
}
|
||||
else
|
||||
{
|
||||
peerConnection.close();
|
||||
Platform.runLater(() -> onResponseFromPing(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(BaseFuture baseFuture) throws Exception
|
||||
{
|
||||
if (sendFuture.isSuccess())
|
||||
{
|
||||
final String pong = (String) sendFuture.getObject();
|
||||
if (pong != null)
|
||||
Platform.runLater(() -> onResponseFromPing(pong.equals(PONG)));
|
||||
}
|
||||
else
|
||||
{
|
||||
peerConnection.close();
|
||||
Platform.runLater(() -> onResponseFromPing(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (Exception e)
|
||||
@ -736,7 +726,7 @@ public class MessageFacade
|
||||
});
|
||||
}
|
||||
|
||||
private void setupStorage() throws IOException
|
||||
private void setupStorage()
|
||||
{
|
||||
//TODO BitSquare.ID just temp...
|
||||
String dirPath = Utilities.getRootDir() + BitSquare.ID + "_tomP2P";
|
||||
@ -765,17 +755,12 @@ public class MessageFacade
|
||||
|
||||
private void setupReplyHandler()
|
||||
{
|
||||
myPeer.setObjectDataReply(new ObjectDataReply()
|
||||
{
|
||||
@Override
|
||||
public Object reply(PeerAddress sender, Object request) throws Exception
|
||||
myPeer.setObjectDataReply((sender, request) -> {
|
||||
if (!sender.equals(myPeer.getPeerAddress()))
|
||||
{
|
||||
if (!sender.equals(myPeer.getPeerAddress()))
|
||||
{
|
||||
Platform.runLater(() -> onMessage(request, sender));
|
||||
}
|
||||
return null;
|
||||
Platform.runLater(() -> onMessage(request, sender));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.bitsquare.msg;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
@ -12,8 +11,9 @@ public class TradeMessage implements Serializable
|
||||
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 signedTakerDepositTxAsHex;
|
||||
private String txScriptSigAsHex;
|
||||
@ -21,10 +21,8 @@ public class TradeMessage implements Serializable
|
||||
private String contractAsJson;
|
||||
private String takerContractSignature;
|
||||
private String takerPayoutAddress;
|
||||
private TradeMessageType type;
|
||||
private String depositTxID;
|
||||
private String depositTxAsHex;
|
||||
|
||||
private String offererSignatureR;
|
||||
private String offererSignatureS;
|
||||
private BigInteger offererPaybackAmount;
|
||||
@ -33,7 +31,6 @@ public class TradeMessage implements Serializable
|
||||
private BigInteger tradeAmount;
|
||||
private String takeOfferFeeTxID;
|
||||
private String takerMultiSigPubKey;
|
||||
private String offerUID;
|
||||
private BankAccount bankAccount;
|
||||
private String accountID;
|
||||
private String offererPubKey;
|
||||
@ -257,16 +254,16 @@ public class TradeMessage implements Serializable
|
||||
return depositTxAsHex;
|
||||
}
|
||||
|
||||
public void setPayoutTxAsHex(String payoutTxAsHex)
|
||||
{
|
||||
this.payoutTxAsHex = payoutTxAsHex;
|
||||
}
|
||||
|
||||
public String getPayoutTxAsHex()
|
||||
{
|
||||
return payoutTxAsHex;
|
||||
}
|
||||
|
||||
public void setPayoutTxAsHex(String payoutTxAsHex)
|
||||
{
|
||||
this.payoutTxAsHex = payoutTxAsHex;
|
||||
}
|
||||
|
||||
public long getOffererTxOutIndex()
|
||||
{
|
||||
return offererTxOutIndex;
|
||||
|
@ -1,10 +1,9 @@
|
||||
package io.bitsquare.msg.listeners;
|
||||
|
||||
import java.util.Map;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ArbitratorListener
|
||||
{
|
||||
void onArbitratorAdded(Data offerData, boolean success);
|
||||
|
@ -1,10 +1,9 @@
|
||||
package io.bitsquare.msg.listeners;
|
||||
|
||||
import java.util.Map;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface OrderBookListener
|
||||
{
|
||||
void onOfferAdded(Data offerData, boolean success);
|
||||
|
@ -3,7 +3,6 @@ package io.bitsquare.settings;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
@ -79,20 +78,6 @@ public class Settings implements Serializable
|
||||
acceptedArbitrators.remove(item);
|
||||
}
|
||||
|
||||
public void setMaxCollateral(int maxCollateral)
|
||||
{
|
||||
this.maxCollateral = maxCollateral;
|
||||
}
|
||||
|
||||
public void setMinCollateral(int minCollateral)
|
||||
{
|
||||
this.minCollateral = minCollateral;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public List<Arbitrator> getAcceptedArbitrators()
|
||||
{
|
||||
return acceptedArbitrators;
|
||||
@ -103,6 +88,10 @@ public class Settings implements Serializable
|
||||
return acceptedLanguageLocales;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public List<Country> getAcceptedCountries()
|
||||
{
|
||||
return acceptedCountryLocales;
|
||||
@ -128,9 +117,19 @@ public class Settings implements Serializable
|
||||
return maxCollateral;
|
||||
}
|
||||
|
||||
public void setMaxCollateral(int maxCollateral)
|
||||
{
|
||||
this.maxCollateral = maxCollateral;
|
||||
}
|
||||
|
||||
public int getMinCollateral()
|
||||
{
|
||||
return minCollateral;
|
||||
}
|
||||
|
||||
public void setMinCollateral(int minCollateral)
|
||||
{
|
||||
this.minCollateral = minCollateral;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,12 +2,11 @@ package io.bitsquare.storage;
|
||||
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.util.Utilities;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Simple storage solution for serialized data
|
||||
@ -53,9 +52,7 @@ public class Storage
|
||||
public Object read(String key)
|
||||
{
|
||||
dict = readDataVO();
|
||||
Object result = dict.get(key);
|
||||
//log.info("Read object with key = " + key + " result = " + result);
|
||||
return result;
|
||||
return dict.get(key);
|
||||
}
|
||||
|
||||
|
||||
@ -88,15 +85,14 @@ public class Storage
|
||||
{
|
||||
FileInputStream fileIn = new FileInputStream(file);
|
||||
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();
|
||||
fileIn.close();
|
||||
} catch (IOException i)
|
||||
} catch (IOException | ClassNotFoundException i)
|
||||
{
|
||||
i.printStackTrace();
|
||||
} catch (ClassNotFoundException c)
|
||||
{
|
||||
c.printStackTrace();
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.bitsquare.trade;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
@ -9,15 +8,15 @@ public class Contract implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 71472356206100158L;
|
||||
|
||||
private Offer offer;
|
||||
private String takeOfferFeeTxID;
|
||||
private BigInteger tradeAmount;
|
||||
private String offererAccountID;
|
||||
private String takerAccountID;
|
||||
private BankAccount offererBankAccount;
|
||||
private BankAccount takerBankAccount;
|
||||
private String offererMessagePubKeyAsHex;
|
||||
private String takerMessagePubKeyAsHex;
|
||||
private final Offer offer;
|
||||
private final String takeOfferFeeTxID;
|
||||
private final BigInteger tradeAmount;
|
||||
private final String offererAccountID;
|
||||
private final String takerAccountID;
|
||||
private final BankAccount offererBankAccount;
|
||||
private final BankAccount takerBankAccount;
|
||||
private final String offererMessagePubKeyAsHex;
|
||||
private final String takerMessagePubKeyAsHex;
|
||||
|
||||
public Contract(Offer offer,
|
||||
BigInteger tradeAmount,
|
||||
|
@ -4,7 +4,6 @@ import io.bitsquare.bank.BankAccountTypeInfo;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
@ -20,7 +19,7 @@ public class Offer implements Serializable
|
||||
private final String id;
|
||||
private final Date creationDate;
|
||||
|
||||
private double price;
|
||||
private final double price;
|
||||
private final BigInteger amount;
|
||||
private final BigInteger minAmount;
|
||||
private final String messagePubKeyAsHex;
|
||||
@ -30,9 +29,9 @@ public class Offer implements Serializable
|
||||
private final int collateral;
|
||||
private final List<Country> acceptedCountries;
|
||||
private final List<Locale> acceptedLanguageLocales;
|
||||
private String offerFeePaymentTxID;
|
||||
private final String bankAccountUID;
|
||||
private final Arbitrator arbitrator;
|
||||
private String offerFeePaymentTxID;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -77,9 +76,9 @@ public class Offer implements Serializable
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setOfferFeePaymentTxID(String offerFeePaymentTxID)
|
||||
public String getMessagePubKeyAsHex()
|
||||
{
|
||||
this.offerFeePaymentTxID = offerFeePaymentTxID;
|
||||
return messagePubKeyAsHex;
|
||||
}
|
||||
|
||||
|
||||
@ -87,11 +86,6 @@ public class Offer implements Serializable
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getMessagePubKeyAsHex()
|
||||
{
|
||||
return messagePubKeyAsHex;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
@ -157,6 +151,11 @@ public class Offer implements Serializable
|
||||
return offerFeePaymentTxID;
|
||||
}
|
||||
|
||||
public void setOfferFeePaymentTxID(String offerFeePaymentTxID)
|
||||
{
|
||||
this.offerFeePaymentTxID = offerFeePaymentTxID;
|
||||
}
|
||||
|
||||
public Arbitrator getArbitrator()
|
||||
{
|
||||
return arbitrator;
|
||||
|
@ -1,29 +1,19 @@
|
||||
package io.bitsquare.trade;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class Trade implements Serializable
|
||||
{
|
||||
public static enum State
|
||||
{
|
||||
NONE,
|
||||
ACCEPTED,
|
||||
COMPLETED
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -8275323072940974077L;
|
||||
|
||||
transient private final SimpleBooleanProperty depositTxChangedProperty = new SimpleBooleanProperty();
|
||||
transient private final SimpleBooleanProperty payoutTxChangedProperty = new SimpleBooleanProperty();
|
||||
transient private final SimpleBooleanProperty contractChangedProperty = new SimpleBooleanProperty();
|
||||
transient private final SimpleStringProperty stateChangedProperty = new SimpleStringProperty();
|
||||
|
||||
private Offer offer;
|
||||
private final Offer offer;
|
||||
private String takeOfferFeeTxID;
|
||||
private BigInteger tradeAmount;
|
||||
private Contract contract;
|
||||
@ -38,59 +28,13 @@ public class Trade implements Serializable
|
||||
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)
|
||||
{
|
||||
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()
|
||||
@ -108,21 +52,47 @@ public class Trade implements Serializable
|
||||
return takeOfferFeeTxID;
|
||||
}
|
||||
|
||||
public void setTakeOfferFeeTxID(String takeOfferFeeTxID)
|
||||
{
|
||||
this.takeOfferFeeTxID = takeOfferFeeTxID;
|
||||
}
|
||||
|
||||
public BigInteger getTradeAmount()
|
||||
{
|
||||
return tradeAmount;
|
||||
}
|
||||
|
||||
public void setTradeAmount(BigInteger tradeAmount)
|
||||
{
|
||||
this.tradeAmount = tradeAmount;
|
||||
}
|
||||
|
||||
public Contract getContract()
|
||||
{
|
||||
return contract;
|
||||
}
|
||||
|
||||
public void setContract(Contract contract)
|
||||
{
|
||||
this.contract = contract;
|
||||
contractChangedProperty.set(!contractChangedProperty.get());
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getContractAsJson()
|
||||
{
|
||||
return contractAsJson;
|
||||
}
|
||||
|
||||
public void setContractAsJson(String contractAsJson)
|
||||
{
|
||||
this.contractAsJson = contractAsJson;
|
||||
}
|
||||
|
||||
public String getTakerSignature()
|
||||
{
|
||||
return takerSignature;
|
||||
@ -133,16 +103,33 @@ public class Trade implements Serializable
|
||||
return depositTransaction;
|
||||
}
|
||||
|
||||
public void setDepositTransaction(Transaction depositTransaction)
|
||||
{
|
||||
this.depositTransaction = depositTransaction;
|
||||
depositTxChangedProperty.set(!depositTxChangedProperty.get());
|
||||
}
|
||||
|
||||
public Transaction getPayoutTransaction()
|
||||
{
|
||||
return payoutTransaction;
|
||||
}
|
||||
|
||||
public void setPayoutTransaction(Transaction payoutTransaction)
|
||||
{
|
||||
this.payoutTransaction = payoutTransaction;
|
||||
payoutTxChangedProperty.set(!payoutTxChangedProperty.get());
|
||||
}
|
||||
|
||||
public State getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(State state)
|
||||
{
|
||||
this.state = state;
|
||||
stateChangedProperty.set(state.toString());
|
||||
}
|
||||
|
||||
public SimpleBooleanProperty getDepositTxChangedProperty()
|
||||
{
|
||||
@ -169,11 +156,6 @@ public class Trade implements Serializable
|
||||
return getTradeAmount().multiply(BigInteger.valueOf(getOffer().getCollateral())).divide(BigInteger.valueOf(100));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// toString
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@ -188,4 +170,16 @@ public class Trade implements Serializable
|
||||
", state=" + state +
|
||||
'}';
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// toString
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public static enum State
|
||||
{
|
||||
NONE,
|
||||
ACCEPTED,
|
||||
COMPLETED
|
||||
}
|
||||
}
|
||||
|
@ -16,36 +16,34 @@ import io.bitsquare.trade.payment.offerer.OffererPaymentProtocolListener;
|
||||
import io.bitsquare.trade.payment.taker.TakerPaymentProtocol;
|
||||
import io.bitsquare.trade.payment.taker.TakerPaymentProtocolListener;
|
||||
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.StringProperty;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
*/
|
||||
public class Trading
|
||||
{
|
||||
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, OffererPaymentProtocol> offererPaymentProtocols = new HashMap<>();
|
||||
private final String storageKey;
|
||||
private User user;
|
||||
private Storage storage;
|
||||
private MessageFacade messageFacade;
|
||||
private BlockChainFacade blockChainFacade;
|
||||
private WalletFacade walletFacade;
|
||||
private CryptoFacade cryptoFacade;
|
||||
private Settings settings;
|
||||
private final User user;
|
||||
private final Storage storage;
|
||||
private final MessageFacade messageFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
private final CryptoFacade cryptoFacade;
|
||||
private final Settings settings;
|
||||
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");
|
||||
if (offersObject != null && offersObject instanceof HashMap)
|
||||
myOffers = (Map) offersObject;
|
||||
myOffers = (Map<String, Offer>) offersObject;
|
||||
|
||||
Object tradesObject = storage.read(storageKey + ".trades");
|
||||
if (tradesObject != null && tradesObject instanceof HashMap)
|
||||
trades = (Map) tradesObject;
|
||||
trades = (Map<String, Trade>) tradesObject;
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +103,7 @@ public class Trading
|
||||
messageFacade.addOffer(offer);
|
||||
}
|
||||
|
||||
public void removeOffer(Offer offer) throws IOException
|
||||
public void removeOffer(Offer offer)
|
||||
{
|
||||
myOffers.remove(offer.getId());
|
||||
saveOffers();
|
||||
@ -128,7 +126,7 @@ public class Trading
|
||||
return trade;
|
||||
}
|
||||
|
||||
public void removeTrade(Trade trade) throws IOException
|
||||
public void removeTrade(Trade trade)
|
||||
{
|
||||
trades.remove(trade.getId());
|
||||
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....
|
||||
offererPaymentProtocol.onTakeOfferRequested(sender);
|
||||
}
|
||||
@ -237,8 +235,8 @@ public class Trading
|
||||
return myOffers;
|
||||
}
|
||||
|
||||
public Offer getOffer(String offerUID)
|
||||
public Offer getOffer(String offerId)
|
||||
{
|
||||
return myOffers.get(offerUID.toString());
|
||||
return myOffers.get(offerId);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
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.ObservableList;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
@ -22,25 +26,17 @@ import net.tomp2p.storage.Data;
|
||||
import org.slf4j.Logger;
|
||||
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
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderBook.class);
|
||||
|
||||
private Settings settings;
|
||||
private User user;
|
||||
private MessageFacade messageFacade;
|
||||
private Trading trading;
|
||||
|
||||
protected ObservableList<OrderBookListItem> allOffers = FXCollections.observableArrayList();
|
||||
private FilteredList<OrderBookListItem> filteredList = new FilteredList<>(allOffers);
|
||||
protected final ObservableList<OrderBookListItem> allOffers = FXCollections.observableArrayList();
|
||||
private final FilteredList<OrderBookListItem> filteredList = new FilteredList<>(allOffers);
|
||||
// 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());
|
||||
}
|
||||
|
||||
public void removeOffer(Offer offer) throws IOException
|
||||
public void removeOffer(Offer offer)
|
||||
{
|
||||
trading.removeOffer(offer);
|
||||
messageFacade.removeOffer(offer);
|
||||
@ -87,90 +83,85 @@ public class OrderBook implements OrderBookListener
|
||||
|
||||
public void applyFilter(OrderBookFilter orderBookFilter)
|
||||
{
|
||||
filteredList.setPredicate(new Predicate<OrderBookListItem>()
|
||||
{
|
||||
@Override
|
||||
public boolean test(OrderBookListItem orderBookListItem)
|
||||
filteredList.setPredicate(orderBookListItem -> {
|
||||
Offer offer = orderBookListItem.getOffer();
|
||||
BankAccount currentBankAccount = user.getCurrentBankAccount();
|
||||
|
||||
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();
|
||||
BankAccount currentBankAccount = user.getCurrentBankAccount();
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
@ -184,7 +175,7 @@ public class OrderBook implements OrderBookListener
|
||||
try
|
||||
{
|
||||
Object offerDataObject = offerData.getObject();
|
||||
if (offerDataObject instanceof Offer && offerDataObject != null)
|
||||
if (offerDataObject instanceof Offer)
|
||||
{
|
||||
Offer offer = (Offer) offerDataObject;
|
||||
allOffers.add(new OrderBookListItem(offer));
|
||||
@ -207,7 +198,7 @@ public class OrderBook implements OrderBookListener
|
||||
try
|
||||
{
|
||||
Object offerDataObject = offerData.getObject();
|
||||
if (offerDataObject instanceof Offer && offerDataObject != null)
|
||||
if (offerDataObject instanceof Offer)
|
||||
{
|
||||
Offer offer = (Offer) offerDataObject;
|
||||
OrderBookListItem orderBookListItem = new OrderBookListItem(offer);
|
||||
@ -233,17 +224,10 @@ public class OrderBook implements OrderBookListener
|
||||
try
|
||||
{
|
||||
Object offerDataObject = offerData.getObject();
|
||||
if (offerDataObject instanceof Offer && offerDataObject != null)
|
||||
if (offerDataObject instanceof Offer)
|
||||
{
|
||||
Offer offer = (Offer) offerDataObject;
|
||||
allOffers.removeIf(new Predicate<OrderBookListItem>()
|
||||
{
|
||||
@Override
|
||||
public boolean test(OrderBookListItem orderBookListItem)
|
||||
{
|
||||
return orderBookListItem.getOffer().getId().equals(offer.getId());
|
||||
}
|
||||
});
|
||||
allOffers.removeIf(orderBookListItem -> orderBookListItem.getOffer().getId().equals(offer.getId()));
|
||||
}
|
||||
} catch (ClassNotFoundException | IOException e)
|
||||
{
|
||||
|
@ -16,42 +16,42 @@ public class OrderBookFilter
|
||||
// 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()
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount)
|
||||
{
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Direction getDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setDirection(Direction direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
directionChangedProperty.set(!directionChangedProperty.get());
|
||||
}
|
||||
|
||||
public double getPrice()
|
||||
{
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(double price)
|
||||
{
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public SimpleBooleanProperty getDirectionChangedProperty()
|
||||
{
|
||||
return directionChangedProperty;
|
||||
|
@ -16,14 +16,12 @@ import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.Utilities;
|
||||
import java.math.BigInteger;
|
||||
import javafx.util.Pair;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
//TODO refactor to process based pattern
|
||||
@ -32,18 +30,18 @@ public class OffererPaymentProtocol
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererPaymentProtocol.class);
|
||||
|
||||
private Trade trade;
|
||||
private Offer offer;
|
||||
private final Trade trade;
|
||||
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 OffererPaymentProtocolListener offererPaymentProtocolListener;
|
||||
private MessageFacade messageFacade;
|
||||
private WalletFacade walletFacade;
|
||||
private BlockChainFacade blockChainFacade;
|
||||
private CryptoFacade cryptoFacade;
|
||||
private User user;
|
||||
private PeerAddress peerAddress;
|
||||
private boolean isTakeOfferRequested;
|
||||
private int numberOfSteps = 10;//TODO
|
||||
private int currentStep = 0;
|
||||
private String preparedOffererDepositTxAsHex;
|
||||
private Transaction depositTransaction;
|
||||
@ -117,15 +115,8 @@ public class OffererPaymentProtocol
|
||||
offererPaymentProtocolListener.onProgress(getProgress());
|
||||
|
||||
isTakeOfferRequested = true;
|
||||
try
|
||||
{
|
||||
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());
|
||||
}
|
||||
log.debug("1.3 messageFacade.removeOffer");
|
||||
messageFacade.removeOffer(offer);
|
||||
|
||||
// It's the takers turn again, so we are in wait mode....
|
||||
}
|
||||
@ -470,29 +461,29 @@ public class OffererPaymentProtocol
|
||||
onDepositTxConfirmedInBlockchain();
|
||||
|
||||
transaction.getConfidence().addEventListener(new TransactionConfidence.Listener()
|
||||
{
|
||||
@Override
|
||||
public void onConfidenceChanged(Transaction tx, ChangeReason reason)
|
||||
{
|
||||
if (reason == ChangeReason.SEEN_PEERS)
|
||||
{
|
||||
updateConfirmation(tx.getConfidence());
|
||||
{
|
||||
@Override
|
||||
public void onConfidenceChanged(Transaction tx, ChangeReason reason)
|
||||
{
|
||||
if (reason == ChangeReason.SEEN_PEERS)
|
||||
{
|
||||
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)
|
||||
{
|
||||
onDepositTxConfirmedInBlockchain();
|
||||
transaction.getConfidenceForAddress().removeEventListener(this);
|
||||
} */
|
||||
|
||||
}
|
||||
if (reason == ChangeReason.TYPE && tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
|
||||
{
|
||||
onDepositTxConfirmedInBlockchain();
|
||||
transaction.getConfidence().removeEventListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (reason == ChangeReason.TYPE && tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
|
||||
{
|
||||
onDepositTxConfirmedInBlockchain();
|
||||
transaction.getConfidence().removeEventListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -583,9 +574,6 @@ public class OffererPaymentProtocol
|
||||
log.debug("3.10 sendTradingMessage BANK_TX_INITED");
|
||||
messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener);
|
||||
|
||||
} catch (InsufficientMoneyException e)
|
||||
{
|
||||
log.error("3.10 offererCreatesAndSignsPayoutTx onFailed InsufficientMoneyException " + e.getMessage());
|
||||
} catch (AddressFormatException e)
|
||||
{
|
||||
log.error("3.10 offererCreatesAndSignsPayoutTx onFailed AddressFormatException " + e.getMessage());
|
||||
|
@ -11,22 +11,19 @@ import org.slf4j.LoggerFactory;
|
||||
public class PaymentProcess
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(PaymentProcess.class);
|
||||
private MessageFacade messageService;
|
||||
private BlockChainFacade bitcoinServices;
|
||||
|
||||
protected String offererDepositPubKey;
|
||||
protected String offererPayoutAddress;
|
||||
protected String offererChangeAddress;
|
||||
protected String offererTotalInputPayment;
|
||||
protected String offererOutputPayment;
|
||||
|
||||
protected String takerDepositPubKey;
|
||||
protected String takerPayoutAddress;
|
||||
protected String takerChangeAddress;
|
||||
protected String takerTotalInputPayment;
|
||||
protected String takerOutputPayment;
|
||||
|
||||
protected String multiSigAddress;
|
||||
private MessageFacade messageService;
|
||||
private BlockChainFacade bitcoinServices;
|
||||
private WalletFacade wallet;
|
||||
|
||||
public PaymentProcess()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user