mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-03 04:06:23 -04:00
Merge pull request #255 from bitsquare/organize
Organize codebase for acyclic modularity
This commit is contained in:
commit
568e2782dd
129 changed files with 1015 additions and 5495 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,3 +18,4 @@ build
|
|||
.classpath
|
||||
.project
|
||||
.settings
|
||||
*.java.hsp
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
language: java
|
||||
jdk: oraclejdk8
|
||||
|
||||
before_install:
|
||||
- "export DISPLAY=:99.0"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
||||
|
||||
notifications:
|
||||
irc:
|
||||
channels: chat.freenode.net#bitsquare
|
||||
|
|
|
@ -17,7 +17,7 @@ sourceCompatibility = 1.8
|
|||
|
||||
sourceSets.main.resources.srcDirs += 'src/main/java'
|
||||
|
||||
mainClassName = "io.bitsquare.Bitsquare"
|
||||
mainClassName = "io.bitsquare.app.gui.Main"
|
||||
|
||||
run {
|
||||
if ( project.hasProperty('args') ) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
C:\Progra~1\Java\jdk1.8.0_20\bin\javapackager.exe -deploy -BappVersion=0.1.0 -native exe -name Bitsquare -title Bitsquare -vendor Bitsquare -outdir build -appclass io.bitsquare.Bitsquare -srcfiles .\build\libs\bitsquare-0.1.0-SNAPSHOT-all.jar -outfile Bitsquare -Bruntime="c:\Program Files\Java\jdk1.8.0_20\jre"
|
||||
C:\Progra~1\Java\jdk1.8.0_20\bin\javapackager.exe -deploy -BappVersion=0.1.0 -native exe -name Bitsquare -title Bitsquare -vendor Bitsquare -outdir build -appclass io.bitsquare.app.gui.Main -srcfiles .\build\libs\bitsquare-0.1.0-SNAPSHOT-all.jar -outfile Bitsquare -Bruntime="c:\Program Files\Java\jdk1.8.0_20\jre"
|
||||
|
|
65
src/main/java/io/bitsquare/AbstractBitsquareModule.java
Normal file
65
src/main/java/io/bitsquare/AbstractBitsquareModule.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AbstractBitsquareModule extends AbstractModule {
|
||||
|
||||
protected final Properties properties;
|
||||
|
||||
private final Set<AbstractBitsquareModule> modules = Sets.newHashSet();
|
||||
|
||||
public AbstractBitsquareModule(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
protected void install(AbstractBitsquareModule module) {
|
||||
super.install(module);
|
||||
modules.add(module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close any instances this module is responsible for and recursively close any
|
||||
* sub-modules installed via {@link #install(AbstractBitsquareModule)}. This method
|
||||
* must be called manually, e.g. at the end of a main() method or in the stop() method
|
||||
* of a JavaFX Application; alternatively it may be registered as a JVM shutdown hook.
|
||||
*
|
||||
* @param injector the Injector originally initialized with this module
|
||||
* @see #doClose(com.google.inject.Injector)
|
||||
*/
|
||||
public final void close(Injector injector) {
|
||||
modules.forEach(module -> module.close(injector));
|
||||
doClose(injector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually perform closing of any instances this module is responsible for. Called by
|
||||
* {@link #close(Injector)}.
|
||||
*
|
||||
* @param injector the Injector originally initialized with this module
|
||||
*/
|
||||
protected void doClose(Injector injector) {
|
||||
}
|
||||
}
|
|
@ -1,152 +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;
|
||||
|
||||
import io.bitsquare.msg.SeedNodeAddress;
|
||||
import io.bitsquare.msg.actor.DHTManager;
|
||||
import io.bitsquare.msg.actor.command.InitializePeer;
|
||||
import io.bitsquare.msg.actor.event.PeerInitialized;
|
||||
import io.bitsquare.util.BitsquareArgumentParser;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javafx.application.Application;
|
||||
|
||||
import net.tomp2p.connection.Ports;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.Inbox;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParserException;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import scala.concurrent.duration.Duration;
|
||||
import scala.concurrent.duration.FiniteDuration;
|
||||
|
||||
public class Bitsquare {
|
||||
private static final Logger log = LoggerFactory.getLogger(Bitsquare.class);
|
||||
|
||||
private static String appName = "Bitsquare";
|
||||
private static int clientPort;
|
||||
private static String interfaceHint;
|
||||
|
||||
public static String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public static int getClientPort() {
|
||||
return clientPort;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
BitsquareArgumentParser parser = new BitsquareArgumentParser();
|
||||
Namespace namespace = null;
|
||||
try {
|
||||
namespace = parser.parseArgs(args);
|
||||
} catch (ArgumentParserException e) {
|
||||
parser.handleError(e);
|
||||
System.exit(1);
|
||||
}
|
||||
if (namespace != null) {
|
||||
|
||||
if (namespace.getString(BitsquareArgumentParser.NAME_FLAG) != null) {
|
||||
appName = appName + "-" + namespace.getString(BitsquareArgumentParser.NAME_FLAG);
|
||||
}
|
||||
|
||||
if (namespace.getString(BitsquareArgumentParser.INFHINT_FLAG) != null) {
|
||||
interfaceHint = namespace.getString(BitsquareArgumentParser.INFHINT_FLAG);
|
||||
}
|
||||
|
||||
int port = -1;
|
||||
if (namespace.getString(BitsquareArgumentParser.PORT_FLAG) != null) {
|
||||
port = Integer.valueOf(namespace.getString(BitsquareArgumentParser.PORT_FLAG));
|
||||
}
|
||||
|
||||
if (namespace.getBoolean(BitsquareArgumentParser.SEED_FLAG) == true) {
|
||||
String seedID = SeedNodeAddress.StaticSeedNodeAddresses.DIGITAL_OCEAN1.getId();
|
||||
if (namespace.getString(BitsquareArgumentParser.PEER_ID_FLAG) != null) {
|
||||
seedID = namespace.getString(BitsquareArgumentParser.PEER_ID_FLAG);
|
||||
}
|
||||
|
||||
ActorSystem actorSystem = ActorSystem.create(getAppName());
|
||||
|
||||
final Set<PeerAddress> peerAddresses = new HashSet<PeerAddress>();
|
||||
final String sid = seedID;
|
||||
SeedNodeAddress.StaticSeedNodeAddresses.getAllSeedNodeAddresses().forEach(a -> {
|
||||
if (!a.getId().equals(sid)) {
|
||||
try {
|
||||
peerAddresses.add(new PeerAddress(Number160.createHash(a.getId()), a.getIp(),
|
||||
a.getPort(), a.getPort()));
|
||||
} catch (UnknownHostException uhe) {
|
||||
log.error("Unknown Host [" + a.getIp() + "]: " + uhe.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int serverPort = (port == -1) ? BitsquareArgumentParser.PORT_DEFAULT : port;
|
||||
|
||||
ActorRef seedNode = actorSystem.actorOf(DHTManager.getProps(), DHTManager.SEED_NAME);
|
||||
Inbox inbox = Inbox.create(actorSystem);
|
||||
inbox.send(seedNode, new InitializePeer(Number160.createHash(sid), serverPort, interfaceHint,
|
||||
peerAddresses));
|
||||
|
||||
Thread seedNodeThread = new Thread(() -> {
|
||||
Boolean quit = false;
|
||||
while (!quit) {
|
||||
try {
|
||||
Object m = inbox.receive(FiniteDuration.create(5L, "seconds"));
|
||||
if (m instanceof PeerInitialized) {
|
||||
log.debug("Seed Peer Initialized on port " + ((PeerInitialized) m).getPort
|
||||
());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (!(e instanceof TimeoutException)) {
|
||||
quit = true;
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
actorSystem.shutdown();
|
||||
try {
|
||||
actorSystem.awaitTermination(Duration.create(5L, "seconds"));
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof TimeoutException)
|
||||
log.error("ActorSystem did not shutdown properly.");
|
||||
else
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
});
|
||||
seedNodeThread.start();
|
||||
}
|
||||
else {
|
||||
// We use a random port for the client if no port is passed to the application
|
||||
clientPort = (port == -1) ? new Ports().tcpPort() : port;
|
||||
Application.launch(BitsquareUI.class, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,159 +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;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.di.BitsquareModule;
|
||||
import io.bitsquare.gui.AWTSystemTray;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import lighthouse.files.AppDirectory;
|
||||
|
||||
public class BitsquareUI extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(BitsquareUI.class);
|
||||
|
||||
private static Stage primaryStage;
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
|
||||
public void BitsquareUI() {
|
||||
Profiler.init();
|
||||
}
|
||||
|
||||
public static Stage getPrimaryStage() {
|
||||
return primaryStage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
Profiler.printMsgWithTime("Bitsquare.start called");
|
||||
BitsquareUI.primaryStage = primaryStage;
|
||||
|
||||
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions
|
||||
(Throwables.getRootCause(throwable)));
|
||||
|
||||
try {
|
||||
AppDirectory.initAppDir(Bitsquare.getAppName());
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
final Injector injector = Guice.createInjector(new BitsquareModule());
|
||||
|
||||
// currently there is not SystemTray support for java fx (planned for version 3) so we use the old AWT
|
||||
AWTSystemTray.createSystemTray(primaryStage, injector.getInstance(ActorSystem.class), this);
|
||||
|
||||
walletFacade = injector.getInstance(WalletFacade.class);
|
||||
messageFacade = injector.getInstance(MessageFacade.class);
|
||||
Profiler.printMsgWithTime("Bitsquare: messageFacade, walletFacade created");
|
||||
|
||||
// apply stored data
|
||||
final User user = injector.getInstance(User.class);
|
||||
final Settings settings = injector.getInstance(Settings.class);
|
||||
final Persistence persistence = injector.getInstance(Persistence.class);
|
||||
persistence.init();
|
||||
|
||||
User persistedUser = (User) persistence.read(user);
|
||||
user.applyPersistedUser(persistedUser);
|
||||
|
||||
settings.applyPersistedSettings((Settings) persistence.read(settings.getClass().getName()));
|
||||
|
||||
primaryStage.setTitle("Bitsquare (" + Bitsquare.getAppName() + ")");
|
||||
|
||||
// sometimes there is a rendering bug, see https://github.com/bitsquare/bitsquare/issues/160
|
||||
if (ImageUtil.isRetina())
|
||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/images/window_icon@2x.png")));
|
||||
else
|
||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/images/window_icon.png")));
|
||||
|
||||
ViewLoader.setInjector(injector);
|
||||
|
||||
final ViewLoader loader =
|
||||
new ViewLoader(getClass().getResource(Navigation.Item.MAIN.getFxmlUrl()), false);
|
||||
try {
|
||||
final Parent view = loader.load();
|
||||
|
||||
final Scene scene = new Scene(view, 1000, 600);
|
||||
scene.getStylesheets().setAll(getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm(),
|
||||
getClass().getResource("/io/bitsquare/gui/images.css").toExternalForm());
|
||||
|
||||
setupCloseHandlers(primaryStage, scene);
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
|
||||
// TODO resizing not fully supported yet
|
||||
|
||||
primaryStage.setMinWidth(75);
|
||||
primaryStage.setMinHeight(50);
|
||||
|
||||
/* primaryStage.setMinWidth(1000);
|
||||
primaryStage.setMinHeight(750);*/
|
||||
|
||||
Profiler.initScene(primaryStage.getScene());
|
||||
|
||||
primaryStage.show();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCloseHandlers(Stage primaryStage, Scene scene) {
|
||||
primaryStage.setOnCloseRequest(e -> AWTSystemTray.setStageHidden());
|
||||
|
||||
KeyCodeCombination keyCodeCombination = new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN);
|
||||
scene.setOnKeyReleased(keyEvent -> {
|
||||
if (keyCodeCombination.match(keyEvent))
|
||||
AWTSystemTray.setStageHidden();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
walletFacade.shutDown();
|
||||
messageFacade.shutDown();
|
||||
|
||||
super.stop();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
|
@ -1,97 +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;
|
||||
|
||||
import io.bitsquare.msg.SeedNodeAddress;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.tomp2p.dht.PeerBuilderDHT;
|
||||
import net.tomp2p.dht.PeerDHT;
|
||||
import net.tomp2p.nat.PeerBuilderNAT;
|
||||
import net.tomp2p.p2p.Peer;
|
||||
import net.tomp2p.p2p.PeerBuilder;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import net.tomp2p.peers.PeerMapChangeListener;
|
||||
import net.tomp2p.peers.PeerStatistic;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SeedNode extends Thread {
|
||||
private static final Logger log = LoggerFactory.getLogger(SeedNode.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
Peer peer = null;
|
||||
SeedNodeAddress.StaticSeedNodeAddresses seedNodeAddress = SeedNodeAddress.StaticSeedNodeAddresses
|
||||
.DIGITAL_OCEAN1;
|
||||
try {
|
||||
peer = new PeerBuilder(Number160.createHash(seedNodeAddress.getId())).ports(seedNodeAddress.getPort())
|
||||
.start();
|
||||
PeerDHT peerDHT = new PeerBuilderDHT(peer).start();
|
||||
new PeerBuilderNAT(peer).start();
|
||||
|
||||
/* peerDHT.peer().objectDataReply((sender, request) -> {
|
||||
log.trace("received request: ", request.toString());
|
||||
return "pong";
|
||||
});*/
|
||||
|
||||
log.debug("peer listening at port: {}", seedNodeAddress.getPort());
|
||||
|
||||
peer.peerBean().peerMap().addPeerMapChangeListener(new PeerMapChangeListener() {
|
||||
@Override
|
||||
public void peerInserted(PeerAddress peerAddress, boolean verified) {
|
||||
log.debug("Peer inserted: peerAddress=" + peerAddress + ", verified=" + verified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void peerRemoved(PeerAddress peerAddress, PeerStatistic peerStatistics) {
|
||||
log.debug("Peer removed: peerAddress=" + peerAddress + ", peerStatistics=" + peerStatistics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void peerUpdated(PeerAddress peerAddress, PeerStatistic peerStatistics) {
|
||||
// log.debug("Peer updated: peerAddress=" + peerAddress + ",
|
||||
// peerStatistics=" + peerStatistics);
|
||||
}
|
||||
});
|
||||
|
||||
final Peer _peer = peer;
|
||||
Thread seedNodeThread = new Thread(() -> {
|
||||
while (true) {
|
||||
try {
|
||||
for (PeerAddress pa : _peer.peerBean().peerMap().all()) {
|
||||
System.out.println("Peer online:" + pa);
|
||||
}
|
||||
Thread.sleep(5000L);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
seedNodeThread.start();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (peer != null)
|
||||
peer.shutdown().awaitUninterruptibly();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -15,45 +15,38 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.util;
|
||||
package io.bitsquare.app;
|
||||
|
||||
import io.bitsquare.msg.SeedNodeAddress;
|
||||
import io.bitsquare.network.BootstrapNode;
|
||||
|
||||
import net.sourceforge.argparse4j.ArgumentParsers;
|
||||
import net.sourceforge.argparse4j.impl.Arguments;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParser;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParserException;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
||||
/*
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-s, --seed Start as DHT seed peer, no UI. (default: false)
|
||||
-d PEERID, --peerid PEERID Seed peer ID. (default: digitalocean1.bitsquare.io)
|
||||
-p PORT, --port PORT IP port to listen on. (default: 5000)
|
||||
-i INTERFACE, --interface INTERFACE Network interface to listen on.
|
||||
-n NAME, --name NAME Append name to application name.
|
||||
*/
|
||||
public class BitsquareArgumentParser {
|
||||
public class ArgumentParser {
|
||||
|
||||
public static String SEED_FLAG = "seed";
|
||||
public static String PEER_ID_FLAG = "peerid";
|
||||
public static String PORT_FLAG = "port";
|
||||
public static Integer PORT_DEFAULT = 5000;
|
||||
public static String INFHINT_FLAG = "interface";
|
||||
public static String NAME_FLAG = "name";
|
||||
|
||||
private final ArgumentParser parser;
|
||||
private final net.sourceforge.argparse4j.inf.ArgumentParser parser;
|
||||
|
||||
public BitsquareArgumentParser() {
|
||||
public ArgumentParser() {
|
||||
parser = ArgumentParsers.newArgumentParser("Bitsquare")
|
||||
.defaultHelp(true)
|
||||
.description("Bitsquare - The decentralized bitcoin exchange.");
|
||||
parser.addArgument("-s", "--" + SEED_FLAG)
|
||||
.action(Arguments.storeTrue())
|
||||
.help("Start as DHT seed peer, no UI.");
|
||||
parser.addArgument("-d", "--" + PEER_ID_FLAG)
|
||||
.setDefault(SeedNodeAddress.StaticSeedNodeAddresses.DIGITAL_OCEAN1.getId())
|
||||
.setDefault(BootstrapNode.DIGITAL_OCEAN1.getId())
|
||||
.help("Seed peer ID.");
|
||||
parser.addArgument("-p", "--" + PORT_FLAG)
|
||||
.help("IP port to listen on.");
|
||||
|
@ -63,11 +56,13 @@ public class BitsquareArgumentParser {
|
|||
.help("Append name to application name.");
|
||||
}
|
||||
|
||||
public Namespace parseArgs(String... args) throws ArgumentParserException {
|
||||
return parser.parseArgs(args);
|
||||
}
|
||||
|
||||
public void handleError(ArgumentParserException e) {
|
||||
parser.handleError(e);
|
||||
public Namespace parseArgs(String... args) {
|
||||
try {
|
||||
return parser.parseArgs(args);
|
||||
} catch (ArgumentParserException e) {
|
||||
parser.handleError(e);
|
||||
System.exit(1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,9 +15,9 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.di;
|
||||
package io.bitsquare.app;
|
||||
|
||||
import io.bitsquare.Bitsquare;
|
||||
import io.bitsquare.AbstractBitsquareModule;
|
||||
import io.bitsquare.btc.BitcoinModule;
|
||||
import io.bitsquare.crypto.CryptoModule;
|
||||
import io.bitsquare.gui.GuiModule;
|
||||
|
@ -29,18 +29,35 @@ import io.bitsquare.trade.TradeModule;
|
|||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.ConfigLoader;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import net.tomp2p.connection.Ports;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import scala.concurrent.duration.Duration;
|
||||
|
||||
public class BitsquareModule extends AbstractBitsquareModule {
|
||||
|
||||
public BitsquareModule() {
|
||||
this(ConfigLoader.loadConfig());
|
||||
private static final Logger log = LoggerFactory.getLogger(BitsquareModule.class);
|
||||
private final Stage primaryStage;
|
||||
private final String appName;
|
||||
|
||||
public BitsquareModule(Stage primaryStage, String appName) {
|
||||
this(primaryStage, appName, ConfigLoader.loadConfig());
|
||||
}
|
||||
|
||||
public BitsquareModule(Properties properties) {
|
||||
public BitsquareModule(Stage primaryStage, String appName, Properties properties) {
|
||||
super(properties);
|
||||
this.primaryStage = primaryStage;
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +72,11 @@ public class BitsquareModule extends AbstractBitsquareModule {
|
|||
install(tradeModule());
|
||||
install(guiModule());
|
||||
|
||||
bind(ActorSystem.class).toInstance(ActorSystem.create(Bitsquare.getAppName()));
|
||||
bindConstant().annotatedWith(Names.named("appName")).to(appName);
|
||||
bind(ActorSystem.class).toInstance(ActorSystem.create(appName));
|
||||
|
||||
int randomPort = new Ports().tcpPort();
|
||||
bindConstant().annotatedWith(Names.named("clientPort")).to(randomPort);
|
||||
}
|
||||
|
||||
protected MessageModule messageModule() {
|
||||
|
@ -75,7 +96,18 @@ public class BitsquareModule extends AbstractBitsquareModule {
|
|||
}
|
||||
|
||||
protected GuiModule guiModule() {
|
||||
return new GuiModule(properties);
|
||||
return new GuiModule(properties, primaryStage);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose(Injector injector) {
|
||||
ActorSystem actorSystem = injector.getInstance(ActorSystem.class);
|
||||
actorSystem.shutdown();
|
||||
try {
|
||||
actorSystem.awaitTermination(Duration.create(5L, "seconds"));
|
||||
} catch (Exception ex) {
|
||||
log.error("Actor system failed to shut down properly", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
124
src/main/java/io/bitsquare/app/cli/SeedNode.java
Normal file
124
src/main/java/io/bitsquare/app/cli/SeedNode.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* 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.app.cli;
|
||||
|
||||
import io.bitsquare.app.ArgumentParser;
|
||||
import io.bitsquare.msg.actor.DHTManager;
|
||||
import io.bitsquare.msg.actor.command.InitializePeer;
|
||||
import io.bitsquare.msg.actor.event.PeerInitialized;
|
||||
import io.bitsquare.network.BootstrapNode;
|
||||
import io.bitsquare.network.Node;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.Inbox;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import scala.concurrent.duration.Duration;
|
||||
import scala.concurrent.duration.FiniteDuration;
|
||||
|
||||
public class SeedNode {
|
||||
private static final Logger log = LoggerFactory.getLogger(SeedNode.class);
|
||||
|
||||
private static String appName = "Bitsquare";
|
||||
private static String interfaceHint;
|
||||
|
||||
public static void main(String[] args) {
|
||||
ArgumentParser parser = new ArgumentParser();
|
||||
Namespace namespace = parser.parseArgs(args);
|
||||
|
||||
if (namespace.getString(ArgumentParser.NAME_FLAG) != null) {
|
||||
appName = appName + "-" + namespace.getString(ArgumentParser.NAME_FLAG);
|
||||
}
|
||||
|
||||
if (namespace.getString(ArgumentParser.INFHINT_FLAG) != null) {
|
||||
interfaceHint = namespace.getString(ArgumentParser.INFHINT_FLAG);
|
||||
}
|
||||
|
||||
int port = -1;
|
||||
if (namespace.getString(ArgumentParser.PORT_FLAG) != null) {
|
||||
port = Integer.valueOf(namespace.getString(ArgumentParser.PORT_FLAG));
|
||||
}
|
||||
|
||||
String seedID = BootstrapNode.DIGITAL_OCEAN1.getId();
|
||||
if (namespace.getString(ArgumentParser.PEER_ID_FLAG) != null) {
|
||||
seedID = namespace.getString(ArgumentParser.PEER_ID_FLAG);
|
||||
}
|
||||
|
||||
ActorSystem actorSystem = ActorSystem.create(appName);
|
||||
|
||||
final Set<PeerAddress> peerAddresses = new HashSet<PeerAddress>();
|
||||
final String sid = seedID;
|
||||
for (Node node : BootstrapNode.values()) {
|
||||
if (!node.getId().equals(sid)) {
|
||||
try {
|
||||
peerAddresses.add(new PeerAddress(Number160.createHash(node.getId()), node.getIp(),
|
||||
node.getPort(), node.getPort()));
|
||||
} catch (UnknownHostException uhe) {
|
||||
log.error("Unknown Host [" + node.getIp() + "]: " + uhe.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int serverPort = (port == -1) ? ArgumentParser.PORT_DEFAULT : port;
|
||||
|
||||
ActorRef seedNode = actorSystem.actorOf(DHTManager.getProps(), DHTManager.SEED_NAME);
|
||||
Inbox inbox = Inbox.create(actorSystem);
|
||||
inbox.send(seedNode, new InitializePeer(Number160.createHash(sid), serverPort, interfaceHint,
|
||||
peerAddresses));
|
||||
|
||||
Thread seedNodeThread = new Thread(() -> {
|
||||
Boolean quit = false;
|
||||
while (!quit) {
|
||||
try {
|
||||
Object m = inbox.receive(FiniteDuration.create(5L, "seconds"));
|
||||
if (m instanceof PeerInitialized) {
|
||||
log.debug("Seed Peer Initialized on port " + ((PeerInitialized) m).getPort
|
||||
());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (!(e instanceof TimeoutException)) {
|
||||
quit = true;
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
actorSystem.shutdown();
|
||||
try {
|
||||
actorSystem.awaitTermination(Duration.create(5L, "seconds"));
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof TimeoutException)
|
||||
log.error("ActorSystem did not shutdown properly.");
|
||||
else
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
});
|
||||
seedNodeThread.start();
|
||||
}
|
||||
}
|
144
src/main/java/io/bitsquare/app/gui/Main.java
Normal file
144
src/main/java/io/bitsquare/app/gui/Main.java
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* 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.app.gui;
|
||||
|
||||
import io.bitsquare.app.ArgumentParser;
|
||||
import io.bitsquare.app.BitsquareModule;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.SystemTray;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import lighthouse.files.AppDirectory;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
||||
public class Main extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(Main.class);
|
||||
private static String appName = "Bitsquare";
|
||||
|
||||
private BitsquareModule bitsquareModule;
|
||||
private Injector injector;
|
||||
|
||||
public static void main(String[] args) {
|
||||
ArgumentParser parser = new ArgumentParser();
|
||||
Namespace namespace = parser.parseArgs(args);
|
||||
|
||||
if (namespace.getString(ArgumentParser.NAME_FLAG) != null) {
|
||||
appName = appName + "-" + namespace.getString(ArgumentParser.NAME_FLAG);
|
||||
}
|
||||
|
||||
Application.launch(Main.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
bitsquareModule = new BitsquareModule(primaryStage, appName);
|
||||
injector = Guice.createInjector(bitsquareModule);
|
||||
|
||||
|
||||
// route uncaught exceptions to a user-facing dialog
|
||||
|
||||
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) ->
|
||||
Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
|
||||
|
||||
|
||||
// configure the Bitsquare application data directory
|
||||
|
||||
try {
|
||||
AppDirectory.initAppDir(appName);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
// load and apply any stored settings
|
||||
|
||||
User user = injector.getInstance(User.class);
|
||||
Settings settings = injector.getInstance(Settings.class);
|
||||
Persistence persistence = injector.getInstance(Persistence.class);
|
||||
persistence.init();
|
||||
|
||||
User persistedUser = (User) persistence.read(user);
|
||||
user.applyPersistedUser(persistedUser);
|
||||
|
||||
settings.applyPersistedSettings((Settings) persistence.read(settings.getClass().getName()));
|
||||
|
||||
|
||||
// load the main view and create the main scene
|
||||
|
||||
ViewLoader.setInjector(injector);
|
||||
ViewLoader loader = new ViewLoader(Navigation.Item.MAIN, false);
|
||||
Parent view = loader.load();
|
||||
|
||||
Scene scene = new Scene(view, 1000, 600);
|
||||
scene.getStylesheets().setAll(
|
||||
"/io/bitsquare/gui/bitsquare.css",
|
||||
"/io/bitsquare/gui/images.css");
|
||||
|
||||
|
||||
// configure the system tray
|
||||
|
||||
SystemTray systemTray = new SystemTray(primaryStage, this::stop);
|
||||
primaryStage.setOnCloseRequest(e -> systemTray.hideStage());
|
||||
scene.setOnKeyReleased(keyEvent -> {
|
||||
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent))
|
||||
systemTray.hideStage();
|
||||
});
|
||||
|
||||
|
||||
// configure the primary stage
|
||||
|
||||
primaryStage.setTitle("Bitsquare (" + appName + ")");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setMinWidth(75);
|
||||
primaryStage.setMinHeight(50);
|
||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(
|
||||
ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png")));
|
||||
|
||||
|
||||
// make the UI visible
|
||||
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
bitsquareModule.close(injector);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
|
@ -17,18 +17,19 @@
|
|||
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import io.bitsquare.AbstractBitsquareModule;
|
||||
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class BitcoinModule extends AbstractModule {
|
||||
public class BitcoinModule extends AbstractBitsquareModule {
|
||||
|
||||
private final Properties properties;
|
||||
private final BitcoinNetwork defaultNetwork;
|
||||
|
||||
public BitcoinModule(Properties properties) {
|
||||
|
@ -36,7 +37,7 @@ public class BitcoinModule extends AbstractModule {
|
|||
}
|
||||
|
||||
public BitcoinModule(Properties properties, BitcoinNetwork defaultNetwork) {
|
||||
this.properties = properties;
|
||||
super(properties);
|
||||
this.defaultNetwork = defaultNetwork;
|
||||
}
|
||||
|
||||
|
@ -48,6 +49,11 @@ public class BitcoinModule extends AbstractModule {
|
|||
bind(NetworkParameters.class).toInstance(network());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doClose(Injector injector) {
|
||||
injector.getInstance(WalletFacade.class).shutDown();
|
||||
}
|
||||
|
||||
private NetworkParameters network() {
|
||||
String networkName = properties.getProperty("networkType", defaultNetwork.name());
|
||||
|
||||
|
@ -62,6 +68,5 @@ public class BitcoinModule extends AbstractModule {
|
|||
throw new IllegalArgumentException("Unknown bitcoin network name: " + networkName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import io.bitsquare.Bitsquare;
|
||||
import io.bitsquare.btc.listeners.AddressConfidenceListener;
|
||||
import io.bitsquare.btc.listeners.BalanceListener;
|
||||
import io.bitsquare.btc.listeners.TxConfidenceListener;
|
||||
|
@ -73,6 +72,7 @@ import java.util.stream.Collectors;
|
|||
import javax.annotation.concurrent.GuardedBy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.util.Pair;
|
||||
|
@ -92,14 +92,13 @@ import static org.bitcoinj.script.ScriptOpCodes.OP_RETURN;
|
|||
public class WalletFacade {
|
||||
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
|
||||
|
||||
public static final String WALLET_PREFIX = Bitsquare.getAppName();
|
||||
|
||||
private final ReentrantLock lock = Threading.lock("lock");
|
||||
private final NetworkParameters params;
|
||||
private WalletAppKit walletAppKit;
|
||||
private final FeePolicy feePolicy;
|
||||
private final CryptoFacade cryptoFacade;
|
||||
private final Persistence persistence;
|
||||
private final String appName;
|
||||
// private final List<DownloadListener> downloadListeners = new CopyOnWriteArrayList<>();
|
||||
private final List<AddressConfidenceListener> addressConfidenceListeners = new CopyOnWriteArrayList<>();
|
||||
private final List<TxConfidenceListener> txConfidenceListeners = new CopyOnWriteArrayList<>();
|
||||
|
@ -118,11 +117,12 @@ public class WalletFacade {
|
|||
|
||||
@Inject
|
||||
public WalletFacade(NetworkParameters params, FeePolicy feePolicy, CryptoFacade cryptoFacade,
|
||||
Persistence persistence) {
|
||||
Persistence persistence, @Named("appName") String appName) {
|
||||
this.params = params;
|
||||
this.feePolicy = feePolicy;
|
||||
this.cryptoFacade = cryptoFacade;
|
||||
this.persistence = persistence;
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,7 +138,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, AppDirectory.dir().toFile(), WALLET_PREFIX) {
|
||||
walletAppKit = new WalletAppKit(params, AppDirectory.dir().toFile(), appName) {
|
||||
@Override
|
||||
protected void onSetupCompleted() {
|
||||
// Don't make the user wait for confirmations for now, as the intention is they're sending it
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.crypto;
|
||||
|
||||
import io.bitsquare.di.AbstractBitsquareModule;
|
||||
import io.bitsquare.AbstractBitsquareModule;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
|
|
@ -1,133 +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;
|
||||
|
||||
|
||||
import io.bitsquare.Bitsquare;
|
||||
import io.bitsquare.BitsquareUI;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import scala.concurrent.duration.Duration;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
private static MenuItem showGuiItem;
|
||||
private static Stage stage;
|
||||
private static ActorSystem actorSystem;
|
||||
private static BitsquareUI application;
|
||||
private static TrayIcon trayIcon;
|
||||
|
||||
public static void createSystemTray(Stage stage, ActorSystem actorSystem, BitsquareUI application) {
|
||||
AWTSystemTray.stage = stage;
|
||||
AWTSystemTray.actorSystem = actorSystem;
|
||||
AWTSystemTray.application = application;
|
||||
|
||||
if (SystemTray.isSupported()) {
|
||||
// prevent exiting the app when the last window get closed
|
||||
Platform.setImplicitExit(false);
|
||||
|
||||
SystemTray systemTray = SystemTray.getSystemTray();
|
||||
if (ImageUtil.isRetina())
|
||||
trayIcon = new TrayIcon(getImage(ImageUtil.SYS_TRAY_HI_RES));
|
||||
else
|
||||
trayIcon = new TrayIcon(getImage(ImageUtil.SYS_TRAY));
|
||||
|
||||
trayIcon.setToolTip("Bitsquare P2P Fiat-Bitcoin exchange");
|
||||
|
||||
PopupMenu popupMenu = new PopupMenu();
|
||||
MenuItem aboutItem = new MenuItem("Info about " + Bitsquare.getAppName());
|
||||
popupMenu.add(aboutItem);
|
||||
popupMenu.addSeparator();
|
||||
showGuiItem = new MenuItem("Close exchange window");
|
||||
popupMenu.add(showGuiItem);
|
||||
popupMenu.addSeparator();
|
||||
MenuItem exitItem = new MenuItem("Exit");
|
||||
popupMenu.add(exitItem);
|
||||
|
||||
trayIcon.setPopupMenu(popupMenu);
|
||||
|
||||
showGuiItem.addActionListener(e -> {
|
||||
if (isStageVisible) {
|
||||
showGuiItem.setLabel("Open exchange window");
|
||||
Platform.runLater(stage::hide);
|
||||
isStageVisible = false;
|
||||
}
|
||||
else {
|
||||
showGuiItem.setLabel("Close exchange window");
|
||||
Platform.runLater(stage::show);
|
||||
isStageVisible = true;
|
||||
}
|
||||
});
|
||||
exitItem.addActionListener(e -> {
|
||||
systemTray.remove(trayIcon);
|
||||
actorSystem.shutdown();
|
||||
try {
|
||||
actorSystem.awaitTermination(Duration.create(5L, "seconds"));
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof TimeoutException)
|
||||
log.error("ActorSystem did not shutdown properly.");
|
||||
else
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
try {
|
||||
application.stop();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
systemTray.add(trayIcon);
|
||||
} catch (AWTException e) {
|
||||
log.error("TrayIcon could not be added.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.error("SystemTray is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setStageHidden() {
|
||||
stage.hide();
|
||||
isStageVisible = false;
|
||||
showGuiItem.setLabel("Open exchange window");
|
||||
}
|
||||
|
||||
private static Image getImage(String path) {
|
||||
return new ImageIcon(AWTSystemTray.class.getResource(path), "system tray icon").getImage();
|
||||
}
|
||||
}
|
|
@ -15,25 +15,16 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.settings.uimock;
|
||||
package io.bitsquare.gui;
|
||||
|
||||
import java.net.URL;
|
||||
@SuppressWarnings("serializable")
|
||||
public class FatalException extends RuntimeException {
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
public class SeedWordsControllerUIMock implements Initializable {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
public FatalException(String format, Object... args) {
|
||||
super(String.format(format, args));
|
||||
}
|
||||
|
||||
|
||||
public FatalException(Throwable cause, String format, Object... args) {
|
||||
super(String.format(format, args), cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
package io.bitsquare.gui;
|
||||
|
||||
import io.bitsquare.di.AbstractBitsquareModule;
|
||||
import io.bitsquare.AbstractBitsquareModule;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
import io.bitsquare.gui.main.trade.offerbook.OfferBook;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.BankAccountNumberValidator;
|
||||
|
@ -28,10 +30,15 @@ import io.bitsquare.gui.util.validation.PasswordValidator;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class GuiModule extends AbstractBitsquareModule {
|
||||
|
||||
public GuiModule(Properties properties) {
|
||||
private final Stage primaryStage;
|
||||
|
||||
public GuiModule(Properties properties, Stage primaryStage) {
|
||||
super(properties);
|
||||
this.primaryStage = primaryStage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,5 +53,9 @@ public class GuiModule extends AbstractBitsquareModule {
|
|||
bind(FiatValidator.class).asEagerSingleton();
|
||||
bind(InputValidator.class).asEagerSingleton();
|
||||
bind(PasswordValidator.class).asEagerSingleton();
|
||||
|
||||
bind(Stage.class).toInstance(primaryStage);
|
||||
Popups.primaryStage = primaryStage;
|
||||
Help.primaryStage = primaryStage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,12 +138,16 @@ public class Navigation {
|
|||
void onNavigationRequested(Item... items);
|
||||
}
|
||||
|
||||
public interface FxmlResource {
|
||||
String getFxmlUrl();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enum
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static enum Item {
|
||||
public static enum Item implements FxmlResource {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Application
|
||||
|
@ -221,6 +225,7 @@ public class Navigation {
|
|||
this.fxmlUrl = fxmlUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFxmlUrl() {
|
||||
return fxmlUrl;
|
||||
}
|
||||
|
|
110
src/main/java/io/bitsquare/gui/SystemTray.java
Normal file
110
src/main/java/io/bitsquare/gui/SystemTray.java
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* There is no JavaFX support yet, so we need to use AWT.
|
||||
*/
|
||||
public class SystemTray {
|
||||
private static final Logger log = LoggerFactory.getLogger(SystemTray.class);
|
||||
|
||||
private static final String ICON_HI_RES = "/images/system_tray_icon@2x.png";
|
||||
private static final String ICON_LO_RES = "/images/system_tray_icon.png";
|
||||
|
||||
public static final String SHOW_WINDOW_LABEL = "Show exchange window";
|
||||
public static final String HIDE_WINDOW_LABEL = "Hide exchange window";
|
||||
|
||||
private final Stage stage;
|
||||
private final Runnable onExit;
|
||||
private final TrayIcon trayIcon = createTrayIcon();
|
||||
private final MenuItem toggleShowHideItem = new MenuItem(HIDE_WINDOW_LABEL);
|
||||
|
||||
public SystemTray(Stage stage, Runnable onExit) {
|
||||
this.stage = stage;
|
||||
this.onExit = onExit;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (!java.awt.SystemTray.isSupported()) {
|
||||
log.error("System tray is not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent exiting the app when the last window gets closed
|
||||
Platform.setImplicitExit(false);
|
||||
|
||||
MenuItem aboutItem = new MenuItem("Info about Bitsquare");
|
||||
MenuItem exitItem = new MenuItem("Exit");
|
||||
|
||||
PopupMenu popupMenu = new PopupMenu();
|
||||
popupMenu.add(aboutItem);
|
||||
popupMenu.addSeparator();
|
||||
popupMenu.add(toggleShowHideItem);
|
||||
popupMenu.addSeparator();
|
||||
popupMenu.add(exitItem);
|
||||
|
||||
trayIcon.setPopupMenu(popupMenu);
|
||||
trayIcon.setToolTip("Bitsquare: The decentralized bitcoin exchange");
|
||||
|
||||
java.awt.SystemTray self = java.awt.SystemTray.getSystemTray();
|
||||
try {
|
||||
self.add(trayIcon);
|
||||
} catch (AWTException ex) {
|
||||
log.error("Icon could not be added to system tray.", ex);
|
||||
}
|
||||
|
||||
toggleShowHideItem.addActionListener(e -> {
|
||||
if (stage.isShowing()) {
|
||||
toggleShowHideItem.setLabel(SHOW_WINDOW_LABEL);
|
||||
Platform.runLater(stage::hide);
|
||||
}
|
||||
else {
|
||||
toggleShowHideItem.setLabel(HIDE_WINDOW_LABEL);
|
||||
Platform.runLater(stage::show);
|
||||
}
|
||||
});
|
||||
|
||||
exitItem.addActionListener(e -> {
|
||||
self.remove(trayIcon);
|
||||
onExit.run();
|
||||
});
|
||||
}
|
||||
|
||||
public void hideStage() {
|
||||
stage.hide();
|
||||
toggleShowHideItem.setLabel(SHOW_WINDOW_LABEL);
|
||||
}
|
||||
|
||||
private TrayIcon createTrayIcon() {
|
||||
String path = ImageUtil.isRetina() ? ICON_HI_RES : ICON_LO_RES;
|
||||
return new TrayIcon(new ImageIcon(getClass().getResource(path)).getImage());
|
||||
}
|
||||
}
|
|
@ -15,12 +15,14 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.util;
|
||||
package io.bitsquare.gui;
|
||||
|
||||
import io.bitsquare.locale.BSResources;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -51,14 +53,11 @@ public class ViewLoader {
|
|||
// TODO maybe add more sophisticated caching strategy with removal of rarely accessed items
|
||||
private static final Map<URL, Item> cachedGUIItems = new HashMap<>();
|
||||
|
||||
public ViewLoader(URL url) {
|
||||
this(url, true);
|
||||
}
|
||||
|
||||
// TODO check relationship with CachedViewCB -> derive caching strategy, but there are some special cases where
|
||||
// we need an override, as caching is done manually in the client class
|
||||
public ViewLoader(URL url, boolean useCaching) {
|
||||
this.url = url;
|
||||
public ViewLoader(Navigation.FxmlResource navItem, boolean useCaching) {
|
||||
this.url = ViewLoader.class.getResource(navItem.getFxmlUrl());
|
||||
if (this.url == null) {
|
||||
throw new FatalException("'%s' could not be loaded as a resource", navItem.getFxmlUrl());
|
||||
}
|
||||
|
||||
isCached = useCaching && cachedGUIItems.containsKey(url);
|
||||
if (!isCached) {
|
||||
|
@ -69,19 +68,26 @@ public class ViewLoader {
|
|||
}
|
||||
}
|
||||
|
||||
public ViewLoader(Navigation.FxmlResource navItem) {
|
||||
this(navItem, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T load() throws java.io.IOException {
|
||||
public <T> T load() {
|
||||
if (isCached) {
|
||||
item = cachedGUIItems.get(url);
|
||||
log.debug("loaded from cache " + url);
|
||||
return (T) cachedGUIItems.get(url).view;
|
||||
}
|
||||
else {
|
||||
log.debug("load from disc " + url);
|
||||
|
||||
log.debug("load from disc " + url);
|
||||
try {
|
||||
T result = loader.load();
|
||||
item = new Item(result, loader.getController());
|
||||
cachedGUIItems.put(url, item);
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
throw new FatalException(e, "Failed to load view at %s", url);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,6 +59,7 @@ public class AddressTextField extends AnchorPane {
|
|||
private final StringProperty address = new SimpleStringProperty();
|
||||
private final StringProperty paymentLabel = new SimpleStringProperty();
|
||||
private final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>();
|
||||
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package io.bitsquare.gui.components;
|
||||
|
||||
import io.bitsquare.BitsquareUI;
|
||||
import io.bitsquare.gui.OverlayManager;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
|
||||
|
@ -30,6 +29,7 @@ import java.util.List;
|
|||
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.controlsfx.control.action.AbstractAction;
|
||||
import org.controlsfx.control.action.Action;
|
||||
|
@ -42,6 +42,8 @@ import org.slf4j.LoggerFactory;
|
|||
public class Popups {
|
||||
private static final Logger log = LoggerFactory.getLogger(Popups.class);
|
||||
|
||||
public static Stage primaryStage;
|
||||
|
||||
// TODO just temporary, class will be removed completely
|
||||
public static void setOverlayManager(OverlayManager overlayManager) {
|
||||
Popups.overlayManager = overlayManager;
|
||||
|
@ -70,7 +72,7 @@ public class Popups {
|
|||
|
||||
public static void openInfoPopup(String masthead, String message, List<Action> actions) {
|
||||
Dialogs.create()
|
||||
.owner(BitsquareUI.getPrimaryStage())
|
||||
.owner(primaryStage)
|
||||
.message(message)
|
||||
.masthead(masthead)
|
||||
.actions(actions)
|
||||
|
@ -107,7 +109,7 @@ public class Popups {
|
|||
|
||||
public static Action openConfirmPopup(String title, String masthead, String message, List<Action> actions) {
|
||||
return Dialogs.create()
|
||||
.owner(BitsquareUI.getPrimaryStage())
|
||||
.owner(primaryStage)
|
||||
.title(title)
|
||||
.message(message)
|
||||
.masthead(masthead)
|
||||
|
@ -140,7 +142,7 @@ public class Popups {
|
|||
|
||||
private static void openWarningPopup(String title, String masthead, String message, List<Action> actions) {
|
||||
Dialogs.create()
|
||||
.owner(BitsquareUI.getPrimaryStage())
|
||||
.owner(primaryStage)
|
||||
.title(title)
|
||||
.message(message)
|
||||
.masthead(masthead)
|
||||
|
@ -173,7 +175,7 @@ public class Popups {
|
|||
|
||||
private static Action openErrorPopup(String title, String masthead, String message, List<Action> actions) {
|
||||
return Dialogs.create()
|
||||
.owner(BitsquareUI.getPrimaryStage())
|
||||
.owner(primaryStage)
|
||||
.title(title)
|
||||
.message(message)
|
||||
.masthead(masthead)
|
||||
|
@ -202,7 +204,7 @@ public class Popups {
|
|||
}
|
||||
});
|
||||
return Dialogs.create()
|
||||
.owner(BitsquareUI.getPrimaryStage())
|
||||
.owner(primaryStage)
|
||||
.title(title)
|
||||
.message(message)
|
||||
.masthead(masthead)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package io.bitsquare.gui.main;
|
||||
|
||||
import io.bitsquare.Bitsquare;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.UIModel;
|
||||
|
@ -35,6 +34,8 @@ import com.google.inject.Inject;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
|
@ -57,6 +58,7 @@ class MainModel extends UIModel {
|
|||
private final MessageFacade messageFacade;
|
||||
private final TradeManager tradeManager;
|
||||
private final Persistence persistence;
|
||||
private final int clientPort;
|
||||
|
||||
private boolean messageFacadeInited;
|
||||
private boolean walletFacadeInited;
|
||||
|
@ -72,12 +74,14 @@ class MainModel extends UIModel {
|
|||
|
||||
@Inject
|
||||
private MainModel(User user, WalletFacade walletFacade, MessageFacade messageFacade,
|
||||
TradeManager tradeManager, Persistence persistence) {
|
||||
TradeManager tradeManager, Persistence persistence,
|
||||
@Named("clientPort") int clientPort) {
|
||||
this.user = user;
|
||||
this.walletFacade = walletFacade;
|
||||
this.messageFacade = messageFacade;
|
||||
this.tradeManager = tradeManager;
|
||||
this.persistence = persistence;
|
||||
this.clientPort = clientPort;
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,7 +111,7 @@ class MainModel extends UIModel {
|
|||
// For testing with the serverside seednode we need the BootstrappedPeerFactory which gets started form
|
||||
// messageFacade.init
|
||||
|
||||
messageFacade.init(Bitsquare.getClientPort(), new BootstrapListener() {
|
||||
messageFacade.init(clientPort, new BootstrapListener() {
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
messageFacadeInited = true;
|
||||
|
|
|
@ -17,26 +17,24 @@
|
|||
|
||||
package io.bitsquare.gui.main;
|
||||
|
||||
import io.bitsquare.Bitsquare;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.OverlayManager;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.components.SystemNotification;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.application.Platform;
|
||||
|
@ -58,9 +56,9 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
|
||||
private final Navigation navigation;
|
||||
private final OverlayManager overlayManager;
|
||||
private Settings settings;
|
||||
|
||||
private final ToggleGroup navButtonsGroup = new ToggleGroup();
|
||||
private final Settings settings;
|
||||
private final String appName;
|
||||
|
||||
private BorderPane baseApplicationContainer;
|
||||
private VBox splashScreen;
|
||||
|
@ -78,12 +76,13 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
|
||||
@Inject
|
||||
private MainViewCB(MainPM presentationModel, Navigation navigation, OverlayManager overlayManager,
|
||||
TradeManager tradeManager, Settings settings) {
|
||||
TradeManager tradeManager, Settings settings, @Named("appName") String appName) {
|
||||
super(presentationModel);
|
||||
|
||||
this.navigation = navigation;
|
||||
this.overlayManager = overlayManager;
|
||||
this.settings = settings;
|
||||
this.appName = appName;
|
||||
|
||||
tradeManager.featureNotImplementedWarningProperty().addListener((ov, oldValue, newValue) -> {
|
||||
if (oldValue == null && newValue != null) {
|
||||
|
@ -146,21 +145,15 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
@Override
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView((navigationItem));
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
final Node view = loader.load();
|
||||
contentContainer.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
final ViewLoader loader = new ViewLoader(navigationItem);
|
||||
final Node view = loader.load();
|
||||
contentContainer.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
|
||||
if (childController instanceof ViewCB)
|
||||
((ViewCB) childController).setParent(this);
|
||||
if (childController instanceof ViewCB)
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
return childController;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
|
||||
}
|
||||
return null;
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
||||
|
@ -213,8 +206,8 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
numPendingTradesLabel.setText(String.valueOf(numPendingTrades));
|
||||
}
|
||||
|
||||
log.trace("openInfoNotification " + Bitsquare.getAppName());
|
||||
SystemNotification.openInfoNotification(Bitsquare.getAppName(), "You got a new trade message.");
|
||||
log.trace("openInfoNotification " + appName);
|
||||
SystemNotification.openInfoNotification(appName, "You got a new trade message.");
|
||||
}
|
||||
else {
|
||||
if (portfolioButtonButtonPane.getChildren().size() > 1)
|
||||
|
|
|
@ -20,9 +20,7 @@ package io.bitsquare.gui.main.account;
|
|||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -136,38 +134,33 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView(navigationItem);
|
||||
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
Node view = loader.load();
|
||||
Tab tab = null;
|
||||
switch (navigationItem) {
|
||||
case ACCOUNT_SETTINGS:
|
||||
tab = accountSettingsTab;
|
||||
tab.setText("Account settings");
|
||||
arbitratorSettingsTab.setDisable(false);
|
||||
break;
|
||||
case ACCOUNT_SETUP:
|
||||
tab = accountSettingsTab;
|
||||
tab.setText("Account setup");
|
||||
arbitratorSettingsTab.setDisable(true);
|
||||
break;
|
||||
case ARBITRATOR_SETTINGS:
|
||||
tab = arbitratorSettingsTab;
|
||||
break;
|
||||
}
|
||||
|
||||
// for IRC demo we deactivate the arbitratorSettingsTab
|
||||
arbitratorSettingsTab.setDisable(true);
|
||||
|
||||
tab.setContent(view);
|
||||
((TabPane) root).getSelectionModel().select(tab);
|
||||
Initializable childController = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Loading view failed. FxmlUrl = " + Navigation.Item.ACCOUNT_SETUP.getFxmlUrl());
|
||||
e.printStackTrace();
|
||||
final ViewLoader loader = new ViewLoader(navigationItem);
|
||||
Node view = loader.load();
|
||||
Tab tab = null;
|
||||
switch (navigationItem) {
|
||||
case ACCOUNT_SETTINGS:
|
||||
tab = accountSettingsTab;
|
||||
tab.setText("Account settings");
|
||||
arbitratorSettingsTab.setDisable(false);
|
||||
break;
|
||||
case ACCOUNT_SETUP:
|
||||
tab = accountSettingsTab;
|
||||
tab.setText("Account setup");
|
||||
arbitratorSettingsTab.setDisable(true);
|
||||
break;
|
||||
case ARBITRATOR_SETTINGS:
|
||||
tab = arbitratorSettingsTab;
|
||||
break;
|
||||
}
|
||||
|
||||
// for IRC demo we deactivate the arbitratorSettingsTab
|
||||
arbitratorSettingsTab.setDisable(true);
|
||||
|
||||
tab.setContent(view);
|
||||
((TabPane) root).getSelectionModel().select(tab);
|
||||
Initializable childController = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,10 @@
|
|||
|
||||
package io.bitsquare.gui.main.account.arbitrator;
|
||||
|
||||
import io.bitsquare.BitsquareUI;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.main.account.arbitrator.registration.ArbitratorRegistrationViewCB;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -45,7 +42,8 @@ public class ArbitratorSettingsViewCB extends CachedViewCB {
|
|||
|
||||
private static final Logger log = LoggerFactory.getLogger(ArbitratorSettingsViewCB.class);
|
||||
|
||||
private Navigation navigation;
|
||||
private final Navigation navigation;
|
||||
private final Stage primaryStage;
|
||||
|
||||
private ArbitratorRegistrationViewCB arbitratorRegistrationViewCB;
|
||||
|
||||
|
@ -55,9 +53,10 @@ public class ArbitratorSettingsViewCB extends CachedViewCB {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private ArbitratorSettingsViewCB(Navigation navigation) {
|
||||
private ArbitratorSettingsViewCB(Navigation navigation, Stage primaryStage) {
|
||||
super();
|
||||
this.navigation = navigation;
|
||||
this.primaryStage = primaryStage;
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,31 +96,26 @@ public class ArbitratorSettingsViewCB extends CachedViewCB {
|
|||
@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 ViewLoader loader = new ViewLoader(navigationItem, false);
|
||||
|
||||
final Stage rootStage = BitsquareUI.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();
|
||||
final Parent view = loader.load();
|
||||
arbitratorRegistrationViewCB = loader.getController();
|
||||
|
||||
return arbitratorRegistrationViewCB;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
final Stage stage = new Stage();
|
||||
stage.setTitle("Arbitrator");
|
||||
stage.setMinWidth(800);
|
||||
stage.setMinHeight(400);
|
||||
stage.setWidth(800);
|
||||
stage.setHeight(600);
|
||||
stage.setX(primaryStage.getX() + 50);
|
||||
stage.setY(primaryStage.getY() + 50);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(primaryStage);
|
||||
Scene scene = new Scene(view, 800, 600);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
||||
return arbitratorRegistrationViewCB;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,15 +21,13 @@ import io.bitsquare.arbitrator.Arbitrator;
|
|||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
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;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -140,17 +138,12 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
|
|||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView(navigationItem);
|
||||
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
Node view = loader.load();
|
||||
((Pane) root).getChildren().set(0, view);
|
||||
Initializable childController = arbitratorProfileViewCB = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
final ViewLoader loader = new ViewLoader(navigationItem);
|
||||
Node view = loader.load();
|
||||
((Pane) root).getChildren().set(0, view);
|
||||
Initializable childController = arbitratorProfileViewCB = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
package io.bitsquare.gui.main.account.content.restrictions;
|
||||
|
||||
import io.bitsquare.BitsquareUI;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
|
@ -28,9 +28,6 @@ import io.bitsquare.gui.main.help.HelpId;
|
|||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.Region;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -56,6 +53,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RestrictionsViewCB.class);
|
||||
private final Stage primaryStage;
|
||||
|
||||
@FXML ListView<Locale> languagesListView;
|
||||
@FXML ListView<Country> countriesListView;
|
||||
|
@ -71,8 +69,9 @@ public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private RestrictionsViewCB(RestrictionsPM presentationModel) {
|
||||
private RestrictionsViewCB(RestrictionsPM presentationModel, Stage primaryStage) {
|
||||
super(presentationModel);
|
||||
this.primaryStage = primaryStage;
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,37 +188,31 @@ public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements
|
|||
@Override
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
// TODO caching causes exception
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
try {
|
||||
final Node view = loader.load();
|
||||
//TODO Resolve type problem...
|
||||
Initializable childController = loader.getController();
|
||||
//childController.setParentController(this);
|
||||
final ViewLoader loader = new ViewLoader(navigationItem, false);
|
||||
final Node view = loader.load();
|
||||
//TODO Resolve type problem...
|
||||
Initializable childController = loader.getController();
|
||||
//childController.setParentController(this);
|
||||
|
||||
final Stage rootStage = BitsquareUI.getPrimaryStage();
|
||||
final Stage stage = new Stage();
|
||||
stage.setTitle("Arbitrator selection");
|
||||
stage.setMinWidth(800);
|
||||
stage.setMinHeight(500);
|
||||
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((Parent) view, 800, 600);
|
||||
stage.setScene(scene);
|
||||
stage.setOnHidden(windowEvent -> {
|
||||
if (navigationItem == Navigation.Item.ARBITRATOR_BROWSER)
|
||||
updateArbitratorList();
|
||||
});
|
||||
stage.show();
|
||||
final Stage stage = new Stage();
|
||||
stage.setTitle("Arbitrator selection");
|
||||
stage.setMinWidth(800);
|
||||
stage.setMinHeight(500);
|
||||
stage.setWidth(800);
|
||||
stage.setHeight(600);
|
||||
stage.setX(primaryStage.getX() + 50);
|
||||
stage.setY(primaryStage.getY() + 50);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(primaryStage);
|
||||
Scene scene = new Scene((Parent) view, 800, 600);
|
||||
stage.setScene(scene);
|
||||
stage.setOnHidden(windowEvent -> {
|
||||
if (navigationItem == Navigation.Item.ARBITRATOR_BROWSER)
|
||||
updateArbitratorList();
|
||||
});
|
||||
stage.show();
|
||||
|
||||
return childController;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,11 +21,9 @@ import io.bitsquare.gui.CachedViewCB;
|
|||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.util.Colors;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -148,19 +146,13 @@ public class AccountSettingsViewCB extends CachedViewCB {
|
|||
|
||||
@Override
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
final Pane view = loader.load();
|
||||
content.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
((ViewCB<? extends PresentationModel>) childController).setParent(this);
|
||||
((ContextAware) childController).useSettingsContext(true);
|
||||
return childController;
|
||||
} catch (IOException e) {
|
||||
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
final ViewLoader loader = new ViewLoader(navigationItem);
|
||||
final Pane view = loader.load();
|
||||
content.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
((ViewCB<? extends PresentationModel>) childController).setParent(this);
|
||||
((ContextAware) childController).useSettingsContext(true);
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package io.bitsquare.gui.main.account.setup;
|
|||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.account.content.irc.IrcAccountViewCB;
|
||||
|
@ -27,9 +28,6 @@ import io.bitsquare.gui.main.account.content.password.PasswordViewCB;
|
|||
import io.bitsquare.gui.main.account.content.registration.RegistrationViewCB;
|
||||
import io.bitsquare.gui.main.account.content.restrictions.RestrictionsViewCB;
|
||||
import io.bitsquare.gui.main.account.content.seedwords.SeedWordsViewCB;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -188,19 +186,13 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
|
|||
|
||||
@Override
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
final Pane view = loader.load();
|
||||
content.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
((ViewCB<? extends PresentationModel>) childController).setParent(this);
|
||||
((ContextAware) childController).useSettingsContext(false);
|
||||
return childController;
|
||||
} catch (IOException e) {
|
||||
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
final ViewLoader loader = new ViewLoader(navigationItem);
|
||||
final Pane view = loader.load();
|
||||
content.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
((ViewCB<? extends PresentationModel>) childController).setParent(this);
|
||||
((ContextAware) childController).useSettingsContext(false);
|
||||
return childController;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@ package io.bitsquare.gui.main.funds;
|
|||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -120,27 +118,22 @@ public class FundsViewCB extends CachedViewCB {
|
|||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView(navigationItem);
|
||||
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
Node view = loader.load();
|
||||
Tab tab = null;
|
||||
switch (navigationItem) {
|
||||
case WITHDRAWAL:
|
||||
tab = withdrawalTab;
|
||||
break;
|
||||
case TRANSACTIONS:
|
||||
tab = transactionsTab;
|
||||
break;
|
||||
}
|
||||
tab.setContent(view);
|
||||
((TabPane) root).getSelectionModel().select(tab);
|
||||
Initializable childController = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
|
||||
e.printStackTrace();
|
||||
final ViewLoader loader = new ViewLoader(navigationItem);
|
||||
Node view = loader.load();
|
||||
Tab tab = null;
|
||||
switch (navigationItem) {
|
||||
case WITHDRAWAL:
|
||||
tab = withdrawalTab;
|
||||
break;
|
||||
case TRANSACTIONS:
|
||||
tab = transactionsTab;
|
||||
break;
|
||||
}
|
||||
tab.setContent(view);
|
||||
((TabPane) root).getSelectionModel().select(tab);
|
||||
Initializable childController = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package io.bitsquare.gui.main.help;
|
||||
|
||||
import io.bitsquare.BitsquareUI;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -35,6 +33,7 @@ public class Help {
|
|||
private static final Logger log = LoggerFactory.getLogger(Help.class);
|
||||
|
||||
private static Stage helpWindow;
|
||||
public static Stage primaryStage;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -49,7 +48,7 @@ public class Help {
|
|||
if (helpWindow == null) {
|
||||
helpWindow = new Stage();
|
||||
helpWindow.initModality(Modality.NONE);
|
||||
helpWindow.initOwner(BitsquareUI.getPrimaryStage());
|
||||
helpWindow.initOwner(primaryStage);
|
||||
webView = new WebView();
|
||||
helpWindow.setScene(new Scene(webView, 800, 600));
|
||||
}
|
||||
|
|
|
@ -20,10 +20,8 @@ package io.bitsquare.gui.main.portfolio;
|
|||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -126,30 +124,25 @@ public class PortfolioViewCB extends CachedViewCB {
|
|||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView(navigationItem);
|
||||
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
Parent view = loader.load();
|
||||
Tab tab = null;
|
||||
switch (navigationItem) {
|
||||
case OFFERS:
|
||||
tab = offersTab;
|
||||
break;
|
||||
case PENDING_TRADES:
|
||||
tab = pendingTradesTab;
|
||||
break;
|
||||
case CLOSED_TRADES:
|
||||
tab = closedTradesTab;
|
||||
break;
|
||||
}
|
||||
tab.setContent(view);
|
||||
((TabPane) root).getSelectionModel().select(tab);
|
||||
Initializable childController = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
|
||||
e.printStackTrace();
|
||||
final ViewLoader loader = new ViewLoader(navigationItem);
|
||||
Parent view = loader.load();
|
||||
Tab tab = null;
|
||||
switch (navigationItem) {
|
||||
case OFFERS:
|
||||
tab = offersTab;
|
||||
break;
|
||||
case PENDING_TRADES:
|
||||
tab = pendingTradesTab;
|
||||
break;
|
||||
case CLOSED_TRADES:
|
||||
tab = closedTradesTab;
|
||||
break;
|
||||
}
|
||||
tab.setContent(view);
|
||||
((TabPane) root).getSelectionModel().select(tab);
|
||||
Initializable childController = loader.getController();
|
||||
((ViewCB) childController).setParent(this);
|
||||
|
||||
return childController;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package io.bitsquare.gui.main.portfolio.closed;
|
||||
|
||||
import io.bitsquare.gui.UIModel;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.portfolio.offer;
|
||||
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
/**
|
||||
* We could remove that wrapper if it is not needed for additional UI only fields.
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package io.bitsquare.gui.main.portfolio.offer;
|
||||
|
||||
import io.bitsquare.gui.UIModel;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import io.bitsquare.btc.FeePolicy;
|
|||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.btc.listeners.TxConfidenceListener;
|
||||
import io.bitsquare.gui.UIModel;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.trade;
|
||||
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
|
|
@ -19,19 +19,17 @@ package io.bitsquare.gui.main.trade;
|
|||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.main.trade.createoffer.CreateOfferViewCB;
|
||||
import io.bitsquare.gui.main.trade.offerbook.OfferBookViewCB;
|
||||
import io.bitsquare.gui.main.trade.takeoffer.TakeOfferViewCB;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -168,63 +166,50 @@ public class TradeViewCB extends CachedViewCB implements TradeNavigator {
|
|||
TabPane tabPane = (TabPane) root;
|
||||
if (navigationItem == Navigation.Item.OFFER_BOOK && offerBookViewCB == null) {
|
||||
// Offerbook must not be cached by ViewLoader as we use 2 instances for sell and buy screens.
|
||||
ViewLoader offerBookLoader =
|
||||
new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
try {
|
||||
final Parent view = offerBookLoader.load();
|
||||
final Tab tab = new Tab(direction == Direction.BUY ? "Buy Bitcoin" : "Sell Bitcoin");
|
||||
tab.setClosable(false);
|
||||
tab.setContent(view);
|
||||
tabPane.getTabs().add(tab);
|
||||
offerBookViewCB = offerBookLoader.getController();
|
||||
offerBookViewCB.setParent(this);
|
||||
ViewLoader offerBookLoader = new ViewLoader(navigationItem, false);
|
||||
final Parent view = offerBookLoader.load();
|
||||
final Tab tab = new Tab(direction == Direction.BUY ? "Buy Bitcoin" : "Sell Bitcoin");
|
||||
tab.setClosable(false);
|
||||
tab.setContent(view);
|
||||
tabPane.getTabs().add(tab);
|
||||
offerBookViewCB = offerBookLoader.getController();
|
||||
offerBookViewCB.setParent(this);
|
||||
|
||||
offerBookViewCB.setDirection(direction);
|
||||
// offerBookViewCB.setNavigationListener(n -> loadView(n));
|
||||
offerBookViewCB.setDirection(direction);
|
||||
// offerBookViewCB.setNavigationListener(n -> loadView(n));
|
||||
|
||||
return offerBookViewCB;
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return offerBookViewCB;
|
||||
}
|
||||
else if (navigationItem == Navigation.Item.CREATE_OFFER && createOfferViewCB == null) {
|
||||
// CreateOffer and TakeOffer must not be cached by ViewLoader as we cannot use a view multiple times
|
||||
// in different graphs
|
||||
ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
try {
|
||||
createOfferView = loader.load();
|
||||
createOfferViewCB = loader.getController();
|
||||
createOfferViewCB.setParent(this);
|
||||
createOfferViewCB.initWithData(direction, amount, price);
|
||||
createOfferViewCB.setCloseListener(this::onCreateOfferViewRemoved);
|
||||
final Tab tab = new Tab("Create offer");
|
||||
tab.setContent(createOfferView);
|
||||
tabPane.getTabs().add(tab);
|
||||
tabPane.getSelectionModel().select(tab);
|
||||
return createOfferViewCB;
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
final ViewLoader loader = new ViewLoader(navigationItem, false);
|
||||
createOfferView = loader.load();
|
||||
createOfferViewCB = loader.getController();
|
||||
createOfferViewCB.setParent(this);
|
||||
createOfferViewCB.initWithData(direction, amount, price);
|
||||
createOfferViewCB.setCloseListener(this::onCreateOfferViewRemoved);
|
||||
final Tab tab = new Tab("Create offer");
|
||||
tab.setContent(createOfferView);
|
||||
tabPane.getTabs().add(tab);
|
||||
tabPane.getSelectionModel().select(tab);
|
||||
return createOfferViewCB;
|
||||
}
|
||||
else if (navigationItem == Navigation.Item.TAKE_OFFER && takeOfferViewCB == null &&
|
||||
offer != null) {
|
||||
// CreateOffer and TakeOffer must not be cached by ViewLoader as we cannot use a view multiple times
|
||||
// in different graphs
|
||||
ViewLoader loader = new ViewLoader(getClass().getResource(Navigation.Item.TAKE_OFFER.getFxmlUrl()), false);
|
||||
try {
|
||||
takeOfferView = loader.load();
|
||||
takeOfferViewCB = loader.getController();
|
||||
takeOfferViewCB.setParent(this);
|
||||
takeOfferViewCB.initWithData(direction, amount, offer);
|
||||
takeOfferViewCB.setCloseListener(this::onCreateOfferViewRemoved);
|
||||
final Tab tab = new Tab("Take offer");
|
||||
tab.setContent(takeOfferView);
|
||||
tabPane.getTabs().add(tab);
|
||||
tabPane.getSelectionModel().select(tab);
|
||||
return takeOfferViewCB;
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
ViewLoader loader = new ViewLoader(Navigation.Item.TAKE_OFFER, false);
|
||||
takeOfferView = loader.load();
|
||||
takeOfferViewCB = loader.getController();
|
||||
takeOfferViewCB.setParent(this);
|
||||
takeOfferViewCB.initWithData(direction, amount, offer);
|
||||
takeOfferViewCB.setCloseListener(this::onCreateOfferViewRemoved);
|
||||
final Tab tab = new Tab("Take offer");
|
||||
tab.setContent(takeOfferView);
|
||||
tabPane.getTabs().add(tab);
|
||||
tabPane.getSelectionModel().select(tab);
|
||||
return takeOfferViewCB;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ import io.bitsquare.btc.listeners.BalanceListener;
|
|||
import io.bitsquare.gui.UIModel;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import io.bitsquare.gui.util.validation.BtcValidator;
|
|||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.offer.Direction;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
|
|
@ -31,7 +31,7 @@ import io.bitsquare.gui.main.help.Help;
|
|||
import io.bitsquare.gui.main.help.HelpId;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.offer.Direction;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
|
|
@ -22,7 +22,7 @@ import io.bitsquare.locale.Country;
|
|||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OfferBookListener;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.gui.main.trade.offerbook;
|
||||
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
|
|
@ -22,9 +22,9 @@ import io.bitsquare.gui.UIModel;
|
|||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import io.bitsquare.gui.util.validation.InputValidator;
|
|||
import io.bitsquare.gui.util.validation.OptionalBtcValidator;
|
||||
import io.bitsquare.gui.util.validation.OptionalFiatValidator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
|
|
@ -28,8 +28,8 @@ import io.bitsquare.gui.util.validation.OptionalBtcValidator;
|
|||
import io.bitsquare.gui.util.validation.OptionalFiatValidator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ import io.bitsquare.btc.FeePolicy;
|
|||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.btc.listeners.BalanceListener;
|
||||
import io.bitsquare.gui.UIModel;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import io.bitsquare.gui.util.BSFormatter;
|
|||
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
|
|
@ -32,8 +32,8 @@ import io.bitsquare.gui.main.help.Help;
|
|||
import io.bitsquare.gui.main.help.HelpId;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ package io.bitsquare.gui.util;
|
|||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
|
|
@ -30,11 +30,6 @@ import org.slf4j.LoggerFactory;
|
|||
public class ImageUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(ImageUtil.class);
|
||||
|
||||
// System tray use AWT and there is no CSS support for loading retina supported images
|
||||
public static final String SYS_TRAY = "/images/system_tray_icon.png";
|
||||
public static final String SYS_TRAY_HI_RES = "/images/system_tray_icon@2x.png";
|
||||
|
||||
|
||||
public static final String REMOVE_ICON = "image-remove";
|
||||
public static final String EXPAND = "image-expand";
|
||||
public static final String COLLAPSE = "image-collapse";
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.google.common.base.Stopwatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.scene.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -56,14 +55,4 @@ public class Profiler {
|
|||
};
|
||||
fpsTimer.start();
|
||||
}
|
||||
|
||||
public static void initScene(Scene scene) {
|
||||
/* PerformanceTracker tracker = PerformanceTracker.getSceneTracker(scene);
|
||||
Timeline timeline = new Timeline(
|
||||
new KeyFrame(Duration.seconds(1), t -> {
|
||||
log.trace("FPS (tracker.getAverageFPS) = " + tracker.getAverageFPS());
|
||||
}));
|
||||
timeline.setCycleCount(Timeline.INDEFINITE);
|
||||
timeline.play();*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.msg;
|
||||
|
||||
import io.bitsquare.network.Node;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
@ -62,8 +63,6 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static io.bitsquare.msg.SeedNodeAddress.StaticSeedNodeAddresses;
|
||||
|
||||
/**
|
||||
* Creates a DHT peer and bootstrap to the network via a seed node
|
||||
*/
|
||||
|
@ -73,7 +72,7 @@ public class BootstrappedPeerFactory {
|
|||
|
||||
private KeyPair keyPair;
|
||||
private Storage storage;
|
||||
private final SeedNodeAddress seedNodeAddress;
|
||||
private final Node bootstrapNode;
|
||||
private final Persistence persistence;
|
||||
|
||||
private final SettableFuture<PeerDHT> settableFuture = SettableFuture.create();
|
||||
|
@ -85,10 +84,9 @@ public class BootstrappedPeerFactory {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public BootstrappedPeerFactory(Persistence persistence,
|
||||
@Named("defaultSeedNode") StaticSeedNodeAddresses defaultStaticSeedNodeAddresses) {
|
||||
public BootstrappedPeerFactory(Persistence persistence, @Named("bootstrapNode") Node bootstrapNode) {
|
||||
this.persistence = persistence;
|
||||
this.seedNodeAddress = new SeedNodeAddress(defaultStaticSeedNodeAddresses);
|
||||
this.bootstrapNode = bootstrapNode;
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,10 +301,10 @@ public class BootstrappedPeerFactory {
|
|||
|
||||
private PeerAddress getBootstrapAddress() {
|
||||
try {
|
||||
return new PeerAddress(Number160.createHash(seedNodeAddress.getId()),
|
||||
InetAddress.getByName(seedNodeAddress.getIp()),
|
||||
seedNodeAddress.getPort(),
|
||||
seedNodeAddress.getPort());
|
||||
return new PeerAddress(Number160.createHash(bootstrapNode.getId()),
|
||||
InetAddress.getByName(bootstrapNode.getIp()),
|
||||
bootstrapNode.getPort(),
|
||||
bootstrapNode.getPort());
|
||||
} catch (UnknownHostException e) {
|
||||
log.error("getBootstrapAddress failed: " + e.getMessage());
|
||||
return null;
|
||||
|
|
|
@ -22,17 +22,12 @@ import io.bitsquare.msg.actor.command.InitializePeer;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.tomp2p.peers.Number160;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
|
||||
public class DHTSeedService extends ActorService {
|
||||
|
||||
private static final List<SeedNodeAddress.StaticSeedNodeAddresses> staticSedNodeAddresses = SeedNodeAddress
|
||||
.StaticSeedNodeAddresses.getAllSeedNodeAddresses();
|
||||
|
||||
@Inject
|
||||
public DHTSeedService(ActorSystem system) {
|
||||
super(system, "/user/" + DHTManager.SEED_NAME);
|
||||
|
|
|
@ -17,8 +17,11 @@
|
|||
|
||||
package io.bitsquare.msg;
|
||||
|
||||
import io.bitsquare.di.AbstractBitsquareModule;
|
||||
import io.bitsquare.AbstractBitsquareModule;
|
||||
import io.bitsquare.network.BootstrapNode;
|
||||
import io.bitsquare.network.Node;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
import java.util.Properties;
|
||||
|
@ -39,8 +42,13 @@ public class DefaultMessageModule extends AbstractBitsquareModule implements Mes
|
|||
// we will probably later use disk storage instead of memory storage for TomP2P
|
||||
bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(false);
|
||||
|
||||
bind(SeedNodeAddress.StaticSeedNodeAddresses.class)
|
||||
.annotatedWith(Names.named("defaultSeedNode"))
|
||||
.toInstance(SeedNodeAddress.StaticSeedNodeAddresses.DIGITAL_OCEAN1);
|
||||
bind(Node.class)
|
||||
.annotatedWith(Names.named("bootstrapNode"))
|
||||
.toInstance(BootstrapNode.DIGITAL_OCEAN1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doClose(Injector injector) {
|
||||
injector.getInstance(MessageFacade.class).shutDown();
|
||||
}
|
||||
}
|
||||
|
|
21
src/main/java/io/bitsquare/msg/Message.java
Normal file
21
src/main/java/io/bitsquare/msg/Message.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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.msg;
|
||||
|
||||
public interface Message {
|
||||
}
|
|
@ -22,12 +22,11 @@ import io.bitsquare.msg.listeners.AddOfferListener;
|
|||
import io.bitsquare.msg.listeners.ArbitratorListener;
|
||||
import io.bitsquare.msg.listeners.BootstrapListener;
|
||||
import io.bitsquare.msg.listeners.GetPeerAddressListener;
|
||||
import io.bitsquare.msg.listeners.IncomingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.IncomingMessageListener;
|
||||
import io.bitsquare.msg.listeners.OfferBookListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.protocol.trade.TradeMessage;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
|
@ -37,15 +36,15 @@ import javafx.beans.property.LongProperty;
|
|||
|
||||
public interface MessageFacade extends MessageBroker {
|
||||
|
||||
void sendTradeMessage(Peer peer, TradeMessage tradeMessage, OutgoingTradeMessageListener listener);
|
||||
void sendMessage(Peer peer, Message message, OutgoingMessageListener listener);
|
||||
|
||||
void shutDown();
|
||||
|
||||
void addArbitrator(Arbitrator arbitrator);
|
||||
|
||||
void addIncomingTradeMessageListener(IncomingTradeMessageListener listener);
|
||||
void addIncomingMessageListener(IncomingMessageListener listener);
|
||||
|
||||
void removeIncomingTradeMessageListener(IncomingTradeMessageListener listener);
|
||||
void removeIncomingMessageListener(IncomingMessageListener listener);
|
||||
|
||||
void addOffer(Offer offer, AddOfferListener addOfferListener);
|
||||
|
||||
|
|
|
@ -1,168 +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.msg;
|
||||
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.msg.listeners.AddOfferListener;
|
||||
import io.bitsquare.msg.listeners.ArbitratorListener;
|
||||
import io.bitsquare.msg.listeners.BootstrapListener;
|
||||
import io.bitsquare.msg.listeners.GetPeerAddressListener;
|
||||
import io.bitsquare.msg.listeners.IncomingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OfferBookListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.protocol.trade.TradeMessage;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.LongProperty;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
|
||||
import net.tomp2p.dht.PeerDHT;
|
||||
|
||||
public class NoopMessageFacade implements MessageFacade {
|
||||
|
||||
private final List<IncomingTradeMessageListener> incomingTradeMessageListeners = new ArrayList<>();
|
||||
private final List<OfferBookListener> offerBookListeners = new ArrayList<>();
|
||||
private final LongProperty invalidationTimestamp = new SimpleLongProperty(0);
|
||||
private final P2PNode p2pNode;
|
||||
private final User user;
|
||||
|
||||
@Inject
|
||||
public NoopMessageFacade(User user, P2PNode p2pNode) {
|
||||
this.user = user;
|
||||
this.p2pNode = p2pNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTradeMessage(Peer peer, TradeMessage tradeMessage, OutgoingTradeMessageListener listener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArbitrator(Arbitrator arbitrator) {
|
||||
//throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIncomingTradeMessageListener(IncomingTradeMessageListener listener) {
|
||||
incomingTradeMessageListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeIncomingTradeMessageListener(IncomingTradeMessageListener listener) {
|
||||
incomingTradeMessageListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOffer(Offer offer, AddOfferListener addOfferListener) {
|
||||
//throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArbitratorListener(ArbitratorListener listener) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getArbitrators(Locale defaultLanguageLocale) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongProperty invalidationTimestampProperty() {
|
||||
return invalidationTimestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOfferBookListener(OfferBookListener offerBookListener) {
|
||||
offerBookListeners.add(offerBookListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOfferBookListener(OfferBookListener offerBookListener) {
|
||||
offerBookListeners.remove(offerBookListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestInvalidationTimeStampFromDHT(String fiatCode) {
|
||||
//throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOffers(String fiatCode) {
|
||||
//throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOffer(Offer offer) {
|
||||
//throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int clientPort, BootstrapListener bootstrapListener) {
|
||||
//System.out.println("DummyMessageFacade.init");
|
||||
//throw new UnsupportedOperationException();
|
||||
|
||||
p2pNode.setMessageBroker(this);
|
||||
p2pNode.setKeyPair(user.getMessageKeyPair());
|
||||
|
||||
p2pNode.start(clientPort, new FutureCallback<PeerDHT>() {
|
||||
@Override
|
||||
public void onSuccess(PeerDHT result) {
|
||||
Platform.runLater(bootstrapListener::onCompleted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
Platform.runLater(() -> bootstrapListener.onFailed(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPeerAddress(PublicKey messagePublicKey, GetPeerAddressListener getPeerAddressListener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Object message, Peer sender) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -1,91 +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.msg;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
// TODO Might be better with a config file
|
||||
public class SeedNodeAddress {
|
||||
private final String id;
|
||||
private final String ip;
|
||||
private final int port;
|
||||
|
||||
public SeedNodeAddress(StaticSeedNodeAddresses staticSeedNodeAddresses) {
|
||||
this(staticSeedNodeAddresses.getId(), staticSeedNodeAddresses.getIp(), staticSeedNodeAddresses.getPort());
|
||||
}
|
||||
|
||||
public SeedNodeAddress(String id, String ip, int port) {
|
||||
this.id = id;
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enum
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public enum StaticSeedNodeAddresses {
|
||||
// Manfreds server: "188.226.179.109"
|
||||
// Steves server: "128.199.251.106"
|
||||
DIGITAL_OCEAN1("digitalocean1.bitsquare.io", "188.226.179.109", 5000),
|
||||
LOCALHOST("localhost", "127.0.0.1", 5000);
|
||||
// DIGITAL_OCEAN2("digitalocean2.bitsquare.io", "128.199.251.106", 5000);
|
||||
//LOCALHOST("localhost", "127.0.0.1", 5000);
|
||||
|
||||
private final String id;
|
||||
private final String ip;
|
||||
private final int port;
|
||||
|
||||
StaticSeedNodeAddresses(String id, String ip, int port) {
|
||||
this.id = id;
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public static List<StaticSeedNodeAddresses> getAllSeedNodeAddresses() {
|
||||
return new ArrayList<>(Arrays.asList(StaticSeedNodeAddresses.values()));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,13 +22,12 @@ import io.bitsquare.msg.listeners.AddOfferListener;
|
|||
import io.bitsquare.msg.listeners.ArbitratorListener;
|
||||
import io.bitsquare.msg.listeners.BootstrapListener;
|
||||
import io.bitsquare.msg.listeners.GetPeerAddressListener;
|
||||
import io.bitsquare.msg.listeners.IncomingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.IncomingMessageListener;
|
||||
import io.bitsquare.msg.listeners.OfferBookListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.network.tomp2p.TomP2PPeer;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.protocol.trade.TradeMessage;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
|
@ -85,7 +84,7 @@ class TomP2PMessageFacade implements MessageFacade {
|
|||
|
||||
private final List<OfferBookListener> offerBookListeners = new ArrayList<>();
|
||||
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
|
||||
private final List<IncomingTradeMessageListener> incomingTradeMessageListeners = new ArrayList<>();
|
||||
private final List<IncomingMessageListener> incomingMessageListeners = new ArrayList<>();
|
||||
private final LongProperty invalidationTimestamp = new SimpleLongProperty(0);
|
||||
|
||||
|
||||
|
@ -317,12 +316,12 @@ class TomP2PMessageFacade implements MessageFacade {
|
|||
// Trade process
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void sendTradeMessage(Peer peer, TradeMessage tradeMessage,
|
||||
OutgoingTradeMessageListener listener) {
|
||||
public void sendMessage(Peer peer, Message message,
|
||||
OutgoingMessageListener listener) {
|
||||
if (!(peer instanceof TomP2PPeer)) {
|
||||
throw new IllegalArgumentException("peer must be of type TomP2PPeer") ;
|
||||
}
|
||||
FutureDirect futureDirect = p2pNode.sendData(((TomP2PPeer)peer).getPeerAddress(), tradeMessage);
|
||||
FutureDirect futureDirect = p2pNode.sendData(((TomP2PPeer)peer).getPeerAddress(), message);
|
||||
futureDirect.addListener(new BaseFutureListener<BaseFuture>() {
|
||||
@Override
|
||||
public void operationComplete(BaseFuture future) throws Exception {
|
||||
|
@ -469,12 +468,12 @@ class TomP2PMessageFacade implements MessageFacade {
|
|||
arbitratorListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void addIncomingTradeMessageListener(IncomingTradeMessageListener listener) {
|
||||
incomingTradeMessageListeners.add(listener);
|
||||
public void addIncomingMessageListener(IncomingMessageListener listener) {
|
||||
incomingMessageListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeIncomingTradeMessageListener(IncomingTradeMessageListener listener) {
|
||||
incomingTradeMessageListeners.remove(listener);
|
||||
public void removeIncomingMessageListener(IncomingMessageListener listener) {
|
||||
incomingMessageListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
|
@ -565,9 +564,9 @@ class TomP2PMessageFacade implements MessageFacade {
|
|||
|
||||
@Override
|
||||
public void handleMessage(Object message, Peer sender) {
|
||||
if (message instanceof TradeMessage) {
|
||||
Platform.runLater(() -> incomingTradeMessageListeners.stream().forEach(e ->
|
||||
e.onMessage((TradeMessage) message, sender)));
|
||||
if (message instanceof Message) {
|
||||
Platform.runLater(() -> incomingMessageListeners.stream().forEach(e ->
|
||||
e.onMessage((Message) message, sender)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
package io.bitsquare.msg.listeners;
|
||||
|
||||
import io.bitsquare.msg.Message;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.protocol.trade.TradeMessage;
|
||||
|
||||
public interface IncomingTradeMessageListener {
|
||||
void onMessage(TradeMessage tradeMessage, Peer sender);
|
||||
public interface IncomingMessageListener {
|
||||
void onMessage(Message message, Peer sender);
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.msg.listeners;
|
||||
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.msg.listeners;
|
||||
|
||||
public interface OutgoingTradeMessageListener {
|
||||
public interface OutgoingMessageListener {
|
||||
void onFailed();
|
||||
|
||||
void onResult();
|
|
@ -15,25 +15,33 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.account.registration.uimock;
|
||||
package io.bitsquare.network;
|
||||
|
||||
import java.net.URL;
|
||||
public enum BootstrapNode implements Node {
|
||||
DIGITAL_OCEAN1("digitalocean1.bitsquare.io", "188.226.179.109", 5000);
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
private final String id;
|
||||
private final String ip;
|
||||
private final int port;
|
||||
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
public class FundRegistrationWalletControllerUIMock implements Initializable {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
BootstrapNode(String id, String ip, int port) {
|
||||
this.id = id;
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,17 +15,15 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.di;
|
||||
package io.bitsquare.network;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
public interface Node {
|
||||
|
||||
import java.util.Properties;
|
||||
String getId();
|
||||
|
||||
public abstract class AbstractBitsquareModule extends AbstractModule {
|
||||
String getIp();
|
||||
|
||||
protected final Properties properties;
|
||||
int getPort();
|
||||
|
||||
public AbstractBitsquareModule(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade;
|
||||
package io.bitsquare.offer;
|
||||
|
||||
public enum Direction {
|
||||
BUY, SELL
|
|
@ -15,7 +15,7 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade;
|
||||
package io.bitsquare.offer;
|
||||
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.bank.BankAccountType;
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package io.bitsquare.persistence;
|
||||
|
||||
import io.bitsquare.Bitsquare;
|
||||
import io.bitsquare.util.FileUtil;
|
||||
|
||||
import org.bitcoinj.utils.Threading;
|
||||
|
@ -39,6 +38,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
import javax.annotation.concurrent.GuardedBy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -52,19 +52,20 @@ public class Persistence {
|
|||
private static final Logger log = LoggerFactory.getLogger(Persistence.class);
|
||||
private static final ReentrantLock lock = Threading.lock("Storage");
|
||||
|
||||
private final String prefix = Bitsquare.getAppName() + "_pref";
|
||||
private final File storageFile = FileUtil.getFile(prefix, "ser");
|
||||
|
||||
@GuardedBy("lock")
|
||||
private Map<String, Serializable> rootMap = new HashMap<>();
|
||||
|
||||
private final String prefix;
|
||||
private final File storageFile;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public Persistence() {
|
||||
public Persistence(@Named("appName") String appName) {
|
||||
this.prefix = appName + "_pref";
|
||||
this.storageFile = FileUtil.getFile(prefix, "ser");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package io.bitsquare.trade;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package io.bitsquare.trade;
|
||||
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
|
|
@ -20,8 +20,11 @@ package io.bitsquare.trade;
|
|||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.msg.Message;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.handlers.ErrorMessageHandler;
|
||||
|
@ -120,7 +123,7 @@ public class TradeManager {
|
|||
closedTrades.putAll((Map<String, Trade>) closedTradesObject);
|
||||
}
|
||||
|
||||
messageFacade.addIncomingTradeMessageListener(this::onIncomingTradeMessage);
|
||||
messageFacade.addIncomingMessageListener(this::onIncomingTradeMessage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,7 +132,7 @@ public class TradeManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void cleanup() {
|
||||
messageFacade.removeIncomingTradeMessageListener(this::onIncomingTradeMessage);
|
||||
messageFacade.removeIncomingMessageListener(this::onIncomingTradeMessage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -411,8 +414,11 @@ public class TradeManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Routes the incoming messages to the responsible protocol
|
||||
private void onIncomingTradeMessage(TradeMessage tradeMessage, Peer sender) {
|
||||
// log.trace("processTradingMessage TradeId " + tradeMessage.getTradeId());
|
||||
private void onIncomingTradeMessage(Message message, Peer sender) {
|
||||
if (!(message instanceof TradeMessage))
|
||||
throw new IllegalArgumentException("message must be of type TradeMessage");
|
||||
TradeMessage tradeMessage = (TradeMessage) message;
|
||||
|
||||
log.trace("onIncomingTradeMessage instance " + tradeMessage.getClass().getSimpleName());
|
||||
log.trace("onIncomingTradeMessage sender " + sender);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.trade;
|
||||
|
||||
import io.bitsquare.di.AbstractBitsquareModule;
|
||||
import io.bitsquare.AbstractBitsquareModule;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ package io.bitsquare.trade.protocol.createoffer;
|
|||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.handlers.FaultHandler;
|
||||
import io.bitsquare.trade.handlers.TransactionResultHandler;
|
||||
import io.bitsquare.trade.protocol.createoffer.tasks.BroadCastOfferFeeTx;
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.trade.protocol.createoffer.tasks;
|
|||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.AddOfferListener;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.handlers.FaultHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.createoffer.tasks;
|
||||
|
||||
import io.bitsquare.btc.Restrictions;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.handlers.FaultHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package io.bitsquare.trade.protocol.trade;
|
||||
|
||||
public interface TradeMessage {
|
||||
import io.bitsquare.msg.Message;
|
||||
|
||||
public interface TradeMessage extends Message {
|
||||
public String getTradeId();
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import io.bitsquare.btc.WalletFacade;
|
|||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.tasks.CreateDepositTx;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.tasks.HandleTakeOfferRequest;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.trade.protocol.trade.offerer;
|
||||
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
|
@ -39,7 +39,7 @@ public class HandleTakeOfferRequest {
|
|||
}
|
||||
RespondToTakeOfferRequestMessage tradeMessage =
|
||||
new RespondToTakeOfferRequestMessage(tradeId, takeOfferRequestAccepted);
|
||||
messageFacade.sendTradeMessage(peer, tradeMessage, new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("RespondToTakeOfferRequestMessage successfully arrived at peer");
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
|||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
@ -44,7 +44,7 @@ public class RequestTakerDepositPayment {
|
|||
log.trace("Run task");
|
||||
RequestTakerDepositPaymentMessage tradeMessage = new RequestTakerDepositPaymentMessage(
|
||||
tradeId, bankAccount, accountId, offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex);
|
||||
messageFacade.sendTradeMessage(peer, tradeMessage, new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("RequestTakerDepositPaymentMessage successfully arrived at peer");
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
@ -39,7 +39,7 @@ public class SendDepositTxIdToTaker {
|
|||
DepositTxPublishedMessage tradeMessage =
|
||||
new DepositTxPublishedMessage(tradeId, Utils.HEX.encode(depositTransaction.bitcoinSerialize()));
|
||||
|
||||
messageFacade.sendTradeMessage(peer, tradeMessage, new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("DepositTxPublishedMessage successfully arrived at peer");
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
|||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
@ -68,7 +68,7 @@ public class SendSignedPayoutTx {
|
|||
takerPaybackAmount,
|
||||
offererPayoutAddress);
|
||||
|
||||
messageFacade.sendTradeMessage(peer, tradeMessage, new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("BankTransferInitedMessage successfully arrived at peer");
|
||||
|
|
|
@ -19,8 +19,8 @@ package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
|||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import io.bitsquare.btc.WalletFacade;
|
|||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.BankTransferInitedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.DepositTxPublishedMessage;
|
||||
|
|
|
@ -19,8 +19,8 @@ package io.bitsquare.trade.protocol.trade.taker.tasks;
|
|||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
@ -33,8 +33,8 @@ public class RequestTakeOffer {
|
|||
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer,
|
||||
MessageFacade messageFacade, String tradeId) {
|
||||
log.trace("Run task");
|
||||
messageFacade.sendTradeMessage(peer, new RequestTakeOfferMessage(tradeId),
|
||||
new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, new RequestTakeOfferMessage(tradeId),
|
||||
new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("RequestTakeOfferMessage successfully arrived at peer");
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
@ -34,7 +34,7 @@ public class SendPayoutTxToOfferer {
|
|||
MessageFacade messageFacade, String tradeId, String payoutTxAsHex) {
|
||||
log.trace("Run task");
|
||||
PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(tradeId, payoutTxAsHex);
|
||||
messageFacade.sendTradeMessage(peer, tradeMessage, new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("PayoutTxPublishedMessage successfully arrived at peer");
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bitsquare.trade.protocol.trade.taker.tasks;
|
|||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
@ -68,7 +68,7 @@ public class SendSignedTakerDepositTxAsHex {
|
|||
walletFacade.getAddressInfoByTradeID(tradeId).getAddressString(),
|
||||
takerTxOutIndex,
|
||||
offererTxOutIndex);
|
||||
messageFacade.sendTradeMessage(peer, tradeMessage, new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("RequestOffererDepositPublicationMessage successfully arrived at peer");
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OutgoingMessageListener;
|
||||
import io.bitsquare.network.Peer;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
|
@ -44,7 +44,7 @@ public class SendTakeOfferFeePayedTxId {
|
|||
TakeOfferFeePayedMessage msg = new TakeOfferFeePayedMessage(tradeId, takeOfferFeeTxId, tradeAmount,
|
||||
pubKeyForThatTradeAsHex);
|
||||
|
||||
messageFacade.sendTradeMessage(peer, msg, new OutgoingTradeMessageListener() {
|
||||
messageFacade.sendMessage(peer, msg, new OutgoingMessageListener() {
|
||||
@Override
|
||||
public void onResult() {
|
||||
log.trace("TakeOfferFeePayedMessage successfully arrived at peer");
|
||||
|
|
|
@ -1,41 +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;
|
||||
|
||||
import io.bitsquare.btc.RestrictionsTest;
|
||||
import io.bitsquare.gui.main.trade.createoffer.CreateOfferPMTest;
|
||||
import io.bitsquare.gui.util.BSFormatterTest;
|
||||
import io.bitsquare.gui.util.validation.BtcValidatorTest;
|
||||
import io.bitsquare.gui.util.validation.FiatValidatorTest;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
RestrictionsTest.class,
|
||||
/* P2PNodeTest.class,*/
|
||||
FiatValidatorTest.class,
|
||||
RestrictionsTest.class,
|
||||
CreateOfferPMTest.class,
|
||||
BSFormatterTest.class,
|
||||
BtcValidatorTest.class
|
||||
})
|
||||
|
||||
public class BitsquareTestSuite {
|
||||
}
|
77
src/test/java/io/bitsquare/gui/ViewLoaderTest.java
Normal file
77
src/test/java/io/bitsquare/gui/ViewLoaderTest.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import io.bitsquare.app.BitsquareModule;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ViewLoaderTest {
|
||||
|
||||
public static class TestApp extends Application {
|
||||
static Stage primaryStage;
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
TestApp.primaryStage = primaryStage;
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void initJavaFX() throws InterruptedException {
|
||||
Thread t = new Thread("JavaFX Init Thread") {
|
||||
public void run() {
|
||||
Application.launch(TestApp.class);
|
||||
}
|
||||
};
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
while (TestApp.primaryStage == null)
|
||||
Thread.sleep(10);
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Injector injector = Guice.createInjector(new BitsquareModule(TestApp.primaryStage, "testApp"));
|
||||
ViewLoader.setInjector(injector);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ViewLoader.setInjector(null);
|
||||
}
|
||||
|
||||
@Test(expected = FatalException.class)
|
||||
public void loadingBogusFxmlResourceShouldThrow() {
|
||||
new ViewLoader(() -> "a bogus fxml resource", false).load();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadingValidFxmlResourceShouldNotThrow() {
|
||||
new ViewLoader(Navigation.Item.ACCOUNT, false).load();
|
||||
}
|
||||
}
|
|
@ -1,101 +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.main.account;
|
||||
|
||||
import io.bitsquare.di.BitsquareModule;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* For testing single isolated UI screens
|
||||
*/
|
||||
public class AccountSettingsUITestRunner extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(AccountSettingsUITestRunner.class);
|
||||
private Scene scene;
|
||||
private Pane view;
|
||||
private Pane pane;
|
||||
private boolean devTest = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
Injector injector = Guice.createInjector(new BitsquareModule());
|
||||
ViewLoader.setInjector(injector);
|
||||
|
||||
pane = new StackPane();
|
||||
scene = new Scene(pane, 1000, 630);
|
||||
scene.getAccelerators().put(KeyCombination.valueOf("Shortcut+S"), this::loadMainWindow);
|
||||
loadMainWindow();
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public void loadMainWindow() {
|
||||
log.debug("re load");
|
||||
pane.getChildren().removeAll();
|
||||
ViewLoader loader = new ViewLoader(
|
||||
getUrl("/io/bitsquare/gui/account/AccountSettingsView.fxml"), false);
|
||||
try {
|
||||
view = loader.load();
|
||||
pane.getChildren().setAll(view);
|
||||
refreshStylesheets();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshStylesheets() {
|
||||
scene.getStylesheets().clear();
|
||||
scene.getStylesheets().setAll(getUrl("/io/bitsquare/gui/bitsquare.css").toExternalForm());
|
||||
}
|
||||
|
||||
private URL getUrl(String subPath) {
|
||||
if (devTest) {
|
||||
try {
|
||||
// load from file system location to make a reload possible. makes dev process easier with hot reload
|
||||
return new URL("file:///Users/mk/Documents/_intellij/bitsquare/src/main/java" + subPath);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return getClass().getResource(subPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,101 +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.main.account;
|
||||
|
||||
import io.bitsquare.di.BitsquareModule;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* For testing single isolated UI screens
|
||||
*/
|
||||
public class AccountUITestRunner extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(AccountUITestRunner.class);
|
||||
private Scene scene;
|
||||
private Node view;
|
||||
private StackPane pane;
|
||||
private boolean devTest = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
Injector injector = Guice.createInjector(new BitsquareModule());
|
||||
ViewLoader.setInjector(injector);
|
||||
|
||||
pane = new StackPane();
|
||||
scene = new Scene(pane, 1000, 630);
|
||||
scene.getAccelerators().put(KeyCombination.valueOf("Shortcut+S"), this::loadMainWindow);
|
||||
loadMainWindow();
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public void loadMainWindow() {
|
||||
log.debug("re load");
|
||||
pane.getChildren().removeAll();
|
||||
ViewLoader loader = new ViewLoader(
|
||||
getUrl("/io/bitsquare/gui/account/AccountView.fxml"), false);
|
||||
try {
|
||||
view = loader.load();
|
||||
pane.getChildren().setAll(view);
|
||||
refreshStylesheets();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshStylesheets() {
|
||||
scene.getStylesheets().clear();
|
||||
scene.getStylesheets().setAll(getUrl("/io/bitsquare/gui/bitsquare.css").toExternalForm());
|
||||
}
|
||||
|
||||
private URL getUrl(String subPath) {
|
||||
if (devTest) {
|
||||
try {
|
||||
// load from file system location to make a reload possible. makes dev process easier with hot reload
|
||||
return new URL("file:///Users/mk/Documents/_intellij/bitsquare/src/main/java" + subPath);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return getClass().getResource(subPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,101 +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.main.account;
|
||||
|
||||
import io.bitsquare.di.BitsquareModule;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* For testing single isolated UI screens
|
||||
*/
|
||||
public class RegistrationUITestRunner extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(RegistrationUITestRunner.class);
|
||||
private Scene scene;
|
||||
private Node view;
|
||||
private StackPane pane;
|
||||
private boolean devTest = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
Injector injector = Guice.createInjector(new BitsquareModule());
|
||||
ViewLoader.setInjector(injector);
|
||||
|
||||
pane = new StackPane();
|
||||
scene = new Scene(pane, 1000, 630);
|
||||
scene.getAccelerators().put(KeyCombination.valueOf("Shortcut+S"), this::loadMainWindow);
|
||||
loadMainWindow();
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public void loadMainWindow() {
|
||||
log.debug("re load");
|
||||
pane.getChildren().removeAll();
|
||||
ViewLoader loader = new ViewLoader(
|
||||
getUrl("/io/bitsquare/gui/account/content/RegistrationView.fxml"), false);
|
||||
try {
|
||||
view = loader.load();
|
||||
pane.getChildren().setAll(view);
|
||||
refreshStylesheets();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshStylesheets() {
|
||||
scene.getStylesheets().clear();
|
||||
scene.getStylesheets().setAll(getUrl("/io/bitsquare/gui/bitsquare.css").toExternalForm());
|
||||
}
|
||||
|
||||
private URL getUrl(String subPath) {
|
||||
if (devTest) {
|
||||
try {
|
||||
// load from file system location to make a reload possible. makes dev process easier with hot reload
|
||||
return new URL("file:///Users/mk/Documents/_intellij/bitsquare/src/main/java" + subPath);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return getClass().getResource(subPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,101 +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.main.account;
|
||||
|
||||
import io.bitsquare.di.BitsquareModule;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* For testing single isolated UI screens
|
||||
*/
|
||||
public class SetupUITestRunner extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetupUITestRunner.class);
|
||||
private Scene scene;
|
||||
private Pane view;
|
||||
private Pane pane;
|
||||
private boolean devTest = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
Injector injector = Guice.createInjector(new BitsquareModule());
|
||||
ViewLoader.setInjector(injector);
|
||||
|
||||
pane = new StackPane();
|
||||
scene = new Scene(pane, 1000, 630);
|
||||
scene.getAccelerators().put(KeyCombination.valueOf("Shortcut+S"), this::loadMainWindow);
|
||||
loadMainWindow();
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public void loadMainWindow() {
|
||||
log.debug("re load");
|
||||
pane.getChildren().removeAll();
|
||||
ViewLoader loader = new ViewLoader(
|
||||
getUrl("/io/bitsquare/gui/account/setup/SetupView.fxml"), false);
|
||||
try {
|
||||
view = loader.load();
|
||||
pane.getChildren().setAll(view);
|
||||
refreshStylesheets();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshStylesheets() {
|
||||
scene.getStylesheets().clear();
|
||||
scene.getStylesheets().setAll(getUrl("/io/bitsquare/gui/bitsquare.css").toExternalForm());
|
||||
}
|
||||
|
||||
private URL getUrl(String subPath) {
|
||||
if (devTest) {
|
||||
try {
|
||||
// load from file system location to make a reload possible. makes dev process easier with hot reload
|
||||
return new URL("file:///Users/mk/Documents/_intellij/bitsquare/src/main/java" + subPath);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return getClass().getResource(subPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,104 +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.main.account.registration.uimock;
|
||||
|
||||
import io.bitsquare.di.BitsquareModule;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* For testing single isolated UI screens
|
||||
*/
|
||||
public class FundRegistrationWalletUIMockRunner extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(FundRegistrationWalletUIMockRunner.class);
|
||||
private Scene scene;
|
||||
private Parent view;
|
||||
private Pane pane;
|
||||
private boolean devTest = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
Injector injector = Guice.createInjector(new BitsquareModule());
|
||||
ViewLoader.setInjector(injector);
|
||||
|
||||
pane = new StackPane();
|
||||
scene = new Scene(pane, 1000, 650);
|
||||
scene.getAccelerators().put(KeyCombination.valueOf("Shortcut+S"), this::loadMainWindow);
|
||||
loadMainWindow();
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public void loadMainWindow() {
|
||||
log.debug("re load");
|
||||
pane.getChildren().removeAll();
|
||||
ViewLoader loader = new ViewLoader(
|
||||
getUrl("/io/bitsquare/gui/account/registration/uimock/FundRegistrationWalletViewUIMock.fxml"), false);
|
||||
|
||||
try {
|
||||
view = loader.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
pane.getChildren().setAll(view);
|
||||
refreshStylesheets();
|
||||
}
|
||||
|
||||
private void refreshStylesheets() {
|
||||
scene.getStylesheets().clear();
|
||||
scene.getStylesheets().setAll(getUrl("/io/bitsquare/gui/bitsquare.css").toExternalForm());
|
||||
}
|
||||
|
||||
private URL getUrl(String subPath) {
|
||||
if (devTest) {
|
||||
try {
|
||||
// load from file system location to make a reload possible. makes dev process easier with hot reload
|
||||
return new URL("file:///Users/mk/Documents/_intellij/bitsquare/src/test/java" + subPath);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return getClass().getResource(subPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
<?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.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<GridPane fx:id="root" hgap="5.0" stylesheets="@../../../../../../../java/io/bitsquare/gui/bitsquare.css"
|
||||
vgap="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
||||
AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="io.bitsquare.gui.main.account.registration.uimock.FundRegistrationWalletControllerUIMock">
|
||||
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="26.0"/>
|
||||
</padding>
|
||||
|
||||
<children>
|
||||
|
||||
<Pane id="form-group-background-active" fx:id="payFundsPane" visible="true" GridPane.columnSpan="3"
|
||||
GridPane.rowSpan="4">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="-10.0" left="-10.0" right="-10.0" top="-10.0"/>
|
||||
</GridPane.margin>
|
||||
<children>
|
||||
<Label id="form-group-title-active" fx:id="payFundsTitleLabel" layoutX="8" layoutY="-8"
|
||||
text="Pay in the registration fee">
|
||||
<padding>
|
||||
<Insets left="5" right="7"/>
|
||||
</padding>
|
||||
</Label>
|
||||
</children>
|
||||
</Pane>
|
||||
|
||||
<Label fx:id="totalToPayLabel" text="Registration fee:" visible="true">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<TextField fx:id="totalToPayTextField" editable="false" focusTraversable="false" text="0.0002 BTC"
|
||||
visible="true" GridPane.columnIndex="1" GridPane.columnSpan="2">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</TextField>
|
||||
|
||||
<Label fx:id="addressLabel" text="Registration BTC address:" visible="true" GridPane.rowIndex="1"/>
|
||||
<TextField fx:id="addressTextField" editable="false" focusTraversable="false"
|
||||
text="mkpymjfTk7WmG9YC4N9c9h1UzwPvMX3aNG" visible="true" GridPane.columnIndex="1"
|
||||
GridPane.columnSpan="2" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label fx:id="balanceLabel" text="Registration wallet balance:" visible="true" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="balanceTextField" editable="false" focusTraversable="false" text="0.00 BTC" visible="true"
|
||||
GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0"/>
|
||||
</GridPane.margin>
|
||||
</TextField>
|
||||
|
||||
<ImageView fx:id="payFundsInfoIcon" GridPane.rowSpan="2" fitHeight="24.0" fitWidth="24.0" pickOnBounds="true"
|
||||
preserveRatio="true"
|
||||
visible="true" GridPane.rowIndex="3" GridPane.valignment="TOP">
|
||||
<image>
|
||||
<Image fx:id="infoIcon" url="@../../../../../../../main/resources/images/info.png"/>
|
||||
</image>
|
||||
<GridPane.margin>
|
||||
<Insets right="2.0" top="4.0"/>
|
||||
</GridPane.margin>
|
||||
</ImageView>
|
||||
|
||||
<Label fx:id="payFundsInfoLabel" prefWidth="740.0"
|
||||
text="You need to pay in a minimal registration fee for storing the bank account data as identification in the Bitcoin block chain. This is needed as security measurement and will not leak and privacy. You need to wait for 1 confirmation before you can start active trading. Open the help menu for more information."
|
||||
visible="true" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
|
||||
<Button GridPane.columnIndex="1" GridPane.rowIndex="4" defaultButton="true"
|
||||
text="Complete registration" visible="true">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="30" top="20.0"/>
|
||||
</GridPane.margin>
|
||||
</Button>
|
||||
|
||||
|
||||
</children>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="200"/>
|
||||
<ColumnConstraints hgrow="ALWAYS"/>
|
||||
<ColumnConstraints hgrow="NEVER" prefWidth="25.0"/>
|
||||
</columnConstraints>
|
||||
|
||||
<rowConstraints>
|
||||
<RowConstraints/>
|
||||
<RowConstraints/>
|
||||
<RowConstraints/>
|
||||
<RowConstraints/>
|
||||
</rowConstraints>
|
||||
</GridPane>
|
|
@ -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.main.account.registration.uimock;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RegistrationControllerUIMock implements Initializable {
|
||||
private static final Logger log = LoggerFactory.getLogger(RegistrationControllerUIMock.class);
|
||||
public HBox prefBox;
|
||||
public Pane content;
|
||||
|
||||
|
||||
@Inject
|
||||
private RegistrationControllerUIMock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
prefBox.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent mouseEvent) {
|
||||
content.getChildren().remove(0);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue