fixed remove offer bug

This commit is contained in:
Manfred Karrer 2014-08-23 19:55:23 +02:00
parent bf08388ac9
commit 3391f6f4d3
6 changed files with 77 additions and 26 deletions

View File

@ -55,7 +55,7 @@ public class MainController implements Initializable, NavigationController
private final ToggleGroup toggleGroup = new ToggleGroup();
private final ViewBuilder viewBuilder;
private ChildController controller;
private ChildController childController;
private ToggleButton prevToggleButton;
private Image prevToggleButtonIcon;
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton;
@ -137,7 +137,7 @@ public class MainController implements Initializable, NavigationController
buyButton.fire();
break;
}
return controller;
return childController;
}
@ -294,22 +294,29 @@ public class MainController implements Initializable, NavigationController
private ChildController loadView(NavigationItem navigationItem)
{
if (controller != null)
controller.cleanup();
if (childController != null)
{
childController.cleanup();
if (childController instanceof Hibernate)
((Hibernate) childController).sleep();
}
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()));
try
{
final Node view = loader.load();
viewBuilder.contentPane.getChildren().setAll(view);
controller = loader.getController();
controller.setNavigationController(this);
childController = loader.getController();
childController.setNavigationController(this);
} catch (IOException e)
{
e.printStackTrace();
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)
@ -328,7 +335,7 @@ public class MainController implements Initializable, NavigationController
prevToggleButtonIcon = ((ImageView) (toggleButton.getGraphic())).getImage();
((ImageView) (toggleButton.getGraphic())).setImage(ImageUtil.getIconImage(navigationItem.getActiveIcon()));
controller = loadView(navigationItem);
childController = loadView(navigationItem);
persistence.write(this, "selectedNavigationItem", navigationItem);

View File

@ -1,6 +1,7 @@
package io.bitsquare.gui.funds;
import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.components.CachingTabPane;
@ -13,10 +14,11 @@ import javax.inject.Inject;
import org.slf4j.Logger;
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 final Persistence persistence;
private ChildController childController;
@FXML
private CachingTabPane root;
@ -66,7 +68,26 @@ public class FundsController implements Initializable, ChildController, Navigati
@Override
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();
}
}

View File

@ -138,6 +138,14 @@ public class CreateOfferController implements Initializable, ChildController, Hi
@Override
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();
setupValidation();
@ -150,15 +158,6 @@ public class CreateOfferController implements Initializable, ChildController, Hi
balanceTextField.setAddress(addressEntry.getAddress());
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()

View File

@ -1,6 +1,7 @@
package io.bitsquare.gui.orders;
import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.Hibernate;
import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.components.CachingTabPane;
@ -13,12 +14,14 @@ import javax.inject.Inject;
import org.slf4j.Logger;
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 int SELECTED_TAB_INDEX = -1;
private static OrdersController INSTANCE;
private final Persistence persistence;
private ChildController childController;
@FXML
private CachingTabPane tabPane;
@ -86,8 +89,28 @@ public class OrdersController implements Initializable, ChildController, Navigat
@Override
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();
}
}

View File

@ -162,8 +162,8 @@ public class TradeManager
(transactionId) -> {
try
{
addOffer(offer);
offer.setOfferFeePaymentTxID(transactionId.getHashAsString());
addOffer(offer);
createOfferCoordinatorMap.remove(offer.getId());
resultHandler.onResult(transactionId);
@ -193,11 +193,11 @@ public class TradeManager
}
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());
}*/
}
offers.remove(offer.getId());
persistOffers();

View File

@ -109,6 +109,7 @@ public class CreateOfferCoordinator
{
model.transaction = transaction;
model.setState(State.OFFER_FEE_TX_CREATED);
offer.setOfferFeePaymentTxID(transaction.getHashAsString());
BroadCastOfferFeeTx.run(this::onOfferFeeTxBroadCasted, this::onFailed, walletFacade, transaction);
}