mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-15 10:26:37 -04:00
Resolve more cyclic package dependencies
This commit is contained in:
parent
62338411d2
commit
892e831b8d
@ -19,6 +19,7 @@ package io.bitsquare;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.di.BitSquareModule;
|
||||
import io.bitsquare.gui.AWTSystemTray;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
@ -26,7 +27,6 @@ import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.AWTSystemTray;
|
||||
import io.bitsquare.util.BSFXMLLoader;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
@ -24,6 +24,9 @@ import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.OverlayController;
|
||||
import io.bitsquare.gui.main.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
import io.bitsquare.msg.BootstrappedPeerFactory;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.P2PNode;
|
||||
@ -31,7 +34,6 @@ import io.bitsquare.msg.SeedNodeAddress;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
@ -67,6 +69,8 @@ public class BitSquareModule extends AbstractModule {
|
||||
bind(TradeManager.class).asEagerSingleton();
|
||||
bind(NavigationController.class).asEagerSingleton();
|
||||
bind(OverlayController.class).asEagerSingleton();
|
||||
bind(BSFormatter.class).asEagerSingleton();
|
||||
bind(FiatValidator.class).asEagerSingleton();
|
||||
|
||||
|
||||
//bind(String.class).annotatedWith(Names.named("networkType")).toInstance(WalletFacade.MAIN_NET);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.util;
|
||||
package io.bitsquare.gui;
|
||||
|
||||
|
||||
import io.bitsquare.BitSquare;
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.gui.main;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.gui.AWTSystemTray;
|
||||
import io.bitsquare.gui.CodeBehind;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
@ -27,7 +28,6 @@ import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
import io.bitsquare.util.AWTSystemTray;
|
||||
import io.bitsquare.util.BSFXMLLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -21,6 +21,7 @@ import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.AWTSystemTray;
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.components.ConfidenceDisplay;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
@ -32,7 +33,6 @@ import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.util.AWTSystemTray;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
import com.google.bitcoin.core.ECKey;
|
||||
|
@ -19,13 +19,13 @@ package io.bitsquare.gui.main.trade.createoffer;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.main.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
|
||||
import com.google.bitcoin.core.Address;
|
||||
import com.google.bitcoin.core.Coin;
|
||||
|
@ -28,9 +28,9 @@ import io.bitsquare.gui.components.btc.AddressTextField;
|
||||
import io.bitsquare.gui.components.btc.BalanceTextField;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
import io.bitsquare.gui.main.help.HelpId;
|
||||
import io.bitsquare.gui.main.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -15,11 +15,10 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.orderbook;
|
||||
package io.bitsquare.gui.main.trade.orderbook;
|
||||
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.gui.main.trade.orderbook.OrderBookListItem;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
@ -50,7 +49,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/*
|
||||
TODO
|
||||
TODO move to OrderBookModel when converted to new UI structure
|
||||
remove dependencies to tomp2p
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
@ -38,8 +38,6 @@ import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.orderbook;
|
||||
package io.bitsquare.gui.main.trade.orderbook;
|
||||
|
||||
import io.bitsquare.trade.Direction;
|
||||
|
||||
@ -24,6 +24,7 @@ import com.google.bitcoin.utils.Fiat;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
||||
//TODO move to OrderBookModel when converted to new UI structure
|
||||
public class OrderBookFilter {
|
||||
// TODO use ObjectProperty<Direction> instead
|
||||
private final SimpleBooleanProperty directionChangedProperty = new SimpleBooleanProperty();
|
@ -21,6 +21,7 @@ import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
import com.google.bitcoin.utils.CoinFormat;
|
||||
@ -37,12 +38,14 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
//TODO a lot of old trash... need to cleanup...
|
||||
//TODO convert to non static
|
||||
|
||||
/**
|
||||
* Central point for formatting and input parsing.
|
||||
@ -71,6 +74,17 @@ public class BSFormatter {
|
||||
|
||||
private static String currencyCode = Currency.getInstance(Locale.getDefault()).getCurrencyCode();
|
||||
|
||||
@Inject
|
||||
public BSFormatter(User user) {
|
||||
if (user.currentBankAccountProperty().get() == null)
|
||||
setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode());
|
||||
else
|
||||
setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode());
|
||||
|
||||
user.currentBankAccountProperty().addListener((ov, oldValue, newValue) ->
|
||||
setFiatCurrencyCode(newValue.getCurrency().getCurrencyCode()));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Config
|
||||
|
@ -18,10 +18,18 @@
|
||||
package io.bitsquare.gui.util.validation;
|
||||
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//TODO convert to non static
|
||||
|
||||
/**
|
||||
* FiatNumberValidator for validating fiat values.
|
||||
* <p>
|
||||
@ -40,6 +48,17 @@ public final class FiatValidator extends NumberValidator {
|
||||
FiatValidator.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public FiatValidator(User user) {
|
||||
if (user.currentBankAccountProperty().get() == null)
|
||||
setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode());
|
||||
else
|
||||
setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode());
|
||||
|
||||
user.currentBankAccountProperty().addListener((ov, oldValue, newValue) ->
|
||||
setFiatCurrencyCode(newValue.getCurrency().getCurrencyCode()));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -20,7 +20,6 @@ package io.bitsquare.trade;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.TakeOfferRequestListener;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
@ -321,9 +320,9 @@ public class TradeManager {
|
||||
@Override
|
||||
public void onFault(Throwable throwable, BuyerAcceptsOfferProtocol.State state) {
|
||||
log.error("Error while executing trade process at state: " + state + " / " + throwable);
|
||||
Popups.openErrorPopup("Error while executing trade process",
|
||||
/* Popups.openErrorPopup("Error while executing trade process",
|
||||
"Error while executing trade process at state: " + state + " / " +
|
||||
throwable);
|
||||
throwable);*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,8 +18,6 @@
|
||||
package io.bitsquare.user;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -28,9 +26,7 @@ import java.security.KeyPair;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -88,8 +84,6 @@ public class User implements Serializable {
|
||||
// TODO use separate thread. DSAKeyUtil.getKeyPair() runs in same thread now
|
||||
messageKeyPair = DSAKeyUtil.generateKeyPair();
|
||||
}
|
||||
|
||||
BSFormatter.setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode());
|
||||
}
|
||||
|
||||
public void setBankAccount(BankAccount bankAccount) {
|
||||
@ -125,11 +119,6 @@ public class User implements Serializable {
|
||||
|
||||
public void setCurrentBankAccount(@Nullable BankAccount bankAccount) {
|
||||
currentBankAccount.set(bankAccount);
|
||||
|
||||
if (currentBankAccount.get() != null) {
|
||||
BSFormatter.setFiatCurrencyCode(currentBankAccount.get().getCurrency().getCurrencyCode());
|
||||
FiatValidator.setFiatCurrencyCode(currentBankAccount.get().getCurrency().getCurrencyCode());
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user