2021 06 23 scalafx dep (#3324)

* WIP

* Remove usage of JFXApp, use JfxApp3
This commit is contained in:
Chris Stewart 2021-06-23 18:15:32 -05:00 committed by GitHub
parent 05204e6235
commit ea26c8b3a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 79 deletions

View File

@ -7,7 +7,7 @@ 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.application.{JFXApp3, Platform}
import scalafx.geometry.Pos
import scalafx.scene.Scene
import scalafx.scene.control.Alert.AlertType
@ -16,7 +16,7 @@ import scalafx.scene.layout.VBox
import java.nio.file.{Path, Paths}
object BundleGUI extends WalletGUI with JFXApp {
object BundleGUI extends WalletGUI with JFXApp3 {
// Catch unhandled exceptions on FX Application thread
Thread
@ -31,8 +31,13 @@ object BundleGUI extends WalletGUI with JFXApp {
}.showAndWait()
})
// Set log location
{
implicit override lazy val system: ActorSystem = ActorSystem(
s"bitcoin-s-gui-${System.currentTimeMillis()}")
lazy val args = parameters.raw
override def start(): Unit = {
// Set log location
val baseConfig: Config = AppConfig
.getBaseConfig(DEFAULT_BITCOIN_S_DATADIR)
.resolve()
@ -43,22 +48,26 @@ object BundleGUI extends WalletGUI with JFXApp {
val usedDir = DatadirUtil.getFinalDatadir(datadir, baseConfig, None)
System.setProperty("bitcoins.log.location", usedDir.toAbsolutePath.toString)
val landingPane = new LandingPane(glassPane)
rootView.children = Vector(landingPane.view, glassPane)
lazy val guiScene: Scene = new Scene(1400, 600) {
root = rootView
stylesheets = GlobalData.currentStyleSheets
}
stage = new JFXApp3.PrimaryStage {
title = "Bitcoin-S Wallet"
scene = guiScene
icons.add(GUIUtil.logo)
}
taskRunner
()
}
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 {
override lazy val glassPane: VBox = new VBox {
children = new ProgressIndicator {
progress = ProgressIndicator.IndeterminateProgress
visible = true
@ -67,13 +76,6 @@ object BundleGUI extends WalletGUI with JFXApp {
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(

View File

@ -6,7 +6,7 @@ import org.bitcoins.cli.ConsoleCli
import org.bitcoins.commons.jsonmodels.BitcoinSServerInfo
import org.bitcoins.core.config._
import org.bitcoins.gui.util.GUIUtil._
import scalafx.application.JFXApp
import scalafx.application.JFXApp3
import scalafx.geometry.Pos
import scalafx.scene.Scene
import scalafx.scene.control.Alert.AlertType
@ -16,9 +16,9 @@ import scalafx.scene.layout.VBox
import scala.util._
object GUI extends WalletGUI with JFXApp {
object GUI extends WalletGUI with JFXApp3 {
implicit lazy val system: ActorSystem = ActorSystem(
implicit override lazy val system: ActorSystem = ActorSystem(
s"bitcoin-s-gui-${System.currentTimeMillis()}")
// Catch unhandled exceptions on FX Application thread
@ -34,30 +34,7 @@ object GUI extends WalletGUI with JFXApp {
}.showAndWait()
})
lazy val argsWithIndex: Vector[(String, Int)] =
parameters.raw.zipWithIndex.toVector
lazy val rpcPortOpt: Option[Int] = {
lazy val portOpt = argsWithIndex.find(_._1.toLowerCase == "--rpcport")
portOpt.map { case (_, idx) =>
parameters.raw(idx + 1).toInt
}
}
GlobalData.rpcPortOpt = rpcPortOpt
lazy val debug: Boolean = {
parameters.raw.exists(_.toLowerCase == "--debug")
}
GlobalData.debug = debug
lazy val walletScene: Scene = new Scene(1400, 800) {
root = rootView
stylesheets = GlobalData.currentStyleSheets
}
lazy val glassPane: VBox = new VBox {
override lazy val glassPane: VBox = new VBox {
children = new ProgressIndicator {
progress = ProgressIndicator.IndeterminateProgress
visible = true
@ -66,34 +43,60 @@ object GUI extends WalletGUI with JFXApp {
visible = false
}
lazy val info: BitcoinSServerInfo =
ConsoleCli.exec(GetInfo, GlobalData.consoleCliConfig) match {
case Failure(exception) =>
throw exception
case Success(str) =>
val json = ujson.read(str)
BitcoinSServerInfo.fromJson(json)
override def start(): Unit = {
lazy val argsWithIndex: Vector[(String, Int)] =
parameters.raw.zipWithIndex.toVector
lazy val rpcPortOpt: Option[Int] = {
lazy val portOpt = argsWithIndex.find(_._1.toLowerCase == "--rpcport")
portOpt.map { case (_, idx) =>
parameters.raw(idx + 1).toInt
}
}
GlobalData.network = info.network
GlobalData.rpcPortOpt = rpcPortOpt
lazy val (img, titleStr): (Image, String) = info.network match {
case MainNet =>
(logo, "Bitcoin-S Wallet")
case TestNet3 =>
(logoTestnet, "Bitcoin-S Wallet - [testnet]")
case RegTest =>
(logoRegtest, "Bitcoin-S Wallet - [regtest]")
case SigNet =>
(logoSignet, "Bitcoin-S Wallet - [signet]")
lazy val debug: Boolean = {
parameters.raw.exists(_.toLowerCase == "--debug")
}
GlobalData.debug = debug
lazy val walletScene: Scene = new Scene(1400, 800) {
root = rootView
stylesheets = GlobalData.currentStyleSheets
}
lazy val info: BitcoinSServerInfo =
ConsoleCli.exec(GetInfo, GlobalData.consoleCliConfig) match {
case Failure(exception) =>
throw exception
case Success(str) =>
val json = ujson.read(str)
BitcoinSServerInfo.fromJson(json)
}
GlobalData.network = info.network
lazy val (img, titleStr): (Image, String) = info.network match {
case MainNet =>
(logo, "Bitcoin-S Wallet")
case TestNet3 =>
(logoTestnet, "Bitcoin-S Wallet - [testnet]")
case RegTest =>
(logoRegtest, "Bitcoin-S Wallet - [regtest]")
case SigNet =>
(logoSignet, "Bitcoin-S Wallet - [signet]")
}
stage = new JFXApp3.PrimaryStage {
title = titleStr
scene = walletScene
icons.add(img)
}
fetchStartingData()
taskRunner
()
}
stage = new JFXApp.PrimaryStage {
title = titleStr
scene = walletScene
icons.add(img)
}
fetchStartingData()
taskRunner
}

View File

@ -24,7 +24,7 @@ object Deps {
val nativeLoaderV = "2.3.5"
val typesafeConfigV = "1.4.1"
val scalaFxV = "16.0.0-R22"
val scalaFxV = "16.0.0-R24"
val javaFxV = "17-ea+8"
val asyncNewScalaV = "0.10.0"