Move arbitration screens to new account tab

This commit is contained in:
Manfred Karrer 2014-09-26 14:20:04 +02:00
parent 9ea6fb9b55
commit 87d89f2dc6
16 changed files with 266 additions and 107 deletions

View file

@ -125,8 +125,14 @@ public class BitSquare extends Application {
setupCloseHandlers(primaryStage, scene);
primaryStage.setScene(scene);
// TODO resizing not fully supported yet
/*
primaryStage.setMinWidth(750);
primaryStage.setMinHeight(500);
primaryStage.setMinHeight(500);*/
primaryStage.setMinWidth(1000);
primaryStage.setMinHeight(750);
Profiler.initScene(primaryStage.getScene());

View file

@ -186,6 +186,7 @@ public class Navigation {
// account
ACCOUNT_SETUP("/io/bitsquare/gui/main/account/setup/AccountSetupView.fxml"),
ACCOUNT_SETTINGS("/io/bitsquare/gui/main/account/settings/AccountSettingsView.fxml"),
ARBITRATOR_SETTINGS("/io/bitsquare/gui/main/account/arbitrator/ArbitratorSettingsView.fxml"),
///////////////////////////////////////////////////////////////////////////////////////////
@ -206,9 +207,11 @@ public class Navigation {
///////////////////////////////////////////////////////////////////////////////////////////
// arbitrator
ARBITRATOR_PROFILE("/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileView.fxml"),
ARBITRATOR_BROWSER("/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserView.fxml"),
ARBITRATOR_REGISTRATION("/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationView.fxml");
ARBITRATOR_PROFILE("/io/bitsquare/gui/main/account/arbitrator/profile/ArbitratorProfileView.fxml"),
ARBITRATOR_BROWSER("/io/bitsquare/gui/main/account/arbitrator/browser/ArbitratorBrowserView.fxml"),
ARBITRATOR_REGISTRATION("/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationView" +
".fxml");
private final String fxmlUrl;

View file

@ -24,7 +24,7 @@
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml">
<Tab fx:id="tab" closable="false">
<Tab fx:id="accountSettingsTab" closable="false"/>
<Tab fx:id="arbitratorSettingsTab" text="Arbitrator settings" closable="false"/>
</Tab>
</TabPane>

View file

@ -30,10 +30,11 @@ import java.util.ResourceBundle;
import javax.inject.Inject;
import javafx.beans.value.ChangeListener;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,9 +44,11 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
private static final Logger log = LoggerFactory.getLogger(AccountViewCB.class);
private final Navigation navigation;
private Navigation.Listener listener;
private Navigation.Listener navigationListener;
@FXML Tab tab;
private ChangeListener<Tab> tabChangeListener;
@FXML Tab accountSettingsTab, arbitratorSettingsTab;
///////////////////////////////////////////////////////////////////////////////////////////
@ -66,13 +69,23 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
@Override
public void initialize(URL url, ResourceBundle rb) {
listener = navigationItems -> {
navigationListener = navigationItems -> {
if (navigationItems != null &&
navigationItems.length == 3 &&
navigationItems[1] == Navigation.Item.ACCOUNT)
loadView(navigationItems[2]);
};
tabChangeListener = (ov, oldValue, newValue) -> {
if (newValue == accountSettingsTab)
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
Navigation.Item.ACCOUNT_SETTINGS);
else
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
Navigation.Item.ARBITRATOR_SETTINGS);
};
super.initialize(url, rb);
}
@ -80,16 +93,23 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
public void activate() {
super.activate();
navigation.addListener(listener);
navigation.addListener(navigationListener);
((TabPane) root).getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
if (navigation.getCurrentItems().length == 2 &&
navigation.getCurrentItems()[1] == Navigation.Item.ACCOUNT) {
if (presentationModel.getNeedRegistration())
if (presentationModel.getNeedRegistration()) {
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
Navigation.Item.ACCOUNT_SETUP);
else
}
else {
if (((TabPane) root).getSelectionModel().getSelectedItem() == accountSettingsTab)
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
Navigation.Item.ACCOUNT_SETTINGS);
else
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
Navigation.Item.ARBITRATOR_SETTINGS);
}
}
}
@ -97,7 +117,8 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
public void deactivate() {
super.deactivate();
navigation.removeListener(listener);
navigation.removeListener(navigationListener);
((TabPane) root).getSelectionModel().selectedItemProperty().removeListener(tabChangeListener);
}
@SuppressWarnings("EmptyMethod")
@ -115,11 +136,25 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
protected Initializable loadView(Navigation.Item navigationItem) {
super.loadView(navigationItem);
tab.setText((navigationItem == Navigation.Item.ACCOUNT_SETUP) ? "Account setup" : "Account settings");
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
try {
AnchorPane view = loader.load();
Node view = loader.load();
Tab tab = null;
switch (navigationItem) {
case ACCOUNT_SETTINGS:
tab = accountSettingsTab;
tab.setText("Account settings");
case ACCOUNT_SETUP:
tab = accountSettingsTab;
tab.setText("Account setup");
break;
case ARBITRATOR_SETTINGS:
tab = arbitratorSettingsTab;
break;
}
tab.setContent(view);
((TabPane) root).getSelectionModel().select(tab);
Initializable childController = loader.getController();
((ViewCB) childController).setParent(this);

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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/>.
-->
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.main.account.arbitrator.ArbitratorSettingsViewCB"
prefHeight="660.0" prefWidth="1000.0"
xmlns:fx="http://javafx.com/fxml">
<VBox spacing="20">
<padding>
<Insets left="10" top="10" right="10"/>
</padding>
<Label text="TODO: Just very basic prototype yet..."/>
<Button text="Register yourself as an arbitrator" onAction="#onArbitratorRegistration"/>
<Button text="Edit my arbitrator details" onAction="#onArbitratorEdit"/>
</VBox>
</AnchorPane>

View file

@ -0,0 +1,143 @@
/*
* 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.main.account.arbitrator;
import io.bitsquare.BitSquare;
import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.main.account.arbitrator.registration.ArbitratorRegistrationViewCB;
import io.bitsquare.util.ViewLoader;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javax.inject.Inject;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.*;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO Arbitration is very basic yet
public class ArbitratorSettingsViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(ArbitratorSettingsViewCB.class);
private Navigation navigation;
private ArbitratorRegistrationViewCB arbitratorRegistrationViewCB;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private ArbitratorSettingsViewCB(Navigation navigation) {
super();
this.navigation = navigation;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb);
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Navigation
///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected Initializable loadView(Navigation.Item navigationItem) {
// don't use caching here, cause exc. -> need to investigate and is rarely called so no caching is better
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
try {
final Parent view = loader.load();
arbitratorRegistrationViewCB = loader.getController();
final Stage rootStage = BitSquare.getPrimaryStage();
final Stage stage = new Stage();
stage.setTitle("Arbitrator");
stage.setMinWidth(800);
stage.setMinHeight(400);
stage.setWidth(800);
stage.setHeight(600);
stage.setX(rootStage.getX() + 50);
stage.setY(rootStage.getY() + 50);
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(rootStage);
Scene scene = new Scene(view, 800, 600);
stage.setScene(scene);
stage.show();
return arbitratorRegistrationViewCB;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
///////////////////////////////////////////////////////////////////////////////////////////
// UI Handlers
///////////////////////////////////////////////////////////////////////////////////////////
@FXML
public void onArbitratorRegistration() {
loadView(Navigation.Item.ARBITRATOR_REGISTRATION);
}
@FXML
public void onArbitratorEdit() {
loadView(Navigation.Item.ARBITRATOR_REGISTRATION);
arbitratorRegistrationViewCB.setEditMode(true);
}
}

View file

@ -18,7 +18,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.main.arbitrators.browser.ArbitratorBrowserViewCB"
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.main.account.arbitrator.browser.ArbitratorBrowserViewCB"
prefHeight="600" prefWidth="800" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"
xmlns:fx="http://javafx.com/fxml">

View file

@ -15,13 +15,13 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.main.arbitrators.browser;
package io.bitsquare.gui.main.account.arbitrator.browser;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.ViewCB;
import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileViewCB;
import io.bitsquare.gui.main.account.arbitrator.profile.ArbitratorProfileViewCB;
import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.ArbitratorListener;
@ -49,14 +49,13 @@ import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Arbitration is not much developed yet
*/
// TODO Arbitration is very basic yet
public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorListener {
private static final Logger log = LoggerFactory.getLogger(ArbitratorBrowserViewCB.class);
private final Settings settings;
private final Persistence persistence;
private MessageFacade messageFacade;
private final List<Arbitrator> allArbitrators = new ArrayList<>();
private Arbitrator currentArbitrator;
@ -72,12 +71,9 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
@Inject
public ArbitratorBrowserViewCB(Settings settings, Persistence persistence, MessageFacade messageFacade) {
this.settings = settings;
this.persistence = persistence;
messageFacade.addArbitratorListener(this);
messageFacade.getArbitrators(LanguageUtil.getDefaultLanguageLocale());
this.messageFacade = messageFacade;
}
@ -87,10 +83,14 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
@Override
public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb);
messageFacade.addArbitratorListener(this);
messageFacade.getArbitrators(LanguageUtil.getDefaultLanguageLocale());
loadView(Navigation.Item.ARBITRATOR_PROFILE);
checkButtonState();
super.initialize(url, rb);
}
@SuppressWarnings("EmptyMethod")

View file

@ -19,7 +19,7 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileViewCB"
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.account.arbitrator.profile.ArbitratorProfileViewCB"
hgap="5.0" vgap="5.0" AnchorPane.bottomAnchor="80.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"
xmlns:fx="http://javafx.com/fxml">

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.main.arbitrators.profile;
package io.bitsquare.gui.main.account.arbitrator.profile;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.gui.CachedViewCB;
@ -32,7 +32,7 @@ import javax.inject.Inject;
import javafx.fxml.FXML;
import javafx.scene.control.*;
// Arbitration is not much developed yet
// TODO Arbitration is very basic yet
public class ArbitratorProfileViewCB extends CachedViewCB {
private final Settings settings;
@ -98,7 +98,7 @@ public class ArbitratorProfileViewCB extends CachedViewCB {
///////////////////////////////////////////////////////////////////////////////////////////
public void applyArbitrator(Arbitrator arbitrator) {
if (arbitrator != null) {
if (arbitrator != null && arbitrator.getIdType() != null) {
String name = "";
switch (arbitrator.getIdType()) {
case REAL_LIFE_ID:

View file

@ -20,7 +20,8 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.main.arbitrators.registration.ArbitratorRegistrationViewCB"
<AnchorPane fx:id="root"
fx:controller="io.bitsquare.gui.main.account.arbitrator.registration.ArbitratorRegistrationViewCB"
prefHeight="600" prefWidth="800" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"
xmlns:fx="http://javafx.com/fxml">

View file

@ -15,14 +15,14 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.main.arbitrators.registration;
package io.bitsquare.gui.main.account.arbitrator.registration;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.arbitrator.Reputation;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileViewCB;
import io.bitsquare.gui.main.account.arbitrator.profile.ArbitratorProfileViewCB;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.LanguageUtil;
@ -61,7 +61,7 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Arbitration is not much developed yet
// TODO Arbitration is very basic yet
public class ArbitratorRegistrationViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationViewCB.class);

View file

@ -29,10 +29,7 @@
<padding>
<Insets left="10" top="10" right="10"/>
</padding>
<Label
text="TODO: Overview section. The buttons here are just temporary for accessing the arbitration management system."/>
<Button text="Register yourself as an arbitrator" onAction="#onArbitratorRegistration"/>
<Button text="Edit my arbitrator details" onAction="#onArbitratorEdit"/>
<Label text="TODO: Overview"/>
</VBox>
</Tab>
</TabPane>

View file

@ -17,24 +17,12 @@
package io.bitsquare.gui.main.home;
import io.bitsquare.BitSquare;
import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.main.arbitrators.registration.ArbitratorRegistrationViewCB;
import io.bitsquare.util.ViewLoader;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.*;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,8 +31,6 @@ import org.slf4j.LoggerFactory;
public class HomeViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(HomeViewCB.class);
private ArbitratorRegistrationViewCB arbitratorRegistrationViewCB;
///////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@ -74,56 +60,5 @@ public class HomeViewCB extends CachedViewCB {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Navigation
///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected Initializable loadView(Navigation.Item navigationItem) {
// don't use caching here, cause exc. -> need to investigate and is rarely called so no caching is better
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
try {
final Parent view = loader.load();
arbitratorRegistrationViewCB = loader.getController();
final Stage rootStage = BitSquare.getPrimaryStage();
final Stage stage = new Stage();
stage.setTitle("Arbitrator");
stage.setMinWidth(800);
stage.setMinHeight(400);
stage.setWidth(800);
stage.setHeight(600);
stage.setX(rootStage.getX() + 50);
stage.setY(rootStage.getY() + 50);
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(rootStage);
Scene scene = new Scene(view, 800, 600);
stage.setScene(scene);
stage.show();
return arbitratorRegistrationViewCB;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
///////////////////////////////////////////////////////////////////////////////////////////
// UI Handlers
///////////////////////////////////////////////////////////////////////////////////////////
@FXML
public void onArbitratorRegistration() {
loadView(Navigation.Item.ARBITRATOR_REGISTRATION);
}
@FXML
public void onArbitratorEdit() {
loadView(Navigation.Item.ARBITRATOR_REGISTRATION);
arbitratorRegistrationViewCB.setEditMode(true);
}
}

View file

@ -30,7 +30,7 @@
<padding>
<Insets left="10" top="10" right="10"/>
</padding>
<Label text="TODO: Communication tools with arbitrators..."/>
<Label text="TODO: Communication tools with arbitrators, Mailbox for trade messages if client was offline"/>
</VBox>
</Tab>
</TabPane>

View file

@ -424,6 +424,7 @@ public class MessageFacade implements MessageBroker {
}
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
log.error("Get arbitrators from DHT failed with exception:" + e.getMessage());
}
}