mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 15:26:03 -04:00
add system try support, add address to create offer screen
This commit is contained in:
parent
01ca7d3e17
commit
65d97819ac
3
META-INF/MANIFEST.MF
Normal file
3
META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: io.bitsquare.BitSquare
|
||||
|
4
bitsquare.properties
Normal file
4
bitsquare.properties
Normal file
@ -0,0 +1,4 @@
|
||||
path.variable.maven_repository=/Users/mk/.m2/repository
|
||||
jdk.home.1.8=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
|
||||
idea.home=/Applications/_DEV/IntelliJ IDEA 13 CE.app
|
||||
javac2.instrumentation.includeJavaRuntime=false
|
489
bitsquare.xml
Normal file
489
bitsquare.xml
Normal file
@ -0,0 +1,489 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="bitsquare" default="all">
|
||||
|
||||
|
||||
<property file="bitsquare.properties"/>
|
||||
<!-- Uncomment the following property if no tests compilation is needed -->
|
||||
<!--
|
||||
<property name="skip.tests" value="true"/>
|
||||
-->
|
||||
|
||||
<!-- Compiler options -->
|
||||
|
||||
<property name="compiler.debug" value="on"/>
|
||||
<property name="compiler.generate.no.warnings" value="off"/>
|
||||
<property name="compiler.args" value=""/>
|
||||
<property name="compiler.max.memory" value="700m"/>
|
||||
<patternset id="ignored.files">
|
||||
<exclude name="**/CVS/**"/>
|
||||
<exclude name="**/SCCS/**"/>
|
||||
<exclude name="**/RCS/**"/>
|
||||
<exclude name="**/rcs/**"/>
|
||||
<exclude name="**/.DS_Store/**"/>
|
||||
<exclude name="**/.svn/**"/>
|
||||
<exclude name="**/.pyc/**"/>
|
||||
<exclude name="**/.pyo/**"/>
|
||||
<exclude name="**/*.pyc/**"/>
|
||||
<exclude name="**/*.pyo/**"/>
|
||||
<exclude name="**/.git/**"/>
|
||||
<exclude name="**/*.hprof/**"/>
|
||||
<exclude name="**/_svn/**"/>
|
||||
<exclude name="**/.hg/**"/>
|
||||
<exclude name="**/*.lib/**"/>
|
||||
<exclude name="**/*~/**"/>
|
||||
<exclude name="**/__pycache__/**"/>
|
||||
<exclude name="**/.bundle/**"/>
|
||||
<exclude name="**/*.rbc/**"/>
|
||||
</patternset>
|
||||
<patternset id="library.patterns">
|
||||
<include name="*.zip"/>
|
||||
<include name="*.apk"/>
|
||||
<include name="*.war"/>
|
||||
<include name="*.egg"/>
|
||||
<include name="*.ear"/>
|
||||
<include name="*.ane"/>
|
||||
<include name="*.swc"/>
|
||||
<include name="*.jar"/>
|
||||
</patternset>
|
||||
<patternset id="compiler.resources">
|
||||
<exclude name="**/?*.java"/>
|
||||
<exclude name="**/?*.form"/>
|
||||
<exclude name="**/?*.class"/>
|
||||
<exclude name="**/?*.groovy"/>
|
||||
<exclude name="**/?*.scala"/>
|
||||
<exclude name="**/?*.flex"/>
|
||||
<exclude name="**/?*.kt"/>
|
||||
<exclude name="**/?*.clj"/>
|
||||
</patternset>
|
||||
|
||||
<!-- JDK definitions -->
|
||||
|
||||
<property name="jdk.bin.1.8" value="${jdk.home.1.8}/bin"/>
|
||||
<path id="jdk.classpath.1.8">
|
||||
<fileset dir="${jdk.home.1.8}">
|
||||
<include name="lib/ant-javafx.jar"/>
|
||||
<include name="lib/dt.jar"/>
|
||||
<include name="lib/javafx-mx.jar"/>
|
||||
<include name="lib/jconsole.jar"/>
|
||||
<include name="lib/sa-jdi.jar"/>
|
||||
<include name="lib/tools.jar"/>
|
||||
<include name="jre/lib/charsets.jar"/>
|
||||
<include name="jre/lib/deploy.jar"/>
|
||||
<include name="jre/lib/htmlconverter.jar"/>
|
||||
<include name="jre/lib/javaws.jar"/>
|
||||
<include name="jre/lib/jce.jar"/>
|
||||
<include name="jre/lib/jfr.jar"/>
|
||||
<include name="jre/lib/jfxswt.jar"/>
|
||||
<include name="jre/lib/jsse.jar"/>
|
||||
<include name="jre/lib/management-agent.jar"/>
|
||||
<include name="jre/lib/plugin.jar"/>
|
||||
<include name="jre/lib/resources.jar"/>
|
||||
<include name="jre/lib/rt.jar"/>
|
||||
<include name="jre/lib/ext/cldrdata.jar"/>
|
||||
<include name="jre/lib/ext/dnsns.jar"/>
|
||||
<include name="jre/lib/ext/jfxrt.jar"/>
|
||||
<include name="jre/lib/ext/localedata.jar"/>
|
||||
<include name="jre/lib/ext/nashorn.jar"/>
|
||||
<include name="jre/lib/ext/sunec.jar"/>
|
||||
<include name="jre/lib/ext/sunjce_provider.jar"/>
|
||||
<include name="jre/lib/ext/sunpkcs11.jar"/>
|
||||
<include name="jre/lib/ext/zipfs.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<property name="project.jdk.home" value="${jdk.home.1.8}"/>
|
||||
<property name="project.jdk.bin" value="${jdk.bin.1.8}"/>
|
||||
<property name="project.jdk.classpath" value="jdk.classpath.1.8"/>
|
||||
|
||||
|
||||
<!-- Project Libraries -->
|
||||
|
||||
<path id="library.maven:_aopalliance:aopalliance:1.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/aopalliance/aopalliance/1.0/aopalliance-1.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_ch.qos.logback:logback-classic:1.1.2.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_ch.qos.logback:logback-core:1.1.2.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/ch/qos/logback/logback-core/1.1.2/logback-core-1.1.2.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google.code.findbugs:jsr305:2.0.3.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google.code.gson:gson:2.2.4.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google.guava:guava:16.0.1.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/guava/guava/16.0.1/guava-16.0.1.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google.inject:guice:no_aop:3.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/inject/guice/3.0/guice-3.0-no_aop.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google.protobuf:protobuf-java:2.5.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google.zxing:core:2.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/zxing/core/2.0/core-2.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google.zxing:javase:2.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/zxing/javase/2.0/javase-2.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.google:bitcoinj:0.11.3.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/google/bitcoinj/0.11.3/bitcoinj-0.11.3.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.lambdaworks:scrypt:1.3.3.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/lambdaworks/scrypt/1.3.3/scrypt-1.3.3.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/madgag/spongycastle/core/1.50.0.0/core-1.50.0.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_com.madgag:sc-light-jdk15on:1.47.0.2.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/com/madgag/sc-light-jdk15on/1.47.0.2/sc-light-jdk15on-1.47.0.2.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_de.jensd:fontawesomefx:8.0.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/de/jensd/fontawesomefx/8.0.0/fontawesomefx-8.0.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_io.netty:netty:3.5.3.patched.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/io/netty/netty/3.5.3.Patched/netty-3.5.3.Patched.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_javax.inject:javax.inject:1.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/javax/inject/javax.inject/1/javax.inject-1.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_jdbm:jdbm:3.0-alpha.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/jdbm/jdbm/3.0-alpha/jdbm-3.0-alpha.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_junit:junit:4.11.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/junit/junit/4.11/junit-4.11.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_net.glxn:qrgen:1.3.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/net/glxn/qrgen/1.3/qrgen-1.3.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_net.jcip:jcip-annotations:1.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_net.tomp2p:tomp2p:4.4.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/net/tomp2p/TomP2P/4.4/TomP2P-4.4.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_org.controlsfx:controlsfx:8.0.5.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/org/controlsfx/controlsfx/8.0.5/controlsfx-8.0.5.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_org.hamcrest:hamcrest-core:1.3.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_org.jetbrains:annotations:13.0.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/org/jetbrains/annotations/13.0/annotations-13.0.jar"/>
|
||||
</path>
|
||||
|
||||
<path id="library.maven:_org.slf4j:slf4j-api:1.7.7.classpath">
|
||||
<pathelement location="${path.variable.maven_repository}/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar"/>
|
||||
</path>
|
||||
<!-- Register Custom Compiler Taskdefs -->
|
||||
<property name="javac2.home" value="${idea.home}/lib"/>
|
||||
<path id="javac2.classpath">
|
||||
<pathelement location="${javac2.home}/javac2.jar"/>
|
||||
<pathelement location="${javac2.home}/jdom.jar"/>
|
||||
<pathelement location="${javac2.home}/asm4-all.jar"/>
|
||||
<pathelement location="${javac2.home}/jgoodies-forms.jar"/>
|
||||
</path>
|
||||
<target name="register.custom.compilers">
|
||||
<taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>
|
||||
<taskdef name="instrumentIdeaExtensions" classname="com.intellij.ant.InstrumentIdeaExtensions" classpathref="javac2.classpath"/>
|
||||
</target>
|
||||
|
||||
<!-- Modules -->
|
||||
|
||||
|
||||
<!-- Module bitsquare -->
|
||||
|
||||
<dirname property="module.bitsquare.basedir" file="${ant.file}"/>
|
||||
|
||||
|
||||
<property name="module.jdk.home.bitsquare" value="${project.jdk.home}"/>
|
||||
<property name="module.jdk.bin.bitsquare" value="${project.jdk.bin}"/>
|
||||
<property name="module.jdk.classpath.bitsquare" value="${project.jdk.classpath}"/>
|
||||
|
||||
<property name="compiler.args.bitsquare" value="-encoding UTF-8 -source 8 -target 1.8 ${compiler.args}"/>
|
||||
|
||||
<property name="bitsquare.output.dir" value="${module.bitsquare.basedir}/target/classes"/>
|
||||
<property name="bitsquare.testoutput.dir" value="${module.bitsquare.basedir}/target/test-classes"/>
|
||||
|
||||
<path id="bitsquare.module.bootclasspath">
|
||||
<!-- Paths to be included in compilation bootclasspath -->
|
||||
</path>
|
||||
|
||||
<path id="bitsquare.module.production.classpath">
|
||||
<path refid="${module.jdk.classpath.bitsquare}"/>
|
||||
<path refid="library.maven:_com.google:bitcoinj:0.11.3.classpath"/>
|
||||
<path refid="library.maven:_com.madgag:sc-light-jdk15on:1.47.0.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.protobuf:protobuf-java:2.5.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.guava:guava:16.0.1.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.findbugs:jsr305:2.0.3.classpath"/>
|
||||
<path refid="library.maven:_net.jcip:jcip-annotations:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.lambdaworks:scrypt:1.3.3.classpath"/>
|
||||
<path refid="library.maven:_org.slf4j:slf4j-api:1.7.7.classpath"/>
|
||||
<path refid="library.maven:_net.tomp2p:tomp2p:4.4.classpath"/>
|
||||
<path refid="library.maven:_io.netty:netty:3.5.3.patched.classpath"/>
|
||||
<path refid="library.maven:_jdbm:jdbm:3.0-alpha.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-classic:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-core:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.inject:guice:no_aop:3.0.classpath"/>
|
||||
<path refid="library.maven:_javax.inject:javax.inject:1.classpath"/>
|
||||
<path refid="library.maven:_aopalliance:aopalliance:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.gson:gson:2.2.4.classpath"/>
|
||||
<path refid="library.maven:_org.controlsfx:controlsfx:8.0.5.classpath"/>
|
||||
<path refid="library.maven:_de.jensd:fontawesomefx:8.0.0.classpath"/>
|
||||
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
|
||||
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
|
||||
</path>
|
||||
|
||||
<path id="bitsquare.runtime.production.module.classpath">
|
||||
<pathelement location="${bitsquare.output.dir}"/>
|
||||
<path refid="library.maven:_com.google:bitcoinj:0.11.3.classpath"/>
|
||||
<path refid="library.maven:_com.madgag:sc-light-jdk15on:1.47.0.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.protobuf:protobuf-java:2.5.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.guava:guava:16.0.1.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.findbugs:jsr305:2.0.3.classpath"/>
|
||||
<path refid="library.maven:_net.jcip:jcip-annotations:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.lambdaworks:scrypt:1.3.3.classpath"/>
|
||||
<path refid="library.maven:_org.slf4j:slf4j-api:1.7.7.classpath"/>
|
||||
<path refid="library.maven:_net.tomp2p:tomp2p:4.4.classpath"/>
|
||||
<path refid="library.maven:_io.netty:netty:3.5.3.patched.classpath"/>
|
||||
<path refid="library.maven:_jdbm:jdbm:3.0-alpha.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-classic:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-core:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.inject:guice:no_aop:3.0.classpath"/>
|
||||
<path refid="library.maven:_javax.inject:javax.inject:1.classpath"/>
|
||||
<path refid="library.maven:_aopalliance:aopalliance:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.gson:gson:2.2.4.classpath"/>
|
||||
<path refid="library.maven:_org.controlsfx:controlsfx:8.0.5.classpath"/>
|
||||
<path refid="library.maven:_de.jensd:fontawesomefx:8.0.0.classpath"/>
|
||||
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
|
||||
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
|
||||
</path>
|
||||
|
||||
<path id="bitsquare.module.classpath">
|
||||
<path refid="${module.jdk.classpath.bitsquare}"/>
|
||||
<pathelement location="${bitsquare.output.dir}"/>
|
||||
<path refid="library.maven:_com.google:bitcoinj:0.11.3.classpath"/>
|
||||
<path refid="library.maven:_com.madgag:sc-light-jdk15on:1.47.0.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.protobuf:protobuf-java:2.5.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.guava:guava:16.0.1.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.findbugs:jsr305:2.0.3.classpath"/>
|
||||
<path refid="library.maven:_net.jcip:jcip-annotations:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.lambdaworks:scrypt:1.3.3.classpath"/>
|
||||
<path refid="library.maven:_org.slf4j:slf4j-api:1.7.7.classpath"/>
|
||||
<path refid="library.maven:_net.tomp2p:tomp2p:4.4.classpath"/>
|
||||
<path refid="library.maven:_io.netty:netty:3.5.3.patched.classpath"/>
|
||||
<path refid="library.maven:_jdbm:jdbm:3.0-alpha.classpath"/>
|
||||
<path refid="library.maven:_junit:junit:4.11.classpath"/>
|
||||
<path refid="library.maven:_org.hamcrest:hamcrest-core:1.3.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-classic:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-core:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.inject:guice:no_aop:3.0.classpath"/>
|
||||
<path refid="library.maven:_javax.inject:javax.inject:1.classpath"/>
|
||||
<path refid="library.maven:_aopalliance:aopalliance:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.gson:gson:2.2.4.classpath"/>
|
||||
<path refid="library.maven:_org.controlsfx:controlsfx:8.0.5.classpath"/>
|
||||
<path refid="library.maven:_de.jensd:fontawesomefx:8.0.0.classpath"/>
|
||||
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
|
||||
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
|
||||
</path>
|
||||
|
||||
<path id="bitsquare.runtime.module.classpath">
|
||||
<pathelement location="${bitsquare.testoutput.dir}"/>
|
||||
<pathelement location="${bitsquare.output.dir}"/>
|
||||
<path refid="library.maven:_com.google:bitcoinj:0.11.3.classpath"/>
|
||||
<path refid="library.maven:_com.madgag:sc-light-jdk15on:1.47.0.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.protobuf:protobuf-java:2.5.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.guava:guava:16.0.1.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.findbugs:jsr305:2.0.3.classpath"/>
|
||||
<path refid="library.maven:_net.jcip:jcip-annotations:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.lambdaworks:scrypt:1.3.3.classpath"/>
|
||||
<path refid="library.maven:_org.slf4j:slf4j-api:1.7.7.classpath"/>
|
||||
<path refid="library.maven:_net.tomp2p:tomp2p:4.4.classpath"/>
|
||||
<path refid="library.maven:_io.netty:netty:3.5.3.patched.classpath"/>
|
||||
<path refid="library.maven:_jdbm:jdbm:3.0-alpha.classpath"/>
|
||||
<path refid="library.maven:_junit:junit:4.11.classpath"/>
|
||||
<path refid="library.maven:_org.hamcrest:hamcrest-core:1.3.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-classic:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_ch.qos.logback:logback-core:1.1.2.classpath"/>
|
||||
<path refid="library.maven:_com.google.inject:guice:no_aop:3.0.classpath"/>
|
||||
<path refid="library.maven:_javax.inject:javax.inject:1.classpath"/>
|
||||
<path refid="library.maven:_aopalliance:aopalliance:1.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.code.gson:gson:2.2.4.classpath"/>
|
||||
<path refid="library.maven:_org.controlsfx:controlsfx:8.0.5.classpath"/>
|
||||
<path refid="library.maven:_de.jensd:fontawesomefx:8.0.0.classpath"/>
|
||||
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
|
||||
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
|
||||
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
|
||||
</path>
|
||||
|
||||
|
||||
<patternset id="excluded.from.module.bitsquare">
|
||||
<patternset refid="ignored.files"/>
|
||||
</patternset>
|
||||
|
||||
<patternset id="excluded.from.compilation.bitsquare">
|
||||
<patternset refid="excluded.from.module.bitsquare"/>
|
||||
</patternset>
|
||||
|
||||
<path id="bitsquare.module.sourcepath">
|
||||
<dirset dir="${module.bitsquare.basedir}">
|
||||
<include name="src/main/java"/>
|
||||
<include name="src/main/resources"/>
|
||||
</dirset>
|
||||
</path>
|
||||
|
||||
<path id="bitsquare.module.test.sourcepath">
|
||||
<dirset dir="${module.bitsquare.basedir}">
|
||||
<include name="src/test/java"/>
|
||||
</dirset>
|
||||
</path>
|
||||
|
||||
|
||||
<target name="compile.module.bitsquare" depends="compile.module.bitsquare.production,compile.module.bitsquare.tests" description="Compile module bitsquare"/>
|
||||
|
||||
<target name="compile.module.bitsquare.production" depends="register.custom.compilers" description="Compile module bitsquare; production classes">
|
||||
<mkdir dir="${bitsquare.output.dir}"/>
|
||||
<javac2 destdir="${bitsquare.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.bitsquare}/javac">
|
||||
<compilerarg line="${compiler.args.bitsquare}"/>
|
||||
<bootclasspath refid="bitsquare.module.bootclasspath"/>
|
||||
<classpath refid="bitsquare.module.production.classpath"/>
|
||||
<src refid="bitsquare.module.sourcepath"/>
|
||||
<patternset refid="excluded.from.compilation.bitsquare"/>
|
||||
</javac2>
|
||||
|
||||
<copy todir="${bitsquare.output.dir}">
|
||||
<fileset dir="${module.bitsquare.basedir}/src/main/java">
|
||||
<patternset refid="compiler.resources"/>
|
||||
<type type="file"/>
|
||||
</fileset>
|
||||
<fileset dir="${module.bitsquare.basedir}/src/main/resources">
|
||||
<patternset refid="compiler.resources"/>
|
||||
<type type="file"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="compile.module.bitsquare.tests" depends="register.custom.compilers,compile.module.bitsquare.production" description="compile module bitsquare; test classes" unless="skip.tests">
|
||||
<mkdir dir="${bitsquare.testoutput.dir}"/>
|
||||
<javac2 destdir="${bitsquare.testoutput.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true"
|
||||
executable="${module.jdk.bin.bitsquare}/javac">
|
||||
<compilerarg line="${compiler.args.bitsquare}"/>
|
||||
<bootclasspath refid="bitsquare.module.bootclasspath"/>
|
||||
<classpath refid="bitsquare.module.classpath"/>
|
||||
<src refid="bitsquare.module.test.sourcepath"/>
|
||||
<patternset refid="excluded.from.compilation.bitsquare"/>
|
||||
</javac2>
|
||||
|
||||
<copy todir="${bitsquare.testoutput.dir}">
|
||||
<fileset dir="${module.bitsquare.basedir}/src/test/java">
|
||||
<patternset refid="compiler.resources"/>
|
||||
<type type="file"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="clean.module.bitsquare" description="cleanup module">
|
||||
<delete dir="${bitsquare.output.dir}"/>
|
||||
<delete dir="${bitsquare.testoutput.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="init" description="Build initialization">
|
||||
<!-- Perform any build initialization in this target -->
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="clean.module.bitsquare, clean.artifact.bitsquare" description="cleanup all"/>
|
||||
|
||||
<target name="build.modules" depends="init, clean, compile.module.bitsquare" description="build all modules"/>
|
||||
|
||||
<target name="init.artifacts">
|
||||
<property name="artifacts.temp.dir" value="${basedir}/__artifacts_temp"/>
|
||||
<property name="artifact.output.bitsquare" value="${basedir}/out/artifacts/bitsquare"/>
|
||||
<mkdir dir="${artifacts.temp.dir}"/>
|
||||
<property name="artifact.temp.output.bitsquare" value="${artifacts.temp.dir}/bitsquare.jar"/>
|
||||
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath="${jdk.home.1.8}/lib/ant-javafx.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="clean.artifact.bitsquare" description="clean bitsquare artifact output">
|
||||
<delete dir="${artifact.output.bitsquare}"/>
|
||||
</target>
|
||||
|
||||
<target name="artifact.bitsquare" depends="init.artifacts, compile.module.bitsquare" description="Build 'bitsquare' artifact" xmlns:fx="javafx:com.sun.javafx.tools.ant">
|
||||
<mkdir dir="${artifact.output.bitsquare}"/>
|
||||
<copy todir="${artifact.temp.output.bitsquare}">
|
||||
<fileset dir="${bitsquare.output.dir}"/>
|
||||
</copy>
|
||||
<fx:fileset id="all_but_bitsquare" dir="${artifact.temp.output.bitsquare}" includes="**/*.jar">
|
||||
<exclude name="bitsquare.jar"/>
|
||||
</fx:fileset>
|
||||
<fx:fileset id="all_bitsquare" dir="${artifact.temp.output.bitsquare}" includes="**/*.jar"/>
|
||||
<fx:application id="bitsquare_id" name="bitsquare" mainClass="io.bitsquare.BitSquare"/>
|
||||
<fx:jar destfile="${artifact.temp.output.bitsquare}/bitsquare.jar">
|
||||
<fx:application refid="bitsquare_id"/>
|
||||
<fileset dir="${artifact.temp.output.bitsquare}" excludes="**/*.jar"/>
|
||||
<fx:resources>
|
||||
<fx:fileset refid="all_but_bitsquare"/>
|
||||
</fx:resources>
|
||||
<manifest>
|
||||
<attribute name="" value=""/>
|
||||
</manifest>
|
||||
</fx:jar>
|
||||
<fx:deploy width="800" height="600" updatemode="background" outdir="${artifact.temp.output.bitsquare}/deploy" outfile="bitsquare" nativeBundles="all">
|
||||
<fx:application refid="bitsquare_id"/>
|
||||
<fx:info title="BitSquare" vendor="bitsquare.io" description="P2P Fiat-Bitcoin exchange"/>
|
||||
<fx:resources>
|
||||
<fx:fileset refid="all_bitsquare"/>
|
||||
</fx:resources>
|
||||
</fx:deploy>
|
||||
<copy todir="${artifact.output.bitsquare}">
|
||||
<fileset dir="${artifact.temp.output.bitsquare}/deploy"/>
|
||||
</copy>
|
||||
<delete includeemptydirs="true">
|
||||
<fileset dir="${artifact.temp.output.bitsquare}"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="build.all.artifacts" depends="artifact.bitsquare" description="Build all artifacts">
|
||||
|
||||
<!-- Delete temporary files -->
|
||||
<delete dir="${artifacts.temp.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="build.modules, build.all.artifacts" description="build all"/>
|
||||
</project>
|
20
pom.xml
20
pom.xml
@ -100,6 +100,7 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
@ -107,6 +108,11 @@
|
||||
<artifactId>bitcoinj</artifactId>
|
||||
<version>0.11.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.madgag</groupId>
|
||||
<artifactId>sc-light-jdk15on</artifactId>
|
||||
<version>1.47.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.tomp2p</groupId>
|
||||
@ -126,7 +132,18 @@
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.7</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.7</version>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
@ -134,6 +151,7 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
|
3
src/main/java/META-INF/MANIFEST.MF
Normal file
3
src/main/java/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: io.bitsquare.BitSquare
|
||||
|
@ -1,124 +1,157 @@
|
||||
package io.bitsquare;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.di.BitSquareModule;
|
||||
import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class BitSquare extends Application
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(BitSquare.class);
|
||||
public static String ID = "bitsquare";
|
||||
private static Stage stage;
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
log.debug("Startup: main");
|
||||
if (args != null && args.length > 0)
|
||||
{
|
||||
ID = args[0];
|
||||
}
|
||||
|
||||
launch(args);
|
||||
}
|
||||
|
||||
public static Stage getStage()
|
||||
{
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage)
|
||||
{
|
||||
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
|
||||
init(stage);
|
||||
}
|
||||
|
||||
private void init(Stage stage)
|
||||
{
|
||||
BitSquare.stage = stage;
|
||||
|
||||
log.debug("Startup: start");
|
||||
final Injector injector = Guice.createInjector(new BitSquareModule());
|
||||
|
||||
walletFacade = injector.getInstance(WalletFacade.class);
|
||||
messageFacade = injector.getInstance(MessageFacade.class);
|
||||
log.debug("Startup: messageFacade, walletFacade inited");
|
||||
|
||||
// apply stored data
|
||||
final User user = injector.getInstance(User.class);
|
||||
final Settings settings = injector.getInstance(Settings.class);
|
||||
final Storage storage = injector.getInstance(Storage.class);
|
||||
storage.init();
|
||||
user.updateFromStorage((User) storage.read(user.getClass().getName()));
|
||||
settings.updateFromStorage((Settings) storage.read(settings.getClass().getName()));
|
||||
|
||||
if (ID.isEmpty())
|
||||
{
|
||||
stage.setTitle("BitSquare");
|
||||
}
|
||||
else
|
||||
{
|
||||
stage.setTitle("BitSquare (" + ID + ")");
|
||||
}
|
||||
|
||||
GuiceFXMLLoader.setInjector(injector);
|
||||
|
||||
stage.setMinWidth(800);
|
||||
stage.setMinHeight(400);
|
||||
stage.setWidth(800);
|
||||
stage.setHeight(600);
|
||||
|
||||
try
|
||||
{
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final Parent mainView = loader.load();
|
||||
final Scene scene = new Scene(mainView, 800, 600);
|
||||
stage.setScene(scene);
|
||||
|
||||
final String bitsquare = getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm();
|
||||
scene.getStylesheets().setAll(bitsquare);
|
||||
|
||||
stage.show();
|
||||
log.debug("Startup: stage displayed");
|
||||
} catch (Exception e)
|
||||
{
|
||||
stage.show();
|
||||
Action response = Popups.openExceptionPopup(e);
|
||||
if (response == Dialog.Actions.OK)
|
||||
{
|
||||
Platform.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception
|
||||
{
|
||||
walletFacade.shutDown();
|
||||
messageFacade.shutDown();
|
||||
|
||||
super.stop();
|
||||
}
|
||||
}
|
||||
package io.bitsquare;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.di.BitSquareModule;
|
||||
import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.AWTSystemTray;
|
||||
import io.bitsquare.util.StorageDirectory;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.MenuBar;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyCodeCombination;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.Stage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class BitSquare extends Application
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(BitSquare.class);
|
||||
public static String ID = "bitsquare";
|
||||
private static Stage primaryStage;
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
log.debug("Startup: main");
|
||||
if (args != null && args.length > 0) ID = args[0];
|
||||
|
||||
launch(args);
|
||||
}
|
||||
|
||||
public static Stage getPrimaryStage()
|
||||
{
|
||||
return primaryStage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException
|
||||
{
|
||||
log.trace("Startup: start");
|
||||
BitSquare.primaryStage = primaryStage;
|
||||
|
||||
// use a local data dir as default storage dir (can be overwritten in the settings)
|
||||
// TODO save root preferences always in app dir top get preferred storage location
|
||||
StorageDirectory.setStorageDirectory(new File(StorageDirectory.getApplicationDirectory().getAbsolutePath() + "/data"));
|
||||
|
||||
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
|
||||
|
||||
// currently there is not SystemTray support for java fx (planned for version 3) so we use the old AWT
|
||||
AWTSystemTray.createSystemTray(primaryStage);
|
||||
|
||||
final Injector injector = Guice.createInjector(new BitSquareModule());
|
||||
|
||||
walletFacade = injector.getInstance(WalletFacade.class);
|
||||
messageFacade = injector.getInstance(MessageFacade.class);
|
||||
log.trace("Startup: messageFacade, walletFacade inited");
|
||||
|
||||
// apply stored data
|
||||
final User user = injector.getInstance(User.class);
|
||||
final Settings settings = injector.getInstance(Settings.class);
|
||||
final Storage storage = injector.getInstance(Storage.class);
|
||||
storage.init();
|
||||
user.updateFromStorage((User) storage.read(user.getClass().getName()));
|
||||
settings.updateFromStorage((Settings) storage.read(settings.getClass().getName()));
|
||||
|
||||
if (ID.isEmpty()) primaryStage.setTitle("BitSquare");
|
||||
else primaryStage.setTitle("BitSquare (" + ID + ")");
|
||||
|
||||
GuiceFXMLLoader.setInjector(injector);
|
||||
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final Parent mainView = loader.load();
|
||||
BorderPane rootPane = new BorderPane();
|
||||
rootPane.setTop(getMenuBar());
|
||||
rootPane.setCenter(mainView);
|
||||
|
||||
final Scene scene = new Scene(rootPane, 800, 600);
|
||||
scene.getStylesheets().setAll(getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm());
|
||||
|
||||
setupCloseHandlers(primaryStage, scene);
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setMinWidth(800);
|
||||
primaryStage.setMinHeight(400);
|
||||
primaryStage.setWidth(800);
|
||||
primaryStage.setHeight(600);
|
||||
|
||||
primaryStage.show();
|
||||
|
||||
log.debug("Startup: stage displayed");
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private MenuBar getMenuBar()
|
||||
{
|
||||
MenuBar menuBar = new MenuBar();
|
||||
menuBar.setUseSystemMenuBar(true);
|
||||
|
||||
Menu fileMenu = new Menu("_File");
|
||||
fileMenu.setMnemonicParsing(true);
|
||||
MenuItem backupMenuItem = new MenuItem("Backup wallet");
|
||||
fileMenu.getItems().addAll(backupMenuItem);
|
||||
|
||||
Menu settingsMenu = new Menu("_Settings");
|
||||
settingsMenu.setMnemonicParsing(true);
|
||||
MenuItem changePwMenuItem = new MenuItem("Change password");
|
||||
settingsMenu.getItems().addAll(changePwMenuItem);
|
||||
|
||||
Menu helpMenu = new Menu("_Help");
|
||||
helpMenu.setMnemonicParsing(true);
|
||||
MenuItem faqMenuItem = new MenuItem("FAQ");
|
||||
MenuItem forumMenuItem = new MenuItem("Forum");
|
||||
helpMenu.getItems().addAll(faqMenuItem, forumMenuItem);
|
||||
|
||||
menuBar.getMenus().setAll(fileMenu, settingsMenu, helpMenu);
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception
|
||||
{
|
||||
walletFacade.shutDown();
|
||||
messageFacade.shutDown();
|
||||
|
||||
super.stop();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,6 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||
try
|
||||
{
|
||||
BitSquareWalletAppKit.this.stopAsync();
|
||||
BitSquareWalletAppKit.this.awaitTerminated();
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* That facade delivers blockchain functionality from the bitcoinJ library
|
||||
|
@ -4,8 +4,8 @@ import com.google.bitcoin.core.Address;
|
||||
import com.google.bitcoin.core.AddressFormatException;
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
import java.math.BigInteger;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class BtcValidator
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.*;
|
||||
import com.google.inject.Inject;
|
||||
import java.math.BigInteger;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -13,7 +13,6 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.btc.listeners.BalanceListener;
|
||||
import io.bitsquare.btc.listeners.ConfidenceListener;
|
||||
@ -27,6 +26,7 @@ import java.util.stream.Collectors;
|
||||
import javafx.application.Platform;
|
||||
import javafx.util.Pair;
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -196,7 +196,6 @@ public class WalletFacade
|
||||
wallet.removeEventListener(walletEventListener);
|
||||
|
||||
walletAppKit.stopAsync();
|
||||
walletAppKit.awaitTerminated();
|
||||
}
|
||||
|
||||
public Wallet getWallet()
|
||||
@ -272,12 +271,10 @@ public class WalletFacade
|
||||
}
|
||||
|
||||
|
||||
AddressEntry getUnusedTradeAddressInfo()
|
||||
public AddressEntry getUnusedTradeAddressInfo()
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList),
|
||||
addressInfo -> (addressInfo != null && addressInfo.getAddressContext()
|
||||
.equals(AddressEntry.AddressContext.TRADE) && addressInfo
|
||||
.getTradeId() == null)));
|
||||
e -> (e != null && e.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && e.getTradeId() == null)));
|
||||
|
||||
if (filteredList != null && !filteredList.isEmpty())
|
||||
{
|
||||
@ -293,9 +290,7 @@ public class WalletFacade
|
||||
private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext)
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList),
|
||||
addressInfo -> (addressInfo != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext()
|
||||
.equals(addressContext)
|
||||
)));
|
||||
e -> (e != null && e.getAddressContext() != null && e.getAddressContext().equals(addressContext))));
|
||||
|
||||
if (filteredList != null && !filteredList.isEmpty())
|
||||
{
|
||||
@ -363,18 +358,16 @@ public class WalletFacade
|
||||
for (AddressEntry addressEntry : addressEntryList)
|
||||
{
|
||||
if (addressEntry.getAddressString().equals(address))
|
||||
{
|
||||
return addressEntry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TransactionConfidence
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public TransactionConfidence getConfidenceForAddress(Address address)
|
||||
{
|
||||
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
|
@ -3,8 +3,8 @@ package io.bitsquare.crypto;
|
||||
import com.google.bitcoin.core.ECKey;
|
||||
import com.google.bitcoin.core.Utils;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.inject.Inject;
|
||||
import java.security.SignatureException;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.google.bitcoin.params.MainNetParams;
|
||||
import com.google.bitcoin.params.RegTestParams;
|
||||
import com.google.bitcoin.params.TestNet3Params;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.name.Named;
|
||||
import com.google.inject.name.Names;
|
||||
@ -22,7 +21,8 @@ import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.FileUtil;
|
||||
import io.bitsquare.util.StorageDirectory;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class BitSquareModule extends AbstractModule
|
||||
{
|
||||
@ -68,7 +68,7 @@ class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit>
|
||||
|
||||
public BitSquareWalletAppKit get()
|
||||
{
|
||||
return new BitSquareWalletAppKit(networkParameters, FileUtil.getRootDirectory());
|
||||
return new BitSquareWalletAppKit(networkParameters, StorageDirectory.getStorageDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
@ -35,6 +34,7 @@ import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.StringConverter;
|
||||
import javax.inject.Inject;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -175,6 +175,7 @@ public class MainController implements Initializable, NavigationController
|
||||
|
||||
private void init()
|
||||
{
|
||||
|
||||
messageFacade.init();
|
||||
|
||||
trading.addTakeOfferRequestListener(this::onTakeOfferRequested);
|
||||
@ -196,7 +197,7 @@ public class MainController implements Initializable, NavigationController
|
||||
|
||||
walletFacade.initWallet();
|
||||
|
||||
buildNavigation();
|
||||
addNavigation();
|
||||
|
||||
Transitions.fadeOutAndRemove(loadingLabel);
|
||||
Transitions.fadeOutAndRemove(loadingBar);
|
||||
@ -214,7 +215,6 @@ public class MainController implements Initializable, NavigationController
|
||||
navigateToView(selectedNavigationItem);
|
||||
}
|
||||
|
||||
|
||||
private void onTakeOfferRequested(String offerId, PeerAddress sender)
|
||||
{
|
||||
final Button alertButton = new Button("", Icons.getIconImageView(Icons.MSG_ALERT));
|
||||
@ -228,7 +228,7 @@ public class MainController implements Initializable, NavigationController
|
||||
ordersButtonButtonHolder.getChildren().add(alertButton);
|
||||
}
|
||||
|
||||
private void buildNavigation()
|
||||
private void addNavigation()
|
||||
{
|
||||
homeButton = addNavButton(leftNavPane, "Overview", NavigationItem.HOME);
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ProgressBar?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="rootPane" id="root-pane" fx:controller="io.bitsquare.gui.MainController"
|
||||
stylesheets="/io/bitsquare/gui/bitsquare.css" xmlns="http://javafx.com/javafx/8">
|
||||
<AnchorPane fx:id="rootPane" id="root-pane" fx:controller="io.bitsquare.gui.MainController" stylesheets="/io/bitsquare/gui/bitsquare.css"
|
||||
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<HBox fx:id="leftNavPane" opacity="0" spacing="10" AnchorPane.leftAnchor="0" AnchorPane.topAnchor="0"/>
|
||||
<HBox fx:id="rightNavPane" opacity="0" spacing="10" AnchorPane.rightAnchor="10" AnchorPane.topAnchor="0"/>
|
||||
<AnchorPane fx:id="contentPane" id="content-pane" opacity="0" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="60"/>
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.arbitrators.overview;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
@ -26,6 +25,7 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import javax.inject.Inject;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.arbitrators.profile;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
@ -14,6 +13,7 @@ import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class ArbitratorProfileController implements Initializable, ChildController
|
||||
|
@ -5,7 +5,6 @@ import com.google.bitcoin.core.Transaction;
|
||||
import com.google.bitcoin.core.Wallet;
|
||||
import com.google.bitcoin.core.WalletEventListener;
|
||||
import com.google.bitcoin.script.Script;
|
||||
import com.google.inject.Inject;
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
@ -37,6 +36,7 @@ import javafx.scene.input.ClipboardContent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.StringConverter;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -71,6 +71,16 @@
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
#copy-icon {
|
||||
-fx-fill: black;
|
||||
-fx-cursor: hand;
|
||||
}
|
||||
|
||||
#copy-icon .hover{
|
||||
-fx-fill: #0096c9;
|
||||
-fx-cursor: hand;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
-fx-fill: #0096c9;
|
||||
-fx-cursor: hand;
|
||||
|
@ -0,0 +1,65 @@
|
||||
package io.bitsquare.gui.components.btc;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.input.Clipboard;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
public class AddressTextField extends AnchorPane
|
||||
{
|
||||
private final Label copyIcon;
|
||||
private final TextField addressTextField;
|
||||
private String address;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public AddressTextField()
|
||||
{
|
||||
addressTextField = new TextField();
|
||||
addressTextField.setEditable(false);
|
||||
|
||||
copyIcon = new Label();
|
||||
copyIcon.setLayoutY(3);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
if (address != null && address.length() > 0)
|
||||
{
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(address);
|
||||
clipboard.setContent(content);
|
||||
}
|
||||
});
|
||||
|
||||
Tooltip copyIconTooltip = new Tooltip("Copy address to clipboard");
|
||||
Tooltip.install(copyIcon, copyIconTooltip);
|
||||
|
||||
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||
copyIcon.setId("copy-icon");
|
||||
|
||||
AnchorPane.setRightAnchor(copyIcon, 5.0);
|
||||
AnchorPane.setRightAnchor(addressTextField, 35.0);
|
||||
AnchorPane.setLeftAnchor(addressTextField, 0.0);
|
||||
|
||||
getChildren().addAll(addressTextField, copyIcon);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public void setAddress(String address)
|
||||
{
|
||||
this.address = address;
|
||||
addressTextField.setText(address);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package io.bitsquare.gui.components.btc;
|
||||
|
||||
import com.google.bitcoin.core.Address;
|
||||
import com.google.bitcoin.core.TransactionConfidence;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.btc.listeners.BalanceListener;
|
||||
import io.bitsquare.btc.listeners.ConfidenceListener;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import java.math.BigInteger;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BalanceTextField extends AnchorPane
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(BalanceTextField.class);
|
||||
|
||||
private final TextField balanceTextField;
|
||||
private Address address;
|
||||
private final Tooltip progressIndicatorTooltip;
|
||||
private final ConfidenceProgressIndicator progressIndicator;
|
||||
private WalletFacade walletFacade;
|
||||
private ConfidenceListener confidenceListener;
|
||||
private BalanceListener balanceListener;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public BalanceTextField()
|
||||
{
|
||||
balanceTextField = new TextField();
|
||||
balanceTextField.setEditable(false);
|
||||
|
||||
progressIndicator = new ConfidenceProgressIndicator();
|
||||
progressIndicator.setPrefSize(24, 24);
|
||||
progressIndicator.setId("funds-confidence");
|
||||
progressIndicator.setLayoutY(1);
|
||||
progressIndicator.setProgress(0);
|
||||
progressIndicator.setVisible(false);
|
||||
|
||||
progressIndicatorTooltip = new Tooltip("-");
|
||||
Tooltip.install(progressIndicator, progressIndicatorTooltip);
|
||||
|
||||
AnchorPane.setRightAnchor(progressIndicator, 0.0);
|
||||
AnchorPane.setRightAnchor(balanceTextField, 35.0);
|
||||
AnchorPane.setLeftAnchor(balanceTextField, 0.0);
|
||||
|
||||
getChildren().addAll(balanceTextField, progressIndicator);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setAddress(Address address)
|
||||
{
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public void setWalletFacade(WalletFacade walletFacade)
|
||||
{
|
||||
this.walletFacade = walletFacade;
|
||||
confidenceListener = walletFacade.addConfidenceListener(new ConfidenceListener(address)
|
||||
{
|
||||
@Override
|
||||
public void onTransactionConfidenceChanged(TransactionConfidence confidence)
|
||||
{
|
||||
updateConfidence(confidence);
|
||||
}
|
||||
});
|
||||
updateConfidence(walletFacade.getConfidenceForAddress(address));
|
||||
|
||||
|
||||
balanceListener = walletFacade.addBalanceListener(new BalanceListener(address)
|
||||
{
|
||||
@Override
|
||||
public void onBalanceChanged(BigInteger balance)
|
||||
{
|
||||
updateBalance(balance);
|
||||
}
|
||||
});
|
||||
updateBalance(walletFacade.getBalanceForAddress(address));
|
||||
}
|
||||
|
||||
// TODO not called yet...
|
||||
public void cleanup()
|
||||
{
|
||||
walletFacade.removeConfidenceListener(confidenceListener);
|
||||
walletFacade.removeBalanceListener(balanceListener);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
private void updateConfidence(TransactionConfidence confidence)
|
||||
{
|
||||
if (confidence != null)
|
||||
{
|
||||
switch (confidence.getConfidenceType())
|
||||
{
|
||||
case UNKNOWN:
|
||||
progressIndicatorTooltip.setText("Unknown transaction status");
|
||||
progressIndicator.setProgress(0);
|
||||
break;
|
||||
case PENDING:
|
||||
progressIndicatorTooltip.setText("Seen by " + confidence.numBroadcastPeers() + " peer(s) / 0 confirmations");
|
||||
progressIndicator.setProgress(-1.0);
|
||||
break;
|
||||
case BUILDING:
|
||||
progressIndicatorTooltip.setText("Confirmed in " + confidence.getDepthInBlocks() + " block(s)");
|
||||
progressIndicator.setProgress(Math.min(1, (double) confidence.getDepthInBlocks() / 6.0));
|
||||
break;
|
||||
case DEAD:
|
||||
progressIndicatorTooltip.setText("Transaction is invalid.");
|
||||
progressIndicator.setProgress(0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (progressIndicator.getProgress() != 0)
|
||||
{
|
||||
progressIndicator.setVisible(true);
|
||||
AnchorPane.setRightAnchor(progressIndicator, 0.0);
|
||||
AnchorPane.setRightAnchor(balanceTextField, 35.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBalance(BigInteger balance)
|
||||
{
|
||||
if (balance != null)
|
||||
{
|
||||
balanceTextField.setText(BtcFormatter.formatSatoshis(balance));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.funds;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
@ -10,6 +9,7 @@ import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.funds.deposit;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
@ -21,6 +20,7 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.input.Clipboard;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import javafx.util.Callback;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.bitsquare.gui.funds.transactions;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
@ -17,6 +16,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.util.Callback;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -4,7 +4,6 @@ import com.google.bitcoin.core.AddressFormatException;
|
||||
import com.google.bitcoin.core.InsufficientMoneyException;
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.inject.Inject;
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bitsquare.btc.*;
|
||||
@ -27,6 +26,7 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.input.Clipboard;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import javafx.util.Callback;
|
||||
import javax.inject.Inject;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -43,8 +43,7 @@ public class WithdrawalListItem
|
||||
progressIndicator.setId("funds-confidence");
|
||||
tooltip = new Tooltip("Not used yet");
|
||||
progressIndicator.setProgress(0);
|
||||
progressIndicator.setPrefHeight(30);
|
||||
progressIndicator.setPrefWidth(30);
|
||||
progressIndicator.setPrefSize(24, 24);
|
||||
Tooltip.install(progressIndicator, tooltip);
|
||||
|
||||
confidenceListener = walletFacade.addConfidenceListener(new ConfidenceListener(getAddress())
|
||||
@ -112,8 +111,6 @@ public class WithdrawalListItem
|
||||
progressIndicator.setProgress(0);
|
||||
break;
|
||||
}
|
||||
|
||||
progressIndicator.setPrefSize(24, 24);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class HomeController implements Initializable, ChildController, Navigatio
|
||||
arbitratorRegistrationController = loader.getController();
|
||||
arbitratorRegistrationController.setNavigationController(this);
|
||||
|
||||
final Stage rootStage = BitSquare.getStage();
|
||||
final Stage rootStage = BitSquare.getPrimaryStage();
|
||||
final Stage stage = new Stage();
|
||||
stage.setTitle("Arbitrator");
|
||||
stage.setMinWidth(800);
|
||||
|
@ -3,8 +3,8 @@ package io.bitsquare.gui.market.createOffer;
|
||||
import com.google.bitcoin.core.InsufficientMoneyException;
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
@ -12,6 +12,8 @@ import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.components.btc.AddressTextField;
|
||||
import io.bitsquare.gui.components.btc.BalanceTextField;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.gui.util.BitSquareConverter;
|
||||
@ -36,6 +38,8 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javax.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -44,22 +48,21 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateOfferController.class);
|
||||
|
||||
private final Trading trading;
|
||||
|
||||
private final WalletFacade walletFacade;
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
private final User user;
|
||||
|
||||
private NavigationController navigationController;
|
||||
private Direction direction;
|
||||
private Offer offer;
|
||||
private AddressEntry addressEntry;
|
||||
|
||||
@FXML
|
||||
private AnchorPane rootContainer;
|
||||
@FXML
|
||||
private Label buyLabel, placeOfferTitle, confirmationLabel, txTitleLabel;
|
||||
@FXML
|
||||
private TextField volumeTextField, amountTextField, priceTextField;
|
||||
private TextField volumeTextField, amountTextField, priceTextField, totalTextField;
|
||||
@FXML
|
||||
private Button placeOfferButton, closeButton;
|
||||
@FXML
|
||||
@ -67,7 +70,8 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
acceptedLanguagesTextField, feeLabel, txTextField;
|
||||
@FXML
|
||||
private ConfidenceProgressIndicator progressIndicator;
|
||||
|
||||
@FXML private AddressTextField addressTextField;
|
||||
@FXML private BalanceTextField balanceTextField;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -96,7 +100,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
buyLabel.setText(BitSquareFormatter.formatDirection(direction, false) + ":");
|
||||
collateralTextField.setText(BitSquareFormatter.formatVolume(settings.getMinCollateral()));
|
||||
updateVolume();
|
||||
|
||||
updateTotals();
|
||||
|
||||
//TODO
|
||||
//amountTextField.setText("" + (int) (new Random().nextDouble() * 100 / 10 + 1));
|
||||
@ -105,8 +109,12 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
minAmountTextField.setText("0,1");
|
||||
collateralTextField.setText("10");
|
||||
updateVolume();
|
||||
updateTotals();
|
||||
|
||||
amountTextField.textProperty().addListener((observable, oldValue, newValue) -> updateVolume());
|
||||
amountTextField.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
updateVolume();
|
||||
updateTotals();
|
||||
});
|
||||
priceTextField.textProperty().addListener((observable, oldValue, newValue) -> updateVolume());
|
||||
}
|
||||
|
||||
@ -128,6 +136,12 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
acceptedCountriesTextField.setText(BitSquareFormatter.countryLocalesToString(settings.getAcceptedCountries()));
|
||||
acceptedLanguagesTextField.setText(BitSquareFormatter.languageLocalesToString(settings.getAcceptedLanguageLocales()));
|
||||
feeLabel.setText(BtcFormatter.formatSatoshis(FeePolicy.CREATE_OFFER_FEE));
|
||||
|
||||
addressEntry = walletFacade.getUnusedTradeAddressInfo();
|
||||
addressTextField.setAddress(addressEntry.getAddress().toString());
|
||||
|
||||
balanceTextField.setAddress(addressEntry.getAddress());
|
||||
balanceTextField.setWalletFacade(walletFacade);
|
||||
}
|
||||
|
||||
|
||||
@ -201,6 +215,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
settings.getAcceptedCountries(),
|
||||
settings.getAcceptedLanguageLocales());
|
||||
|
||||
addressEntry.setTradeId(offer.getId());
|
||||
|
||||
try
|
||||
{
|
||||
@ -215,7 +230,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
offer.setOfferFeePaymentTxID(transaction.getHashAsString());
|
||||
setupSuccessScreen(transaction);
|
||||
|
||||
placeOfferTitle.setText("Transaction sent:");
|
||||
// placeOfferTitle.setText("Transaction sent:");
|
||||
try
|
||||
{
|
||||
trading.addOffer(offer);
|
||||
@ -227,7 +242,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t)
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
{
|
||||
log.warn("sendResult onFailure:" + t);
|
||||
Popups.openErrorPopup("Fee payment failed", "Fee payment failed. " + t);
|
||||
@ -267,8 +282,16 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
closeButton.setVisible(true);
|
||||
|
||||
txTextField.setText(newTransaction.getHashAsString());
|
||||
}
|
||||
|
||||
// ConfidenceDisplay confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, newTransaction, progressIndicator);
|
||||
private void updateTotals()
|
||||
{
|
||||
double amountAsDouble = BitSquareConverter.stringToDouble(amountTextField.getText());
|
||||
double collateralPercentAsDouble = BitSquareConverter.stringToDouble(collateralTextField.getText());
|
||||
double collateralAmountAsDouble = collateralPercentAsDouble * amountAsDouble / 100;
|
||||
BigInteger collateral = BtcFormatter.doubleValueToSatoshis(collateralAmountAsDouble);
|
||||
BigInteger totals = FeePolicy.CREATE_OFFER_FEE.add(collateral);
|
||||
totalTextField.setText(BtcFormatter.formatSatoshis(totals));
|
||||
}
|
||||
|
||||
private void updateVolume()
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import io.bitsquare.gui.components.btc.AddressTextField?>
|
||||
<?import io.bitsquare.gui.components.btc.BalanceTextField?>
|
||||
<?import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
@ -8,6 +10,7 @@
|
||||
AnchorPane.topAnchor="10.0" xmlns="http://javafx.com/javafx/8" fx:controller="io.bitsquare.gui.market.createOffer.CreateOfferController">
|
||||
|
||||
<GridPane hgap="5.0" vgap="5.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
|
||||
|
||||
<Label id="form-header-text" text="Create new offer" GridPane.rowIndex="0"/>
|
||||
|
||||
<Label fx:id="buyLabel" GridPane.rowIndex="1"/>
|
||||
@ -27,50 +30,54 @@
|
||||
<Label text="Collateral (%):" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="collateralTextField" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<Label id="form-header-text" text="Offer details" GridPane.rowIndex="4">
|
||||
<Label text="Offer fee:" GridPane.rowIndex="4"/>
|
||||
<TextField fx:id="feeLabel" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||
|
||||
<Label text="Total BTC funds needed:" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="totalTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
|
||||
<Label text="BTC address for deposit:" GridPane.rowIndex="6"/>
|
||||
<AddressTextField fx:id="addressTextField" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
|
||||
|
||||
<Label text="Balance:" GridPane.rowIndex="7"/>
|
||||
<BalanceTextField fx:id="balanceTextField" GridPane.columnIndex="1" GridPane.rowIndex="7"/>
|
||||
|
||||
|
||||
<Label id="form-header-text" text="Offer details" GridPane.rowIndex="8">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
|
||||
<Label text="Bank account type:" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
<Label text="Bank account type:" GridPane.rowIndex="9"/>
|
||||
<TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
|
||||
|
||||
<Label text="Bank account currency:" GridPane.rowIndex="6"/>
|
||||
<TextField fx:id="bankAccountCurrencyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
|
||||
<Label text="Bank account currency:" GridPane.rowIndex="10"/>
|
||||
<TextField fx:id="bankAccountCurrencyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="10"/>
|
||||
|
||||
<Label text="Bank account county:" GridPane.rowIndex="7"/>
|
||||
<TextField fx:id="bankAccountCountyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="7"/>
|
||||
<Label text="Bank account county:" GridPane.rowIndex="11"/>
|
||||
<TextField fx:id="bankAccountCountyTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="11"/>
|
||||
|
||||
<Label text="Accepted countries:" GridPane.rowIndex="8"/>
|
||||
<TextField fx:id="acceptedCountriesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8"/>
|
||||
<Label text="Accepted countries:" GridPane.rowIndex="12"/>
|
||||
<TextField fx:id="acceptedCountriesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
|
||||
|
||||
<Label text="Accepted languages:" GridPane.rowIndex="9"/>
|
||||
<TextField fx:id="acceptedLanguagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
|
||||
<Label text="Accepted languages:" GridPane.rowIndex="13"/>
|
||||
<TextField fx:id="acceptedLanguagesTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="13"/>
|
||||
|
||||
|
||||
<Label id="form-header-text" fx:id="placeOfferTitle" text="Place offer:" GridPane.rowIndex="10">
|
||||
<GridPane.margin>
|
||||
<Insets top="10.0"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Button fx:id="placeOfferButton" defaultButton="true" onAction="#onPlaceOffer" text="Place offer" GridPane.columnIndex="1" GridPane.rowIndex="14"/>
|
||||
|
||||
<Label text="Offer fee:" GridPane.rowIndex="11"/>
|
||||
<TextField fx:id="feeLabel" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="11"/>
|
||||
|
||||
<Button fx:id="placeOfferButton" defaultButton="true" onAction="#onPlaceOffer" text="Place offer" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
|
||||
|
||||
<Label fx:id="txTitleLabel" text="Transaction ID:" visible="false" GridPane.rowIndex="12"/>
|
||||
<TextField fx:id="txTextField" visible="false" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
|
||||
<Label fx:id="txTitleLabel" text="Transaction ID:" visible="false" GridPane.rowIndex="15"/>
|
||||
<TextField fx:id="txTextField" visible="false" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="15"/>
|
||||
<ConfidenceProgressIndicator fx:id="progressIndicator" visible="false" progress="0" GridPane.columnIndex="2" GridPane.halignment="LEFT"
|
||||
GridPane.rowIndex="12" GridPane.rowSpan="2" GridPane.valignment="TOP">
|
||||
GridPane.rowIndex="15" GridPane.rowSpan="2" GridPane.valignment="TOP">
|
||||
<GridPane.margin>
|
||||
<Insets top="2.0"/>
|
||||
</GridPane.margin>
|
||||
</ConfidenceProgressIndicator>
|
||||
<Label fx:id="confirmationLabel" text="Checking confirmations..." visible="false" GridPane.columnIndex="3" GridPane.rowIndex="12"/>
|
||||
<Label fx:id="confirmationLabel" text="Checking confirmations..." visible="false" GridPane.columnIndex="3" GridPane.rowIndex="15"/>
|
||||
|
||||
<Button fx:id="closeButton" visible="false" defaultButton="true" onAction="#onClose" text="Close" GridPane.columnIndex="1" GridPane.rowIndex="13"/>
|
||||
<Button fx:id="closeButton" visible="false" defaultButton="true" onAction="#onClose" text="Close" GridPane.columnIndex="1" GridPane.rowIndex="16"/>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
|
||||
@ -78,26 +85,6 @@
|
||||
<ColumnConstraints hgrow="SOMETIMES" prefWidth="20.0" minWidth="20"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
<RowConstraints vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
<opaqueInsets>
|
||||
<Insets/>
|
||||
</opaqueInsets>
|
||||
|
||||
</GridPane>
|
||||
</AnchorPane>
|
||||
|
@ -3,7 +3,6 @@ package io.bitsquare.gui.market.orderbook;
|
||||
import com.google.bitcoin.core.InsufficientMoneyException;
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
@ -51,6 +50,7 @@ import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.util.Callback;
|
||||
import javax.inject.Inject;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.controlsfx.dialog.Dialogs;
|
||||
@ -321,22 +321,18 @@ public class OrderBookController implements Initializable, ChildController
|
||||
{
|
||||
if (isRegistered())
|
||||
{
|
||||
if (walletFacade.isUnusedTradeAddressBalanceAboveCreationFee())
|
||||
{
|
||||
ChildController nextController = navigationController.navigateToView(NavigationItem.CREATE_OFFER);
|
||||
if (nextController != null)
|
||||
{
|
||||
((CreateOfferController) nextController).setOrderBookFilter(orderBookFilter);
|
||||
}
|
||||
}
|
||||
/* if (walletFacade.isUnusedTradeAddressBalanceAboveCreationFee())
|
||||
{ */
|
||||
ChildController nextController = navigationController.navigateToView(NavigationItem.CREATE_OFFER);
|
||||
if (nextController != null)
|
||||
((CreateOfferController) nextController).setOrderBookFilter(orderBookFilter);
|
||||
/* }
|
||||
else
|
||||
{
|
||||
Action response = Popups.openErrorPopup("No funds for a trade", "You have to add some funds before you create a new offer.");
|
||||
if (response == Dialog.Actions.OK)
|
||||
{
|
||||
MainController.GET_INSTANCE().navigateToView(NavigationItem.FUNDS);
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
<Insets left="10" right="10" top="10" bottom="10"/>
|
||||
</padding>
|
||||
|
||||
<Label text="Take offer:" id="headline-label"/>
|
||||
<Label text="Take offer:" id="form-header-text"/>
|
||||
|
||||
<Label text="Amount (BTC):" GridPane.rowIndex="1"/>
|
||||
<ValidatedTextField fx:id="amountTextField" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
<Button fx:id="takeOfferButton" text="Take offer and pay" onAction="#onTakeOffer" defaultButton="true" GridPane.rowIndex="7" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Offer details:" id="headline-label" GridPane.rowIndex="8"/>
|
||||
<Label text="Offer details:" id="form-header-text" GridPane.rowIndex="8"/>
|
||||
|
||||
<Label text="Bank account type:" GridPane.rowIndex="9"/>
|
||||
<TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.rowIndex="9" GridPane.columnIndex="1"/>
|
||||
@ -88,7 +88,7 @@
|
||||
<Insets left="10" right="10" top="10" bottom="10"/>
|
||||
</padding>
|
||||
|
||||
<Label fx:id="headLineLabel" text="Deposit transaction published" id="headline-label"/>
|
||||
<Label fx:id="headLineLabel" text="Deposit transaction published" id="form-header-text"/>
|
||||
|
||||
<Label text="Status information:" GridPane.rowIndex="1" GridPane.valignment="TOP"/>
|
||||
<Label fx:id="infoLabel" GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.valignment="TOP"/>
|
||||
@ -120,7 +120,7 @@
|
||||
<Insets left="10" right="10" top="10" bottom="10"/>
|
||||
</padding>
|
||||
|
||||
<Label text="Trade completed" id="headline-label"/>
|
||||
<Label text="Trade completed" id="form-header-text"/>
|
||||
<Label text="Summary:" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="You have sold (BTC):" GridPane.rowIndex="2"/>
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.market.trade;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
@ -26,6 +25,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -1,488 +0,0 @@
|
||||
package io.bitsquare.gui.market.trade;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.components.processbar.ProcessStepBar;
|
||||
import io.bitsquare.gui.components.processbar.ProcessStepItem;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.gui.util.BitSquareConverter;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.gui.util.FormBuilder;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.util.Utilities;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
public class TakerTradeController implements Initializable, ChildController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerTradeController.class);
|
||||
|
||||
private final Trading trading;
|
||||
private final WalletFacade walletFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private final List<ProcessStepItem> processStepItems = new ArrayList<>();
|
||||
private Offer offer;
|
||||
private Trade trade;
|
||||
private BigInteger requestedAmount;
|
||||
private int row;
|
||||
private NavigationController navigationController;
|
||||
private TextField amountTextField, totalToPayLabel, totalLabel, collateralTextField, isOnlineTextField;
|
||||
private Label infoLabel;
|
||||
private Button nextButton;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
private AnimationTimer checkOnlineStatusTimer;
|
||||
private Pane isOnlineCheckerHolder;
|
||||
private Label headerLabel;
|
||||
|
||||
@FXML
|
||||
private AnchorPane rootContainer;
|
||||
@FXML
|
||||
private ProcessStepBar<String> processStepBar;
|
||||
@FXML
|
||||
private GridPane gridPane;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private TakerTradeController(Trading trading, WalletFacade walletFacade, MessageFacade messageFacade)
|
||||
{
|
||||
this.trading = trading;
|
||||
this.walletFacade = walletFacade;
|
||||
this.messageFacade = messageFacade;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void initWithData(Offer offer, BigInteger requestedAmount)
|
||||
{
|
||||
this.offer = offer;
|
||||
this.requestedAmount = requestedAmount.compareTo(BigInteger.ZERO) > 0 ? requestedAmount : offer.getAmount();
|
||||
|
||||
processStepItems.add(new ProcessStepItem(takerIsSelling() ? "Sell BTC" : "Buy BTC"));
|
||||
processStepItems.add(new ProcessStepItem("Bank transfer"));
|
||||
processStepItems.add(new ProcessStepItem("Completed"));
|
||||
processStepBar.setProcessStepItems(processStepItems);
|
||||
|
||||
buildTakeOfferScreen();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface implementation: Initializable
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface implementation: ChildController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
if (checkOnlineStatusTimer != null)
|
||||
{
|
||||
checkOnlineStatusTimer.stop();
|
||||
checkOnlineStatusTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
public void onPingPeerResult(boolean success)
|
||||
{
|
||||
setIsOnlineStatus(success);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// trade process
|
||||
private void buildTakeOfferScreen()
|
||||
{
|
||||
row = -1;
|
||||
|
||||
FormBuilder.addHeaderLabel(gridPane, "Take offer:", ++row);
|
||||
amountTextField = FormBuilder.addTextField(gridPane, "Amount (BTC):", BtcFormatter.formatSatoshis(requestedAmount), ++row, true, true);
|
||||
amountTextField.textProperty().addListener(e -> {
|
||||
applyVolume();
|
||||
applyCollateral();
|
||||
totalToPayLabel.setText(getTotalToPayAsString());
|
||||
|
||||
});
|
||||
Label amountRangeLabel = new Label("(" + BtcFormatter.formatSatoshis(offer.getMinAmount()) + " - " + BtcFormatter.formatSatoshis(offer.getAmount()) + ")");
|
||||
gridPane.add(amountRangeLabel, 2, row);
|
||||
|
||||
FormBuilder.addTextField(gridPane, "Price (" + offer.getCurrency() + "/BTC):", BitSquareFormatter.formatPrice(offer.getPrice()), ++row);
|
||||
totalLabel = FormBuilder.addTextField(gridPane, "Total (" + offer.getCurrency() + "):", BitSquareFormatter.formatVolume(getVolume()), ++row);
|
||||
collateralTextField = FormBuilder.addTextField(gridPane, "Collateral (BTC):", "", ++row);
|
||||
applyCollateral();
|
||||
FormBuilder.addTextField(gridPane, "Offer fee (BTC):", BtcFormatter.formatSatoshis(FeePolicy.TAKE_OFFER_FEE.add(FeePolicy.TX_FEE)), ++row);
|
||||
totalToPayLabel = FormBuilder.addTextField(gridPane, "Total to pay (BTC):", getTotalToPayAsString(), ++row);
|
||||
|
||||
isOnlineTextField = FormBuilder.addTextField(gridPane, "Online status:", "Checking offerers online status...", ++row);
|
||||
ConfidenceProgressIndicator isOnlineChecker = new ConfidenceProgressIndicator();
|
||||
isOnlineChecker.setPrefSize(20, 20);
|
||||
isOnlineChecker.setLayoutY(3);
|
||||
isOnlineCheckerHolder = new Pane();
|
||||
isOnlineCheckerHolder.getChildren().addAll(isOnlineChecker);
|
||||
gridPane.add(isOnlineCheckerHolder, 2, row);
|
||||
|
||||
//TODO
|
||||
// messageFacade.pingPeer(offer.getMessagePubKeyAsHex());
|
||||
checkOnlineStatusTimer = Utilities.setTimeout(1000, (AnimationTimer animationTimer) -> {
|
||||
setIsOnlineStatus(true);
|
||||
//noinspection ReturnOfNull
|
||||
return null;
|
||||
});
|
||||
|
||||
nextButton = FormBuilder.addButton(gridPane, "Take offer and pay", ++row);
|
||||
nextButton.setDefaultButton(true);
|
||||
nextButton.setOnAction(e -> takeOffer());
|
||||
|
||||
// details
|
||||
FormBuilder.addVSpacer(gridPane, ++row);
|
||||
FormBuilder.addHeaderLabel(gridPane, "Offerer details:", ++row);
|
||||
FormBuilder.addTextField(gridPane, "Bank account type:", offer.getBankAccountType().toString(), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Country:", offer.getBankAccountCountry().getName(), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Arbitrator:", offer.getArbitrator().getName(), ++row);
|
||||
Label arbitratorLink = new Label(offer.getArbitrator().getWebUrl());
|
||||
arbitratorLink.setId("label-url");
|
||||
gridPane.add(arbitratorLink, 2, row);
|
||||
arbitratorLink.setOnMouseClicked(e -> {
|
||||
try
|
||||
{
|
||||
if (offer.getArbitrator() != null && offer.getArbitrator().getWebUrl() != null)
|
||||
{
|
||||
Utilities.openURL(offer.getArbitrator().getWebUrl());
|
||||
}
|
||||
} catch (Exception e1)
|
||||
{
|
||||
log.warn(e1.toString());
|
||||
}
|
||||
});
|
||||
|
||||
FormBuilder.addTextField(gridPane, "Supported languages:", BitSquareFormatter.languageLocalesToString(offer.getAcceptedLanguageLocales()), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Supported countries:", BitSquareFormatter.countryLocalesToString(offer.getAcceptedCountries()), ++row);
|
||||
}
|
||||
|
||||
private void takeOffer()
|
||||
{
|
||||
if (!tradeAmountValid())
|
||||
{
|
||||
Popups.openErrorPopup("Your input is not valid", "The requested amount you entered is outside of the range of the offered amount.");
|
||||
return;
|
||||
}
|
||||
|
||||
// offerId = tradeId
|
||||
// we don't want to create the trade before the balance check
|
||||
AddressEntry addressEntry = walletFacade.getAddressInfoByTradeID(offer.getId());
|
||||
// log.debug("balance " + walletFacade.getBalanceForAddress(addressEntry.getAddress()).toString());
|
||||
if (getTotalToPay().compareTo(walletFacade.getBalanceForAddress(addressEntry != null ? addressEntry.getAddress() : null)) > 0)
|
||||
{
|
||||
Popups.openErrorPopup("Insufficient money", "You don't have enough funds for that trade.");
|
||||
return;
|
||||
}
|
||||
|
||||
//if (trading.isOfferAlreadyInTrades(offer))
|
||||
// {
|
||||
trade = trading.createTrade(offer);
|
||||
trade.setTradeAmount(BtcFormatter.stringValueToSatoshis(amountTextField.getText()));
|
||||
|
||||
/* if (!blockChainFacade.verifyAccountRegistration(offer.getTakerAccountId()))
|
||||
{
|
||||
Popups.openErrorPopup("Offerers account ID not valid", "Offerers registration tx is not found in blockchain or does not match the requirements.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockChainFacade.isAccountIDBlacklisted(offer.getTakerAccountId()))
|
||||
{
|
||||
Popups.openErrorPopup("Offerers account ID is blacklisted", "Offerers account ID is blacklisted.");
|
||||
return;
|
||||
} */
|
||||
|
||||
amountTextField.setEditable(false);
|
||||
|
||||
gridPane.getChildren().clear();
|
||||
|
||||
row = -1;
|
||||
FormBuilder.addHeaderLabel(gridPane, "Trade request inited", ++row, 0);
|
||||
|
||||
Label statusTextField = FormBuilder.addLabel(gridPane, "Current activity:", "Request confirmation from offerer to take that offer.", ++row);
|
||||
GridPane.setColumnSpan(statusTextField, 2);
|
||||
FormBuilder.addLabel(gridPane, "Progress:", "", ++row);
|
||||
progressBar = new ProgressBar();
|
||||
progressBar.setProgress(0.0);
|
||||
progressBar.setPrefWidth(300);
|
||||
GridPane.setFillWidth(progressBar, true);
|
||||
gridPane.add(progressBar, 1, row);
|
||||
|
||||
FormBuilder.addLabel(gridPane, "Status:", "", ++row);
|
||||
ConfidenceProgressIndicator progressIndicator = new ConfidenceProgressIndicator();
|
||||
progressIndicator.setPrefSize(20, 20);
|
||||
progressIndicator.setLayoutY(2);
|
||||
Pane progressIndicatorHolder = new Pane();
|
||||
progressIndicatorHolder.getChildren().addAll(progressIndicator);
|
||||
gridPane.add(progressIndicatorHolder, 1, row);
|
||||
|
||||
/*TakerPaymentProtocol takerPaymentProtocol = trading.addTakerPaymentProtocol(trade, new TakerPaymentProtocolListener()
|
||||
{
|
||||
@Override
|
||||
public void onProgress(double progress)
|
||||
{
|
||||
progressBar.setProgress(progress);
|
||||
|
||||
/*switch (state)
|
||||
{
|
||||
case FOUND_PEER_ADDRESS:
|
||||
statusTextField.setText("Peer found.");
|
||||
break;
|
||||
case SEND_TAKE_OFFER_REQUEST_ARRIVED:
|
||||
statusTextField.setText("Take offer request successfully sent to peer.");
|
||||
break;
|
||||
case SEND_TAKE_OFFER_REQUEST_ACCEPTED:
|
||||
statusTextField.setText("Take offer request accepted by peer.");
|
||||
break;
|
||||
case SEND_TAKE_OFFER_REQUEST_REJECTED:
|
||||
statusTextField.setText("Take offer request rejected by peer.");
|
||||
break;
|
||||
case INSUFFICIENT_MONEY_FOR_OFFER_FEE:
|
||||
Popups.openErrorPopup("Not enough money available", "There is not enough money available. Please pay in first to your wallet.");
|
||||
break;
|
||||
case OFFER_FEE_PAYED:
|
||||
statusTextField.setText("Offer fee payed. Send offerer payment transaction ID for confirmation.");
|
||||
break;
|
||||
} */
|
||||
/*
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String failureMessage)
|
||||
{
|
||||
log.warn(failureMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDepositTxPublishedMessage(String depositTxID)
|
||||
{
|
||||
buildDepositPublishedScreen(depositTxID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBankTransferInitedMessage(TradeMessage tradeMessage)
|
||||
{
|
||||
buildBankTransferInitedScreen(tradeMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPayoutTxPublished(String hashAsString)
|
||||
{
|
||||
showSummary(hashAsString);
|
||||
}
|
||||
});
|
||||
|
||||
takerPaymentProtocol.takeOffer(); */
|
||||
}
|
||||
//}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
private void updateTx(Trade trade)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buildDepositPublishedScreen(String depositTxID)
|
||||
{
|
||||
gridPane.getChildren().clear();
|
||||
|
||||
row = -1;
|
||||
headerLabel = FormBuilder.addHeaderLabel(gridPane, "Deposit transaction published", ++row, 0);
|
||||
infoLabel = FormBuilder.addLabel(gridPane, "Status:", "Deposit transaction published by offerer.\nAs soon as the offerer starts the \nBank transfer, you will get informed.", ++row);
|
||||
FormBuilder.addTextField(gridPane, "Transaction ID:", depositTxID, ++row, false, true);
|
||||
|
||||
// todo need to load that tx from blockchain, or listen to blockchain
|
||||
// confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, progressIndicator);
|
||||
}
|
||||
|
||||
private void buildBankTransferInitedScreen()
|
||||
{
|
||||
processStepBar.next();
|
||||
|
||||
headerLabel.setText("Bank transfer inited");
|
||||
infoLabel.setText("Check your bank account and continue \nwhen you have received the money.");
|
||||
gridPane.add(nextButton, 1, ++row);
|
||||
nextButton.setText("I have received the money at my bank");
|
||||
nextButton.setOnAction(e -> releaseBTC());
|
||||
}
|
||||
|
||||
private void releaseBTC()
|
||||
{
|
||||
processStepBar.next();
|
||||
trading.onFiatReceived(trade.getId());
|
||||
|
||||
nextButton.setText("Close");
|
||||
nextButton.setOnAction(e -> close());
|
||||
|
||||
gridPane.getChildren().clear();
|
||||
row = -1;
|
||||
FormBuilder.addHeaderLabel(gridPane, "Trade successfully completed", ++row);
|
||||
|
||||
String fiatReceived = BitSquareFormatter.formatVolume(trade.getOffer().getPrice() * BtcFormatter.satoshiToBTC(trade.getTradeAmount()));
|
||||
|
||||
FormBuilder.addTextField(gridPane, "You have sold (BTC):", BtcFormatter.formatSatoshis(trade.getTradeAmount()), ++row);
|
||||
if (takerIsSelling())
|
||||
{
|
||||
FormBuilder.addTextField(gridPane, "You have received (" + offer.getCurrency() + "):\"", fiatReceived, ++row);
|
||||
FormBuilder.addTextField(gridPane, "Total fees (take offer fee + tx fee):", BtcFormatter.formatSatoshis(FeePolicy.TAKE_OFFER_FEE.add(FeePolicy.TX_FEE)), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Refunded collateral:", BtcFormatter.formatSatoshis(trade.getCollateralAmount()), ++row);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
FormBuilder.addTextField(gridPane, "You got returned collateral (BTC):", BtcFormatter.formatSatoshis(getCollateralInSatoshis()), ++row);
|
||||
FormBuilder.addTextField(gridPane, "You have received (" + offer.getCurrency() + "):", BitSquareFormatter.formatVolume(getVolume()), ++row);
|
||||
FormBuilder.addTextField(gridPane, "You have received (BTC):", BtcFormatter.formatSatoshis(offer.getAmount()), ++row);
|
||||
}
|
||||
|
||||
gridPane.add(nextButton, 1, ++row);
|
||||
}
|
||||
|
||||
private void showSummary(String hashAsString)
|
||||
{
|
||||
gridPane.getChildren().clear();
|
||||
|
||||
}
|
||||
|
||||
private void close()
|
||||
{
|
||||
TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
|
||||
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
|
||||
|
||||
navigationController.navigateToView(NavigationItem.ORDER_BOOK);
|
||||
}
|
||||
|
||||
// Other Private methods
|
||||
private boolean tradeAmountValid()
|
||||
{
|
||||
BigInteger tradeAmount = BtcFormatter.stringValueToSatoshis(amountTextField.getText());
|
||||
return tradeAmount.compareTo(offer.getAmount()) <= 0 && tradeAmount.compareTo(offer.getMinAmount()) >= 0;
|
||||
}
|
||||
|
||||
private boolean takerIsSelling()
|
||||
{
|
||||
return offer.getDirection() == Direction.BUY;
|
||||
}
|
||||
|
||||
private void setIsOnlineStatus(boolean isOnline)
|
||||
{
|
||||
if (checkOnlineStatusTimer != null)
|
||||
{
|
||||
checkOnlineStatusTimer.stop();
|
||||
checkOnlineStatusTimer = null;
|
||||
}
|
||||
|
||||
//noinspection UnnecessaryLocalVariable
|
||||
boolean offererIsOnline = isOnline;
|
||||
isOnlineTextField.setText(offererIsOnline ? "Online" : "Offline");
|
||||
gridPane.getChildren().remove(isOnlineCheckerHolder);
|
||||
|
||||
isOnlineTextField.setId(isOnline ? "online-label" : "offline-label");
|
||||
isOnlineTextField.layout();
|
||||
}
|
||||
|
||||
private void applyVolume()
|
||||
{
|
||||
totalLabel.setText(BitSquareFormatter.formatVolume(getVolume(), offer.getCurrency()));
|
||||
}
|
||||
|
||||
private double getVolume()
|
||||
{
|
||||
return offer.getPrice() * BitSquareConverter.stringToDouble(amountTextField.getText());
|
||||
}
|
||||
|
||||
private String getTotalToPayAsString()
|
||||
{
|
||||
if (takerIsSelling())
|
||||
{
|
||||
return BtcFormatter.formatSatoshis(getTotalToPay());
|
||||
}
|
||||
else
|
||||
{
|
||||
return BtcFormatter.formatSatoshis(getTotalToPay()) + "\n" +
|
||||
BitSquareFormatter.formatVolume(getVolume(), offer.getCurrency());
|
||||
}
|
||||
}
|
||||
|
||||
private BigInteger getTotalToPay()
|
||||
{
|
||||
if (takerIsSelling())
|
||||
{
|
||||
return getAmountInSatoshis().add(FeePolicy.TAKE_OFFER_FEE).add(Transaction.MIN_NONDUST_OUTPUT).add(FeePolicy.TX_FEE).add(getCollateralInSatoshis());
|
||||
}
|
||||
else
|
||||
{
|
||||
return FeePolicy.TAKE_OFFER_FEE.add(Transaction.MIN_NONDUST_OUTPUT).add(FeePolicy.TX_FEE).add(getCollateralInSatoshis());
|
||||
}
|
||||
}
|
||||
|
||||
private void applyCollateral()
|
||||
{
|
||||
collateralTextField.setText(BtcFormatter.formatSatoshis(getCollateralInSatoshis()));
|
||||
}
|
||||
|
||||
private BigInteger getCollateralInSatoshis()
|
||||
{
|
||||
double amount = BitSquareConverter.stringToDouble(amountTextField.getText());
|
||||
double resultDouble = amount * (double) offer.getCollateral() / 100.0;
|
||||
return BtcFormatter.doubleValueToSatoshis(resultDouble);
|
||||
}
|
||||
|
||||
private BigInteger getAmountInSatoshis()
|
||||
{
|
||||
return BtcFormatter.stringValueToSatoshis(amountTextField.getText());
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import io.bitsquare.gui.components.processbar.ProcessStepBar?>
|
||||
<?import io.bitsquare.gui.components.VSpacer?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:id="rootContainer"
|
||||
fx:controller="io.bitsquare.gui.market.trade.TakerTradeController">
|
||||
<ScrollPane fitToWidth="true" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||
AnchorPane.bottomAnchor="0">
|
||||
|
||||
<VBox spacing="10">
|
||||
<padding>
|
||||
<Insets left="10" right="10" top="10" bottom="10"/>
|
||||
</padding>
|
||||
<ProcessStepBar fx:id="processStepBar"/>
|
||||
<VSpacer prefHeight="5"/>
|
||||
<GridPane fx:id="gridPane" vgap="5" hgap="5">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</padding>
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT"/>
|
||||
<ColumnConstraints halignment="LEFT" prefWidth="400"/>
|
||||
<ColumnConstraints halignment="LEFT"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
||||
</VBox>
|
||||
</ScrollPane>
|
||||
</AnchorPane>
|
@ -1,11 +1,11 @@
|
||||
package io.bitsquare.gui.msg;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.orders;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
@ -10,6 +9,7 @@ import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package io.bitsquare.gui.orders.closed;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
<Label id="headline-label" text="Closed"/>
|
||||
<Label id="form-header-text" text="Closed"/>
|
||||
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.orders.offer;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
@ -21,6 +20,7 @@ import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.util.Callback;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.google.bitcoin.core.Transaction;
|
||||
import com.google.bitcoin.core.Wallet;
|
||||
import com.google.bitcoin.core.WalletEventListener;
|
||||
import com.google.bitcoin.script.Script;
|
||||
import com.google.inject.Inject;
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
@ -30,8 +29,6 @@ import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
@ -46,6 +43,7 @@ import javafx.scene.input.ClipboardContent;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.Callback;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -260,14 +258,7 @@ public class PendingTradeController implements Initializable, ChildController, H
|
||||
Transaction transaction = trade.getDepositTransaction();
|
||||
if (transaction == null)
|
||||
{
|
||||
trade.getDepositTxChangedProperty().addListener(new ChangeListener<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2)
|
||||
{
|
||||
updateTx(trade.getDepositTransaction());
|
||||
}
|
||||
});
|
||||
trade.depositTxChangedProperty().addListener((observableValue, aBoolean, aBoolean2) -> updateTx(trade.getDepositTransaction()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -281,25 +272,11 @@ public class PendingTradeController implements Initializable, ChildController, H
|
||||
}
|
||||
else
|
||||
{
|
||||
trade.getContractChangedProperty().addListener(new ChangeListener<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2)
|
||||
{
|
||||
setBankData(trade);
|
||||
}
|
||||
});
|
||||
trade.contractChangedProperty().addListener((observableValue, aBoolean, aBoolean2) -> setBankData(trade));
|
||||
}
|
||||
|
||||
// state
|
||||
trade.getStateChangedProperty().addListener(new ChangeListener<String>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends String> observableValue, String aString, String aString2)
|
||||
{
|
||||
setState(trade);
|
||||
}
|
||||
});
|
||||
trade.stateChangedProperty().addListener((observableValue, aString, aString2) -> setState(trade));
|
||||
}
|
||||
|
||||
private void setState(Trade trade)
|
||||
|
@ -52,7 +52,7 @@
|
||||
<GridPane hgap="5.0" vgap="5.0">
|
||||
|
||||
<!-- row 0 -->
|
||||
<Label fx:id="txHeaderLabel" id="headline-label" text="Deposit transaction" GridPane.columnSpan="2" GridPane.halignment="LEFT"/>
|
||||
<Label fx:id="txHeaderLabel" id="form-header-text" text="Deposit transaction" GridPane.columnSpan="2" GridPane.halignment="LEFT"/>
|
||||
|
||||
<!-- row 1 -->
|
||||
<Label fx:id="txTitleLabel" text="Deposit transaction ID:" GridPane.rowIndex="1"/>
|
||||
@ -74,7 +74,7 @@
|
||||
<Label fx:id="confirmationLabel" visible="false" GridPane.columnIndex="4" GridPane.rowIndex="1"/>
|
||||
|
||||
<!-- row 2 -->
|
||||
<Label fx:id="bankAccountDetailsHeaderLabel" id="headline-label" text="Bank details" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="LEFT"
|
||||
<Label fx:id="bankAccountDetailsHeaderLabel" id="form-header-text" text="Bank details" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="LEFT"
|
||||
GridPane.rowIndex="2"/>
|
||||
|
||||
<!-- row 3 -->
|
||||
|
@ -22,7 +22,7 @@ public class Popups
|
||||
|
||||
public static void openInformationPopup(String title, String message, String masthead)
|
||||
{
|
||||
Dialogs.create().owner(BitSquare.getStage()).title(title).message(message).masthead(masthead).showInformation();
|
||||
Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead).showInformation();
|
||||
}
|
||||
|
||||
// Confirm
|
||||
@ -36,7 +36,7 @@ public class Popups
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(Dialog.Actions.OK);
|
||||
actions.add(Dialog.Actions.CANCEL);
|
||||
return Dialogs.create().owner(BitSquare.getStage()).title(title).message(message).masthead(masthead).actions(actions).showConfirm();
|
||||
return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead).actions(actions).showConfirm();
|
||||
}
|
||||
|
||||
// Warning
|
||||
@ -52,7 +52,7 @@ public class Popups
|
||||
|
||||
public static void openWarningPopup(String title, String message, String masthead)
|
||||
{
|
||||
Dialogs.create().owner(BitSquare.getStage()).title(title).message(message).masthead(masthead).showWarning();
|
||||
Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead).showWarning();
|
||||
}
|
||||
|
||||
// Error
|
||||
@ -68,7 +68,7 @@ public class Popups
|
||||
|
||||
public static Action openErrorPopup(String title, String message, String masthead)
|
||||
{
|
||||
return Dialogs.create().owner(BitSquare.getStage()).title(title).message(message).masthead(masthead).showError();
|
||||
return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead).showError();
|
||||
}
|
||||
|
||||
// Exception
|
||||
@ -84,7 +84,7 @@ public class Popups
|
||||
|
||||
public static Action openExceptionPopup(Throwable throwable, String title, String message, String masthead)
|
||||
{
|
||||
return Dialogs.create().owner(BitSquare.getStage()).title(title).message(message).masthead(masthead).showException(throwable);
|
||||
return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead).showException(throwable);
|
||||
}
|
||||
|
||||
// Support handling of uncaught exception from any thread (also non gui thread)
|
||||
@ -98,34 +98,17 @@ public class Popups
|
||||
if (Throwables.getRootCause(throwable) instanceof BlockStoreException)
|
||||
{
|
||||
Action response = Popups.openErrorPopup("Application already running", "This application is already running and cannot be started twice.", "");
|
||||
if (response == Dialog.Actions.OK)
|
||||
{
|
||||
Platform.exit();
|
||||
}
|
||||
if (response == Dialog.Actions.OK) Platform.exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
Action response = Popups.openExceptionPopup(throwable,
|
||||
"Exception",
|
||||
"",
|
||||
"A critical error has occurred.\nPlease copy the exception details and send a bug report to bugs@bitsquare.io.");
|
||||
if (response == Dialog.Actions.OK)
|
||||
{
|
||||
Platform.exit();
|
||||
}
|
||||
Action response = Popups.openExceptionPopup(throwable, "Exception", "", "A critical error has occurred.\nPlease copy the exception details and send a bug report to bugs@bitsquare.io.");
|
||||
if (response == Dialog.Actions.OK) Platform.exit();
|
||||
}
|
||||
};
|
||||
|
||||
if (Platform.isFxApplicationThread())
|
||||
{
|
||||
runnable.run();
|
||||
}
|
||||
else
|
||||
{
|
||||
Platform.runLater(runnable);
|
||||
}
|
||||
|
||||
|
||||
if (Platform.isFxApplicationThread()) runnable.run();
|
||||
else Platform.runLater(runnable);
|
||||
}
|
||||
|
||||
// custom
|
||||
@ -136,6 +119,6 @@ public class Popups
|
||||
|
||||
public static Action openRegistrationMissingPopup(String title, String message, String masthead, List<Dialogs.CommandLink> commandLinks, int selectedIndex)
|
||||
{
|
||||
return Dialogs.create().owner(BitSquare.getStage()).title(title).message(message).masthead(masthead).showCommandLinks(commandLinks.get(selectedIndex), commandLinks);
|
||||
return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead).showCommandLinks(commandLinks.get(selectedIndex), commandLinks);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.gui.settings;
|
||||
|
||||
import com.google.bitcoin.core.ECKey;
|
||||
import com.google.bitcoin.core.Utils;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
@ -38,6 +37,7 @@ import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.StringConverter;
|
||||
import javax.inject.Inject;
|
||||
|
||||
// TODO separate in 2 view/controllers
|
||||
public class SettingsController implements Initializable, ChildController, NavigationController
|
||||
@ -217,7 +217,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
childController = loader.getController();
|
||||
childController.setNavigationController(this);
|
||||
|
||||
final Stage rootStage = BitSquare.getStage();
|
||||
final Stage rootStage = BitSquare.getPrimaryStage();
|
||||
final Stage stage = new Stage();
|
||||
stage.setTitle("Arbitrator selection");
|
||||
stage.setMinWidth(800);
|
||||
|
@ -1,12 +1,11 @@
|
||||
package io.bitsquare.msg;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.msg.listeners.*;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
import io.bitsquare.util.FileUtil;
|
||||
import io.bitsquare.util.StorageDirectory;
|
||||
import java.io.IOException;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PublicKey;
|
||||
@ -14,6 +13,7 @@ import java.util.*;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javax.inject.Inject;
|
||||
import net.tomp2p.connection.Bindings;
|
||||
import net.tomp2p.connection.PeerConnection;
|
||||
import net.tomp2p.futures.*;
|
||||
@ -665,7 +665,7 @@ public class MessageFacade
|
||||
|
||||
private void setupStorage()
|
||||
{
|
||||
myPeer.getPeerBean().setStorage(new StorageDisk(FileUtil.getDirectory(BitSquare.ID + "_tomP2P").getAbsolutePath()));
|
||||
myPeer.getPeerBean().setStorage(new StorageDisk(StorageDirectory.getStorageDirectory().getAbsolutePath() + "/" + BitSquare.ID + "_tomP2P"));
|
||||
}
|
||||
|
||||
private void saveMyAddressToDHT() throws IOException
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.settings;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import java.io.Serializable;
|
||||
@ -8,6 +7,7 @@ import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Settings implements Serializable
|
||||
{
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.storage;
|
||||
|
||||
import com.google.bitcoin.core.Utils;
|
||||
import com.google.bitcoin.utils.Threading;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.util.FileUtil;
|
||||
import java.io.*;
|
||||
@ -11,6 +10,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -9,10 +9,7 @@ import javafx.beans.property.SimpleStringProperty;
|
||||
public class Trade implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -8275323072940974077L;
|
||||
transient private final SimpleBooleanProperty depositTxChangedProperty = new SimpleBooleanProperty();
|
||||
transient private final SimpleBooleanProperty payoutTxChangedProperty = new SimpleBooleanProperty();
|
||||
transient private final SimpleBooleanProperty contractChangedProperty = new SimpleBooleanProperty();
|
||||
transient private final SimpleStringProperty stateChangedProperty = new SimpleStringProperty();
|
||||
|
||||
private final Offer offer;
|
||||
private String takeOfferFeeTxID;
|
||||
private BigInteger tradeAmount;
|
||||
@ -23,9 +20,22 @@ public class Trade implements Serializable
|
||||
private Transaction payoutTransaction;
|
||||
private State state = State.OPEN;
|
||||
|
||||
// The Property fields are not serialized and therefore not initialized when read from disc.
|
||||
// We need to access then with the getter to be sure it is not null.
|
||||
// Don't access them directly, use the getter method
|
||||
transient private SimpleBooleanProperty _depositTxChangedProperty;
|
||||
transient private SimpleBooleanProperty _payoutTxChangedProperty;
|
||||
transient private SimpleBooleanProperty _contractChangedProperty;
|
||||
transient private SimpleStringProperty _stateChangedProperty;
|
||||
|
||||
public Trade(Offer offer)
|
||||
{
|
||||
this.offer = offer;
|
||||
|
||||
_depositTxChangedProperty = new SimpleBooleanProperty();
|
||||
_payoutTxChangedProperty = new SimpleBooleanProperty();
|
||||
_contractChangedProperty = new SimpleBooleanProperty();
|
||||
_stateChangedProperty = new SimpleStringProperty();
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +71,7 @@ public class Trade implements Serializable
|
||||
public void setContract(Contract contract)
|
||||
{
|
||||
this.contract = contract;
|
||||
contractChangedProperty.set(!contractChangedProperty.get());
|
||||
_contractChangedProperty.set(!_contractChangedProperty.get());
|
||||
}
|
||||
|
||||
public String getId()
|
||||
@ -107,7 +117,7 @@ public class Trade implements Serializable
|
||||
public void setDepositTransaction(Transaction depositTransaction)
|
||||
{
|
||||
this.depositTransaction = depositTransaction;
|
||||
depositTxChangedProperty.set(!depositTxChangedProperty.get());
|
||||
depositTxChangedProperty().set(!depositTxChangedProperty().get());
|
||||
}
|
||||
|
||||
public Transaction getPayoutTransaction()
|
||||
@ -118,7 +128,7 @@ public class Trade implements Serializable
|
||||
public void setPayoutTransaction(Transaction payoutTransaction)
|
||||
{
|
||||
this.payoutTransaction = payoutTransaction;
|
||||
payoutTxChangedProperty.set(!payoutTxChangedProperty.get());
|
||||
payoutTxChangedProperty().set(!payoutTxChangedProperty().get());
|
||||
}
|
||||
|
||||
public State getState()
|
||||
@ -129,30 +139,37 @@ public class Trade implements Serializable
|
||||
public void setState(State state)
|
||||
{
|
||||
this.state = state;
|
||||
stateChangedProperty.set(state.toString());
|
||||
stateChangedProperty().set(state.toString());
|
||||
}
|
||||
|
||||
public SimpleBooleanProperty getDepositTxChangedProperty()
|
||||
// The Property fields are not serialized and therefore not initialized when read from disc.
|
||||
// We need to access then with the getter to be sure it is not null.
|
||||
public SimpleBooleanProperty depositTxChangedProperty()
|
||||
{
|
||||
return depositTxChangedProperty;
|
||||
if (_depositTxChangedProperty == null) _depositTxChangedProperty = new SimpleBooleanProperty();
|
||||
|
||||
return _depositTxChangedProperty;
|
||||
}
|
||||
|
||||
|
||||
public SimpleBooleanProperty getContractChangedProperty()
|
||||
public SimpleBooleanProperty contractChangedProperty()
|
||||
{
|
||||
return contractChangedProperty;
|
||||
if (_contractChangedProperty == null) _contractChangedProperty = new SimpleBooleanProperty();
|
||||
return _contractChangedProperty;
|
||||
}
|
||||
|
||||
|
||||
public SimpleBooleanProperty getPayoutTxChangedProperty()
|
||||
public SimpleBooleanProperty payoutTxChangedProperty()
|
||||
{
|
||||
return payoutTxChangedProperty;
|
||||
if (_payoutTxChangedProperty == null) _payoutTxChangedProperty = new SimpleBooleanProperty();
|
||||
return _payoutTxChangedProperty;
|
||||
}
|
||||
|
||||
|
||||
public SimpleStringProperty getStateChangedProperty()
|
||||
public SimpleStringProperty stateChangedProperty()
|
||||
{
|
||||
return stateChangedProperty;
|
||||
if (_stateChangedProperty == null) _stateChangedProperty = new SimpleStringProperty();
|
||||
return _stateChangedProperty;
|
||||
}
|
||||
|
||||
public BigInteger getCollateralAmount()
|
||||
|
@ -3,7 +3,6 @@ package io.bitsquare.trade;
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.bitcoin.core.TransactionConfidence;
|
||||
import com.google.bitcoin.core.Utils;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
@ -23,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javax.inject.Inject;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.trade.orderbook;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.gui.market.orderbook.OrderBookListItem;
|
||||
import io.bitsquare.locale.Country;
|
||||
@ -21,6 +20,7 @@ import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javax.inject.Inject;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -100,7 +100,6 @@ public class ProtocolForOffererAsBuyer
|
||||
private State state;
|
||||
private int step = 0;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,9 +1,9 @@
|
||||
package io.bitsquare.trade.protocol.old;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
87
src/main/java/io/bitsquare/util/AWTSystemTray.java
Normal file
87
src/main/java/io/bitsquare/util/AWTSystemTray.java
Normal file
@ -0,0 +1,87 @@
|
||||
package io.bitsquare.util;
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
import javafx.application.Platform;
|
||||
import javafx.stage.Stage;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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;
|
||||
|
||||
public static void createSystemTray(Stage stage)
|
||||
{
|
||||
AWTSystemTray.stage = stage;
|
||||
if (SystemTray.isSupported())
|
||||
{
|
||||
// prevent exiting the app when the last window get closed
|
||||
Platform.setImplicitExit(false);
|
||||
|
||||
SystemTray systemTray = SystemTray.getSystemTray();
|
||||
TrayIcon trayIcon = new TrayIcon(getImage());
|
||||
trayIcon.setToolTip("BitSquare P2P Fiat-Bitcoin exchange");
|
||||
|
||||
PopupMenu popupMenu = new PopupMenu();
|
||||
showGuiItem = new MenuItem("Close exchange window");
|
||||
popupMenu.add(showGuiItem);
|
||||
popupMenu.addSeparator();
|
||||
MenuItem exitItem = new MenuItem("Exit");
|
||||
popupMenu.add(exitItem);
|
||||
|
||||
trayIcon.setPopupMenu(popupMenu);
|
||||
|
||||
trayIcon.addActionListener(e -> JOptionPane.showMessageDialog(null, "This dialog box is run from System Tray"));
|
||||
|
||||
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);
|
||||
Platform.exit();
|
||||
});
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
return new ImageIcon(AWTSystemTray.class.getResource("/images/systemTrayIcon.png"), "system tray icon").getImage();
|
||||
}
|
||||
}
|
35
src/main/java/io/bitsquare/util/Controller.java
Normal file
35
src/main/java/io/bitsquare/util/Controller.java
Normal file
@ -0,0 +1,35 @@
|
||||
package io.bitsquare.util;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.MenuBar;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class Controller implements Initializable
|
||||
{
|
||||
|
||||
public GridPane root;
|
||||
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
BorderPane borderPane = new BorderPane();
|
||||
Text text = new Text("BEFORE");
|
||||
borderPane.setCenter(text);
|
||||
|
||||
MenuBar menuBar = new MenuBar();
|
||||
Menu mainMenu = new Menu("File");
|
||||
MenuItem exitCmd = new MenuItem("Exit");
|
||||
MenuItem textCmd = new MenuItem("Colour Text");
|
||||
mainMenu.getItems().addAll(textCmd, exitCmd);
|
||||
// borderPane.setTop(menuBar);
|
||||
|
||||
root.getChildren().addAll(menuBar);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -8,49 +8,16 @@ import org.slf4j.LoggerFactory;
|
||||
public class FileUtil
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
|
||||
private final static File rootDirectory = new File(FileUtil.class.getProtectionDomain().getCodeSource().getLocation().getFile()).getParentFile();
|
||||
|
||||
public static File getRootDirectory()
|
||||
{
|
||||
return rootDirectory;
|
||||
}
|
||||
|
||||
// not used yet
|
||||
/* public static void setRootDirectory( File rootDirectory)
|
||||
{
|
||||
FileUtil.rootDirectory = rootDirectory;
|
||||
if (!rootDirectory.exists())
|
||||
{
|
||||
if (!rootDirectory.mkdir())
|
||||
log.error("Could not create directory. " + rootDirectory.getAbsolutePath());
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
public static File getDirectory(String name)
|
||||
{
|
||||
final File dir = new File(rootDirectory, name);
|
||||
if (!dir.exists())
|
||||
{
|
||||
if (!dir.mkdir())
|
||||
{
|
||||
log.error("Could not create directory. " + dir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
public static File getFile(String name, String suffix)
|
||||
{
|
||||
return new File(rootDirectory, name + "." + suffix);
|
||||
return new File(StorageDirectory.getStorageDirectory(), name + "." + suffix);
|
||||
}
|
||||
|
||||
|
||||
public static File getTempFile(String prefix) throws IOException
|
||||
{
|
||||
return File.createTempFile("temp_" + prefix, null, rootDirectory);
|
||||
return File.createTempFile("temp_" + prefix, null, StorageDirectory.getStorageDirectory());
|
||||
}
|
||||
|
||||
}
|
||||
|
89
src/main/java/io/bitsquare/util/StorageDirectory.java
Normal file
89
src/main/java/io/bitsquare/util/StorageDirectory.java
Normal file
@ -0,0 +1,89 @@
|
||||
package io.bitsquare.util;
|
||||
|
||||
import java.io.File;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class StorageDirectory
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(StorageDirectory.class);
|
||||
private static final String USER_PROPERTIES_FILE_NAME = "bitsquare.properties";
|
||||
private static File storageDirectory;
|
||||
|
||||
static
|
||||
{
|
||||
useApplicationDirectory();
|
||||
log.info("Default application data directory = " + storageDirectory);
|
||||
}
|
||||
|
||||
public static File getStorageDirectory()
|
||||
{
|
||||
return storageDirectory;
|
||||
}
|
||||
|
||||
public static void setStorageDirectory(File directory)
|
||||
{
|
||||
storageDirectory = directory;
|
||||
log.info("User defined application data directory = " + directory);
|
||||
|
||||
createDirIfNotExists();
|
||||
}
|
||||
|
||||
public static void useApplicationDirectory()
|
||||
{
|
||||
setStorageDirectory(getApplicationDirectory());
|
||||
}
|
||||
|
||||
public static void useSystemApplicationDataDirectory()
|
||||
{
|
||||
setStorageDirectory(getSystemApplicationDataDirectory());
|
||||
}
|
||||
|
||||
public static File getApplicationDirectory()
|
||||
{
|
||||
File propertiesFile = new File(USER_PROPERTIES_FILE_NAME);
|
||||
if (propertiesFile.exists())
|
||||
{
|
||||
return new File("");
|
||||
}
|
||||
else
|
||||
{
|
||||
// when running form a packed app the file structure is different on mac
|
||||
String operatingSystemName = System.getProperty("os.name");
|
||||
if (operatingSystemName != null && operatingSystemName.startsWith("Mac"))
|
||||
{
|
||||
if (new File("../../../../" + USER_PROPERTIES_FILE_NAME).exists())
|
||||
{
|
||||
return new File("../../../..");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static File getSystemApplicationDataDirectory()
|
||||
{
|
||||
String osName = System.getProperty("os.name");
|
||||
if (osName != null && osName.startsWith("Windows"))
|
||||
return new File(System.getenv("APPDATA") + File.separator + "BitSquare");
|
||||
else if (osName != null && osName.startsWith("Mac"))
|
||||
return new File(System.getProperty("user.home") + "/Library/Application Support/BitSquare");
|
||||
else
|
||||
return new File(System.getProperty("user.home") + "/BitSquare");
|
||||
}
|
||||
|
||||
private static void createDirIfNotExists()
|
||||
{
|
||||
if (!storageDirectory.exists())
|
||||
{
|
||||
boolean created = storageDirectory.mkdir();
|
||||
if (!created)
|
||||
log.error("Could not create the application data directory of '" + storageDirectory + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
src/main/resources/images/systemTrayIcon.png
Normal file
BIN
src/main/resources/images/systemTrayIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 367 B |
@ -1,18 +0,0 @@
|
||||
package io.bitsquare;
|
||||
|
||||
import io.bitsquare.btc.BtcValidatorTest;
|
||||
import io.bitsquare.gui.util.BitSquareConverterTest;
|
||||
import io.bitsquare.gui.util.BitSquareValidatorTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
BtcValidatorTest.class,
|
||||
BitSquareConverterTest.class,
|
||||
BitSquareValidatorTest.class,
|
||||
})
|
||||
|
||||
public class BitSquareTestSuite
|
||||
{
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import java.math.BigInteger;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BtcValidatorTest
|
||||
{
|
||||
@Test
|
||||
public void testIsMinSpendableAmount()
|
||||
{
|
||||
BigInteger amount = null;
|
||||
//noinspection ConstantConditions
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = BigInteger.ZERO;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = Transaction.MIN_NONDUST_OUTPUT;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT);
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT).add(BigInteger.ONE);
|
||||
assertTrue("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class BitSquareConverterTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testStringToDouble()
|
||||
{
|
||||
|
||||
assertEquals(1, BitSquareConverter.stringToDouble("1"), 0);
|
||||
assertEquals(0.1, BitSquareConverter.stringToDouble("0.1"), 0);
|
||||
assertEquals(0.1, BitSquareConverter.stringToDouble("0,1"), 0);
|
||||
assertEquals(1, BitSquareConverter.stringToDouble("1.0"), 0);
|
||||
assertEquals(1, BitSquareConverter.stringToDouble("1,0"), 0);
|
||||
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("1,000.2"), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("1,000.2"), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(null), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(""), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(""), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("."), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(","), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("a"), 0);
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BitSquareValidatorTest
|
||||
{
|
||||
@Test
|
||||
public void testValidateStringAsDouble()
|
||||
{
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("0"));
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("1"));
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("0,1"));
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("0.01"));
|
||||
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble(""));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("a"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("0.0.1"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("1,000.1"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("1.000,1"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateStringNotEmpty()
|
||||
{
|
||||
assertTrue(BitSquareValidator.validateStringNotEmpty("a"));
|
||||
assertTrue(BitSquareValidator.validateStringNotEmpty("123"));
|
||||
|
||||
assertFalse(BitSquareValidator.validateStringNotEmpty(""));
|
||||
assertFalse(BitSquareValidator.validateStringNotEmpty(" "));
|
||||
assertFalse(BitSquareValidator.validateStringNotEmpty(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTradeAmountOutOfRange()
|
||||
{
|
||||
|
||||
assertFalse(BitSquareValidator.tradeAmountOutOfRange(BigInteger.ZERO, new MockOffer(BigInteger.TEN, BigInteger.valueOf(0))));
|
||||
assertTrue(BitSquareValidator.tradeAmountOutOfRange(BigInteger.ZERO, new MockOffer(BigInteger.TEN, BigInteger.valueOf(1))));
|
||||
assertFalse(BitSquareValidator.tradeAmountOutOfRange(BigInteger.TEN, new MockOffer(BigInteger.TEN, BigInteger.valueOf(0))));
|
||||
assertFalse(BitSquareValidator.tradeAmountOutOfRange(BigInteger.TEN, new MockOffer(BigInteger.TEN, BigInteger.valueOf(2))));
|
||||
assertTrue(BitSquareValidator.tradeAmountOutOfRange(BigInteger.TEN, new MockOffer(BigInteger.ONE, BigInteger.valueOf(0))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGreaterThanZero()
|
||||
{
|
||||
assertFalse(BitSquareValidator.greaterThanZero(BigInteger.ZERO));
|
||||
assertFalse(BitSquareValidator.greaterThanZero(BigInteger.valueOf(-1)));
|
||||
assertTrue(BitSquareValidator.greaterThanZero(BigInteger.ONE));
|
||||
}
|
||||
|
||||
public static class MockOffer extends Offer
|
||||
{
|
||||
|
||||
public MockOffer(BigInteger amount, BigInteger minAmount)
|
||||
{
|
||||
super(null, null, 0, amount, minAmount, null, null, null, null, null, 0, null, null);
|
||||
}
|
||||
|
||||
public MockOffer(String messagePubKeyAsHex, Direction direction, double price, BigInteger amount, BigInteger minAmount, BankAccountType bankAccountType, Currency currency, Country bankAccountCountry, String bankAccountUID, Arbitrator arbitrator, int collateral, List<Country> acceptedCountries, List<Locale> acceptedLanguageLocales)
|
||||
{
|
||||
super(messagePubKeyAsHex, direction, price, amount, minAmount, bankAccountType, currency, bankAccountCountry, bankAccountUID, arbitrator, collateral, acceptedCountries, acceptedLanguageLocales);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user