mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-15 04:52:15 -04:00
fixed remove offer bug
This commit is contained in:
parent
bf08388ac9
commit
3391f6f4d3
6 changed files with 77 additions and 26 deletions
|
@ -55,7 +55,7 @@ public class MainController implements Initializable, NavigationController
|
||||||
private final ToggleGroup toggleGroup = new ToggleGroup();
|
private final ToggleGroup toggleGroup = new ToggleGroup();
|
||||||
private final ViewBuilder viewBuilder;
|
private final ViewBuilder viewBuilder;
|
||||||
|
|
||||||
private ChildController controller;
|
private ChildController childController;
|
||||||
private ToggleButton prevToggleButton;
|
private ToggleButton prevToggleButton;
|
||||||
private Image prevToggleButtonIcon;
|
private Image prevToggleButtonIcon;
|
||||||
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton;
|
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton;
|
||||||
|
@ -137,7 +137,7 @@ public class MainController implements Initializable, NavigationController
|
||||||
buyButton.fire();
|
buyButton.fire();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return controller;
|
return childController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,22 +294,29 @@ public class MainController implements Initializable, NavigationController
|
||||||
|
|
||||||
private ChildController loadView(NavigationItem navigationItem)
|
private ChildController loadView(NavigationItem navigationItem)
|
||||||
{
|
{
|
||||||
if (controller != null)
|
if (childController != null)
|
||||||
controller.cleanup();
|
{
|
||||||
|
childController.cleanup();
|
||||||
|
if (childController instanceof Hibernate)
|
||||||
|
((Hibernate) childController).sleep();
|
||||||
|
}
|
||||||
|
|
||||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Node view = loader.load();
|
final Node view = loader.load();
|
||||||
viewBuilder.contentPane.getChildren().setAll(view);
|
viewBuilder.contentPane.getChildren().setAll(view);
|
||||||
controller = loader.getController();
|
childController = loader.getController();
|
||||||
controller.setNavigationController(this);
|
childController.setNavigationController(this);
|
||||||
} catch (IOException e)
|
} catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("Loading view failed. " + navigationItem.getFxmlUrl());
|
log.error("Loading view failed. " + navigationItem.getFxmlUrl());
|
||||||
}
|
}
|
||||||
return controller;
|
if (childController instanceof Hibernate)
|
||||||
|
((Hibernate) childController).awake();
|
||||||
|
|
||||||
|
return childController;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToggleButton addNavButton(Pane parent, String title, NavigationItem navigationItem)
|
private ToggleButton addNavButton(Pane parent, String title, NavigationItem navigationItem)
|
||||||
|
@ -328,7 +335,7 @@ public class MainController implements Initializable, NavigationController
|
||||||
prevToggleButtonIcon = ((ImageView) (toggleButton.getGraphic())).getImage();
|
prevToggleButtonIcon = ((ImageView) (toggleButton.getGraphic())).getImage();
|
||||||
((ImageView) (toggleButton.getGraphic())).setImage(ImageUtil.getIconImage(navigationItem.getActiveIcon()));
|
((ImageView) (toggleButton.getGraphic())).setImage(ImageUtil.getIconImage(navigationItem.getActiveIcon()));
|
||||||
|
|
||||||
controller = loadView(navigationItem);
|
childController = loadView(navigationItem);
|
||||||
|
|
||||||
persistence.write(this, "selectedNavigationItem", navigationItem);
|
persistence.write(this, "selectedNavigationItem", navigationItem);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.bitsquare.gui.funds;
|
package io.bitsquare.gui.funds;
|
||||||
|
|
||||||
import io.bitsquare.gui.ChildController;
|
import io.bitsquare.gui.ChildController;
|
||||||
|
import io.bitsquare.gui.Hibernate;
|
||||||
import io.bitsquare.gui.NavigationController;
|
import io.bitsquare.gui.NavigationController;
|
||||||
import io.bitsquare.gui.NavigationItem;
|
import io.bitsquare.gui.NavigationItem;
|
||||||
import io.bitsquare.gui.components.CachingTabPane;
|
import io.bitsquare.gui.components.CachingTabPane;
|
||||||
|
@ -13,10 +14,11 @@ import javax.inject.Inject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class FundsController implements Initializable, ChildController, NavigationController
|
public class FundsController implements Initializable, ChildController, NavigationController, Hibernate
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(FundsController.class);
|
private static final Logger log = LoggerFactory.getLogger(FundsController.class);
|
||||||
private final Persistence persistence;
|
private final Persistence persistence;
|
||||||
|
private ChildController childController;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private CachingTabPane root;
|
private CachingTabPane root;
|
||||||
|
@ -66,7 +68,26 @@ public class FundsController implements Initializable, ChildController, Navigati
|
||||||
@Override
|
@Override
|
||||||
public ChildController navigateToView(NavigationItem navigationItem)
|
public ChildController navigateToView(NavigationItem navigationItem)
|
||||||
{
|
{
|
||||||
return root.navigateToView(navigationItem.getFxmlUrl());
|
childController = root.navigateToView(navigationItem.getFxmlUrl());
|
||||||
|
return childController;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Interface implementation: Hibernate
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sleep()
|
||||||
|
{
|
||||||
|
if (childController instanceof Hibernate)
|
||||||
|
((Hibernate) childController).sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void awake()
|
||||||
|
{
|
||||||
|
if (childController instanceof Hibernate)
|
||||||
|
((Hibernate) childController).awake();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,14 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb)
|
public void initialize(URL url, ResourceBundle rb)
|
||||||
{
|
{
|
||||||
|
//TODO just for dev testing
|
||||||
|
if (BitSquare.fillFormsWithDummyData)
|
||||||
|
{
|
||||||
|
amountTextField.setText("1.0");
|
||||||
|
minAmountTextField.setText("0.1");
|
||||||
|
priceTextField.setText("" + (int) (499 - new Random().nextDouble() * 1000 / 100));
|
||||||
|
}
|
||||||
|
|
||||||
setupBindings();
|
setupBindings();
|
||||||
setupValidation();
|
setupValidation();
|
||||||
|
|
||||||
|
@ -150,15 +158,6 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||||
balanceTextField.setAddress(addressEntry.getAddress());
|
balanceTextField.setAddress(addressEntry.getAddress());
|
||||||
balanceTextField.setWalletFacade(walletFacade);
|
balanceTextField.setWalletFacade(walletFacade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO just for dev testing
|
|
||||||
if (BitSquare.fillFormsWithDummyData)
|
|
||||||
{
|
|
||||||
amountTextField.setText("1.0");
|
|
||||||
minAmountTextField.setText("0.1");
|
|
||||||
priceTextField.setText("" + (int) (499 - new Random().nextDouble() * 1000 / 100));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupBindings()
|
private void setupBindings()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.bitsquare.gui.orders;
|
package io.bitsquare.gui.orders;
|
||||||
|
|
||||||
import io.bitsquare.gui.ChildController;
|
import io.bitsquare.gui.ChildController;
|
||||||
|
import io.bitsquare.gui.Hibernate;
|
||||||
import io.bitsquare.gui.NavigationController;
|
import io.bitsquare.gui.NavigationController;
|
||||||
import io.bitsquare.gui.NavigationItem;
|
import io.bitsquare.gui.NavigationItem;
|
||||||
import io.bitsquare.gui.components.CachingTabPane;
|
import io.bitsquare.gui.components.CachingTabPane;
|
||||||
|
@ -13,12 +14,14 @@ import javax.inject.Inject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class OrdersController implements Initializable, ChildController, NavigationController
|
public class OrdersController implements Initializable, ChildController, NavigationController, Hibernate
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(OrdersController.class);
|
private static final Logger log = LoggerFactory.getLogger(OrdersController.class);
|
||||||
private static int SELECTED_TAB_INDEX = -1;
|
private static int SELECTED_TAB_INDEX = -1;
|
||||||
private static OrdersController INSTANCE;
|
private static OrdersController INSTANCE;
|
||||||
private final Persistence persistence;
|
private final Persistence persistence;
|
||||||
|
private ChildController childController;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private CachingTabPane tabPane;
|
private CachingTabPane tabPane;
|
||||||
|
|
||||||
|
@ -86,7 +89,27 @@ public class OrdersController implements Initializable, ChildController, Navigat
|
||||||
@Override
|
@Override
|
||||||
public ChildController navigateToView(NavigationItem navigationItem)
|
public ChildController navigateToView(NavigationItem navigationItem)
|
||||||
{
|
{
|
||||||
return tabPane.navigateToView(navigationItem.getFxmlUrl());
|
childController = tabPane.navigateToView(navigationItem.getFxmlUrl());
|
||||||
|
return childController;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Interface implementation: Hibernate
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sleep()
|
||||||
|
{
|
||||||
|
if (childController instanceof Hibernate)
|
||||||
|
((Hibernate) childController).sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void awake()
|
||||||
|
{
|
||||||
|
if (childController instanceof Hibernate)
|
||||||
|
((Hibernate) childController).awake();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,8 +162,8 @@ public class TradeManager
|
||||||
(transactionId) -> {
|
(transactionId) -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
addOffer(offer);
|
|
||||||
offer.setOfferFeePaymentTxID(transactionId.getHashAsString());
|
offer.setOfferFeePaymentTxID(transactionId.getHashAsString());
|
||||||
|
addOffer(offer);
|
||||||
createOfferCoordinatorMap.remove(offer.getId());
|
createOfferCoordinatorMap.remove(offer.getId());
|
||||||
|
|
||||||
resultHandler.onResult(transactionId);
|
resultHandler.onResult(transactionId);
|
||||||
|
@ -193,11 +193,11 @@ public class TradeManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeOffer(Offer offer)
|
public void removeOffer(Offer offer)
|
||||||
{ //TODO
|
{
|
||||||
/* if (!offers.containsKey(offer.getId()))
|
if (!offers.containsKey(offer.getId()))
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("offers does not contain the offer with the ID " + offer.getId());
|
throw new IllegalStateException("offers does not contain the offer with the ID " + offer.getId());
|
||||||
}*/
|
}
|
||||||
|
|
||||||
offers.remove(offer.getId());
|
offers.remove(offer.getId());
|
||||||
persistOffers();
|
persistOffers();
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class CreateOfferCoordinator
|
||||||
{
|
{
|
||||||
model.transaction = transaction;
|
model.transaction = transaction;
|
||||||
model.setState(State.OFFER_FEE_TX_CREATED);
|
model.setState(State.OFFER_FEE_TX_CREATED);
|
||||||
|
offer.setOfferFeePaymentTxID(transaction.getHashAsString());
|
||||||
BroadCastOfferFeeTx.run(this::onOfferFeeTxBroadCasted, this::onFailed, walletFacade, transaction);
|
BroadCastOfferFeeTx.run(this::onOfferFeeTxBroadCasted, this::onFailed, walletFacade, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue