mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-29 17:17:19 -04:00
Remove cyclic dependencies inside gui package
This commit is contained in:
parent
cd606d4b96
commit
a51aafbdbd
4 changed files with 32 additions and 16 deletions
|
@ -73,9 +73,6 @@ public class CreateOfferModel extends UIModel {
|
||||||
private final User user;
|
private final User user;
|
||||||
|
|
||||||
private final String offerId;
|
private final String offerId;
|
||||||
@Nullable private Direction direction = null;
|
|
||||||
|
|
||||||
public AddressEntry addressEntry;
|
|
||||||
|
|
||||||
public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty();
|
public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty();
|
||||||
public final StringProperty transactionId = new SimpleStringProperty();
|
public final StringProperty transactionId = new SimpleStringProperty();
|
||||||
|
@ -104,6 +101,9 @@ public class CreateOfferModel extends UIModel {
|
||||||
public final ObservableList<Locale> acceptedLanguages = FXCollections.observableArrayList();
|
public final ObservableList<Locale> acceptedLanguages = FXCollections.observableArrayList();
|
||||||
public final ObservableList<Arbitrator> acceptedArbitrators = FXCollections.observableArrayList();
|
public final ObservableList<Arbitrator> acceptedArbitrators = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
@Nullable private Direction direction = null;
|
||||||
|
private AddressEntry addressEntry;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
|
@ -118,8 +118,6 @@ public class CreateOfferModel extends UIModel {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
offerId = UUID.randomUUID().toString();
|
offerId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
// Node: Don't do setup in constructor to make object creation faster
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,13 +136,13 @@ public class CreateOfferModel extends UIModel {
|
||||||
if (walletFacade != null && walletFacade.getWallet() != null) {
|
if (walletFacade != null && walletFacade.getWallet() != null) {
|
||||||
addressEntry = walletFacade.getAddressInfoByTradeID(offerId);
|
addressEntry = walletFacade.getAddressInfoByTradeID(offerId);
|
||||||
|
|
||||||
walletFacade.addBalanceListener(new BalanceListener(addressEntry.getAddress()) {
|
walletFacade.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) {
|
||||||
@Override
|
@Override
|
||||||
public void onBalanceChanged(@NotNull Coin balance) {
|
public void onBalanceChanged(@NotNull Coin balance) {
|
||||||
updateBalance(balance);
|
updateBalance(balance);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateBalance(walletFacade.getBalanceForAddress(addressEntry.getAddress()));
|
updateBalance(walletFacade.getBalanceForAddress(getAddressEntry().getAddress()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,4 +295,8 @@ public class CreateOfferModel extends UIModel {
|
||||||
private void updateBalance(@NotNull Coin balance) {
|
private void updateBalance(@NotNull Coin balance) {
|
||||||
isWalletFunded.set(totalToPayAsCoin.get() != null && balance.compareTo(totalToPayAsCoin.get()) >= 0);
|
isWalletFunded.set(totalToPayAsCoin.get() != null && balance.compareTo(totalToPayAsCoin.get()) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AddressEntry getAddressEntry() {
|
||||||
|
return addressEntry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,6 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||||
@Inject
|
@Inject
|
||||||
CreateOfferPM(CreateOfferModel model) {
|
CreateOfferPM(CreateOfferModel model) {
|
||||||
super(model);
|
super(model);
|
||||||
|
|
||||||
// Note: Don't do setup in constructor to make object creation faster
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,9 +119,9 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||||
// static
|
// static
|
||||||
paymentLabel.set(BSResources.get("createOffer.fundsBox.paymentLabel", model.getOfferId()));
|
paymentLabel.set(BSResources.get("createOffer.fundsBox.paymentLabel", model.getOfferId()));
|
||||||
|
|
||||||
if (model.addressEntry != null) {
|
if (model.getAddressEntry() != null) {
|
||||||
addressAsString.set(model.addressEntry.getAddress().toString());
|
addressAsString.set(model.getAddressEntry().getAddress().toString());
|
||||||
address.set(model.addressEntry.getAddress());
|
address.set(model.getAddressEntry().getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
setupBindings();
|
setupBindings();
|
||||||
|
|
|
@ -135,6 +135,11 @@ public class TradeController extends CachedViewController {
|
||||||
createOfferView = loader.load();
|
createOfferView = loader.load();
|
||||||
createOfferCodeBehind = loader.getController();
|
createOfferCodeBehind = loader.getController();
|
||||||
createOfferCodeBehind.setParentController(this);
|
createOfferCodeBehind.setParentController(this);
|
||||||
|
createOfferCodeBehind.setOnClose(() -> {
|
||||||
|
orderBookController.onCreateOfferViewRemoved();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
final Tab tab = new Tab("Create offer");
|
final Tab tab = new Tab("Create offer");
|
||||||
tab.setContent(createOfferView);
|
tab.setContent(createOfferView);
|
||||||
tabPane.getTabs().add(tab);
|
tabPane.getTabs().add(tab);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import io.bitsquare.gui.components.btc.BalanceTextField;
|
||||||
import io.bitsquare.gui.help.Help;
|
import io.bitsquare.gui.help.Help;
|
||||||
import io.bitsquare.gui.help.HelpId;
|
import io.bitsquare.gui.help.HelpId;
|
||||||
import io.bitsquare.gui.pm.trade.CreateOfferPM;
|
import io.bitsquare.gui.pm.trade.CreateOfferPM;
|
||||||
import io.bitsquare.gui.trade.TradeController;
|
|
||||||
import io.bitsquare.gui.util.ImageUtil;
|
import io.bitsquare.gui.util.ImageUtil;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.BSResources;
|
||||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||||
|
@ -38,6 +37,7 @@ import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
|
||||||
acceptedLanguagesTextField;
|
acceptedLanguagesTextField;
|
||||||
@FXML private AddressTextField addressTextField;
|
@FXML private AddressTextField addressTextField;
|
||||||
@FXML private BalanceTextField balanceTextField;
|
@FXML private BalanceTextField balanceTextField;
|
||||||
|
private Callable<Void> onCloseCallBack;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -137,8 +138,15 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
|
||||||
public void terminate() {
|
public void terminate() {
|
||||||
super.terminate();
|
super.terminate();
|
||||||
|
|
||||||
// Used to reset disable state of createOfferButton in OrderBookController
|
// Inform parent that we gor removed.
|
||||||
if (parentController != null) ((TradeController) parentController).onCreateOfferViewRemoved();
|
// Needed to reset disable state of createOfferButton in OrderBookController
|
||||||
|
if (onCloseCallBack != null)
|
||||||
|
try {
|
||||||
|
onCloseCallBack.call();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,5 +521,8 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
|
||||||
return new Point2D(x, y);
|
return new Point2D(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnClose(Callable<Void> onCloseCallBack) {
|
||||||
|
this.onCloseCallBack = onCloseCallBack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue