-
Notifications
You must be signed in to change notification settings - Fork 84
/
BundleGUI.scala
94 lines (77 loc) · 2.43 KB
/
BundleGUI.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package org.bitcoins.bundle.gui
import akka.actor.ActorSystem
import com.typesafe.config.Config
import org.bitcoins.db.AppConfig
import org.bitcoins.db.AppConfig.DEFAULT_BITCOIN_S_DATADIR
import org.bitcoins.gui._
import org.bitcoins.gui.util.GUIUtil
import org.bitcoins.server.util.DatadirUtil
import scalafx.application.{JFXApp, Platform}
import scalafx.geometry.Pos
import scalafx.scene.Scene
import scalafx.scene.control.Alert.AlertType
import scalafx.scene.control._
import scalafx.scene.layout.VBox
import java.nio.file.{Path, Paths}
import scala.util.Properties
object BundleGUI extends WalletGUI with JFXApp {
// Catch unhandled exceptions on FX Application thread
Thread
.currentThread()
.setUncaughtExceptionHandler((_: Thread, ex: Throwable) => {
ex.printStackTrace()
lazy val _ = new Alert(AlertType.Error) {
initOwner(owner)
title = "Unhandled exception"
headerText = "Exception: " + ex.getClass + ""
contentText = Option(ex.getMessage).getOrElse("")
}.showAndWait()
})
// Set log location
{
val baseConfig: Config = AppConfig
.getBaseConfig(DEFAULT_BITCOIN_S_DATADIR)
.resolve()
val datadir: Path =
Paths.get(baseConfig.getString("bitcoin-s.datadir"))
val usedDir = DatadirUtil.getFinalDatadir(datadir, baseConfig, None)
System.setProperty("bitcoins.log.location", usedDir.toAbsolutePath.toString)
if (Properties.isWin) {
System.setProperty("HOME", datadir.getParent.toAbsolutePath.toString)
}
}
implicit lazy val system: ActorSystem = ActorSystem(
s"bitcoin-s-gui-${System.currentTimeMillis()}")
lazy val args = parameters.raw
val landingPane = new LandingPane(glassPane)
rootView.children = Vector(landingPane.view, glassPane)
lazy val guiScene: Scene = new Scene(1400, 600) {
root = rootView
stylesheets = GlobalData.currentStyleSheets
}
lazy val glassPane: VBox = new VBox {
children = new ProgressIndicator {
progress = ProgressIndicator.IndeterminateProgress
visible = true
}
alignment = Pos.Center
visible = false
}
stage = new JFXApp.PrimaryStage {
title = "Bitcoin-S Wallet"
scene = guiScene
icons.add(GUIUtil.logo)
}
taskRunner
def changeToWalletGUIScene(): Unit = {
Platform.runLater(
rootView.children = Vector(
borderPane,
glassPane
))
}
override def stopApp(): Unit = {
super.stopApp()
// sys.exit()
}
}