Skip to content

Commit 8407cac

Browse files
committed
clean up; bump to 2.1.0-SNAPSHOT
- add explicit return types (e.g. Proxy's self now is Any) - fully qualify imports, avoid wildcard imports - remove dummy class Matrix
1 parent c52d48b commit 8407cac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+165
-274
lines changed

build.sbt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,32 @@ scalaModuleSettings
44

55
name := "scala-swing"
66

7-
version := "2.0.4-SNAPSHOT"
7+
version := "2.1.0-SNAPSHOT"
88

99
scalacOptions ++= Seq("-deprecation", "-feature")
1010

1111
// Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]]
1212
scalaVersionsByJvm in ThisBuild := Map(
13-
8 -> List("2.11.12", "2.12.6", "2.13.0-M3").map(_ -> true),
14-
9 -> List("2.11.12", "2.12.6", "2.13.0-M3").map(_ -> false),
15-
10 -> List("2.11.12", "2.12.6", "2.13.0-M3").map(_ -> false),
16-
11 -> List("2.11.12", "2.12.6", "2.13.0-M3").map(_ -> false)
13+
8 -> List("2.11.12", "2.12.6", "2.13.0-M5").map(_ -> true),
14+
9 -> List("2.11.12", "2.12.6", "2.13.0-M5").map(_ -> false),
15+
10 -> List("2.11.12", "2.12.6", "2.13.0-M5").map(_ -> false),
16+
11 -> List("2.11.12", "2.12.6", "2.13.0-M5").map(_ -> false)
1717
)
1818

19+
scalaVersion in ThisBuild := "2.12.8" // for testing
20+
1921
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}")
2022

21-
mimaPreviousVersion := Some("2.0.0")
23+
mimaPreviousVersion := None // Some("2.0.0")
2224

2325
// set the prompt (for this build) to include the project id.
2426
shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " }
2527

2628
lazy val swing = project.in(file("."))
2729
.settings(
2830
libraryDependencies += {
29-
val v = if (scalaVersion.value == "2.13.0-M3") "3.0.5-M1" else "3.0.5"
30-
"org.scalatest" %% "scalatest" % v % "test"
31+
val v = if (scalaVersion.value == "2.13.0-M5") "3.0.6-SNAP5" else "3.0.5"
32+
"org.scalatest" %% "scalatest" % v % Test
3133
}
3234
)
3335

src/main/scala/scala/swing/AbstractButton.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
package scala.swing
1212

13-
import event._
14-
import javax.swing.{AbstractButton => JAbstractButton, Icon}
13+
import javax.swing.{Icon, AbstractButton => JAbstractButton}
14+
15+
import scala.swing.event.{ButtonClicked, Key}
1516

1617
/**
1718
* Base class of all button-like widgets, such as push buttons,

src/main/scala/scala/swing/Action.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
package scala.swing
1212

13-
import javax.swing.{KeyStroke, Icon}
1413
import java.awt.event.ActionListener
1514

15+
import javax.swing.{Icon, KeyStroke}
16+
1617
object Action {
1718
/**
1819
* Special action that has an empty title and all default properties and does nothing.
@@ -29,7 +30,7 @@ object Action {
2930
def addActionListener(a: ActionListener): Unit
3031
def removeActionListener(a: ActionListener): Unit
3132
def setAction(a: javax.swing.Action): Unit
32-
def getAction(): javax.swing.Action
33+
def getAction(): javax.swing.Action // note: must keep empty parentheses for Java compatibility
3334
}
3435

3536
// TODO: we need an action cache

src/main/scala/scala/swing/BoxPanel.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package scala.swing
1717
* @see javax.swing.BoxLayout
1818
*/
1919
class BoxPanel(orientation: Orientation.Value) extends Panel with SequentialContainer.Wrapper {
20-
override lazy val peer = {
20+
override lazy val peer: javax.swing.JPanel = {
2121
val p = new javax.swing.JPanel with SuperMixin
2222
val l = new javax.swing.BoxLayout(p, orientation.id)
2323
p.setLayout(l)

src/main/scala/scala/swing/Button.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
package scala.swing
1010

11-
import javax.swing._
11+
import javax.swing.JButton
1212

1313
object Button {
14-
def apply(text0: String)(op: => Unit) = new Button(Action(text0)(op))
14+
def apply(text0: String)(op: => Unit): Button = new Button(Action(text0)(op))
1515
}
1616

1717
/**

src/main/scala/scala/swing/ButtonGroup.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ButtonGroup(initialButtons: AbstractButton*) {
2525
def contains(b: AbstractButton): Boolean = this.iterator.contains(b)
2626
override def size: Int = peer.getButtonCount
2727
def iterator: Iterator[AbstractButton] = new Iterator[AbstractButton] {
28-
val enum = peer.getElements
28+
private val enum = peer.getElements
2929
def next: AbstractButton = UIElement.cachedWrapper[AbstractButton](enum.nextElement)
3030
def hasNext: Boolean = enum.hasMoreElements
3131
}

src/main/scala/scala/swing/CheckBox.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
package scala.swing
1212

13-
import javax.swing._
13+
import javax.swing.JCheckBox
1414

1515
/**
1616
* Two state button that can either be checked or unchecked.

src/main/scala/scala/swing/ComboBox.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
package scala.swing
1010

1111
import java.awt.event.ActionListener
12+
1213
import javax.swing.{AbstractListModel, ComboBoxModel, InputVerifier, JComboBox, JComponent, JTextField, ListCellRenderer}
1314

14-
import scala.swing.event._
15+
import scala.swing.event.ActionEvent
1516

1617
object ComboBox {
1718
/**
@@ -44,7 +45,7 @@ object ComboBox {
4445

4546
def getEditorComponent: JComponent = Editor.this.component.peer
4647

47-
def getItem(): AnyRef = item.asInstanceOf[AnyRef]
48+
def getItem: AnyRef = item.asInstanceOf[AnyRef]
4849

4950
def selectAll(): Unit = startEditing()
5051

@@ -84,7 +85,7 @@ object ComboBox {
8485

8586
def getEditorComponent: JComponent = editor.getEditorComponent.asInstanceOf[JComponent]
8687
def selectAll(): Unit = editor.selectAll()
87-
def getItem(): AnyRef = { verifier.verify(getEditorComponent); value.asInstanceOf[AnyRef] }
88+
def getItem: AnyRef = { verifier.verify(getEditorComponent); value.asInstanceOf[AnyRef] }
8889
def setItem(a: Any): Unit = editor.setItem(a)
8990

9091
val verifier: InputVerifier = new InputVerifier {

src/main/scala/scala/swing/Component.scala

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
package scala.swing
1010

11-
import event._
12-
1311
import java.awt.Graphics
1412
import java.awt.event._
1513
import javax.swing.JComponent
@@ -42,7 +40,9 @@ object Component {
4240
*/
4341
abstract class Component extends UIElement {
4442
override lazy val peer: javax.swing.JComponent = new javax.swing.JComponent with SuperMixin {}
45-
var initP: JComponent = null
43+
44+
// TODO: what was this used for?
45+
// var initP: JComponent = null
4646

4747
/**
4848
* This trait is used to redirect certain calls from the peer to the wrapper
@@ -127,13 +127,13 @@ abstract class Component extends UIElement {
127127
def mouseEntered(e: java.awt.event.MouseEvent): Unit = ()
128128
def mouseExited(e: java.awt.event.MouseEvent): Unit = ()
129129
def mouseClicked(e: java.awt.event.MouseEvent): Unit =
130-
publish(new MouseClicked(e))
130+
publish(new event.MouseClicked(e))
131131

132132
def mousePressed(e: java.awt.event.MouseEvent): Unit =
133-
publish(new MousePressed(e))
133+
publish(new event.MousePressed(e))
134134

135135
def mouseReleased(e: java.awt.event.MouseEvent): Unit =
136-
publish(new MouseReleased(e))
136+
publish(new event.MouseReleased(e))
137137
}
138138

139139
def onFirstSubscribe (): Unit = peer.addMouseListener(l)
@@ -145,10 +145,10 @@ abstract class Component extends UIElement {
145145
val moves: Publisher = new LazyPublisher {
146146
lazy val mouseListener: MouseListener = new MouseListener {
147147
def mouseEntered(e: java.awt.event.MouseEvent): Unit =
148-
publish(new MouseEntered(e))
148+
publish(new event.MouseEntered(e))
149149

150150
def mouseExited(e: java.awt.event.MouseEvent): Unit =
151-
publish(new MouseExited(e))
151+
publish(new event.MouseExited(e))
152152

153153
def mouseClicked (e: java.awt.event.MouseEvent): Unit = ()
154154
def mousePressed (e: java.awt.event.MouseEvent): Unit = ()
@@ -157,10 +157,10 @@ abstract class Component extends UIElement {
157157

158158
lazy val mouseMotionListener: MouseMotionListener = new MouseMotionListener {
159159
def mouseMoved(e: java.awt.event.MouseEvent): Unit =
160-
publish(new MouseMoved(e))
160+
publish(new event.MouseMoved(e))
161161

162162
def mouseDragged(e: java.awt.event.MouseEvent): Unit =
163-
publish(new MouseDragged(e))
163+
publish(new event.MouseDragged(e))
164164
}
165165
def onFirstSubscribe(): Unit = {
166166
peer.addMouseListener(mouseListener)
@@ -179,7 +179,7 @@ abstract class Component extends UIElement {
179179
// mouse wheel events if there is a listener installed. See ticket #1442.
180180
lazy val l: MouseWheelListener = new MouseWheelListener {
181181
def mouseWheelMoved(e: java.awt.event.MouseWheelEvent): Unit =
182-
publish(new MouseWheelMoved(e))
182+
publish(new event.MouseWheelMoved(e))
183183
}
184184
def onFirstSubscribe (): Unit = peer.addMouseWheelListener(l)
185185
def onLastUnsubscribe(): Unit = peer.removeMouseWheelListener(l)
@@ -188,9 +188,9 @@ abstract class Component extends UIElement {
188188

189189
object keys extends Publisher {
190190
peer.addKeyListener(new KeyListener {
191-
def keyPressed (e: java.awt.event.KeyEvent): Unit = publish(new KeyPressed(e))
192-
def keyReleased (e: java.awt.event.KeyEvent): Unit = publish(new KeyReleased(e))
193-
def keyTyped (e: java.awt.event.KeyEvent): Unit = publish(new KeyTyped(e))
191+
def keyPressed (e: java.awt.event.KeyEvent): Unit = publish(new event.KeyPressed (e))
192+
def keyReleased (e: java.awt.event.KeyEvent): Unit = publish(new event.KeyReleased(e))
193+
def keyTyped (e: java.awt.event.KeyEvent): Unit = publish(new event.KeyTyped (e))
194194
})
195195
}
196196

@@ -205,16 +205,16 @@ abstract class Component extends UIElement {
205205
// TODO: deprecated, remove after 2.8
206206
peer.addComponentListener(new java.awt.event.ComponentListener {
207207
def componentHidden(e: java.awt.event.ComponentEvent): Unit =
208-
publish(UIElementHidden(Component.this))
208+
publish(event.UIElementHidden(Component.this))
209209

210210
def componentShown(e: java.awt.event.ComponentEvent): Unit =
211-
publish(UIElementShown(Component.this))
211+
publish(event.UIElementShown(Component.this))
212212

213213
def componentMoved(e: java.awt.event.ComponentEvent): Unit =
214-
publish(UIElementMoved(Component.this))
214+
publish(event.UIElementMoved(Component.this))
215215

216216
def componentResized(e: java.awt.event.ComponentEvent): Unit =
217-
publish(UIElementResized(Component.this))
217+
publish(event.UIElementResized(Component.this))
218218
})
219219

220220
peer.addFocusListener(new java.awt.event.FocusListener {
@@ -224,18 +224,18 @@ abstract class Component extends UIElement {
224224
}
225225

226226
def focusGained(e: java.awt.event.FocusEvent): Unit =
227-
publish(FocusGained(Component.this, other(e), e.isTemporary))
227+
publish(event.FocusGained(Component.this, other(e), e.isTemporary))
228228

229229
def focusLost(e: java.awt.event.FocusEvent): Unit =
230-
publish(FocusLost(Component.this, other(e), e.isTemporary))
230+
publish(event.FocusLost(Component.this, other(e), e.isTemporary))
231231
})
232232

233233
peer.addPropertyChangeListener(new java.beans.PropertyChangeListener {
234234
def propertyChange(e: java.beans.PropertyChangeEvent): Unit =
235235
e.getPropertyName match {
236-
case "font" => publish(FontChanged (Component.this))
237-
case "background" => publish(BackgroundChanged(Component.this))
238-
case "foreground" => publish(ForegroundChanged(Component.this))
236+
case "font" => publish(event.FontChanged (Component.this))
237+
case "background" => publish(event.BackgroundChanged(Component.this))
238+
case "foreground" => publish(event.ForegroundChanged(Component.this))
239239
case _ =>
240240
/*case "focusable" =>
241241
case "focusTraversalKeysEnabled" =>

src/main/scala/scala/swing/Container.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
package scala.swing
1212

13-
import scala.swing.event._
13+
import scala.swing.event.{ComponentAdded, ComponentRemoved}
1414

1515
object Container {
1616
/**

src/main/scala/scala/swing/EditorPane.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
package scala.swing
1010

11-
import javax.swing._
12-
import javax.swing.text._
11+
import javax.swing.JEditorPane
12+
import javax.swing.text.EditorKit
1313

1414
/**
15-
* A text component that allows multiline text input and display.
15+
* A text component that allows multi-line text input and display.
1616
*
1717
* @see javax.swing.JEditorPane
1818
*/

src/main/scala/scala/swing/FileChooser.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
package scala.swing
1010

1111
import java.io.File
12-
import javax.swing._
13-
import javax.swing.filechooser._
12+
13+
import javax.swing.filechooser.FileFilter
14+
import javax.swing.{Icon, JFileChooser}
1415

1516
object FileChooser {
1617
/**

src/main/scala/scala/swing/FlowPanel.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package scala.swing
1212

1313
import java.awt.FlowLayout
14+
1415
import javax.swing.JPanel
1516

1617
object FlowPanel {
@@ -38,7 +39,7 @@ class FlowPanel(alignment: FlowPanel.Alignment.Value)(contents0: Component*) ext
3839

3940
contents ++= contents0
4041

41-
private def layoutManager = peer.getLayout.asInstanceOf[java.awt.FlowLayout]
42+
private def layoutManager: FlowLayout = peer.getLayout.asInstanceOf[FlowLayout]
4243

4344
def vGap: Int = layoutManager.getVgap
4445
def vGap_=(n: Int): Unit = layoutManager.setVgap(n)

src/main/scala/scala/swing/FormattedTextField.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package scala.swing
1010

11-
import javax.swing._
11+
import javax.swing.JFormattedTextField
1212

1313
object FormattedTextField {
1414
/**

src/main/scala/scala/swing/GridBagPanel.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class GridBagPanel extends Panel with LayoutContainer {
5151
override lazy val peer = new javax.swing.JPanel(new GridBagLayout) with SuperMixin
5252
import GridBagPanel._
5353

54-
private def layoutManager = peer.getLayout.asInstanceOf[GridBagLayout]
54+
private def layoutManager: GridBagLayout = peer.getLayout.asInstanceOf[GridBagLayout]
5555

5656
/**
5757
* Convenient conversion from xy-coords given as pairs to
@@ -65,7 +65,7 @@ class GridBagPanel extends Panel with LayoutContainer {
6565
}
6666

6767
class Constraints(val peer: GridBagConstraints) extends Proxy {
68-
def self = peer
68+
def self: Any = peer
6969
def this(gridx: Int, gridy: Int,
7070
gridwidth: Int, gridheight: Int,
7171
weightx: Double, weighty: Double,
@@ -107,7 +107,7 @@ class GridBagPanel extends Panel with LayoutContainer {
107107
def ipady_=(y: Int): Unit = { peer.ipady = y }
108108
}
109109

110-
protected def constraintsFor(comp: Component) =
110+
protected def constraintsFor(comp: Component): Constraints =
111111
new Constraints(layoutManager.getConstraints(comp.peer))
112112

113113
protected def areValid(c: Constraints): (Boolean, String) = (true, "")

src/main/scala/scala/swing/GridPanel.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
package scala.swing
1212

13+
import java.awt.GridLayout
14+
1315
object GridPanel {
1416
val Adapt = 0
1517
}
@@ -37,7 +39,7 @@ class GridPanel(rows0: Int, cols0: Int) extends Panel with SequentialContainer.W
3739
protected def areValid(c: Constraints): (Boolean, String) =
3840
((c._1 > 0 && c._2 > 0), "Grid coordinates (row,col) must be >= 1 but where " + c)*/
3941

40-
private def layoutManager = peer.getLayout.asInstanceOf[java.awt.GridLayout]
42+
private def layoutManager: GridLayout = peer.getLayout.asInstanceOf[GridLayout]
4143

4244
def rows: Int = layoutManager.getRows
4345
def rows_=(n: Int): Unit = layoutManager.setRows(n)

src/main/scala/scala/swing/Label.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
package scala.swing
1212

13-
import javax.swing._
14-
import scala.swing.Swing._
13+
import javax.swing.{Icon, JLabel}
14+
15+
import scala.swing.Swing.{EmptyIcon, toNullIcon}
1516

1617
/**
1718
* A label component that display either a text, an icon, or both.

0 commit comments

Comments
 (0)