Deactivate close tab button when funds are paid (#130)

This commit is contained in:
Manfred Karrer 2014-11-13 02:35:33 +01:00
parent e459ce8419
commit 704230fbdd
5 changed files with 23 additions and 6 deletions

View file

@ -188,8 +188,8 @@ public class TradeViewCB extends CachedViewCB implements TradeNavigator {
createOfferViewCB = loader.getController(); createOfferViewCB = loader.getController();
createOfferViewCB.setParent(this); createOfferViewCB.setParent(this);
createOfferViewCB.initWithData(direction, amount, price); createOfferViewCB.initWithData(direction, amount, price);
createOfferViewCB.setCloseListener(this::onCreateOfferViewRemoved);
final Tab tab = new Tab("Create offer"); final Tab tab = new Tab("Create offer");
createOfferViewCB.configCloseHandlers(this::onCreateOfferViewRemoved, tab.closableProperty());
tab.setContent(createOfferView); tab.setContent(createOfferView);
tabPane.getTabs().add(tab); tabPane.getTabs().add(tab);
tabPane.getSelectionModel().select(tab); tabPane.getSelectionModel().select(tab);
@ -204,8 +204,8 @@ public class TradeViewCB extends CachedViewCB implements TradeNavigator {
takeOfferViewCB = loader.getController(); takeOfferViewCB = loader.getController();
takeOfferViewCB.setParent(this); takeOfferViewCB.setParent(this);
takeOfferViewCB.initWithData(direction, amount, offer); takeOfferViewCB.initWithData(direction, amount, offer);
takeOfferViewCB.setCloseListener(this::onCreateOfferViewRemoved);
final Tab tab = new Tab("Take offer"); final Tab tab = new Tab("Take offer");
takeOfferViewCB.setCloseListener(this::onCreateOfferViewRemoved, tab.closableProperty());
tab.setContent(takeOfferView); tab.setContent(takeOfferView);
tabPane.getTabs().add(tab); tabPane.getTabs().add(tab);
tabPane.getSelectionModel().select(tab); tabPane.getSelectionModel().select(tab);

View file

@ -81,6 +81,7 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
final BooleanProperty showWarningInvalidFiatDecimalPlaces = new SimpleBooleanProperty(); final BooleanProperty showWarningInvalidFiatDecimalPlaces = new SimpleBooleanProperty();
final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty(); final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty();
final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty(); final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty();
final BooleanProperty tabIsClosable = new SimpleBooleanProperty(true);
final ObjectProperty<InputValidator.ValidationResult> amountValidationResult = new SimpleObjectProperty<>(); final ObjectProperty<InputValidator.ValidationResult> amountValidationResult = new SimpleObjectProperty<>();
final ObjectProperty<InputValidator.ValidationResult> minAmountValidationResult = new final ObjectProperty<InputValidator.ValidationResult> minAmountValidationResult = new
@ -347,8 +348,10 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
updateButtonDisableState(); updateButtonDisableState();
}); });
model.isWalletFunded.addListener((ov, oldValue, newValue) -> { model.isWalletFunded.addListener((ov, oldValue, newValue) -> {
if (newValue) if (newValue) {
updateButtonDisableState(); updateButtonDisableState();
tabIsClosable.set(false);
}
}); });
// Binding with Bindings.createObjectBinding does not work because of bi-directional binding // Binding with Bindings.createObjectBinding does not work because of bi-directional binding

View file

@ -44,6 +44,7 @@ import java.util.ResourceBundle;
import javax.inject.Inject; import javax.inject.Inject;
import javafx.beans.property.BooleanProperty;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.HPos; import javafx.geometry.HPos;
@ -79,6 +80,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
private final Navigation navigation; private final Navigation navigation;
private final OverlayManager overlayManager; private final OverlayManager overlayManager;
private CloseListener closeListener; private CloseListener closeListener;
private BooleanProperty tabIsClosable;
private boolean detailsVisible; private boolean detailsVisible;
private boolean advancedScreenInited; private boolean advancedScreenInited;
@ -143,6 +145,8 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
@SuppressWarnings("EmptyMethod") @SuppressWarnings("EmptyMethod")
public void deactivate() { public void deactivate() {
super.deactivate(); super.deactivate();
tabIsClosable.unbind();
} }
@Override @Override
@ -169,10 +173,13 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
imageView.setId("image-sell-large"); imageView.setId("image-sell-large");
} }
public void setCloseListener(CloseListener closeListener) { public void configCloseHandlers(CloseListener closeListener, BooleanProperty tabIsClosable) {
this.closeListener = closeListener; this.closeListener = closeListener;
this.tabIsClosable = tabIsClosable;
tabIsClosable.bind(presentationModel.tabIsClosable);
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// UI Handlers // UI Handlers
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -80,6 +80,7 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
final BooleanProperty isTakeOfferButtonDisabled = new SimpleBooleanProperty(true); final BooleanProperty isTakeOfferButtonDisabled = new SimpleBooleanProperty(true);
final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty(); final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty();
final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty(); final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty();
final BooleanProperty tabIsClosable = new SimpleBooleanProperty(true);
final ObjectProperty<InputValidator.ValidationResult> amountValidationResult = new SimpleObjectProperty<>(); final ObjectProperty<InputValidator.ValidationResult> amountValidationResult = new SimpleObjectProperty<>();
@ -322,8 +323,10 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
}); });
model.isWalletFunded.addListener((ov, oldValue, newValue) -> { model.isWalletFunded.addListener((ov, oldValue, newValue) -> {
if (newValue) if (newValue) {
updateButtonDisableState(); updateButtonDisableState();
tabIsClosable.set(false);
}
}); });
// Binding with Bindings.createObjectBinding does not work because of bi-directional binding // Binding with Bindings.createObjectBinding does not work because of bi-directional binding

View file

@ -45,6 +45,7 @@ import java.util.ResourceBundle;
import javax.inject.Inject; import javax.inject.Inject;
import javafx.beans.property.BooleanProperty;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.HPos; import javafx.geometry.HPos;
@ -74,6 +75,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
private final Navigation navigation; private final Navigation navigation;
private final OverlayManager overlayManager; private final OverlayManager overlayManager;
private CloseListener closeListener; private CloseListener closeListener;
private BooleanProperty tabIsClosable;
private boolean detailsVisible; private boolean detailsVisible;
private boolean advancedScreenInited; private boolean advancedScreenInited;
@ -184,8 +186,10 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
acceptedArbitratorsTextField.setText(presentationModel.getAcceptedArbitrators()); acceptedArbitratorsTextField.setText(presentationModel.getAcceptedArbitrators());
} }
public void setCloseListener(CloseListener closeListener) { public void setCloseListener(CloseListener closeListener, BooleanProperty tabIsClosable) {
this.closeListener = closeListener; this.closeListener = closeListener;
this.tabIsClosable = tabIsClosable;
tabIsClosable.bind(presentationModel.tabIsClosable);
} }