Skip to content

Commit 9dd2330

Browse files
committed
[SI7597] manual test
1 parent 17d869f commit 9dd2330

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

build.sbt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ lazy val examples = project.in( file("examples") )
4444
fork := true
4545
)
4646

47+
lazy val uitest = project.in( file("uitest") )
48+
.dependsOn(swing)
49+
.settings(
50+
scalaVersion := "2.11.1",
51+
fork in run := true,
52+
fork := true
53+
)
54+
4755

4856

4957

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
import scala.swing.FileChooser.Result
13+
import scala.swing.Swing._
14+
import scala.swing.event.ButtonClicked
15+
import scala.swing._
16+
17+
/**
18+
* Test for issue SI-7597 https://issues.scala-lang.org/browse/SI-7597
19+
*/
20+
object SI7597 extends SimpleSwingApplication {
21+
def top = new MainFrame {
22+
title = "SI7597 FileChooser test"
23+
24+
25+
lazy val dialog = aDialog
26+
27+
val fileChooser = new FileChooser
28+
29+
30+
contents = new FlowPanel {
31+
contents ++= Seq(
32+
fileChooserStyles[Component]("Component", this),
33+
fileChooserStyles[Frame]("Frame", top),
34+
fileChooserStyles[Dialog]("Dialog", dialog)
35+
)
36+
}
37+
38+
size = new Dimension(400, 400)
39+
40+
41+
def fileChooserStyles[T <: PeerContainer](rowTitle: String, parent: => T) = new FlowPanel {
42+
contents ++= Seq(
43+
new Label(s"Parent is $rowTitle"),
44+
fileChooserButton("Open", fileChooser.showOpenDialog(parent)),
45+
fileChooserButton("Save", fileChooser.showSaveDialog(parent)),
46+
fileChooserButton("Text", fileChooser.showDialog(parent, "Text"))
47+
)
48+
}
49+
50+
def fileChooserButton(parentTitle: String, fileChooserStyle: => Result.Value): Button = new Button {
51+
text = parentTitle
52+
reactions += {
53+
case ButtonClicked(_) =>
54+
text = fileChooserStyle match {
55+
case Result.Approve => s"$parentTitle: ${fileChooser.selectedFile.toString}"
56+
case _ => parentTitle
57+
}
58+
}
59+
}
60+
61+
}
62+
63+
64+
def aDialog = new Dialog(top) {
65+
title = "A Dialog"
66+
size = new Dimension(300, 300)
67+
contents = new Label("Do not Close")
68+
visible = true
69+
}
70+
71+
}

0 commit comments

Comments
 (0)