Make setup visible

This commit is contained in:
Manfred Karrer 2014-09-04 16:59:45 +02:00
parent 51a7f5cc84
commit 3fcd3d8c9b
9 changed files with 223 additions and 28 deletions

View File

@ -200,7 +200,35 @@ public class MainController extends ViewController {
private void onNavigationAdded() {
Profiler.printMsgWithTime("MainController.onNavigationAdded");
Platform.runLater(this::loadContentView);
// Platform.runLater(this::loadContentView);
// TODO for dev testing
Platform.runLater(this::loadSetup);
}
//TODO for dev testing
private void loadSetup() {
Profiler.printMsgWithTime("MainController.loadSetup");
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationItem.SETUP.getFxmlUrl()));
try {
final Node view = loader.load();
viewBuilder.contentPane.getChildren().setAll(view);
childController = loader.getController();
//TODO Remove that when all UIs are converted to CodeBehind
if (childController instanceof ViewController)
((ViewController) childController).setParentController(this);
else if (childController instanceof CodeBehind)
((CodeBehind) childController).setParentController(this);
} catch (IOException e) {
log.error("Loading view failed. FxmlUrl = " + NavigationItem.SETUP.getFxmlUrl());
log.error(e.getCause().toString());
log.error(e.getMessage());
log.error(e.getStackTrace().toString());
}
Platform.runLater(this::onContentViewLoaded);
}
private void onContentViewLoaded() {
@ -310,15 +338,24 @@ public class MainController extends ViewController {
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
private void loadViewFromNavButton(NavigationItem navigationItem) {
private void loadView(NavigationItem navigationItem) {
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()));
try {
final Node view = loader.load();
viewBuilder.contentPane.getChildren().setAll(view);
childController = loader.getController();
childController.setParentController(this);
//TODO Remove that when all UIs are converted to CodeBehind
if (childController instanceof ViewController)
((ViewController) childController).setParentController(this);
else if (childController instanceof CodeBehind)
((CodeBehind) childController).setParentController(this);
} catch (IOException e) {
log.error("Loading view failed. " + navigationItem.getFxmlUrl());
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
log.error(e.getCause().toString());
log.error(e.getMessage());
log.error(e.getStackTrace().toString());
}
}
@ -336,7 +373,7 @@ public class MainController extends ViewController {
prevToggleButtonIcon = ((ImageView) (toggleButton.getGraphic())).getImage();
((ImageView) (toggleButton.getGraphic())).setImage(ImageUtil.getIconImage(navigationItem.getActiveIcon()));
loadViewFromNavButton(navigationItem);
loadView(navigationItem);
persistence.write(this, "selectedNavigationItem", navigationItem);
@ -517,7 +554,7 @@ class ViewBuilder {
logo.setFitWidth(300);
logo.setFitHeight(300);
Label subTitle = new Label("The P2P Fiat-Bitcoin Exchange");
Label subTitle = new Label("The decentralized Bitcoin exchange");
subTitle.setAlignment(Pos.CENTER);
subTitle.setId("logo-sub-title-label");

View File

@ -36,8 +36,8 @@ import org.slf4j.LoggerFactory;
public abstract class ViewController implements Initializable {
private static final Logger log = LoggerFactory.getLogger(ViewController.class);
protected ViewController childController;
protected ViewController parentController;
protected Initializable childController;
protected Initializable parentController;
@FXML protected Parent root;
@ -63,7 +63,14 @@ public abstract class ViewController implements Initializable {
*/
public void terminate() {
log.trace("Lifecycle: terminate " + this.getClass().getSimpleName());
if (childController != null) childController.terminate();
if (childController != null) {
if (childController instanceof ViewController)
((ViewController) childController).terminate();
else if (childController instanceof CodeBehind)
((CodeBehind) childController).terminate();
}
}
/**

View File

@ -18,7 +18,6 @@
package io.bitsquare.gui.registration;
import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.trade.TradeController;
import java.net.URL;
@ -54,9 +53,6 @@ public class RegistrationController extends CodeBehind {
@Override
public void terminate() {
super.terminate();
// Used to reset disable state of createOfferButton in OrderBookController
if (parentController != null) ((TradeController) parentController).onCreateOfferViewRemoved();
}

View File

@ -18,7 +18,6 @@
package io.bitsquare.gui.setup;
import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.trade.TradeController;
import java.net.URL;
@ -29,18 +28,20 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SetupController extends CodeBehind {
public class SetupCB extends CodeBehind {
private static final Logger log = LoggerFactory.getLogger(SetupController.class);
private static final Logger log = LoggerFactory.getLogger(SetupCB.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public SetupController() {
public SetupCB(SetupPm presentationModel) {
super(presentationModel);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@ -54,9 +55,6 @@ public class SetupController extends CodeBehind {
@Override
public void terminate() {
super.terminate();
// Used to reset disable state of createOfferButton in OrderBookController
if (parentController != null) ((TradeController) parentController).onCreateOfferViewRemoved();
}

View File

@ -0,0 +1,65 @@
/*
* 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 io.bitsquare.gui.setup;
import io.bitsquare.gui.UIModel;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SetupModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(SetupModel.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public SetupModel() {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
}

View File

@ -0,0 +1,65 @@
/*
* 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 io.bitsquare.gui.setup;
import io.bitsquare.gui.PresentationModel;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SetupPm extends PresentationModel<SetupModel> {
private static final Logger log = LoggerFactory.getLogger(SetupPm.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public SetupPm(SetupModel model) {
super(model);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
}

View File

@ -17,15 +17,19 @@
~ along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
-->
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.setup.SetupController"
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.setup.SetupCB"
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml">
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<Label id="headline-label" text="Reg"/>
<ImageView fitWidth="1000.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@/images/screenshot.png"/>
</image>
</ImageView>
</VBox>
</AnchorPane>

View File

@ -21,6 +21,7 @@ import io.bitsquare.bank.BankAccountType;
import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.CachedViewController;
import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.MainController;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.ViewController;
@ -229,7 +230,18 @@ public class OrderBookController extends CachedViewController {
public void createOffer() {
if (isRegistered()) {
createOfferButton.setDisable(true);
Initializable nextController = parentController.loadViewAndGetChildController(NavigationItem.CREATE_OFFER);
//TODO Remove that when all UIs are converted to CodeBehind
Initializable nextController = null;
if (parentController != null) {
if (parentController instanceof ViewController)
nextController = ((ViewController) parentController).loadViewAndGetChildController(NavigationItem
.CREATE_OFFER);
else if (parentController instanceof CodeBehind)
nextController = ((CodeBehind) parentController).loadViewAndGetChildController(NavigationItem
.CREATE_OFFER);
}
if (nextController != null)
((CreateOfferCB) nextController).setOrderBookFilter(orderBookFilter);
}
@ -345,8 +357,19 @@ public class OrderBookController extends CachedViewController {
private void takeOffer(Offer offer) {
if (isRegistered()) {
TakeOfferController takeOfferController =
(TakeOfferController) parentController.loadViewAndGetChildController(NavigationItem.TAKE_OFFER);
//TODO Remove that when all UIs are converted to CodeBehind
TakeOfferController takeOfferController = null;
if (parentController != null) {
if (parentController instanceof ViewController)
takeOfferController = (TakeOfferController) ((ViewController) parentController)
.loadViewAndGetChildController(NavigationItem
.TAKE_OFFER);
else if (parentController instanceof CodeBehind)
takeOfferController = (TakeOfferController) ((CodeBehind) parentController)
.loadViewAndGetChildController(NavigationItem
.TAKE_OFFER);
}
Coin requestedAmount;
if (!"".equals(amount.getText())) {

View File

@ -32,7 +32,7 @@ createOffer.amountPriceBox.amountDescr=Amount of Bitcoin to buy
createOffer.amountPriceBox.priceDescr=Price per Bitcoin in {0}
createOffer.amountPriceBox.volumeDescr=Amount in {0} to spend
createOffer.amountPriceBox.minAmountDescr=Minimum amount of Bitcoin
createOffer.amountPriceBox.info=With the minimum amount you can attract more potential traders with giving them more flexibility. But note that there is no automatic creation of a new offer for the remaining amount in the case that a trader takes your offer with a lower amount as defined in the amount field. Your offer will be removed from the orderbook once a trader has taken your offer.
createOffer.amountPriceBox.info=Define a price for which you want to byu Bitcoin and either enter the amount or the trade volume. With the minimum amount you can attract more potential traders with giving them more flexibility. But note that there is no automatic creation of a new offer for the remaining amount in the case that a trader takes your offer with a lower amount as defined in the amount field. Your offer will be removed from the orderbook once a trader has taken your offer.
createOffer.amountPriceBox.next=Next step
createOffer.amountPriceBox.warning.invalidBtcDecimalPlaces=The amount you have entered exceeds the number of allowed decimal places.\nThe amount has been adjusted to 4 decimal places.
createOffer.amountPriceBox.warning.invalidFiatDecimalPlaces=The amount you have entered exceeds the number of allowed decimal places. The amount has been adjusted to 2 decimal places.
@ -46,7 +46,7 @@ createOffer.fundsBox.totalsNeeded=Funds needed for that trade:
createOffer.fundsBox.address=Trade wallet address:
createOffer.fundsBox.balance=Trade wallet balance:
createOffer.fundsBox.info=For every offer there is a dedicated trade wallet. You need to fund that trade wallet with the necessary Bitcoin amount. Those funds are reserved and will be used in the case that your offer gets executed. If you cancel your offer you can withdraw your funds from that trading wallet. The only payment which will be done now when placing the offer is the offer fee payment.
createOffer.fundsBox.collateral=Collateral ({0}):
createOffer.fundsBox.collateral=Refundable collateral ({0}):
createOffer.fundsBox.offerFee=Offer fee:
createOffer.fundsBox.networkFee=Bitcoin network fee:
createOffer.fundsBox.total=Total: