jrubyfx-openjfx.patch 1.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +202 -0
  3. data/README.md +121 -0
  4. data/bin/jrubyfx-compile +32 -0
  5. data/bin/jrubyfx-generator +98 -0
  6. data/bin/jrubyfx-jarify +115 -0
  7. data/lib/jrubyfx.rb +41 -0
  8. data/lib/jrubyfx/application.rb +42 -0
  9. data/lib/jrubyfx/compiler_app.rb +51 -0
  10. data/lib/jrubyfx/controller.rb +375 -0
  11. data/lib/jrubyfx/core_ext/border_pane.rb +30 -0
  12. data/lib/jrubyfx/core_ext/column_constraints.rb +43 -0
  13. data/lib/jrubyfx/core_ext/drag_event.rb +32 -0
  14. data/lib/jrubyfx/core_ext/duration.rb +30 -0
  15. data/lib/jrubyfx/core_ext/effects.rb +32 -0
  16. data/lib/jrubyfx/core_ext/exts.yml +57 -0
  17. data/lib/jrubyfx/core_ext/file_chooser.rb +63 -0
  18. data/lib/jrubyfx/core_ext/geometry.rb +27 -0
  19. data/lib/jrubyfx/core_ext/grid_pane.rb +30 -0
  20. data/lib/jrubyfx/core_ext/image_view.rb +25 -0
  21. data/lib/jrubyfx/core_ext/media_player.rb +25 -0
  22. data/lib/jrubyfx/core_ext/observable_value.rb +158 -0
  23. data/lib/jrubyfx/core_ext/pagination.rb +28 -0
  24. data/lib/jrubyfx/core_ext/path.rb +37 -0
  25. data/lib/jrubyfx/core_ext/precompiled.rb +1883 -0
  26. data/lib/jrubyfx/core_ext/progress_indicator.rb +41 -0
  27. data/lib/jrubyfx/core_ext/radial_gradient.rb +37 -0
  28. data/lib/jrubyfx/core_ext/region.rb +42 -0
  29. data/lib/jrubyfx/core_ext/rotate.rb +39 -0
  30. data/lib/jrubyfx/core_ext/stage.rb +89 -0
  31. data/lib/jrubyfx/core_ext/table_view.rb +31 -0
  32. data/lib/jrubyfx/core_ext/timeline.rb +56 -0
  33. data/lib/jrubyfx/core_ext/transition.rb +26 -0
  34. data/lib/jrubyfx/core_ext/tree_view.rb +40 -0
  35. data/lib/jrubyfx/core_ext/xy_chart.rb +53 -0
  36. data/lib/jrubyfx/dsl.rb +330 -0
  37. data/lib/jrubyfx/dsl_control.rb +28 -0
  38. data/lib/jrubyfx/dsl_map.rb +273 -0
  39. data/lib/jrubyfx/imports.rb +324 -0
  40. data/lib/jrubyfx/java_fx_impl.rb +144 -0
  41. data/lib/jrubyfx/module.rb +178 -0
  42. data/lib/jrubyfx/part_imports.rb +141 -0
  43. data/lib/jrubyfx/utils.rb +86 -0
  44. data/lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb +30 -0
  45. data/lib/jrubyfx/utils/common_converters.rb +223 -0
  46. data/lib/jrubyfx/utils/common_utils.rb +72 -0
  47. data/lib/jrubyfx/utils/string_utils.rb +48 -0
  48. data/lib/jrubyfx/version.rb +4 -0
  49. data/lib/jrubyfx_tasks.rb +183 -0
  50. metadata +145 -0
