removed unused code, comments, small refactorings

This commit is contained in:
Manfred Karrer 2014-08-26 21:52:04 +02:00
parent d3d23cc459
commit 919cde4e43
75 changed files with 142 additions and 457 deletions

View file

@ -25,10 +25,10 @@ import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.util.Profiler;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.user.User;
import io.bitsquare.util.AWTSystemTray;
import io.bitsquare.util.StorageDirectory;
import io.bitsquare.util.AppDirectoryUtil;
import com.google.common.base.Throwables;
@ -48,7 +48,6 @@ import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BitSquare extends Application {
private static final Logger log = LoggerFactory.getLogger(BitSquare.class);
@ -83,8 +82,8 @@ public class BitSquare extends Application {
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions
(Throwables.getRootCause(throwable)));
StorageDirectory.setStorageDirectory(
new File(StorageDirectory.getApplicationDirectory().getCanonicalPath() + "/data"));
AppDirectoryUtil.setStorageDirectory(
new File(AppDirectoryUtil.getApplicationDirectory().getCanonicalPath() + "/data"));
// currently there is not SystemTray support for java fx (planned for version 3) so we use the old AWT
AWTSystemTray.createSystemTray(primaryStage);

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.user;
package io.bitsquare.arbitrator;
import java.io.Serializable;

View file

@ -15,13 +15,18 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.user;
package io.bitsquare.arbitrator;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//TODO still open if we use that really...
/**
* Reputation for Arbitrators
*/
public class Reputation implements Serializable {
private static final long serialVersionUID = -3073174320050879490L;

View file

@ -21,8 +21,8 @@ import io.bitsquare.BitSquare;
import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.btc.listeners.ConfidenceListener;
import io.bitsquare.crypto.CryptoFacade;
import io.bitsquare.storage.Persistence;
import io.bitsquare.util.StorageDirectory;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.util.AppDirectoryUtil;
import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.AddressFormatException;
@ -139,7 +139,7 @@ public class WalletFacade {
Threading.USER_THREAD = Platform::runLater;
// If seed is non-null it means we are restoring from backup.
walletAppKit = new WalletAppKit(params, StorageDirectory.getStorageDirectory(), WALLET_PREFIX) {
walletAppKit = new WalletAppKit(params, AppDirectoryUtil.getStorageDirectory(), WALLET_PREFIX) {
@Override
protected void onSetupCompleted() {
// Don't make the user wait for confirmations for now, as the intention is they're sending it

View file

@ -28,7 +28,7 @@ import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.P2PNode;
import io.bitsquare.msg.SeedNodeAddress;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.trade.orderbook.OrderBook;
import io.bitsquare.user.User;

View file

@ -29,7 +29,7 @@ import io.bitsquare.gui.util.Profiler;
import io.bitsquare.gui.util.Transitions;
import io.bitsquare.msg.listeners.BootstrapListener;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.user.User;
import io.bitsquare.util.AWTSystemTray;

View file

@ -43,7 +43,7 @@ public enum NavigationItem {
TRANSACTIONS("/io/bitsquare/gui/funds/transactions/TransactionsView.fxml"),
ARBITRATOR_PROFILE("/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileView.fxml"),
ARBITRATOR_OVERVIEW("/io/bitsquare/gui/arbitrators/overview/ArbitratorOverviewView.fxml"),
ARBITRATOR_BROWSER("/io/bitsquare/gui/arbitrators/browser/ArbitratorBrowserView.fxml"),
ARBITRATOR_REGISTRATION("/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationView.fxml");
private final String fxmlUrl;

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.arbitrators.overview;
package io.bitsquare.gui.arbitrators.browser;
import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.CachedViewController;
@ -26,8 +26,8 @@ import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.ArbitratorListener;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Persistence;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.arbitrator.Arbitrator;
import java.io.IOException;
@ -56,7 +56,7 @@ import net.tomp2p.storage.Data;
*
* Arbitration is not much developed yet
*/
public class ArbitratorOverviewController extends CachedViewController implements ArbitratorListener {
public class ArbitratorBrowserController extends CachedViewController implements ArbitratorListener {
private final Settings settings;
private final Persistence persistence;
@ -74,7 +74,7 @@ public class ArbitratorOverviewController extends CachedViewController implement
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public ArbitratorOverviewController(Settings settings, Persistence persistence, MessageFacade messageFacade) {
public ArbitratorBrowserController(Settings settings, Persistence persistence, MessageFacade messageFacade) {
this.settings = settings;
this.persistence = persistence;

View file

@ -18,7 +18,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.arbitrators.overview.ArbitratorOverviewController"
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.arbitrators.browser.ArbitratorBrowserController"
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

@ -22,8 +22,8 @@ import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.ViewController;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Persistence;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.arbitrator.Arbitrator;
import java.net.URL;

View file

@ -25,13 +25,13 @@ import io.bitsquare.gui.arbitrators.profile.ArbitratorProfileController;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.BitSquareValidator;
import io.bitsquare.gui.util.ConfidenceDisplay;
import io.bitsquare.gui.components.ConfidenceDisplay;
import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.locale.Localisation;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.storage.Persistence;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.Reputation;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.arbitrator.Reputation;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;

View file

@ -19,7 +19,7 @@ package io.bitsquare.gui.components;
import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.ViewController;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import java.io.IOException;
@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
* So when switching back to an already opened tab it is faster as no fxml loading is needed anymore.
*/
//TODO remove manual caching as its done now in loader
public class CachingTabPane extends TabPane {
private static final Logger log = LoggerFactory.getLogger(CachingTabPane.class);

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.util;
package io.bitsquare.gui.components;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
@ -35,19 +35,15 @@ import javafx.scene.control.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO refactor
public class ConfidenceDisplay {
private static final Logger log = LoggerFactory.getLogger(ConfidenceDisplay.class);
private WalletEventListener walletEventListener;
private Wallet wallet;
private Label confirmationLabel;
private TextField balanceTextField;
private Transaction transaction;
private ConfidenceProgressIndicator progressIndicator;
public ConfidenceDisplay(Wallet wallet, Label confirmationLabel, TextField balanceTextField,

View file

@ -21,8 +21,6 @@ package io.bitsquare.gui.components;
import javafx.scene.layout.*;
public class HSpacer extends Pane {
public HSpacer() {
}
public HSpacer(double width) {
setPrefWidth(width);

View file

@ -23,6 +23,8 @@ import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.util.Duration;
// TODO replace with new notification component from lighthouse/bitcoinJ
public class NetworkSyncPane extends HBox {
private final ProgressBar networkSyncProgressBar;

View file

@ -1,29 +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 io.bitsquare.gui.components;
import javafx.scene.control.*;
class NoFocusScrollPane extends ScrollPane {
public NoFocusScrollPane() {
}
public void requestFocus() {
// prevent focus
}
}

View file

@ -32,6 +32,9 @@ import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
import org.controlsfx.dialog.Dialogs;
/**
* Collection of controlsfx Popups
*/
public class Popups {
// Information

View file

@ -21,8 +21,6 @@ package io.bitsquare.gui.components;
import javafx.scene.layout.*;
public class VSpacer extends Pane {
public VSpacer() {
}
public VSpacer(double height) {
setPrefHeight(height);

View file

@ -46,6 +46,8 @@ import org.slf4j.LoggerFactory;
* </div>
* </p>
*/
//TODO replace with ValidatingTextField
@Deprecated
public class ValidatedTextField extends TextField {
private static final Logger log = LoggerFactory.getLogger(ValidatedTextField.class);

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.components;
import io.bitsquare.gui.util.NumberValidator;
import io.bitsquare.gui.util.validation.NumberValidator;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;

View file

@ -35,6 +35,8 @@ import javafx.css.PseudoClass;
import javafx.css.StyleableProperty;
import javafx.scene.control.*;
// TODO Copied form OpenJFX, check license issues and way how we integrated it
// We changed behaviour which was not exposed via APIs
/**
* A circular control which is used for indicating progress, either

View file

@ -31,6 +31,11 @@ import java.util.Collections;
import com.sun.javafx.scene.control.behavior.BehaviorBase;
// TODO Copied form OpenJFX, check license issues and way how we integrated it
// We changed behaviour which was not exposed via APIs
/**
* @param <C>
*/
public class ConfidenceProgressIndicatorBehavior<C extends ConfidenceProgressIndicator> extends BehaviorBase<C> {
/**

View file

@ -64,7 +64,9 @@ import com.sun.javafx.css.converters.PaintConverter;
import com.sun.javafx.css.converters.SizeConverter;
import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
@SuppressWarnings({"WeakerAccess", "SameReturnValue"})
// TODO Copied form OpenJFX, check license issues and way how we integrated it
// We changed behaviour which was not exposed via APIs
public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<ConfidenceProgressIndicator,
ConfidenceProgressIndicatorBehavior<ConfidenceProgressIndicator>> {

View file

@ -1,58 +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 io.bitsquare.gui.components.processbar;
import java.util.List;
import javafx.scene.control.*;
public class ProcessStepBar<T> extends Control {
private List<ProcessStepItem> processStepItems = null;
public ProcessStepBar() {
}
public ProcessStepBar(List<ProcessStepItem> processStepItems) {
this.processStepItems = processStepItems;
}
@Override
protected Skin<?> createDefaultSkin() {
return new ProcessStepBarSkin<>(this);
}
List<ProcessStepItem> getProcessStepItems() {
return processStepItems;
}
public void setProcessStepItems(List<ProcessStepItem> processStepItems) {
this.processStepItems = processStepItems;
if (getSkin() != null) {
((ProcessStepBarSkin) getSkin()).dataChanged();
}
}
public void next() {
((ProcessStepBarSkin) getSkin()).next();
}
}

View file

@ -1,208 +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 io.bitsquare.gui.components.processbar;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import com.sun.javafx.scene.control.behavior.BehaviorBase;
import com.sun.javafx.scene.control.behavior.KeyBinding;
import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, BehaviorBase<ProcessStepBar<T>>> {
private final ProcessStepBar<T> controller;
private LabelWithBorder currentLabelWithBorder;
private LabelWithBorder prevLabelWithBorder;
private int index;
private List<LabelWithBorder> labelWithBorders;
public ProcessStepBarSkin(final ProcessStepBar<T> control) {
super(control, new BehaviorBase<>(control, Collections.<KeyBinding>emptyList()));
controller = getSkinnable();
applyData();
}
public void dataChanged() {
applyData();
}
private void applyData() {
if (controller.getProcessStepItems() != null) {
int i = 0;
labelWithBorders = new ArrayList<>();
int size = controller.getProcessStepItems().size();
for (ProcessStepItem processStepItem : controller.getProcessStepItems()) {
LabelWithBorder labelWithBorder = new LabelWithBorder(processStepItem, i == 0, i == size - 1);
getChildren().add(labelWithBorder);
labelWithBorders.add(labelWithBorder);
if (i == 0) {
currentLabelWithBorder = prevLabelWithBorder = labelWithBorder;
}
i++;
}
currentLabelWithBorder.select();
}
}
public void next() {
index++;
prevLabelWithBorder.deSelect();
if (index < labelWithBorders.size()) {
currentLabelWithBorder = labelWithBorders.get(index);
currentLabelWithBorder.select();
prevLabelWithBorder = currentLabelWithBorder;
}
}
@Override
protected void layoutChildren(double x, double y, double width, double height) {
double distance = 10;
double padding = 50;
for (int i = 0; i < getChildren().size(); i++) {
Node node = getChildren().get(i);
double newWidth = snapSize(node.prefWidth(height)) + padding;
double newHeight = snapSize(node.prefHeight(-1) + 10);
if (i > 0) {
x = snapPosition(x - ((LabelWithBorder) node).getArrowWidth());
}
x = snapPosition(x);
y = snapPosition(y);
node.resize(newWidth, newHeight);
node.relocate(x, y);
x += newWidth + distance;
}
}
public static class LabelWithBorder extends Label {
final double borderWidth = 1;
private final double arrowWidth = 10;
private final double arrowHeight = 30;
private final ProcessStepItem processStepItem;
private final boolean isFirst;
private final boolean isLast;
public LabelWithBorder(ProcessStepItem processStepItem, boolean isFirst, boolean isLast) {
super(processStepItem.getLabel());
this.processStepItem = processStepItem;
this.isFirst = isFirst;
this.isLast = isLast;
setAlignment(Pos.CENTER);
setTextFill(Color.GRAY);
setStyle("-fx-font-size: 14");
this.setShape(createButtonShape());
BorderStroke borderStroke = new BorderStroke(Color.LIGHTGRAY, BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
this.setBorder(new Border(borderStroke));
}
public void select() {
BorderStroke borderStroke = new BorderStroke(processStepItem.getColor(), BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
this.setBorder(new Border(borderStroke));
setTextFill(processStepItem.getColor());
}
public void deSelect() {
}
public double getArrowWidth() {
return arrowWidth;
}
private Path createButtonShape() {
// build the following shape (or home without left arrow)
// --------
// \ \
// / /
// --------
Path path = new Path();
// begin in the upper left corner
MoveTo e1 = new MoveTo(0, 0);
path.getElements().add(e1);
// draw a horizontal line that defines the width of the shape
HLineTo e2 = new HLineTo();
// bind the width of the shape to the width of the button
e2.xProperty().bind(this.widthProperty().subtract(arrowWidth));
path.getElements().add(e2);
if (!isLast) {
// draw upper part of right arrow
LineTo e3 = new LineTo();
// the x endpoint of this line depends on the x property of line e2
e3.xProperty().bind(e2.xProperty().add(arrowWidth));
e3.setY(arrowHeight / 2.0);
path.getElements().add(e3);
}
// draw lower part of right arrow
LineTo e4 = new LineTo();
// the x endpoint of this line depends on the x property of line e2
e4.xProperty().bind(e2.xProperty());
e4.setY(arrowHeight);
path.getElements().add(e4);
// draw lower horizontal line
HLineTo e5 = new HLineTo(0);
path.getElements().add(e5);
if (!isFirst) {
LineTo e6 = new LineTo(arrowWidth, arrowHeight / 2.0);
path.getElements().add(e6);
}
// close path
ClosePath e7 = new ClosePath();
path.getElements().add(e7);
// this is a dummy color to fill the shape, it won't be visible
path.setFill(Color.BLACK);
return path;
}
}
}

View file

@ -1,54 +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 io.bitsquare.gui.components.processbar;
import io.bitsquare.gui.util.Colors;
import javafx.scene.paint.*;
public class ProcessStepItem {
private final String label;
private final Paint color;
private final boolean progressIndicator;
public ProcessStepItem(String label) {
this(label, Colors.BLUE, false);
}
public ProcessStepItem(String label, Paint color) {
this(label, color, false);
}
private ProcessStepItem(String label, Paint color, boolean hasProgressIndicator) {
this.label = label;
this.color = color;
this.progressIndicator = hasProgressIndicator;
}
public String getLabel() {
return label;
}
public Paint getColor() {
return color;
}
public boolean hasProgressIndicator() {
return progressIndicator;
}
}

View file

@ -21,7 +21,7 @@ import io.bitsquare.gui.CachedViewController;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.ViewController;
import io.bitsquare.gui.components.CachingTabPane;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import java.net.URL;

View file

@ -43,6 +43,7 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: might be removed completely
public class DepositController extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(DepositController.class);

View file

@ -35,6 +35,8 @@ import javafx.scene.*;
import javafx.stage.Modality;
import javafx.stage.Stage;
// home is just hosting the arbiters buttons yet, but that's just for dev, not clear yet what will be in home,
// probably overview, event history, new, charts,... -> low prio
public class HomeController extends CachedViewController {
private ArbitratorRegistrationController arbitratorRegistrationController;

View file

@ -30,6 +30,8 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// will be probably only used for arbitration communication, will be renamed and the icon changed
public class MsgController extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(MsgController.class);

View file

@ -21,7 +21,7 @@ import io.bitsquare.gui.CachedViewController;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.ViewController;
import io.bitsquare.gui.components.CachingTabPane;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import java.net.URL;

View file

@ -27,7 +27,7 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//TODO impl. missing yet
public class ClosedTradeController extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(ClosedTradeController.class);

View file

@ -24,7 +24,7 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.CachedViewController;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.ConfidenceDisplay;
import io.bitsquare.gui.components.ConfidenceDisplay;
import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.locale.Country;
import io.bitsquare.locale.Localisation;

View file

@ -35,9 +35,9 @@ import io.bitsquare.locale.Localisation;
import io.bitsquare.locale.Region;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Persistence;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.Reputation;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.arbitrator.Reputation;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;
@ -74,6 +74,9 @@ import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
// TODO separate in 2 view/controllers
// TODO: change ui to dispaly a menu on the left and the content on the right
// there will be more screens
public class SettingsController extends CachedViewController {
private final User user;
private final Settings settings;
@ -183,7 +186,7 @@ public class SettingsController extends CachedViewController {
Scene scene = new Scene((Parent) view, 800, 600);
stage.setScene(scene);
stage.setOnHidden(windowEvent -> {
if (navigationItem == NavigationItem.ARBITRATOR_OVERVIEW)
if (navigationItem == NavigationItem.ARBITRATOR_BROWSER)
updateArbitrators();
});
stage.show();
@ -232,7 +235,7 @@ public class SettingsController extends CachedViewController {
@FXML
public void onOpenArbitratorScreen() {
loadViewAndGetChildController(NavigationItem.ARBITRATOR_OVERVIEW);
loadViewAndGetChildController(NavigationItem.ARBITRATOR_BROWSER);
}

View file

@ -24,7 +24,7 @@ import io.bitsquare.gui.ViewController;
import io.bitsquare.gui.components.ValidatingTextField;
import io.bitsquare.gui.trade.createoffer.CreateOfferCodeBehind;
import io.bitsquare.gui.trade.orderbook.OrderBookController;
import io.bitsquare.gui.trade.takeoffer.TakerOfferController;
import io.bitsquare.gui.trade.takeoffer.TakeOfferController;
import io.bitsquare.trade.Direction;
import java.io.IOException;
@ -47,7 +47,7 @@ public class TradeController extends CachedViewController {
protected OrderBookController orderBookController;
protected CreateOfferCodeBehind createOfferCodeBehind;
protected TakerOfferController takerOfferController;
protected TakeOfferController takeOfferController;
protected GuiceFXMLLoader orderBookLoader;
@ -126,20 +126,20 @@ public class TradeController extends CachedViewController {
return null;
}
else if (navigationItem == NavigationItem.TAKE_OFFER) {
checkArgument(takerOfferController == null);
checkArgument(takeOfferController == null);
// CreateOffer and TakeOffer must not be cached by GuiceFXMLLoader as we cannot use a view multiple times
// in different graphs
GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
try {
final Parent view = loader.load();
takerOfferController = loader.getController();
takerOfferController.setParentController(this);
takeOfferController = loader.getController();
takeOfferController.setParentController(this);
final Tab tab = new Tab("Take offer");
tab.setContent(view);
tabPane.getTabs().add(tab);
tabPane.getSelectionModel().select(tabPane.getTabs().size() - 1);
return takerOfferController;
return takeOfferController;
} catch (IOException e) {
log.error(e.getMessage());
}
@ -163,7 +163,7 @@ public class TradeController extends CachedViewController {
}
public void onTakeOfferViewRemoved() {
takerOfferController = null;
takeOfferController = null;
}

View file

@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkArgument;
/**
* Model:
* Data model:
* Does not know the Presenter and View (CodeBehind)
* Use Guice for DI
* <p/>

View file

@ -45,7 +45,7 @@ import static javafx.beans.binding.Bindings.createStringBinding;
* Knows Model, does not know the View (CodeBehind)
* <p/>
* - Holds data and state of the View (formatted)
* - Receive view input from Controller. Validates input, apply business logic, format to Presenter properties and
* - Receive view input from CodeBehind. Validates input, apply business logic, format to Presenter properties and
* convert input to Model.
* - Listen to updates from Model, apply business logic and format it to Presenter properties. Model update handling
* can be done via Binding.

View file

@ -26,7 +26,7 @@ import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.ViewController;
import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.trade.createoffer.CreateOfferCodeBehind;
import io.bitsquare.gui.trade.takeoffer.TakerOfferController;
import io.bitsquare.gui.trade.takeoffer.TakeOfferController;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.locale.Country;
@ -34,7 +34,7 @@ import io.bitsquare.locale.CurrencyUtil;
import io.bitsquare.locale.Localisation;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.Direction;
import io.bitsquare.trade.Offer;
import io.bitsquare.trade.orderbook.OrderBook;
@ -343,8 +343,8 @@ public class OrderBookController extends CachedViewController {
private void takeOffer(Offer offer) {
if (isRegistered()) {
TakerOfferController takerOfferController =
(TakerOfferController) parentController.loadViewAndGetChildController(NavigationItem.TAKE_OFFER);
TakeOfferController takeOfferController =
(TakeOfferController) parentController.loadViewAndGetChildController(NavigationItem.TAKE_OFFER);
Coin requestedAmount;
if (!"".equals(amount.getText())) {
@ -354,8 +354,8 @@ public class OrderBookController extends CachedViewController {
requestedAmount = offer.getAmount();
}
if (takerOfferController != null) {
takerOfferController.initWithData(offer, requestedAmount);
if (takeOfferController != null) {
takeOfferController.initWithData(offer, requestedAmount);
}
}
else {

View file

@ -46,8 +46,8 @@ import javafx.scene.control.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TakerOfferController extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(TakerOfferController.class);
public class TakeOfferController extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(TakeOfferController.class);
private final TradeManager tradeManager;
private final WalletFacade walletFacade;
@ -74,7 +74,7 @@ public class TakerOfferController extends CachedViewController {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private TakerOfferController(TradeManager tradeManager, WalletFacade walletFacade) {
private TakeOfferController(TradeManager tradeManager, WalletFacade walletFacade) {
this.tradeManager = tradeManager;
this.walletFacade = walletFacade;
}

View file

@ -21,7 +21,7 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.trade.takeoffer.TakerOfferController"
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.trade.takeoffer.TakeOfferController"
xmlns:fx="http://javafx.com/fxml">
<Accordion fx:id="accordion" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">

View file

@ -20,7 +20,7 @@ package io.bitsquare.gui.util;
import io.bitsquare.locale.Country;
import io.bitsquare.locale.Localisation;
import io.bitsquare.trade.Direction;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.arbitrator.Arbitrator;
import com.google.bitcoin.core.Coin;
import com.google.bitcoin.utils.CoinFormat;

View file

@ -47,12 +47,10 @@ public class ImageUtil {
public static final String SELL = "/images/sell.png";
public static final String REMOVE = "/images/removeOffer.png";
public static Image getIconImage(String iconName) {
return new Image(ImageUtil.class.getResourceAsStream(iconName));
}
public static ImageView getIconImageView(String iconName) {
return new ImageView(new Image(ImageUtil.class.getResourceAsStream(iconName)));
}

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.util;
package io.bitsquare.gui.util.validation;
import com.google.bitcoin.core.NetworkParameters;

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.util;
package io.bitsquare.gui.util.validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.util;
package io.bitsquare.gui.util.validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.util;
package io.bitsquare.gui.util.validation;
import io.bitsquare.gui.components.ValidatingTextField;

View file

@ -17,7 +17,7 @@
package io.bitsquare.msg;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;

View file

@ -24,8 +24,8 @@ import io.bitsquare.msg.listeners.IncomingTradeMessageListener;
import io.bitsquare.msg.listeners.OrderBookListener;
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
import io.bitsquare.trade.Offer;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.user.User;
import com.google.common.util.concurrent.FutureCallback;

View file

@ -18,7 +18,7 @@
package io.bitsquare.msg;
import io.bitsquare.BitSquare;
import io.bitsquare.util.StorageDirectory;
import io.bitsquare.util.AppDirectoryUtil;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
@ -302,7 +302,7 @@ public class P2PNode {
if (useDiscStorage) {
try {
File path = new File(StorageDirectory.getStorageDirectory().getCanonicalPath() + "/" + BitSquare
File path = new File(AppDirectoryUtil.getStorageDirectory().getCanonicalPath() + "/" + BitSquare
.getAppName() + "_tomP2P");
if (!path.exists()) {
boolean created = path.mkdir();

View file

@ -17,7 +17,7 @@
package io.bitsquare.msg.listeners;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import net.tomp2p.peers.PeerAddress;

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.storage;
package io.bitsquare.persistence;
import io.bitsquare.BitSquare;
import io.bitsquare.util.FileUtil;

View file

@ -18,7 +18,7 @@
package io.bitsquare.settings;
import io.bitsquare.locale.Country;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.arbitrator.Arbitrator;
import com.google.bitcoin.core.Coin;

View file

@ -26,6 +26,9 @@ import java.io.Serializable;
import java.security.PublicKey;
//TODO flatten down?
// TODO The relation Offer, Trade and Contract need to be reviewed and might be changed
public class Contract implements Serializable {
private static final long serialVersionUID = 71472356206100158L;

View file

@ -19,7 +19,7 @@ package io.bitsquare.trade;
import io.bitsquare.bank.BankAccountType;
import io.bitsquare.locale.Country;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.arbitrator.Arbitrator;
import com.google.bitcoin.core.Coin;
@ -34,6 +34,8 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
//TODO flatten down?
public class Offer implements Serializable {
private static final long serialVersionUID = -971164804305475826L;

View file

@ -25,6 +25,8 @@ import java.io.Serializable;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
//TODO flatten down?
public class Trade implements Serializable {
private static final long serialVersionUID = -8275323072940974077L;

View file

@ -24,10 +24,10 @@ import io.bitsquare.gui.components.Popups;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.TakeOfferRequestListener;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.handlers.ErrorMessageHandler;
import io.bitsquare.trade.handlers.TransactionResultHandler;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import io.bitsquare.trade.protocol.createoffer.CreateOfferCoordinator;
import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocol;
import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocolListener;
@ -67,6 +67,10 @@ import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The domain for the trading
* TODO: Too messy, need to be improved a lot....
*/
public class TradeManager {
private static final Logger log = LoggerFactory.getLogger(TradeManager.class);

View file

@ -27,7 +27,7 @@ import io.bitsquare.settings.Settings;
import io.bitsquare.trade.Direction;
import io.bitsquare.trade.Offer;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.user.User;
import java.io.IOException;

View file

@ -19,7 +19,7 @@ package io.bitsquare.trade.protocol.createoffer;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.storage.Persistence;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.Offer;
import io.bitsquare.trade.handlers.FaultHandler;
import io.bitsquare.trade.handlers.TransactionResultHandler;

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol;
package io.bitsquare.trade.protocol.trade;
public interface TradeMessage {
public String getTradeId();

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.messages;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import com.google.bitcoin.core.Coin;

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.messages;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import java.io.Serializable;

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.offerer.messages;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import java.io.Serializable;

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.messages;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import java.io.Serializable;

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.messages;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import java.io.Serializable;

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.taker.messages;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import java.io.Serializable;

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.messages;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import java.io.Serializable;

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.messages;
import io.bitsquare.trade.protocol.TradeMessage;
import io.bitsquare.trade.protocol.trade.TradeMessage;
import com.google.bitcoin.core.Coin;

View file

@ -40,7 +40,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The User is persisted locally it is never transmitted over the wire (messageKeyPair contains private key!).
* The User is persisted locally.
* It must never be transmitted over the wire (messageKeyPair contains private key!).
*/
public class User implements Serializable {
private static final Logger log = LoggerFactory.getLogger(User.class);

View file

@ -31,6 +31,10 @@ import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* There is no JavaFX support yet, so we need to use AWT.
* TODO research more
*/
public class AWTSystemTray {
private static final Logger log = LoggerFactory.getLogger(AWTSystemTray.class);
private static boolean isStageVisible = true;

View file

@ -23,8 +23,8 @@ import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class StorageDirectory {
private static final Logger log = LoggerFactory.getLogger(StorageDirectory.class);
public class AppDirectoryUtil {
private static final Logger log = LoggerFactory.getLogger(AppDirectoryUtil.class);
private static File storageDirectory;
static {
@ -53,7 +53,7 @@ public class StorageDirectory {
public static File getApplicationDirectory() {
File executionRoot =
new File(StorageDirectory.class.getProtectionDomain().getCodeSource().getLocation().getFile());
new File(AppDirectoryUtil.class.getProtectionDomain().getCodeSource().getLocation().getFile());
try {
log.trace("executionRoot " + executionRoot.getCanonicalPath());

View file

@ -31,12 +31,6 @@ import org.slf4j.LoggerFactory;
public class DSAKeyUtil {
private static final Logger log = LoggerFactory.getLogger(DSAKeyUtil.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////
public static String getHexStringFromPublicKey(PublicKey publicKey) {
final X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(publicKey.getEncoded());
return Utils.HEX.encode(x509EncodedKeySpec.getEncoded());

View file

@ -29,11 +29,11 @@ public class FileUtil {
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
public static File getFile(String name, String suffix) {
return new File(StorageDirectory.getStorageDirectory(), name + "." + suffix);
return new File(AppDirectoryUtil.getStorageDirectory(), name + "." + suffix);
}
public static File getTempFile(String prefix) throws IOException {
return File.createTempFile("temp_" + prefix, null, StorageDirectory.getStorageDirectory());
return File.createTempFile("temp_" + prefix, null, AppDirectoryUtil.getStorageDirectory());
}
public static void writeTempFileToFile(File tempFile, File file) throws IOException {

View file

@ -1,3 +1,4 @@
# TODO: locale support will be added when ui is more final
# generic
OTHER=Other

View file

@ -17,6 +17,9 @@
package io.bitsquare.gui.util;
import io.bitsquare.gui.util.validation.BtcValidator;
import io.bitsquare.gui.util.validation.NumberValidator;
import com.google.bitcoin.core.Coin;
import com.google.bitcoin.core.NetworkParameters;

View file

@ -17,6 +17,9 @@
package io.bitsquare.gui.util;
import io.bitsquare.gui.util.validation.FiatValidator;
import io.bitsquare.gui.util.validation.NumberValidator;
import org.junit.Test;
import static org.junit.Assert.*;