diff --git a/app/gui/src/main/scala/org/bitcoins/gui/WalletGUIModel.scala b/app/gui/src/main/scala/org/bitcoins/gui/WalletGUIModel.scala index cb40c3d789..0a17fb17ff 100644 --- a/app/gui/src/main/scala/org/bitcoins/gui/WalletGUIModel.scala +++ b/app/gui/src/main/scala/org/bitcoins/gui/WalletGUIModel.scala @@ -183,7 +183,7 @@ class WalletGUIModel(dlcModel: DLCPaneModel)(implicit system: ActorSystem) /** Retrieves the tor endpoint address */ - def updateTorAddress() = { + def updateTorAddress(): Unit = { ConsoleCli.exec(GetDLCHostAddress, GlobalData.consoleCliConfig) match { case Failure(err) => logger.error(s"Error fetching tor address", err) diff --git a/app/gui/src/main/scala/org/bitcoins/gui/dlc/DLCPane.scala b/app/gui/src/main/scala/org/bitcoins/gui/dlc/DLCPane.scala index 4023ef4e43..c40abae97a 100644 --- a/app/gui/src/main/scala/org/bitcoins/gui/dlc/DLCPane.scala +++ b/app/gui/src/main/scala/org/bitcoins/gui/dlc/DLCPane.scala @@ -1,6 +1,5 @@ package org.bitcoins.gui.dlc -import javafx.event.{ActionEvent, EventHandler} import org.bitcoins.core.protocol.dlc.models.DLCStatus import org.bitcoins.gui.TaskRunner import org.bitcoins.gui.util.GUIUtil @@ -29,9 +28,7 @@ class DLCPane(glassPane: VBox)(implicit ec: ExecutionContext) { private val offerButton = new Button { text = "Offer" - onAction = new EventHandler[ActionEvent] { - override def handle(event: ActionEvent): Unit = model.onOffer() - } + onAction = _ => model.onOffer() tooltip = Tooltip( "Initiates a DLC with the given oracle and contract parameters, generating an Offer message.") tooltip.value.setShowDelay(new javafx.util.Duration(100)) @@ -39,27 +36,21 @@ class DLCPane(glassPane: VBox)(implicit ec: ExecutionContext) { private val acceptButton = new Button { text = "Accept" - onAction = new EventHandler[ActionEvent] { - override def handle(event: ActionEvent): Unit = model.onAccept() - } + onAction = _ => model.onAccept() tooltip = Tooltip("In response to an Offer, generates an Accept message.") tooltip.value.setShowDelay(new javafx.util.Duration(100)) } private val signButton = new Button { text = "Sign" - onAction = new EventHandler[ActionEvent] { - override def handle(event: ActionEvent): Unit = model.onSign() - } + onAction = _ => model.onSign() tooltip = Tooltip("In response to an Accept, generates a Sign message.") tooltip.value.setShowDelay(new javafx.util.Duration(100)) } private val broadcastDLCButton = new Button { text = "Broadcast DLC" - onAction = new EventHandler[ActionEvent] { - override def handle(event: ActionEvent): Unit = model.onBroadcastDLC() - } + onAction = _ => model.onBroadcastDLC() tooltip = Tooltip( "In response to a Sign, saves signatures and broadcasts the funding transaction.") tooltip.value.setShowDelay(new javafx.util.Duration(100)) @@ -114,18 +105,15 @@ class DLCPane(glassPane: VBox)(implicit ec: ExecutionContext) { } val exportResultButton: Button = new Button("Export Result") { - onAction = _ => { + onAction = _ => GUIUtil.showSaveDialog("Result", Some(resultTextArea.text.value), None) - } } val copyResultButton: Button = new Button("Copy Result") { - onAction = _ => { - GUIUtil.setStringToClipboard(resultTextArea.text.value) - } + onAction = _ => GUIUtil.setStringToClipboard(resultTextArea.text.value) } - val resultButtonHBox: HBox = new HBox() { + val resultButtonHBox: HBox = new HBox { spacing = 10 children = Vector(exportResultButton, copyResultButton) } diff --git a/app/gui/src/main/scala/org/bitcoins/gui/dlc/dialog/DLCDialog.scala b/app/gui/src/main/scala/org/bitcoins/gui/dlc/dialog/DLCDialog.scala index 64faf53218..7218cd6fc7 100644 --- a/app/gui/src/main/scala/org/bitcoins/gui/dlc/dialog/DLCDialog.scala +++ b/app/gui/src/main/scala/org/bitcoins/gui/dlc/dialog/DLCDialog.scala @@ -10,10 +10,9 @@ import scalafx.geometry.Insets import scalafx.scene.Node import scalafx.scene.control._ import scalafx.scene.layout.GridPane -import scalafx.stage.{FileChooser, Window} +import scalafx.stage.Window import java.io.File -import scala.util.Properties abstract class DLCDialog[T <: CliCommand]( dialogTitle: String, @@ -147,27 +146,6 @@ object DLCDialog { } } - def fileChooserButton[T](open: Boolean, handleFile: File => T): Node = { - new Button("Browse...") { - onAction = _ => { - val fileChooser = new FileChooser() { - initialDirectory = new File(Properties.userHome) - } - - val selectedFile = - if (open) - fileChooser.showOpenDialog(null) - else - fileChooser.showSaveDialog(null) - - if (selectedFile != null) { - handleFile(selectedFile) - () - } - } - } - } - var offerDLCFile: Option[File] = None var acceptDLCFile: Option[File] = None var signDLCFile: Option[File] = None