@@ -0,0 +1,30 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+
18
+ # JRubyFX DSL extensions for BorderPanes
19
+ class Java::javafx::scene::layout::BorderPane
20
+ include JRubyFX::DSL
21
+
22
+ # We don't want to add automatically for this type of pane
23
+ alias :method_missing :node_method_missing
24
+
25
+ alias :left :setLeft
26
+ alias :right :setRight
27
+ alias :top :setTop
28
+ alias :bottom :setBottom
29
+ alias :center :setCenter
30
+ end
@@ -0,0 +1,43 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX Column Constraints
20
+ class Java::javafx::scene::layout::ColumnConstraints
21
+ extend JRubyFX::Utils::CommonConverters
22
+
23
+ constrain = map_converter(constrain_to_pref: CONSTRAIN_TO_PREF,
24
+ constrain: CONSTRAIN_TO_PREF,
25
+ pref: CONSTRAIN_TO_PREF,
26
+ preferred: CONSTRAIN_TO_PREF)
27
+
28
+ converter_for :new, [], [:none], [:none, :none, constrain], [:none, :none, constrain, :none, :none, :none]
29
+
30
+ end
31
+
32
+ # JRubyFX DSL extensions for JavaFX Row Constraints
33
+ class Java::javafx::scene::layout::RowConstraints
34
+ extend JRubyFX::Utils::CommonConverters
35
+
36
+ constrain = map_converter(constrain_to_pref: CONSTRAIN_TO_PREF,
37
+ constrain: CONSTRAIN_TO_PREF,
38
+ pref: CONSTRAIN_TO_PREF,
39
+ preferred: CONSTRAIN_TO_PREF)
40
+
41
+ converter_for :new, [], [:none], [:none, :none, constrain], [:none, :none, constrain, :none, :none, :none]
42
+
43
+ end
@@ -0,0 +1,32 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/utils/common_converters'
18
+
19
+ # JRubyFX DSL extensions for JavaFX drag events
20
+ class Java::javafx::scene::input::DragEvent
21
+ extend JRubyFX::Utils::CommonConverters
22
+ include JRubyFX::Utils::CommonUtils
23
+
24
+ tmc = enum_converter(Java::javafx::scene::input::TransferMode)
25
+ converter_for :accept_transfer_modes, &tmc
26
+
27
+ # FIXME: For non-dsl calls like this we want converter logic
28
+ alias :accept_transfer_modes_orig :accept_transfer_modes
29
+ def accept_transfer_modes(*values)
30
+ accept_transfer_modes_orig *attempt_conversion(self, "accept_transfer_modes", *values)
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX Duration
20
+ class Numeric
21
+ # defines #ms, #sec, etc to create a JavaFX duration object of respective type
22
+ {:ms => :millis, :sec => :seconds, :min => :minutes,
23
+ :hrs => :hours, :hr => :hours}.each do |rname, jname|
24
+ self.instance_eval do
25
+ define_method rname do
26
+ Java.javafx.util.Duration.method(jname).call(self)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX drop shadows
20
+ class Java::javafx::scene::effect::DropShadow
21
+ extend JRubyFX::Utils::CommonConverters
22
+
23
+ converter_for :color, [:color]
24
+
25
+ class << self
26
+ extend JRubyFX::Utils::CommonConverters
27
+
28
+ converter_for :new, [], [:none, :color], [:none, :none, :none, :color],
29
+ [enum_converter(Java::javafx::scene::effect::BlurType), :color, :none, :none, :none, :none]
30
+ end
31
+
32
+ end
@@ -0,0 +1,57 @@
1
+ ## YAML Template.
2
+ ---
3
+ "Java::JavafxScene::Node":
4
+ rotate: []
5
+ getter_setter: effect
6
+ "Java::JavafxSceneControl::TabPane":
7
+ logical_children: tabs
8
+ "Java::JavafxSceneControl::Tab":
9
+ logical_child: content
10
+ "Java::JavafxScene::Scene":
11
+ logical_child: root
12
+ new_converter: [[none], [none, color], [none, none, none], [none, none, none, color]]
13
+ "Java::JavafxScene::Parent":
14
+ method_missing: "Java::JavafxScene::Node"
15
+ add: get_children
16
+ "Java::JavafxSceneControl::TreeItem":
17
+ method_missing: "Java::JavafxSceneControl::TreeItem"
18
+ add: get_children
19
+ "Java::JavafxSceneControl::TableView":
20
+ method_missing: "Java::JavafxSceneControl::TableColumn"
21
+ add: get_columns
22
+ "Java::JavafxAnimation::ParallelTransition":
23
+ method_missing: "Java::JavafxAnimation::Animation"
24
+ add: get_children
25
+ "Java::JavafxSceneControl::MenuBar":
26
+ method_missing: "Java::JavafxSceneControl::Menu"
27
+ add: get_menus
28
+ "Java::JavafxSceneControl::Menu":
29
+ method_missing: "Java::JavafxSceneControl::MenuItem"
30
+ add: get_items
31
+ "Java::JavafxSceneControl::ContextMenu":
32
+ method_missing: "Java::JavafxSceneControl::MenuItem"
33
+ add: get_items
34
+ "Java::JavafxSceneControl::MenuButton":
35
+ method_missing: "Java::JavafxSceneControl::MenuItem"
36
+ add: get_items
37
+ "Java::JavafxSceneControl::MenuItem":
38
+ dsl: Need to insert manually
39
+ "Java::JavafxAnimation::Timeline":
40
+ method_missing: "Java::JavafxAnimation::KeyFrame"
41
+ add: key_frames
42
+ "Java::JavafxSceneShape::Path":
43
+ add: elements
44
+ rotate: []
45
+ "Java::JavafxSceneControl::TitledPane":
46
+ logical_child: content
47
+ "Java::JavafxSceneControl::ScrollPane":
48
+ logical_child: content
49
+ "Java::JavafxSceneControl::Accordion":
50
+ add: panes
51
+ logical_children: panes
52
+ "Java::JavafxSceneShape::Circle":
53
+ new_converter: [[], [none], [none, color], [none, none, none], [none, none, none, color]]
54
+ "Java::JavafxScenePaint::Stop":
55
+ new_converter: [[none, color]]
56
+ "Java::JavafxSceneShape::Shape":
57
+ getter_setter: fill
@@ -0,0 +1,63 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX FileChooser
20
+ class Java::javafx::stage::FileChooser
21
+ include JRubyFX::DSL
22
+
23
+ # call-seq:
24
+ # add_extension_filter(description)
25
+ # add_extension_filter(description, filter)
26
+ # add_extension_filter(description, [filter, ...])
27
+ #
28
+ # Takes ether a straight descriptions with embedded (*.whatnot) filter, or
29
+ # separately, where filter can be an array or a string. Note that without a
30
+ # filter, the description MUST contain a list of extensions in parens.
31
+ # === Examples
32
+ # add_extension_filter("Ruby Files (*.rb)")
33
+ # add_extension_filter("Ruby Files (*.rb)", "*.rb")
34
+ # add_extension_filter("Ruby Files (*.rb)", ["*.rb", "*.rbw"])
35
+ #
36
+ def add_extension_filter(desc, filter=nil)
37
+ if filter == nil
38
+ # Attempt to parse out list of stuff in parens
39
+ filter = desc.match(/\(([\*\.\w;:, ]+)\)$/)[1] # grab everthing inside last parens
40
+ filter = filter.split(/[:; ,]/).delete_if(&:empty?)
41
+ end
42
+ filter = [filter] unless filter.is_a? Array
43
+ extension_filters.add(ExtensionFilter.new(desc.to_s, filter))
44
+ end
45
+
46
+ # call-seq:
47
+ # add_extension_filters([description, ...])
48
+ # add_extension_filters({description => filter, ...})
49
+ # add_extension_filters({description => [filter, ...], ...})
50
+ #
51
+ # Takes a straight list of descriptions with embedded (*.whatnot) filters, or
52
+ # a hash of "description" => "*.whatnot" or a hash of "description => ["*.whatnot", "*.etc"]
53
+ # === Examples
54
+ # add_extension_filters(["Ruby Files (*.rb)", "Python Files (*.py)"])
55
+ # add_extension_filters("Ruby Files (*.rb)" => "*.rb", "Python Files (*.py)" => ["*.py", "*.pyc"])
56
+ #
57
+ def add_extension_filters(filters)
58
+ #works with both arrays and hashes
59
+ filters.each do |filters|
60
+ add_extension_filter(*filters)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,27 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX Paths
20
+ class Java::javafx::geometry::Point2D
21
+ def to_a
22
+ [x,y]
23
+ end
24
+ def to_ary
25
+ [x,y]
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX Grid panes
20
+ class Java::javafx::scene::layout::GridPane
21
+ include JRubyFX::DSL
22
+ # don't kill the add(node, int, int..) methods
23
+ def add(node, *moar)
24
+ if moar.length > 1
25
+ self.java_send :add, [Node, *([Java::int]*moar.length)], node, *moar
26
+ else
27
+ children << node
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX Image Views
20
+ class Java::javafx::scene::image::ImageView
21
+ extend JRubyFX::Utils::CommonConverters
22
+
23
+ converter_for :viewport, [:rectangle2d]
24
+ # NO: logical_child :image this is not possible as the image is not a node, hnce no id
25
+ end
@@ -0,0 +1,25 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX color stops
20
+ class Java::javafx::scene::media::MediaPlayer
21
+ extend JRubyFX::Utils::CommonConverters
22
+
23
+ converter_for :cycle_count, [map_converter(indefinite: INDEFINITE)]
24
+
25
+ end
@@ -0,0 +1,158 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx'
18
+
19
+ # JRubyFX DSL extensions for JavaFX ObservableValues
20
+ module Java::javafx::beans::value::ObservableValue
21
+ java_import Java::javafx.beans.value.ChangeListener
22
+ java_import Java::javafx.beans.InvalidationListener
23
+
24
+ ##
25
+ # call-seq:
26
+ # add_change_listener { |observable, old_value, new_value| block }
27
+ # add_change_listener { |new_value| block }
28
+ #
29
+ # Add a ruby block to call when the property changes changes
30
+ def add_change_listener(type=nil, &block)
31
+ unless type
32
+ type = :list if self.is_a? Java::javafx::collections::ObservableList
33
+ type = :map if self.is_a? Java::javafx::collections::ObservableMap
34
+ end
35
+ if type == :list || type == :map
36
+ super(&block)
37
+ else
38
+ old_verbose = $VERBOSE
39
+ begin
40
+ $VERBOSE = nil
41
+ addListener(ChangeListener.impl {|name, x, y, z|
42
+ if block.arity == 1
43
+ block.call(z) # just call with new
44
+ else
45
+ block.call(x, y, z)
46
+ end
47
+ })
48
+ ensure
49
+ # always re-set to old value, even if block raises an exception
50
+ $VERBOSE = old_verbose
51
+ end
52
+ end
53
+ end
54
+
55
+
56
+ ##
57
+ # call-seq:
58
+ # add_invalidation_listener { |observable| block }
59
+ #
60
+ # Add a ruby block to call when the property invalidates itself (bad property!)
61
+ def add_invalidation_listener(&block)
62
+ old_verbose = $VERBOSE
63
+ begin
64
+ $VERBOSE = nil
65
+ addListener(InvalidationListener.impl {|name, change| block.call(change) })
66
+ ensure
67
+ # always re-set to old value, even if block raises an exception
68
+ $VERBOSE = old_verbose
69
+ end
70
+ end
71
+
72
+ # FIXME: Not sure how to remove with this API. We are passing in a proc
73
+ # and we would need to examine each proc to determine which listener to
74
+ # remove. Probably a way to do it in each derived real class which actually
75
+ # stores the listeners.
76
+ end
77
+
78
+ # JRubyFX DSL extensions for JavaFX ObservableLists
79
+ module Java::javafx::collections::ObservableList
80
+ java_import Java::javafx.collections.ListChangeListener
81
+
82
+ ##
83
+ # call-seq:
84
+ # add_change_listener { |change| block }
85
+ #
86
+ # Add a ruby block to call when the property changes changes
87
+ def add_change_listener(&block)
88
+ old_verbose = $VERBOSE
89
+ begin
90
+ $VERBOSE = nil
91
+ addListener(ListChangeListener.impl {|name, x|block.call(x)})
92
+ ensure
93
+ # always re-set to old value, even if block raises an exception
94
+ $VERBOSE = old_verbose
95
+ end
96
+ end
97
+
98
+ def index(x)
99
+ indexOf(x)
100
+ end
101
+
102
+ # FIXME: Not sure how to remove with this API. We are passing in a proc
103
+ # and we would need to examine each proc to determine which listener to
104
+ # remove. Probably a way to do it in each derived real class which actually
105
+ # stores the listeners.
106
+ end
107
+
108
+ # JRubyFX DSL extensions for JavaFX ObservableMaps
109
+ module Java::javafx::collections::ObservableMap
110
+ java_import Java::javafx.collections.MapChangeListener
111
+
112
+ ##
113
+ # call-seq:
114
+ # add_change_listener { |change| block }
115
+ #
116
+ # Add a ruby block to call when the property changes changes
117
+ def add_change_listener(&block)
118
+ old_verbose = $VERBOSE
119
+ begin
120
+ $VERBOSE = nil
121
+ addListener(MapChangeListener.impl {|name, x|block.call(x)})
122
+ ensure
123
+ # always re-set to old value, even if block raises an exception
124
+ $VERBOSE = old_verbose
125
+ end
126
+ end
127
+
128
+ # FIXME: Not sure how to remove with this API. We are passing in a proc
129
+ # and we would need to examine each proc to determine which listener to
130
+ # remove. Probably a way to do it in each derived real class which actually
131
+ # stores the listeners.
132
+ end
133
+
134
+ class Class
135
+ def property_writer(*symbol_names)
136
+ symbol_names.each do |symbol_name|
137
+ send(:define_method, symbol_name.id2name + "=") do |val|
138
+ instance_variable_get("@#{symbol_name}").setValue val
139
+ end
140
+ end
141
+ end
142
+ def property_reader(*symbol_names)
143
+ symbol_names.each do |symbol_name|
144
+ send(:define_method, symbol_name.id2name) do
145
+ instance_variable_get("@#{symbol_name}").getValue
146
+ end
147
+ end
148
+ end
149
+ def property_accessor(*symbol_names)
150
+ property_reader *symbol_names
151
+ property_writer *symbol_names
152
+ symbol_names.each do |symbol_name|
153
+ send(:define_method, symbol_name.id2name + "_property") do
154
+ instance_variable_get("@#{symbol_name}")
155
+ end
156
+ end
157
+ end
158
+ end