|
| 1 | +/* __ *\ |
| 2 | +** ________ ___ / / ___ Scala API ** |
| 3 | +** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** |
| 4 | +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** |
| 5 | +** /____/\___/_/ |_/____/_/ | | ** |
| 6 | +** |/ ** |
| 7 | +\* */ |
| 8 | + |
| 9 | +package scala.swing.uitest |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +import scala.swing.Swing._ |
| 14 | +import scala.swing.event.ButtonClicked |
| 15 | +import scala.swing._ |
| 16 | + |
| 17 | + |
| 18 | +/** |
| 19 | + * Test for issue SI-7597 https://issues.scala-lang.org/browse/SI-7597 |
| 20 | + * (expanded to include other showXXXDialog dialogs ) |
| 21 | + */ |
| 22 | +object SI7597 extends SimpleSwingApplication { |
| 23 | + def top = new MainFrame { |
| 24 | + title = "SI7597 showXXXDialog tests" |
| 25 | + size = new Dimension(900, 200) |
| 26 | + |
| 27 | + lazy val dialog = aDialog |
| 28 | + |
| 29 | + val fileChooserDialog = new FileChooser |
| 30 | + val colorChooser = new ColorChooser |
| 31 | + |
| 32 | + contents = new BoxPanel(Orientation.Vertical) { |
| 33 | + contents ++= Seq( |
| 34 | + fileChooserStyles("Component", parent = this), |
| 35 | + fileChooserStyles("Frame", parent = top), |
| 36 | + fileChooserStyles("Dialog", parent = dialog) |
| 37 | + ) |
| 38 | + } |
| 39 | + |
| 40 | + def fileChooserStyles(rowTitle : String, parent : => PeerContainer) = new FlowPanel { |
| 41 | + contents ++= Seq(new Label(s"Parent is $rowTitle")) |
| 42 | + |
| 43 | + contents ++= Seq( |
| 44 | + simpleButton("Open", fileChooserDialog.showOpenDialog(parent)), |
| 45 | + simpleButton("Save", fileChooserDialog.showSaveDialog(parent)), |
| 46 | + simpleButton("Text", fileChooserDialog.showDialog(parent, "Text")), |
| 47 | + simpleButton("Confirmation", Dialog.showConfirmation(parent, "Confirmation") ), |
| 48 | + simpleButton("Input", Dialog.showInput(parent, "Input", initial = "Some text") ), |
| 49 | + simpleButton("Message", Dialog.showMessage(parent, "Message" )), |
| 50 | + simpleButton("Message", Dialog.showOptions(parent, "Message", entries = List("First", "Second", "Third"), initial=1 )), |
| 51 | + simpleButton("Color", ColorChooser.showDialog(parent, "Color", java.awt.Color.RED)) |
| 52 | + ) |
| 53 | + } |
| 54 | + |
| 55 | + def simpleButton(parentTitle : String, dialogChooser : => Any): Button = new Button { |
| 56 | + text = parentTitle |
| 57 | + reactions += { |
| 58 | + case _ : ButtonClicked => |
| 59 | + dialogChooser match { |
| 60 | + case action => println(s"Result: $action") |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + |
| 67 | + def aDialog:Dialog = new Dialog(top) { |
| 68 | + title = "A Dialog" |
| 69 | + size = new Dimension(300, 600) |
| 70 | + contents = new Label("Test Dialog. Do Not Close") |
| 71 | + visible = true |
| 72 | + } |
| 73 | +} |
0 commit comments