diff --git a/src/main/java/io/bitsquare/BitSquare.java b/src/main/java/io/bitsquare/BitSquare.java index 397cf254d3..c79b066289 100644 --- a/src/main/java/io/bitsquare/BitSquare.java +++ b/src/main/java/io/bitsquare/BitSquare.java @@ -27,7 +27,7 @@ import io.bitsquare.msg.MessageFacade; import io.bitsquare.persistence.Persistence; import io.bitsquare.settings.Settings; import io.bitsquare.user.User; -import io.bitsquare.util.BSFXMLLoader; +import io.bitsquare.util.ViewLoader; import com.google.common.base.Throwables; @@ -105,16 +105,16 @@ public class BitSquare extends Application { User persistedUser = (User) persistence.read(user); user.applyPersistedUser(persistedUser); - persistence.write(user); + //persistence.write(user); settings.applyPersistedSettings((Settings) persistence.read(settings.getClass().getName())); primaryStage.setTitle("BitSquare (" + APP_NAME + ")"); - BSFXMLLoader.setInjector(injector); + ViewLoader.setInjector(injector); - final BSFXMLLoader loader = - new BSFXMLLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), false); + final ViewLoader loader = + new ViewLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), false); try { final Parent view = loader.load(); diff --git a/src/main/java/io/bitsquare/di/BitSquareModule.java b/src/main/java/io/bitsquare/di/BitSquareModule.java index be7015e7a7..fa4baf70ca 100644 --- a/src/main/java/io/bitsquare/di/BitSquareModule.java +++ b/src/main/java/io/bitsquare/di/BitSquareModule.java @@ -57,7 +57,6 @@ public class BitSquareModule extends AbstractModule { @Override protected void configure() { bind(User.class).asEagerSingleton(); - bind(OrderBook.class).asEagerSingleton(); bind(Persistence.class).asEagerSingleton(); bind(Settings.class).asEagerSingleton(); @@ -71,6 +70,7 @@ public class BitSquareModule extends AbstractModule { bind(BootstrappedPeerFactory.class).asEagerSingleton(); bind(TradeManager.class).asEagerSingleton(); + bind(OrderBook.class).asEagerSingleton(); bind(NavigationController.class).asEagerSingleton(); bind(OverlayController.class).asEagerSingleton(); bind(BSFormatter.class).asEagerSingleton(); @@ -81,7 +81,6 @@ public class BitSquareModule extends AbstractModule { bind(InputValidator.class).asEagerSingleton(); bind(PasswordValidator.class).asEagerSingleton(); - //bind(String.class).annotatedWith(Names.named("networkType")).toInstance(WalletFacade.MAIN_NET); // how to use reg test see description in the readme file bind(String.class).annotatedWith(Names.named("networkType")).toInstance(WalletFacade.REG_TEST_NET); diff --git a/src/main/java/io/bitsquare/gui/CachedViewCB.java b/src/main/java/io/bitsquare/gui/CachedViewCB.java index 4f557fc660..96b90aadfd 100644 --- a/src/main/java/io/bitsquare/gui/CachedViewCB.java +++ b/src/main/java/io/bitsquare/gui/CachedViewCB.java @@ -19,6 +19,10 @@ public class CachedViewCB extends ViewCB { super(presentationModel); } + public CachedViewCB() { + super(); + } + /** * Get called form GUI framework when the UI is ready. * In caching controllers the initialize is only used for static UI setup. @@ -36,8 +40,11 @@ public class CachedViewCB extends ViewCB { // lets terminate log.trace("Lifecycle: sceneProperty changed: " + this.getClass().getSimpleName() + " / oldValue=" + oldValue + " / newValue=" + newValue); - if (oldValue == null && newValue != null) activate(); - else if (oldValue != null && newValue == null) deactivate(); + + if (oldValue == null && newValue != null) + activate(); + else if (oldValue != null && newValue == null) + deactivate(); }); } @@ -50,7 +57,8 @@ public class CachedViewCB extends ViewCB { */ public void activate() { log.trace("Lifecycle: activate " + this.getClass().getSimpleName()); - if (childController instanceof CachedViewCB) ((CachedViewCB) childController).activate(); + if (childController instanceof CachedViewCB) + ((CachedViewCB) childController).activate(); if (presentationModel != null) presentationModel.activate(); @@ -61,7 +69,8 @@ public class CachedViewCB extends ViewCB { */ public void deactivate() { log.trace("Lifecycle: deactivate " + this.getClass().getSimpleName()); - if (childController instanceof CachedViewCB) ((CachedViewCB) childController).deactivate(); + if (childController instanceof CachedViewCB) + ((CachedViewCB) childController).deactivate(); if (presentationModel != null) presentationModel.deactivate(); diff --git a/src/main/java/io/bitsquare/gui/CloseListener.java b/src/main/java/io/bitsquare/gui/CloseListener.java new file mode 100644 index 0000000000..e20cea8ab9 --- /dev/null +++ b/src/main/java/io/bitsquare/gui/CloseListener.java @@ -0,0 +1,22 @@ +/* + * 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 . + */ + +package io.bitsquare.gui; + +public interface CloseListener { + void onClosed(); +} diff --git a/src/main/java/io/bitsquare/gui/NavigationListener.java b/src/main/java/io/bitsquare/gui/NavigationListener.java new file mode 100644 index 0000000000..442f385ec5 --- /dev/null +++ b/src/main/java/io/bitsquare/gui/NavigationListener.java @@ -0,0 +1,22 @@ +/* + * 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 . + */ + +package io.bitsquare.gui; + +public interface NavigationListener { + public void navigate(NavigationItem navigationItem); +} diff --git a/src/main/java/io/bitsquare/gui/PresentationModel.java b/src/main/java/io/bitsquare/gui/PresentationModel.java index e054feb611..930358ef32 100644 --- a/src/main/java/io/bitsquare/gui/PresentationModel.java +++ b/src/main/java/io/bitsquare/gui/PresentationModel.java @@ -1,6 +1,10 @@ package io.bitsquare.gui; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class PresentationModel { + private static final Logger log = LoggerFactory.getLogger(PresentationModel.class); protected T model; @@ -13,26 +17,26 @@ public class PresentationModel { } public void initialize() { + log.trace("Lifecycle: initialize " + this.getClass().getSimpleName()); if (model != null) model.initialize(); - - activate(); } public void activate() { + log.trace("Lifecycle: activate " + this.getClass().getSimpleName()); if (model != null) model.activate(); } public void deactivate() { + log.trace("Lifecycle: deactivate " + this.getClass().getSimpleName()); if (model != null) model.deactivate(); } public void terminate() { + log.trace("Lifecycle: terminate " + this.getClass().getSimpleName()); if (model != null) model.terminate(); - - deactivate(); } } diff --git a/src/main/java/io/bitsquare/gui/UIModel.java b/src/main/java/io/bitsquare/gui/UIModel.java index f8c4029614..25f68b9610 100644 --- a/src/main/java/io/bitsquare/gui/UIModel.java +++ b/src/main/java/io/bitsquare/gui/UIModel.java @@ -7,16 +7,18 @@ public class UIModel { private static final Logger log = LoggerFactory.getLogger(UIModel.class); public void initialize() { - activate(); + log.trace("Lifecycle: initialize " + this.getClass().getSimpleName()); } public void activate() { + log.trace("Lifecycle: activate " + this.getClass().getSimpleName()); } public void deactivate() { + log.trace("Lifecycle: deactivate " + this.getClass().getSimpleName()); } public void terminate() { - deactivate(); + log.trace("Lifecycle: terminate " + this.getClass().getSimpleName()); } } diff --git a/src/main/java/io/bitsquare/gui/ViewCB.java b/src/main/java/io/bitsquare/gui/ViewCB.java index 23db64c46b..02ca06e1a6 100644 --- a/src/main/java/io/bitsquare/gui/ViewCB.java +++ b/src/main/java/io/bitsquare/gui/ViewCB.java @@ -31,7 +31,6 @@ public class ViewCB implements Initializable { this.presentationModel = presentationModel; } - // TODO Still open question if we enforce a presentationModel or not? For small UIs it might be too much overhead. public ViewCB() { } diff --git a/src/main/java/io/bitsquare/gui/bitsquare.css b/src/main/java/io/bitsquare/gui/bitsquare.css index 844de01512..a14b611b86 100644 --- a/src/main/java/io/bitsquare/gui/bitsquare.css +++ b/src/main/java/io/bitsquare/gui/bitsquare.css @@ -14,6 +14,12 @@ upper gradient color on tab: d3d3d3 lower gradient color on tab: dddddd */ +.root { + -bs-theme-color: #0096c9; + -bs-dark-grey: #333333; + -bs-bg-grey: #dddddd; +} + /* Splash */ #splash { @@ -27,7 +33,7 @@ lower gradient color on tab: dddddd } #base-content-container { - -fx-background-color: #dddddd; + -fx-background-color: -bs-bg-grey; } #content-pane { @@ -63,7 +69,7 @@ lower gradient color on tab: dddddd } #nav-button:selected .text { - -fx-font-size: 11; + -fx-font-size: 11; -fx-font-weight: bold; } @@ -103,7 +109,7 @@ lower gradient color on tab: dddddd } .copy-icon { - -fx-text-fill: #0096c9; + -fx-text-fill: -bs-theme-color; -fx-cursor: hand; } @@ -111,6 +117,12 @@ lower gradient color on tab: dddddd -fx-text-fill: black; } +.tooltip { + -fx-background-color: white; + -fx-text-fill: black; +} + + /* Same style like non editable textfield. But textfield spans a whole column in a grid, so we use generally textfield */ #label-with-background { @@ -121,7 +133,7 @@ textfield */ #address-text-field { -fx-cursor: hand; - -fx-text-fill: #0096c9; + -fx-text-fill: -bs-theme-color; } #address-text-field:hover { -fx-text-fill: black; @@ -157,7 +169,7 @@ textfield */ } .table-view .table-row-cell .copy-icon .text { - -fx-fill: #0096c9; + -fx-fill: -bs-theme-color; } .table-view .table-row-cell .copy-icon .text:hover { @@ -173,7 +185,7 @@ textfield */ } .table-view .table-row-cell .hyperlink .text { - -fx-fill: #0096c9; + -fx-fill: -bs-theme-color; } .table-view .table-row-cell .hyperlink .text:hover { @@ -194,12 +206,12 @@ textfield */ } #clickable-icon { - -fx-text-fill: #0096c9; + -fx-text-fill: -bs-theme-color; -fx-cursor: hand; } #clickable-icon:hover { - -fx-text-fill: #666; + -fx-text-fill: #666666; } #form-title { @@ -255,13 +267,13 @@ textfield */ -fx-background-color: #cfcfcf, linear-gradient(#cfcfcf 0%, #b5b5b5 100%), - linear-gradient(#d3d3d3 0%, #dddddd 100%); + linear-gradient(#d3d3d3 0%, -bs-bg-grey 100%); -fx-background-insets: 0 0 0 0,0,1; } #content-pane-label { -fx-font-size: 14; - -fx-text-fill: #000; + -fx-text-fill: black; } #info-icon-label { -fx-font-size:16; @@ -272,7 +284,7 @@ textfield */ #direction-icon-label { -fx-font-weight:bold; -fx-font-size:16; - -fx-text-fill: #333; + -fx-text-fill: -bs-dark-grey; } #input-description-label { @@ -289,14 +301,14 @@ textfield */ #currency-info-label { -fx-border-radius: 0 4 4 0; -fx-padding: 4 4 4 4; - -fx-background-color: linear-gradient(to bottom, #eee, #ddd); + -fx-background-color: #f6f6f6; -fx-border-color: #aaa; -fx-border-style: solid solid solid none; -fx-border-insets: 0 0 0 -2; } #totals-separator { - -fx-background: #aaa; + -fx-background: #AAAAAA; } #payment-info { @@ -308,32 +320,32 @@ textfield */ #wizard-title-deactivated { -fx-font-weight: bold; -fx-font-size: 16; - -fx-text-fill: #ccc; + -fx-text-fill: #CCCCCC; } #wizard-title-active { -fx-font-weight: bold; -fx-font-size: 16; - -fx-text-fill: #000; + -fx-text-fill: black; } #wizard-title-completed { -fx-font-weight: bold; -fx-font-size: 16; - -fx-text-fill: #000; + -fx-text-fill: black; } #wizard-sub-title-deactivated { - -fx-text-fill: #ccc; + -fx-text-fill: #CCCCCC; } #wizard-sub-title-active { - -fx-text-fill: #000; + -fx-text-fill: black; } #wizard-sub-title-completed { - -fx-text-fill: #000; + -fx-text-fill: black; } #wizard-item-background-deactivated { -fx-body-color: linear-gradient(to bottom, #f4f4f4, #F0F0F0); - -fx-outer-border: linear-gradient(to bottom, #ddd, #ccc); + -fx-outer-border: linear-gradient(to bottom, #dddddd, #ccc); -fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, @@ -369,22 +381,22 @@ textfield */ #wizard-title-disabled { -fx-font-weight: bold; -fx-font-size: 16; - -fx-text-fill: #ccc; + -fx-text-fill: #CCCCCC; } #wizard-title-active { -fx-font-weight: bold; -fx-font-size: 16; - -fx-text-fill: #000; + -fx-text-fill: black; } #wizard-title-selected { -fx-font-weight: bold; -fx-font-size: 16; - -fx-text-fill: #0096c9; + -fx-text-fill: -bs-theme-color; } #account-settings-item-background-disabled { -fx-body-color: linear-gradient(to bottom, #f4f4f4, #F0F0F0); - -fx-outer-border: linear-gradient(to bottom, #ddd, #ccc); + -fx-outer-border: linear-gradient(to bottom, #dddddd, #ccc); -fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, @@ -395,7 +407,7 @@ textfield */ #account-settings-item-background-active { -fx-body-color: linear-gradient(to bottom, #f4f4f4, #F0F0F0); - -fx-outer-border: linear-gradient(to bottom, #ddd, #ccc); + -fx-outer-border: linear-gradient(to bottom, #dddddd, #ccc); -fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, @@ -420,18 +432,18 @@ textfield */ #titled-group-bg-label { -fx-font-weight: bold; -fx-font-size: 14; - -fx-text-fill: #333; + -fx-text-fill: -bs-dark-grey; -fx-background-color: #f4f4f4; } #titled-group-bg-label-active { -fx-font-weight: bold; -fx-font-size: 14; - -fx-text-fill: #0096c9; + -fx-text-fill: -bs-theme-color; -fx-background-color: #f4f4f4; } #titled-group-bg { -fx-body-color: linear-gradient(to bottom, #f4f4f4, #F0F0F0); - -fx-outer-border: linear-gradient(to bottom, #ddd, #ccc); + -fx-outer-border: linear-gradient(to bottom, #dddddd, #ccc); -fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, @@ -449,3 +461,26 @@ textfield */ -fx-background-insets: 0 0 -1 0, 0, 1, 2; -fx-background-radius: 3px, 3px, 2px, 1px; } + + + +/* TitledSeparator */ +#titled-separator-label { + -fx-font-weight: bold; + -fx-font-size: 14; + -fx-text-fill: -bs-dark-grey; + -fx-background-color: #f4f4f4; +} +#titled-separator-label-active { + -fx-font-weight: bold; + -fx-font-size: 14; + -fx-text-fill: -bs-theme-color; + -fx-background-color: #f4f4f4; +} +#titled-separator:horizontal .line { + -fx-border-color: #cccccc transparent #999999 transparent; +} + +#titled-separator-active:horizontal .line { + -fx-border-color: #dddddd transparent derive(-bs-theme-color, 50%) transparent; +} \ No newline at end of file diff --git a/src/main/java/io/bitsquare/gui/components/CachingTabPane.java b/src/main/java/io/bitsquare/gui/components/CachingTabPane.java index 6c1c240d68..006f364077 100644 --- a/src/main/java/io/bitsquare/gui/components/CachingTabPane.java +++ b/src/main/java/io/bitsquare/gui/components/CachingTabPane.java @@ -19,7 +19,7 @@ package io.bitsquare.gui.components; import io.bitsquare.gui.ViewController; import io.bitsquare.persistence.Persistence; -import io.bitsquare.util.BSFXMLLoader; +import io.bitsquare.util.ViewLoader; import java.io.IOException; @@ -96,7 +96,7 @@ public class CachingTabPane extends TabPane { selectedTabIndex = getSelectionModel().getSelectedIndex(); TabInfo selectedTabInfo = tabInfoList.get(selectedTabIndex); - final BSFXMLLoader loader = new BSFXMLLoader(getClass().getResource(selectedTabInfo.url)); + final ViewLoader loader = new ViewLoader(getClass().getResource(selectedTabInfo.url)); try { Node view = loader.load(); selectedTabInfo.controller = loader.getController(); diff --git a/src/main/java/io/bitsquare/gui/components/InfoDisplay.java b/src/main/java/io/bitsquare/gui/components/InfoDisplay.java index 4a42ae4447..9fc7cde03a 100644 --- a/src/main/java/io/bitsquare/gui/components/InfoDisplay.java +++ b/src/main/java/io/bitsquare/gui/components/InfoDisplay.java @@ -21,8 +21,10 @@ import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.locale.BSResources; import javafx.application.Platform; +import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; @@ -35,6 +37,7 @@ import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.image.*; import javafx.scene.layout.*; +import javafx.scene.text.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,12 +54,14 @@ public class InfoDisplay extends Parent { private final StringProperty text = new SimpleStringProperty(); private final IntegerProperty rowIndex = new SimpleIntegerProperty(0); private final IntegerProperty columnIndex = new SimpleIntegerProperty(0); + private final DoubleProperty prefWidth = new SimpleDoubleProperty(740); private final ObjectProperty> onAction = new SimpleObjectProperty<>(); - private final ObjectProperty gridPane = new SimpleObjectProperty<>(); + private boolean useReadMore; + private final ImageView icon; - private final VBox vBox; + private final TextFlow textFlow; private final Label label; private final Hyperlink link; @@ -70,34 +75,58 @@ public class InfoDisplay extends Parent { icon = ImageUtil.getIconImageView(ImageUtil.INFO); icon.setPickOnBounds(true); icon.setPreserveRatio(true); - + icon.visibleProperty().bind(visibleProperty()); GridPane.setValignment(icon, VPos.TOP); GridPane.setMargin(icon, new Insets(4, 2, 0, 0)); GridPane.setRowSpan(icon, 2); label = new Label(); - label.textProperty().bindBidirectional(text); - label.setWrapText(true); + label.textProperty().bind(text); + label.prefWidthProperty().bind(prefWidth); + label.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); link = new Hyperlink(BSResources.get("shared.readMore")); link.setPadding(new Insets(0, 0, 0, -2)); - vBox = new VBox(); - vBox.setSpacing(0); - vBox.getChildren().addAll(label, link); + // We need that to know if we have a wrapping or not. + // Did not find a way to get that from the API. + Label testLabel = new Label(); + testLabel.textProperty().bind(text); - visibleProperty().addListener((ov, oldValue, newValue) -> { - icon.setVisible(newValue); - vBox.setVisible(newValue); + textFlow = new TextFlow(); + textFlow.visibleProperty().bind(visibleProperty()); + textFlow.getChildren().addAll(testLabel); + + testLabel.widthProperty().addListener((ov, o, n) -> { + if ((double) n > textFlow.getWidth()) { + link.setText(BSResources.get("shared.readMore")); + useReadMore = true; + } + else { + link.setText(BSResources.get("shared.openHelp")); + } + Platform.runLater(() -> textFlow.getChildren().setAll(label, link)); }); - // The text in the label does not get correctly displayed if there is not enough available overall height. - // Did not find a better way yet to solve the issue... - label.heightProperty().addListener((ov, o, n) -> { - vBox.setMinHeight((double) n + 100); - label.setMinHeight((double) n); - Platform.runLater(() -> vBox.setMinHeight(label.getHeight() + 15)); + // when clicking "Read more..." we expand and change the link to the Help + link.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent actionEvent) { + if (useReadMore) { + + label.setWrapText(true); + link.setText(BSResources.get("shared.openHelp")); + label.prefWidthProperty().bind(textFlow.widthProperty()); + link.setVisited(false); + // focus border is a bit confusing here so we remove it + link.setStyle("-fx-focus-color: transparent;"); + link.setOnAction(onAction.get()); + } + else { + onAction.get().handle(actionEvent); + } + } }); } @@ -108,41 +137,42 @@ public class InfoDisplay extends Parent { public void setText(String text) { this.text.set(text); + } - label.setText(text); + public void setPrefWidth(double prefWidth) { + this.prefWidth.set(prefWidth); + // label.setPrefWidth(getPrefWidth()); } public void setGridPane(GridPane gridPane) { this.gridPane.set(gridPane); - gridPane.getChildren().addAll(icon, vBox); + gridPane.getChildren().addAll(icon, textFlow); GridPane.setColumnIndex(icon, columnIndex.get()); - GridPane.setColumnIndex(vBox, columnIndex.get() + 1); + GridPane.setColumnIndex(textFlow, columnIndex.get() + 1); GridPane.setRowIndex(icon, rowIndex.get()); - GridPane.setRowIndex(vBox, rowIndex.get()); + GridPane.setRowIndex(textFlow, rowIndex.get()); } public void setRowIndex(int rowIndex) { this.rowIndex.set(rowIndex); GridPane.setRowIndex(icon, rowIndex); - GridPane.setRowIndex(vBox, rowIndex); + GridPane.setRowIndex(textFlow, rowIndex); } public void setColumnIndex(int columnIndex) { this.columnIndex.set(columnIndex); GridPane.setColumnIndex(icon, columnIndex); - GridPane.setColumnIndex(vBox, columnIndex + 1); + GridPane.setColumnIndex(textFlow, columnIndex + 1); } - public final void setOnAction(javafx.event.EventHandler eventHandler) { + public final void setOnAction(EventHandler eventHandler) { onAction.set(eventHandler); - - link.setOnAction(eventHandler); } @@ -158,6 +188,14 @@ public class InfoDisplay extends Parent { return text; } + public double getPrefWidth() { + return prefWidth.get(); + } + + public DoubleProperty prefWidthProperty() { + return prefWidth; + } + public int getColumnIndex() { return columnIndex.get(); } @@ -189,4 +227,5 @@ public class InfoDisplay extends Parent { public ObjectProperty gridPaneProperty() { return gridPane; } + } diff --git a/src/main/java/io/bitsquare/gui/components/TitledSeparator.java b/src/main/java/io/bitsquare/gui/components/TitledSeparator.java new file mode 100644 index 0000000000..1a33430af0 --- /dev/null +++ b/src/main/java/io/bitsquare/gui/components/TitledSeparator.java @@ -0,0 +1,79 @@ +/* + * 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 . + */ + +package io.bitsquare.gui.components; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.geometry.Insets; +import javafx.scene.control.*; +import javafx.scene.layout.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TitledSeparator extends Pane { + private static final Logger log = LoggerFactory.getLogger(TitledSeparator.class); + + private final Label label; + private final Separator separator; + private StringProperty text = new SimpleStringProperty(); + + /////////////////////////////////////////////////////////////////////////////////////////// + // Constructor + /////////////////////////////////////////////////////////////////////////////////////////// + + public TitledSeparator() { + GridPane.setMargin(this, new Insets(-10, -10, -10, -10)); + GridPane.setColumnSpan(this, 2); + + separator = new Separator(); + separator.prefWidthProperty().bind(widthProperty()); + + label = new Label(); + label.textProperty().bind(text); + label.setLayoutX(8); + label.setLayoutY(-8); + label.setPadding(new Insets(0, 7, 0, 5)); + setActive(); + getChildren().addAll(separator, label); + } + + public void setInactive() { + separator.setId("titled-separator"); + label.setId("titled-separator-label"); + } + + public void setActive() { + separator.setId("titled-separator-active"); + label.setId("titled-separator-label-active"); + } + + public String getText() { + return text.get(); + } + + public StringProperty textProperty() { + return text; + } + + public void setText(String text) { + this.text.set(text); + } + + +} diff --git a/src/main/java/io/bitsquare/gui/main/MainModel.java b/src/main/java/io/bitsquare/gui/main/MainModel.java index 9b86ea6434..f50d73b4d0 100644 --- a/src/main/java/io/bitsquare/gui/main/MainModel.java +++ b/src/main/java/io/bitsquare/gui/main/MainModel.java @@ -44,7 +44,7 @@ import javafx.collections.ObservableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class MainModel extends UIModel { +class MainModel extends UIModel { private static final Logger log = LoggerFactory.getLogger(MainModel.class); private final User user; @@ -56,11 +56,11 @@ public class MainModel extends UIModel { private boolean messageFacadeInited; private boolean walletFacadeInited; - public final BooleanProperty backendInited = new SimpleBooleanProperty(); - public final DoubleProperty networkSyncProgress = new SimpleDoubleProperty(); - public final BooleanProperty networkSyncComplete = new SimpleBooleanProperty(); - public final BooleanProperty takeOfferRequested = new SimpleBooleanProperty(); - public final ObjectProperty balance = new SimpleObjectProperty<>(); + final BooleanProperty backendInited = new SimpleBooleanProperty(); + final DoubleProperty networkSyncProgress = new SimpleDoubleProperty(); + final BooleanProperty networkSyncComplete = new SimpleBooleanProperty(); + final BooleanProperty takeOfferRequested = new SimpleBooleanProperty(); + final ObjectProperty balance = new SimpleObjectProperty<>(); /////////////////////////////////////////////////////////////////////////////////////////// @@ -99,7 +99,7 @@ public class MainModel extends UIModel { // Public /////////////////////////////////////////////////////////////////////////////////////////// - public void initBackend() { + void initBackend() { Profiler.printMsgWithTime("MainModel.initFacades"); messageFacade.init(new BootstrapListener() { @Override @@ -135,27 +135,29 @@ public class MainModel extends UIModel { // Setters /////////////////////////////////////////////////////////////////////////////////////////// - public void setSelectedNavigationItem(NavigationItem navigationItem) { + void setSelectedNavigationItem(NavigationItem navigationItem) { persistence.write(this, "selectedNavigationItem", navigationItem); } - public void setCurrentBankAccount(BankAccount bankAccount) { + void setCurrentBankAccount(BankAccount bankAccount) { user.setCurrentBankAccount(bankAccount); + persistence.write(user); } + /////////////////////////////////////////////////////////////////////////////////////////// // Getters /////////////////////////////////////////////////////////////////////////////////////////// - public ObservableList getBankAccounts() { + ObservableList getBankAccounts() { return user.getBankAccounts(); } - public ObjectProperty currentBankAccountProperty() { + ObjectProperty currentBankAccountProperty() { return user.currentBankAccountProperty(); } - public NavigationItem[] getSelectedNavigationItems() { + NavigationItem[] getSelectedNavigationItems() { NavigationItem[] selectedNavigationItems = (NavigationItem[]) persistence.read(this, "selectedNavigationItems"); if (selectedNavigationItems == null || selectedNavigationItems.length == 0) selectedNavigationItems = new NavigationItem[]{NavigationItem.BUY}; @@ -187,7 +189,6 @@ public class MainModel extends UIModel { backendInited.set(true); } - private void updateBalance(Coin balance) { this.balance.set(balance); } diff --git a/src/main/java/io/bitsquare/gui/main/MainPM.java b/src/main/java/io/bitsquare/gui/main/MainPM.java index 6e472078b7..1a737a7976 100644 --- a/src/main/java/io/bitsquare/gui/main/MainPM.java +++ b/src/main/java/io/bitsquare/gui/main/MainPM.java @@ -36,16 +36,16 @@ import javafx.util.StringConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class MainPM extends PresentationModel { +class MainPM extends PresentationModel { private static final Logger log = LoggerFactory.getLogger(MainPM.class); - public final BooleanProperty backendInited = new SimpleBooleanProperty(); - public final StringProperty balance = new SimpleStringProperty(); - public final StringProperty bankAccountsComboBoxPrompt = new SimpleStringProperty(); - public final BooleanProperty bankAccountsComboBoxDisable = new SimpleBooleanProperty(); - public final StringProperty splashScreenInfoText = new SimpleStringProperty(); - public final BooleanProperty networkSyncComplete = new SimpleBooleanProperty(); - public final BooleanProperty takeOfferRequested = new SimpleBooleanProperty(); + final BooleanProperty backendInited = new SimpleBooleanProperty(); + final StringProperty balance = new SimpleStringProperty(); + final StringProperty bankAccountsComboBoxPrompt = new SimpleStringProperty(); + final BooleanProperty bankAccountsComboBoxDisable = new SimpleBooleanProperty(); + final StringProperty splashScreenInfoText = new SimpleStringProperty(); + final BooleanProperty networkSyncComplete = new SimpleBooleanProperty(); + final BooleanProperty takeOfferRequested = new SimpleBooleanProperty(); /////////////////////////////////////////////////////////////////////////////////////////// @@ -103,7 +103,7 @@ public class MainPM extends PresentationModel { // Public /////////////////////////////////////////////////////////////////////////////////////////// - public void initBackend() { + void initBackend() { model.initBackend(); } @@ -112,11 +112,11 @@ public class MainPM extends PresentationModel { // Setters /////////////////////////////////////////////////////////////////////////////////////////// - public void setSelectedNavigationItem(NavigationItem navigationItem) { + void setSelectedNavigationItem(NavigationItem navigationItem) { model.setSelectedNavigationItem(navigationItem); } - public void setCurrentBankAccount(BankAccount bankAccount) { + void setCurrentBankAccount(BankAccount bankAccount) { model.setCurrentBankAccount(bankAccount); } @@ -125,19 +125,19 @@ public class MainPM extends PresentationModel { // Getters /////////////////////////////////////////////////////////////////////////////////////////// - public NavigationItem[] getSelectedNavigationItems() { + NavigationItem[] getSelectedNavigationItems() { return model.getSelectedNavigationItems(); } - public ObservableList getBankAccounts() { + ObservableList getBankAccounts() { return model.getBankAccounts(); } - public ObjectProperty currentBankAccountProperty() { + ObjectProperty currentBankAccountProperty() { return model.currentBankAccountProperty(); } - public StringConverter getBankAccountsConverter() { + StringConverter getBankAccountsConverter() { return new StringConverter() { @Override public String toString(BankAccount bankAccount) { diff --git a/src/main/java/io/bitsquare/gui/main/MainViewCB.java b/src/main/java/io/bitsquare/gui/main/MainViewCB.java index 663bc4f4db..828cc5dcbc 100644 --- a/src/main/java/io/bitsquare/gui/main/MainViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/MainViewCB.java @@ -28,7 +28,7 @@ import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.Profiler; import io.bitsquare.gui.util.Transitions; -import io.bitsquare.util.BSFXMLLoader; +import io.bitsquare.util.ViewLoader; import java.io.IOException; @@ -53,20 +53,17 @@ import org.slf4j.LoggerFactory; public class MainViewCB extends ViewCB { private static final Logger log = LoggerFactory.getLogger(MainViewCB.class); - private NavigationController navigationController; - private OverlayController overlayController; + private final NavigationController navigationController; + private final OverlayController overlayController; private final ToggleGroup navButtonsGroup = new ToggleGroup(); private NavigationItem mainNavigationItem; private BorderPane baseApplicationContainer; private VBox baseOverlayContainer; - private AnchorPane applicationContainer; private AnchorPane contentContainer; private HBox leftNavPane, rightNavPane; private NetworkSyncPane networkSyncPane; - private MenuBar menuBar; - private Label loadingLabel; private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton, accountButton; private Pane ordersButtonButtonPane; @@ -83,15 +80,27 @@ public class MainViewCB extends ViewCB { this.navigationController = navigationController; this.overlayController = overlayController; + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Lifecycle + /////////////////////////////////////////////////////////////////////////////////////////// + + @SuppressWarnings("EmptyMethod") + @Override + public void initialize(URL url, ResourceBundle rb) { + super.initialize(url, rb); + Profiler.printMsgWithTime("MainController.initialize"); // just temp. ugly hack... Popups will be removed Popups.setOverlayController(overlayController); navigationController.addListener(navigationItems -> { if (navigationItems != null) { - for (int i = 0; i < navigationItems.length; i++) { - if (navigationItems[i].getLevel() == 1) { - mainNavigationItem = navigationItems[i]; + for (NavigationItem navigationItem : navigationItems) { + if (navigationItem.getLevel() == 1) { + mainNavigationItem = navigationItem; break; } } @@ -115,19 +124,7 @@ public class MainViewCB extends ViewCB { Transitions.removeBlur(baseApplicationContainer); } }); - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Lifecycle - /////////////////////////////////////////////////////////////////////////////////////////// - - @SuppressWarnings("EmptyMethod") - @Override - public void initialize(URL url, ResourceBundle rb) { - super.initialize(url, rb); - - Profiler.printMsgWithTime("MainController.initialize"); startup(); } @@ -142,43 +139,11 @@ public class MainViewCB extends ViewCB { // Navigation /////////////////////////////////////////////////////////////////////////////////////////// - public void selectMainMenuButton(NavigationItem navigationItem) { - switch (navigationItem) { - case HOME: - homeButton.setSelected(true); - break; - case FUNDS: - fundsButton.setSelected(true); - break; - case MSG: - msgButton.setSelected(true); - break; - case ORDERS: - ordersButton.setSelected(true); - break; - case SETTINGS: - settingsButton.setSelected(true); - break; - case SELL: - sellButton.setSelected(true); - break; - case BUY: - buyButton.setSelected(true); - break; - case ACCOUNT: - accountButton.setSelected(true); - break; - default: - log.error(navigationItem.getFxmlUrl() + " is no main navigation item"); - break; - } - } - @Override public Initializable loadView(NavigationItem navigationItem) { super.loadView((navigationItem)); - final BSFXMLLoader loader = new BSFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl())); + final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl())); try { final Node view = loader.load(); contentContainer.getChildren().setAll(view); @@ -212,8 +177,8 @@ public class MainViewCB extends ViewCB { private void onBaseContainersCreated() { Profiler.printMsgWithTime("MainController.onBaseContainersCreated"); - menuBar = getMenuBar(); - applicationContainer = getApplicationContainer(); + MenuBar menuBar = getMenuBar(); + AnchorPane applicationContainer = getApplicationContainer(); baseApplicationContainer.setTop(menuBar); baseApplicationContainer.setCenter(applicationContainer); @@ -260,6 +225,38 @@ public class MainViewCB extends ViewCB { // Private /////////////////////////////////////////////////////////////////////////////////////////// + private void selectMainMenuButton(NavigationItem navigationItem) { + switch (navigationItem) { + case HOME: + homeButton.setSelected(true); + break; + case FUNDS: + fundsButton.setSelected(true); + break; + case MSG: + msgButton.setSelected(true); + break; + case ORDERS: + ordersButton.setSelected(true); + break; + case SETTINGS: + settingsButton.setSelected(true); + break; + case SELL: + sellButton.setSelected(true); + break; + case BUY: + buyButton.setSelected(true); + break; + case ACCOUNT: + accountButton.setSelected(true); + break; + default: + log.error(navigationItem.getFxmlUrl() + " is no main navigation item"); + break; + } + } + private BorderPane getBaseApplicationContainer() { BorderPane borderPane = new BorderPane(); borderPane.setId("base-content-container"); @@ -280,7 +277,7 @@ public class MainViewCB extends ViewCB { subTitle.setAlignment(Pos.CENTER); subTitle.setId("logo-sub-title-label"); - loadingLabel = new Label(); + Label loadingLabel = new Label(); loadingLabel.setAlignment(Pos.CENTER); loadingLabel.setPadding(new Insets(80, 0, 0, 0)); loadingLabel.textProperty().bind(presentationModel.splashScreenInfoText); @@ -460,6 +457,4 @@ public class MainViewCB extends ViewCB { vBox.getChildren().setAll(comboBox, titleLabel); parent.getChildren().add(vBox); } - - } diff --git a/src/main/java/io/bitsquare/gui/main/account/AccountViewCB.java b/src/main/java/io/bitsquare/gui/main/account/AccountViewCB.java index 0fbb707923..d2091fc1f1 100644 --- a/src/main/java/io/bitsquare/gui/main/account/AccountViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/AccountViewCB.java @@ -22,7 +22,7 @@ import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.ViewCB; import io.bitsquare.gui.main.account.setup.AccountSetupViewCB; -import io.bitsquare.util.BSFXMLLoader; +import io.bitsquare.util.ViewLoader; import java.io.IOException; @@ -105,7 +105,7 @@ public class AccountViewCB extends CachedViewCB { public Initializable loadView(NavigationItem navigationItem) { super.loadView(navigationItem); - final BSFXMLLoader loader = new BSFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl())); + final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl())); try { Pane view = loader.load(); tab.setContent(view); diff --git a/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml b/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml index a796afdda6..e83b0c366d 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml +++ b/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml @@ -59,7 +59,7 @@ - diff --git a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml index 9a3f38636d..1e9fac8143 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml +++ b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml @@ -72,7 +72,7 @@ visible="false" prefWidth="150.0"/> - @@ -111,7 +111,7 @@ + + +