mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +01:00
Remove ChildView
This commit is contained in:
parent
3b75cc2fd0
commit
5f8f7446e3
12 changed files with 68 additions and 67 deletions
|
@ -37,7 +37,7 @@ public class ChangePasswordView extends InitializableView<GridPane, ChangePasswo
|
|||
@FXML Button saveButton, skipButton;
|
||||
@FXML PasswordField oldPasswordField, passwordField, repeatedPasswordField;
|
||||
|
||||
private Wizard parent;
|
||||
private Wizard wizard;
|
||||
|
||||
@Inject
|
||||
private ChangePasswordView(ChangePasswordViewModel model) {
|
||||
|
@ -53,8 +53,8 @@ public class ChangePasswordView extends InitializableView<GridPane, ChangePasswo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setParent(Wizard parent) {
|
||||
this.parent = parent;
|
||||
public void setWizard(Wizard wizard) {
|
||||
this.wizard = wizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,7 +65,7 @@ public class ChangePasswordView extends InitializableView<GridPane, ChangePasswo
|
|||
@FXML
|
||||
private void onSaved() {
|
||||
if (model.requestSavePassword())
|
||||
parent.nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
else
|
||||
log.debug(model.getErrorMessage()); // TODO use validating TF
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class ChangePasswordView extends InitializableView<GridPane, ChangePasswo
|
|||
|
||||
@FXML
|
||||
private void onSkipped() {
|
||||
parent.nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
|
|||
@FXML ComboBox<BankAccountType> typesComboBox;
|
||||
@FXML ComboBox<Currency> currencyComboBox;
|
||||
|
||||
private Wizard parent;
|
||||
private Wizard wizard;
|
||||
|
||||
private final OverlayManager overlayManager;
|
||||
|
||||
|
@ -99,8 +99,8 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setParent(Wizard parent) {
|
||||
this.parent = parent;
|
||||
public void setWizard(Wizard wizard) {
|
||||
this.wizard = wizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,7 +151,7 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
|
|||
|
||||
@FXML
|
||||
void onCompleted() {
|
||||
parent.nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -29,8 +29,8 @@ import java.util.Currency;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import viewfx.view.FxmlView;
|
||||
import viewfx.view.support.ActivatableViewAndModel;
|
||||
import viewfx.view.Wizard;
|
||||
import viewfx.view.support.ActivatableViewAndModel;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -50,7 +50,7 @@ public class IrcAccountView extends ActivatableViewAndModel<GridPane, IrcAccount
|
|||
@FXML ComboBox<BankAccountType> typesComboBox;
|
||||
@FXML ComboBox<Currency> currencyComboBox;
|
||||
|
||||
private Wizard parent;
|
||||
private Wizard wizard;
|
||||
|
||||
@Inject
|
||||
public IrcAccountView(IrcAccountViewModel model) {
|
||||
|
@ -132,8 +132,8 @@ public class IrcAccountView extends ActivatableViewAndModel<GridPane, IrcAccount
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setParent(Wizard parent) {
|
||||
this.parent = parent;
|
||||
public void setWizard(Wizard wizard) {
|
||||
this.wizard = wizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,7 +153,7 @@ public class IrcAccountView extends ActivatableViewAndModel<GridPane, IrcAccount
|
|||
@FXML
|
||||
void onSave() {
|
||||
if (model.requestSaveBankAccount().isValid)
|
||||
parent.nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -37,7 +37,7 @@ public class PasswordView extends InitializableView<GridPane, PasswordViewModel>
|
|||
@FXML Button saveButton, skipButton;
|
||||
@FXML PasswordField oldPasswordField, passwordField, repeatedPasswordField;
|
||||
|
||||
private Wizard parent;
|
||||
private Wizard wizard;
|
||||
|
||||
@Inject
|
||||
private PasswordView(PasswordViewModel model) {
|
||||
|
@ -53,8 +53,8 @@ public class PasswordView extends InitializableView<GridPane, PasswordViewModel>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setParent(Wizard parent) {
|
||||
this.parent = parent;
|
||||
public void setWizard(Wizard wizard) {
|
||||
this.wizard = wizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,14 +65,14 @@ public class PasswordView extends InitializableView<GridPane, PasswordViewModel>
|
|||
@FXML
|
||||
private void onSaved() {
|
||||
if (model.requestSavePassword())
|
||||
parent.nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
else
|
||||
log.debug(model.getErrorMessage()); // TODO use validating passwordTF
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void onSkipped() {
|
||||
parent.nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -53,7 +53,7 @@ public class RegistrationView extends InitializableView<GridPane, RegistrationVi
|
|||
@FXML Label paymentSpinnerInfoLabel;
|
||||
@FXML ProgressIndicator paymentSpinner;
|
||||
|
||||
private Wizard parent;
|
||||
private Wizard wizard;
|
||||
|
||||
private final OverlayManager overlayManager;
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class RegistrationView extends InitializableView<GridPane, RegistrationVi
|
|||
public void handle(ActionEvent actionEvent) {
|
||||
getProperties().put("type", "CLOSE");
|
||||
try {
|
||||
parent.nextStep(RegistrationView.this);
|
||||
wizard.nextStep(RegistrationView.this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ public class RegistrationView extends InitializableView<GridPane, RegistrationVi
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setParent(Wizard parent) {
|
||||
this.parent = parent;
|
||||
public void setWizard(Wizard wizard) {
|
||||
this.wizard = wizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,8 +33,8 @@ import viewfx.view.FxmlView;
|
|||
import viewfx.view.View;
|
||||
import viewfx.view.ViewLoader;
|
||||
import viewfx.view.Wizard;
|
||||
import viewfx.view.support.CachingViewLoader;
|
||||
import viewfx.view.support.ActivatableViewAndModel;
|
||||
import viewfx.view.support.CachingViewLoader;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.*;
|
||||
|
@ -57,7 +57,7 @@ public class RestrictionsView extends ActivatableViewAndModel<GridPane, Restrict
|
|||
@FXML ComboBox<Country> countryComboBox;
|
||||
@FXML Button completedButton, addAllEuroCountriesButton;
|
||||
|
||||
private Wizard parent;
|
||||
private Wizard wizard;
|
||||
|
||||
private final ViewLoader viewLoader;
|
||||
private final Stage primaryStage;
|
||||
|
@ -86,8 +86,8 @@ public class RestrictionsView extends ActivatableViewAndModel<GridPane, Restrict
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setParent(Wizard parent) {
|
||||
this.parent = parent;
|
||||
public void setWizard(Wizard wizard) {
|
||||
this.wizard = wizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,8 +130,7 @@ public class RestrictionsView extends ActivatableViewAndModel<GridPane, Restrict
|
|||
|
||||
@FXML
|
||||
private void onCompleted() {
|
||||
if (parent instanceof Wizard)
|
||||
((Wizard) parent).nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SeedWordsView extends InitializableView<GridPane, SeedWordsViewMode
|
|||
@FXML Button completedButton;
|
||||
@FXML TextArea seedWordsTextArea;
|
||||
|
||||
private Wizard parent;
|
||||
private Wizard wizard;
|
||||
|
||||
@Inject
|
||||
private SeedWordsView(SeedWordsViewModel model) {
|
||||
|
@ -49,8 +49,8 @@ public class SeedWordsView extends InitializableView<GridPane, SeedWordsViewMode
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setParent(Wizard parent) {
|
||||
this.parent = parent;
|
||||
public void setWizard(Wizard wizard) {
|
||||
this.wizard = wizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +60,7 @@ public class SeedWordsView extends InitializableView<GridPane, SeedWordsViewMode
|
|||
|
||||
@FXML
|
||||
private void onCompleted() {
|
||||
parent.nextStep(this);
|
||||
wizard.nextStep(this);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -155,7 +155,7 @@ public class AccountSetupWizard extends ActivatableView implements Wizard {
|
|||
View view = viewLoader.load(viewClass);
|
||||
content.getChildren().setAll(view.getRoot());
|
||||
if (view instanceof Wizard.Step)
|
||||
((Step) view).setParent(this);
|
||||
((Step) view).setWizard(this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@ public abstract class TradeView extends ActivatableView<TabPane, Void> {
|
|||
navigation.removeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
public void createOffer(Coin amount, Fiat price) {
|
||||
this.amount = amount;
|
||||
this.price = price;
|
||||
|
@ -128,7 +127,26 @@ public abstract class TradeView extends ActivatableView<TabPane, Void> {
|
|||
tab.setContent(view.getRoot());
|
||||
tabPane.getTabs().add(tab);
|
||||
offerBookView = (OfferBookView) view;
|
||||
offerBookView.setParent(this);
|
||||
|
||||
OfferActionHandler offerActionHandler = new OfferActionHandler() {
|
||||
@Override
|
||||
public void createOffer(Coin amount, Fiat price) {
|
||||
TradeView.this.amount = amount;
|
||||
TradeView.this.price = price;
|
||||
TradeView.this.navigation.navigateTo(MainView.class, TradeView.this.getClass(),
|
||||
CreateOfferView.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeOffer(Coin amount, Fiat price, Offer offer) {
|
||||
TradeView.this.amount = amount;
|
||||
TradeView.this.price = price;
|
||||
TradeView.this.offer = offer;
|
||||
TradeView.this.navigation.navigateTo(MainView.class, TradeView.this.getClass(),
|
||||
TakeOfferView.class);
|
||||
}
|
||||
};
|
||||
offerBookView.setOfferActionHandler(offerActionHandler);
|
||||
|
||||
offerBookView.setDirection(direction);
|
||||
|
||||
|
@ -177,5 +195,11 @@ public abstract class TradeView extends ActivatableView<TabPane, Void> {
|
|||
// update the navigation state
|
||||
navigation.navigateTo(MainView.class, this.getClass(), OfferBookView.class);
|
||||
}
|
||||
|
||||
public interface OfferActionHandler {
|
||||
void createOffer(Coin amount, Fiat price);
|
||||
|
||||
void takeOffer(Coin amount, Fiat price, Offer offer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ import java.util.List;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import viewfx.view.ChildView;
|
||||
import viewfx.view.FxmlView;
|
||||
import viewfx.view.support.ActivatableViewAndModel;
|
||||
|
||||
|
@ -61,8 +60,7 @@ import org.controlsfx.dialog.Dialog;
|
|||
import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
|
||||
@FxmlView
|
||||
public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookViewModel>
|
||||
implements ChildView<TradeView> {
|
||||
public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookViewModel> {
|
||||
|
||||
@FXML CheckBox showOnlyMatchingCheckBox;
|
||||
@FXML TableView<OfferBookListItem> table;
|
||||
|
@ -73,7 +71,6 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
@FXML Label amountBtcLabel, priceDescriptionLabel, priceFiatLabel, volumeDescriptionLabel, volumeFiatLabel,
|
||||
extendedButton1Label, extendedButton2Label, extendedCheckBoxLabel;
|
||||
|
||||
private TradeView parent;
|
||||
private ImageView expand;
|
||||
private ImageView collapse;
|
||||
|
||||
|
@ -85,6 +82,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
private final OverlayManager overlayManager;
|
||||
private final OptionalBtcValidator optionalBtcValidator;
|
||||
private final OptionalFiatValidator optionalFiatValidator;
|
||||
private TradeView.OfferActionHandler offerActionHandler;
|
||||
|
||||
@Inject
|
||||
OfferBookView(OfferBookViewModel model,
|
||||
|
@ -163,7 +161,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
void createOffer() {
|
||||
if (model.isRegistered()) {
|
||||
createOfferButton.setDisable(true);
|
||||
parent.createOffer(model.getAmountAsCoin(), model.getPriceAsCoin());
|
||||
offerActionHandler.createOffer(model.getAmountAsCoin(), model.getPriceAsCoin());
|
||||
}
|
||||
else {
|
||||
openSetupScreen();
|
||||
|
@ -222,7 +220,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
|
||||
if (model.isRegistered()) {
|
||||
if (offer.getDirection() == Direction.BUY) {
|
||||
parent.takeOffer(model.getAmountAsCoin(), model.getPriceAsCoin(), offer);
|
||||
offerActionHandler.takeOffer(model.getAmountAsCoin(), model.getPriceAsCoin(), offer);
|
||||
}
|
||||
else {
|
||||
Popups.openInfoPopup("Not implemented yet",
|
||||
|
@ -350,8 +348,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
.getBankAccountType()));
|
||||
}
|
||||
|
||||
public void setParent(TradeView parent) {
|
||||
this.parent = parent;
|
||||
public void setOfferActionHandler(TradeView.OfferActionHandler offerActionHandler) {
|
||||
this.offerActionHandler = offerActionHandler;
|
||||
}
|
||||
|
||||
private void setAmountColumnCellFactory() {
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package viewfx.view;
|
||||
|
||||
public interface ChildView<Parent extends View> extends View {
|
||||
void setParent(Parent parent);
|
||||
}
|
|
@ -20,7 +20,9 @@ package viewfx.view;
|
|||
public interface Wizard extends View {
|
||||
void nextStep(Step currentStep);
|
||||
|
||||
public interface Step extends ChildView<Wizard> {
|
||||
public interface Step {
|
||||
void hideWizardNavigation();
|
||||
|
||||
void setWizard(Wizard wizard);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue