forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scala-2.10.2-jdk-1.7-swing.patch
236 lines (212 loc) · 10.8 KB
/
scala-2.10.2-jdk-1.7-swing.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
--- scala-2.10.2-orig/build.xml 2013-05-31 00:44:27.000000000 +1000
+++ scala-2.10.2/build.xml 2013-08-20 20:41:23.335756000 +1000
@@ -343,6 +343,8 @@
<echo level="warning"> You are using JDK7 for this build.
While this will be able to build most of Scala, it will not build the Swing project.
You will be unable to create a distribution.
+ ^ The above is a message from the scala 2.10.2 release, the Gentoo
+ ebuild applies patches for jdk 1.7 swing.
</echo>
</then></if>
@@ -1153,7 +1155,7 @@
<target name="quick.partest" depends="quick.scalap, quick.comp, asm.done">
<staged-build with="locker" stage="quick" project="partest" version="partest"/> </target>
- <target name="quick.swing" depends="quick.actors, quick.lib" if="has.java6">
+ <target name="quick.swing" depends="quick.actors, quick.lib">
<staged-build with="locker" stage="quick" project="swing"/> </target>
<target name="quick.plugins" depends="quick.comp">
@@ -1204,7 +1206,7 @@
<staged-pack project="library"/></target>
<target name="pack.actors" depends="quick.lib"> <staged-pack project="actors"/> </target>
- <target name="pack.swing" if="has.java6" depends="quick.swing"> <staged-pack project="swing"/> </target>
+ <target name="pack.swing" depends="quick.swing"> <staged-pack project="swing"/> </target>
<target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target>
<target name="pack.comp" depends="quick.comp, asm.done">
@@ -1351,9 +1353,7 @@
<make-plugin-bundle name="continuations" version="${osgi.version.number}" />
<touch file="${build-osgi.dir}/bundles.complete" verbose="no"/>
- <if><isset property="has.java6"/><then>
- <make-bundle name="scala-swing" version="${osgi.version.number}"/></then>
- </if>
+ <make-bundle name="scala-swing" version="${osgi.version.number}"/>
<stopwatch name="osgi.bundle.timer" action="total"/></then>
</if>
</target>
--- scala-2.10.2-orig/src/swing/scala/swing/ComboBox.scala 2013-05-31 00:44:27.000000000 +1000
+++ scala-2.10.2/src/swing/scala/swing/ComboBox.scala 2013-08-20 20:26:48.334061000 +1000
@@ -9,7 +9,7 @@
package scala.swing
import event._
-import javax.swing.{JList, JComponent, JComboBox, JTextField, ComboBoxModel, AbstractListModel, ListCellRenderer}
+import javax.swing.{ JComponent, JComboBox, JTextField, ComboBoxModel, AbstractListModel, ListCellRenderer }
import java.awt.event.ActionListener
object ComboBox {
@@ -118,10 +118,10 @@
implicit def floatEditor(c: ComboBox[Float]): Editor[Float] = new BuiltInEditor(c)(s => s.toFloat, s => s.toString)
implicit def doubleEditor(c: ComboBox[Double]): Editor[Double] = new BuiltInEditor(c)(s => s.toDouble, s => s.toString)
- def newConstantModel[A](items: Seq[A]): ComboBoxModel = {
- new AbstractListModel with ComboBoxModel {
+ def newConstantModel[A](items: Seq[A]): ComboBoxModel[A] = {
+ new AbstractListModel[A] with ComboBoxModel[A] {
private var selected: A = if (items.isEmpty) null.asInstanceOf[A] else items(0)
- def getSelectedItem: AnyRef = selected.asInstanceOf[AnyRef]
+ def getSelectedItem = selected.asInstanceOf[AnyRef]
def setSelectedItem(a: Any) {
if ((selected != null && selected != a) ||
selected == null && a != null) {
@@ -129,7 +129,7 @@
fireContentsChanged(this, -1, -1)
}
}
- def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
+ def getElementAt(n: Int) = items(n).asInstanceOf[A]
def getSize = items.size
}
}
@@ -157,7 +157,7 @@
* @see javax.swing.JComboBox
*/
class ComboBox[A](items: Seq[A]) extends Component with Publisher {
- override lazy val peer: JComboBox = new JComboBox(ComboBox.newConstantModel(items)) with SuperMixin
+ override lazy val peer: JComboBox[A] = new JComboBox(ComboBox.newConstantModel(items)) with SuperMixin
object selection extends Publisher {
def index: Int = peer.getSelectedIndex
@@ -182,7 +182,8 @@
* of the component to its own defaults _after_ the renderer has been
* configured. That's Swing's principle of most suprise.
*/
- def renderer: ListView.Renderer[A] = ListView.Renderer.wrap(peer.getRenderer)
+ def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getRenderer.asInstanceOf[ListCellRenderer[A]])
+ // def renderer: ListView.Renderer[A] = ListView.Renderer.wrap(peer.getRenderer)
def renderer_=(r: ListView.Renderer[A]) { peer.setRenderer(r.peer) }
/* XXX: currently not safe to expose:
@@ -201,8 +202,8 @@
peer.setEditor(editor(this).comboBoxPeer)
}
- def prototypeDisplayValue: Option[A] = toOption[A](peer.getPrototypeDisplayValue)
+ def prototypeDisplayValue: Option[A] = Option(peer.getPrototypeDisplayValue)
def prototypeDisplayValue_=(v: Option[A]) {
- peer.setPrototypeDisplayValue((v map toAnyRef).orNull)
+ peer.setPrototypeDisplayValue((v map toAnyRef).orNull.asInstanceOf[A])
}
}
--- scala-2.10.2-orig/src/swing/scala/swing/ListView.scala 2013-05-31 00:44:27.000000000 +1000
+++ scala-2.10.2/src/swing/scala/swing/ListView.scala 2013-08-20 20:26:48.334716000 +1000
@@ -24,21 +24,21 @@
val MultiInterval = Value(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
}
- def wrap[A](c: JList) = new ListView[A] {
+ def wrap[A](c: JList[A]) = new ListView[A] {
override lazy val peer = c
}
object Renderer {
- def wrap[A](r: ListCellRenderer): Renderer[A] = new Wrapped[A](r)
+ def wrap[A](r: ListCellRenderer[A]): Renderer[A] = new Wrapped[A](r)
/**
* Wrapper for <code>javax.swing.ListCellRenderer<code>s
*/
- class Wrapped[A](override val peer: ListCellRenderer) extends Renderer[A] {
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int) = {
+ class Wrapped[A](override val peer: ListCellRenderer[A]) extends Renderer[A] {
+ def componentFor(list: ListView[_ <: A], isSelected: Boolean, focused: Boolean, a: A, index: Int) = {
Component.wrap(peer.getListCellRendererComponent(list.peer, a, index, isSelected, focused).asInstanceOf[JComponent])
+ }
}
- }
/**
* Returns a renderer for items of type <code>A</code>. The given function
@@ -55,8 +55,8 @@
* </code>
*/
def apply[A,B](f: A => B)(implicit renderer: Renderer[B]): Renderer[A] = new Renderer[A] {
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component =
- renderer.componentFor(list, isSelected, focused, f(a), index)
+ def componentFor(list: ListView[_ <: A], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component =
+ renderer.componentFor(list.asInstanceOf[ListView[_ <: B]], isSelected, focused, f(a), index)
}
}
@@ -69,11 +69,11 @@
* @see javax.swing.ListCellRenderer
*/
abstract class Renderer[-A] {
- def peer: ListCellRenderer = new ListCellRenderer {
- def getListCellRendererComponent(list: JList, a: Any, index: Int, isSelected: Boolean, focused: Boolean) =
- componentFor(ListView.wrap[A](list), isSelected, focused, a.asInstanceOf[A], index).peer
+ def peer: ListCellRenderer[_ >: A] = new ListCellRenderer[A] {
+ def getListCellRendererComponent(list: JList[_ <: A], a: A, index: Int, isSelected: Boolean, focused: Boolean) =
+ componentFor(ListView.wrap[A](list.asInstanceOf[JList[A]]), isSelected, focused, a, index).peer
}
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component
+ def componentFor(list: ListView[_ <: A], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component
}
/**
@@ -110,7 +110,7 @@
/**
* Configures the component before returning it.
*/
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component = {
+ def componentFor(list: ListView[_ <: A], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component = {
preConfigure(list, isSelected, focused, a, index)
configure(list, isSelected, focused, a, index)
component
@@ -123,10 +123,10 @@
* that renders the string returned from an item's <code>toString</code>.
*/
implicit object GenericRenderer extends Renderer[Any] {
- override lazy val peer: ListCellRenderer = new DefaultListCellRenderer
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: Any, index: Int): Component = {
- val c = peer.getListCellRendererComponent(list.peer, a, index, isSelected, focused).asInstanceOf[JComponent]
- Component.wrap(c)
+ override lazy val peer: ListCellRenderer[Any] = (new DefaultListCellRenderer).asInstanceOf[ListCellRenderer[Any]]
+ def componentFor(list: ListView[_ <: Any], isSelected: Boolean, focused: Boolean, a: Any, index: Int): Component = {
+ val c = peer.getListCellRendererComponent(list.peer, a, index, isSelected, focused)
+ Component.wrap(c.asInstanceOf[JComponent])
}
}
}
@@ -142,34 +142,34 @@
*/
class ListView[A] extends Component {
import ListView._
- override lazy val peer: JList = new JList with SuperMixin
+ override lazy val peer: JList[A] = new JList[A] with SuperMixin
def this(items: Seq[A]) = {
this()
listData = items
}
- protected class ModelWrapper(val items: Seq[A]) extends AbstractListModel {
- def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
+ protected class ModelWrapper[A](val items: Seq[A]) extends AbstractListModel[A] {
+ def getElementAt(n: Int) = items(n)
def getSize = items.size
}
def listData: Seq[A] = peer.getModel match {
- case model: ModelWrapper => model.items
- case model @ _ => new Seq[A] { selfSeq =>
+ case model: ModelWrapper[a] => model.items
+ case model => new Seq[A] { selfSeq =>
def length = model.getSize
def iterator = new Iterator[A] {
var idx = 0
def next = { idx += 1; apply(idx-1) }
def hasNext = idx < selfSeq.length
}
- def apply(n: Int) = model.getElementAt(n).asInstanceOf[A]
+ def apply(n: Int): A = model.getElementAt(n)
}
}
def listData_=(items: Seq[A]) {
- peer.setModel(new AbstractListModel {
- def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
+ peer.setModel(new AbstractListModel[A] {
+ def getElementAt(n: Int) = items(n)
def getSize = items.size
})
}
@@ -216,7 +216,7 @@
def adjusting = peer.getSelectionModel.getValueIsAdjusting
}
- def renderer: ListView.Renderer[A] = ListView.Renderer.wrap(peer.getCellRenderer)
+ def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getCellRenderer.asInstanceOf[ListCellRenderer[A]])
def renderer_=(r: ListView.Renderer[A]) { peer.setCellRenderer(r.peer) }
def fixedCellWidth = peer.getFixedCellWidth