Skip to content

Commit

Permalink
ShowMessage - allow for resizing all message dialogs #32
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsacha committed Apr 4, 2024
1 parent 3eefe11 commit 8125f42
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scalafx-extras/src/main/scala/org/scalafx/extras/ShowMessage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,18 @@ object ShowMessage {
* @param t exception.
* @param parentWindow owner window that will be blacked by the dialog.
*/
def exception(title: String, message: String, t: Throwable, parentWindow: Option[Window] = None): Unit = {
def exception(
title: String,
message: String,
t: Throwable,
parentWindow: Option[Window] = None,
resizable: Boolean = false
): Unit = {
t.printStackTrace()

// Rename to avoid name clashes
val dialogTitle = title
val _title = title
val _resizable = resizable

// Create expandable Exception.
val exceptionText = {
Expand Down Expand Up @@ -118,11 +125,12 @@ object ShowMessage {
onFXAndWait {
new Alert(AlertType.Error) {
initOwner(parentWindow.orNull)
this.title = dialogTitle
this.title = _title
headerText = message
contentText = Option(t.getMessage).getOrElse("")
// Set expandable Exception into the dialog pane.
dialogPane().expandableContent = expContent
this.resizable = _resizable
}.showAndWait()
}
}
Expand Down Expand Up @@ -237,7 +245,7 @@ trait ShowMessage {
* @param message Message (excluding t.getMessage(), it is automatically displayed)
* @param t exception to be displayed in the dialog
*/
def showException(title: String, message: String, t: Throwable): Unit = {
def showException(title: String, message: String, t: Throwable, resizable: Boolean = false): Unit = {
messageLogger.foreach(_.error(s"<$title> $message", t))
ShowMessage.exception(title, message, t, parentWindow)
}
Expand Down

0 comments on commit 8125f42

Please sign in to comment.