jrubyfx 1.1.0-java → 1.1.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e779816cf2c32f18185c48d093e9578ccfdc40c8
4
+ data.tar.gz: 5a86e7f2556ff10b25164fc7fe8153a28d186f23
5
+ SHA512:
6
+ metadata.gz: 0568951c9f29eabead092a89898801f404bad06b438726af98562ee30e9702960fc2997aee1ae20c94efdc85850e98ded68545f2d0064b8b1b6db647926d3147
7
+ data.tar.gz: 0a90fe37ecc726d9d158a61a3990e509110b85df46c7412ae26c30bfc1815e4034cd4622afc783185abaf34d67f002f9e44f70e2c5d53faef26c119015b4b53b
@@ -34,6 +34,7 @@ end
34
34
  require_relative 'jrubyfx/imports'
35
35
  require_relative 'jrubyfx/module'
36
36
  require_relative 'jrubyfx/dsl'
37
+ require_relative 'jrubyfx/dsl_control'
37
38
  JRubyFX::DSL.load_dsl # load it after we require the dsl package to not loop around
38
39
  require_relative 'jrubyfx/application'
39
40
  require_relative 'jrubyfx/controller'
@@ -15,7 +15,13 @@ See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  =end
17
17
 
18
- require 'jrubyfx-fxmlloader'
18
+ require 'jrubyfx/utils/string_utils'
19
+ # If fxmlloader is installed, require it here
20
+ begin
21
+ require 'jrubyfx-fxmlloader'
22
+ rescue LoadError
23
+ # no fxmlloader, ignore it
24
+ end
19
25
 
20
26
  # Special methods for fxml loading
21
27
  module Kernel
@@ -64,7 +70,7 @@ module JRubyFX::Controller
64
70
 
65
71
  def self.included(base)
66
72
  base.extend(ClassMethods)
67
- base.extend(JRubyFX::FXMLClassUtils)
73
+ base.extend(JRubyFX::FXMLClassUtils) if defined? JRubyFX::FXMLClassUtils
68
74
  base.extend(JRubyFX::FXImports)
69
75
  # register ourselves as a control. overridable with custom_fxml_control
70
76
  register_type base if base.is_a? Class
@@ -333,10 +339,21 @@ module JRubyFX::Controller
333
339
  def self.get_fxml_loader(filename, controller = nil, root_dir = nil)
334
340
  fx = FxmlLoader.new
335
341
  fx.location =
336
- if JRubyFX::Application.in_jar?
342
+ if JRubyFX::Application.in_jar?
337
343
  # If we are in a jar file, use the class loader to get the file from the jar (like java)
338
344
  # TODO: should just be able to use URLs
339
- JRuby.runtime.jruby_class_loader.get_resource File.join(root_dir, filename)
345
+
346
+ # According to how class loader works, the correct path for a file inside a jar is NOT "/folder/file.fxml"
347
+ # but "folder/file.fxml" (without starting "/" or ".", which would both make the path to be seen as a filesystem
348
+ # reference) so we assume that if root_dir is set to "" or to any other path not starting with "." or "/" then
349
+ # we want to point to a folder inside the jar, otherwise to a filesystem's one. According to this we format and
350
+ # feed the right path to the class loader.
351
+
352
+ if root_dir == "" or not ["/", "."].include? (root_dir[0])
353
+ JRuby.runtime.jruby_class_loader.get_resource filename
354
+ else
355
+ JRuby.runtime.jruby_class_loader.get_resource File.join(root_dir, filename)
356
+ end
340
357
  else
341
358
  root_dir ||= fxml_root
342
359
  # If we are in the normal filesystem, create a file url path relative to relative_to or this file
@@ -1,20 +1,20 @@
1
1
  class Java::JavafxAnimation::PathTransition
2
2
  include JRubyFX::DSL
3
3
  def orientation=(rbenum)
4
- java_send "setOrientation", [Java::JavafxAnimation::OrientationType], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxAnimation::OrientationType)
4
+ java_send "setOrientation", [Java::JavafxAnimation::PathTransition::OrientationType], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxAnimation::PathTransition::OrientationType)
5
5
  end
6
6
  end
7
7
  class Java::JavafxScene::Node
8
8
  include JRubyFX::DSL
9
- def blend_mode=(rbenum)
10
- java_send "setBlendMode", [Java::JavafxSceneEffect::BlendMode], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneEffect::BlendMode)
11
- end
12
9
  def cache_hint=(rbenum)
13
10
  java_send "setCacheHint", [Java::JavafxScene::CacheHint], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxScene::CacheHint)
14
11
  end
15
12
  def depth_test=(rbenum)
16
13
  java_send "setDepthTest", [Java::JavafxScene::DepthTest], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxScene::DepthTest)
17
14
  end
15
+ def blend_mode=(rbenum)
16
+ java_send "setBlendMode", [Java::JavafxSceneEffect::BlendMode], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneEffect::BlendMode)
17
+ end
18
18
  def on_context_menu_requested(&block)
19
19
  if block_given?
20
20
  setOnContextMenuRequested block
@@ -367,23 +367,23 @@ end
367
367
  class Java::JavafxSceneControl::ScrollPane
368
368
  include JRubyFX::DSL
369
369
  def hbar_policy=(rbenum)
370
- java_send "setHbarPolicy", [Java::JavafxSceneControl::ScrollBarPolicy], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::ScrollBarPolicy)
370
+ java_send "setHbarPolicy", [Java::JavafxSceneControl::ScrollPane::ScrollBarPolicy], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::ScrollPane::ScrollBarPolicy)
371
371
  end
372
372
  def vbar_policy=(rbenum)
373
- java_send "setVbarPolicy", [Java::JavafxSceneControl::ScrollBarPolicy], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::ScrollBarPolicy)
373
+ java_send "setVbarPolicy", [Java::JavafxSceneControl::ScrollPane::ScrollBarPolicy], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::ScrollPane::ScrollBarPolicy)
374
374
  end
375
375
  #TODO: logical_child(content)
376
376
  end
377
377
  class Java::JavafxSceneControl::Separator
378
378
  include JRubyFX::DSL
379
- def halignment=(rbenum)
380
- java_send "setHalignment", [Java::JavafxGeometry::HPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::HPos)
379
+ def orientation=(rbenum)
380
+ java_send "setOrientation", [Java::JavafxGeometry::Orientation], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Orientation)
381
381
  end
382
382
  def valignment=(rbenum)
383
383
  java_send "setValignment", [Java::JavafxGeometry::VPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::VPos)
384
384
  end
385
- def orientation=(rbenum)
386
- java_send "setOrientation", [Java::JavafxGeometry::Orientation], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Orientation)
385
+ def halignment=(rbenum)
386
+ java_send "setHalignment", [Java::JavafxGeometry::HPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::HPos)
387
387
  end
388
388
  end
389
389
  class Java::JavafxSceneControl::Slider
@@ -401,7 +401,7 @@ end
401
401
  class Java::JavafxSceneControl::TableColumn
402
402
  include JRubyFX::DSL
403
403
  def sort_type=(rbenum)
404
- java_send "setSortType", [Java::JavafxSceneControl::SortType], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::SortType)
404
+ java_send "setSortType", [Java::JavafxSceneControl::TableColumn::SortType], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::TableColumn::SortType)
405
405
  end
406
406
  def on_edit_cancel(&block)
407
407
  if block_given?
@@ -427,12 +427,12 @@ class Java::JavafxSceneControl::TableColumn
427
427
  end
428
428
  class Java::JavafxSceneControl::TabPane
429
429
  include JRubyFX::DSL
430
- def tab_closing_policy=(rbenum)
431
- java_send "setTabClosingPolicy", [Java::JavafxSceneControl::TabClosingPolicy], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::TabClosingPolicy)
432
- end
433
430
  def side=(rbenum)
434
431
  java_send "setSide", [Java::JavafxGeometry::Side], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Side)
435
432
  end
433
+ def tab_closing_policy=(rbenum)
434
+ java_send "setTabClosingPolicy", [Java::JavafxSceneControl::TabPane::TabClosingPolicy], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::TabPane::TabClosingPolicy)
435
+ end
436
436
  #TODO: logical_children(tabs)
437
437
  end
438
438
  class Java::JavafxSceneControl::TextField
@@ -462,15 +462,15 @@ class Java::JavafxSceneControl::ToggleButton
462
462
  def alignment=(rbenum)
463
463
  java_send "setAlignment", [Java::JavafxGeometry::Pos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Pos)
464
464
  end
465
- def blend_mode=(rbenum)
466
- java_send "setBlendMode", [Java::JavafxSceneEffect::BlendMode], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneEffect::BlendMode)
467
- end
468
465
  def cache_hint=(rbenum)
469
466
  java_send "setCacheHint", [Java::JavafxScene::CacheHint], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxScene::CacheHint)
470
467
  end
471
468
  def depth_test=(rbenum)
472
469
  java_send "setDepthTest", [Java::JavafxScene::DepthTest], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxScene::DepthTest)
473
470
  end
471
+ def blend_mode=(rbenum)
472
+ java_send "setBlendMode", [Java::JavafxSceneEffect::BlendMode], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneEffect::BlendMode)
473
+ end
474
474
  def text_fill=(value)
475
475
  setTextFill(JRubyFX::Utils::CommonConverters::CONVERTERS[:color].call(value))
476
476
  end
@@ -808,27 +808,27 @@ class Java::JavafxSceneEffect::Shadow
808
808
  end
809
809
  class Java::JavafxSceneLayout::ColumnConstraints
810
810
  include JRubyFX::DSL
811
- def hgrow=(rbenum)
812
- java_send "setHgrow", [Java::JavafxSceneLayout::Priority], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneLayout::Priority)
813
- end
814
811
  def halignment=(rbenum)
815
812
  java_send "setHalignment", [Java::JavafxGeometry::HPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::HPos)
816
813
  end
814
+ def hgrow=(rbenum)
815
+ java_send "setHgrow", [Java::JavafxSceneLayout::Priority], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneLayout::Priority)
816
+ end
817
817
  end
818
818
  class Java::JavafxSceneLayout::FlowPane
819
819
  include JRubyFX::DSL
820
+ def orientation=(rbenum)
821
+ java_send "setOrientation", [Java::JavafxGeometry::Orientation], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Orientation)
822
+ end
823
+ def alignment=(rbenum)
824
+ java_send "setAlignment", [Java::JavafxGeometry::Pos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Pos)
825
+ end
820
826
  def column_halignment=(rbenum)
821
827
  java_send "setColumnHalignment", [Java::JavafxGeometry::HPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::HPos)
822
828
  end
823
829
  def row_valignment=(rbenum)
824
830
  java_send "setRowValignment", [Java::JavafxGeometry::VPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::VPos)
825
831
  end
826
- def alignment=(rbenum)
827
- java_send "setAlignment", [Java::JavafxGeometry::Pos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Pos)
828
- end
829
- def orientation=(rbenum)
830
- java_send "setOrientation", [Java::JavafxGeometry::Orientation], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Orientation)
831
- end
832
832
  end
833
833
  class Java::JavafxSceneLayout::GridPane
834
834
  include JRubyFX::DSL
@@ -844,12 +844,12 @@ class Java::JavafxSceneLayout::HBox
844
844
  end
845
845
  class Java::JavafxSceneLayout::RowConstraints
846
846
  include JRubyFX::DSL
847
- def vgrow=(rbenum)
848
- java_send "setVgrow", [Java::JavafxSceneLayout::Priority], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneLayout::Priority)
849
- end
850
847
  def valignment=(rbenum)
851
848
  java_send "setValignment", [Java::JavafxGeometry::VPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::VPos)
852
849
  end
850
+ def vgrow=(rbenum)
851
+ java_send "setVgrow", [Java::JavafxSceneLayout::Priority], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneLayout::Priority)
852
+ end
853
853
  end
854
854
  class Java::JavafxSceneLayout::StackPane
855
855
  include JRubyFX::DSL
@@ -859,14 +859,14 @@ class Java::JavafxSceneLayout::StackPane
859
859
  end
860
860
  class Java::JavafxSceneLayout::TilePane
861
861
  include JRubyFX::DSL
862
- def tile_alignment=(rbenum)
863
- java_send "setTileAlignment", [Java::JavafxGeometry::Pos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Pos)
862
+ def orientation=(rbenum)
863
+ java_send "setOrientation", [Java::JavafxGeometry::Orientation], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Orientation)
864
864
  end
865
865
  def alignment=(rbenum)
866
866
  java_send "setAlignment", [Java::JavafxGeometry::Pos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Pos)
867
867
  end
868
- def orientation=(rbenum)
869
- java_send "setOrientation", [Java::JavafxGeometry::Orientation], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Orientation)
868
+ def tile_alignment=(rbenum)
869
+ java_send "setTileAlignment", [Java::JavafxGeometry::Pos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::Pos)
870
870
  end
871
871
  end
872
872
  class Java::JavafxSceneLayout::VBox
@@ -904,12 +904,12 @@ class Java::JavafxSceneShape::Shape
904
904
  def stroke_type=(rbenum)
905
905
  java_send "setStrokeType", [Java::JavafxSceneShape::StrokeType], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneShape::StrokeType)
906
906
  end
907
- def fill=(value)
908
- setFill(JRubyFX::Utils::CommonConverters::CONVERTERS[:color].call(value))
909
- end
910
907
  def stroke=(value)
911
908
  setStroke(JRubyFX::Utils::CommonConverters::CONVERTERS[:color].call(value))
912
909
  end
910
+ def fill=(value)
911
+ setFill(JRubyFX::Utils::CommonConverters::CONVERTERS[:color].call(value))
912
+ end
913
913
  def fill(*r)
914
914
  if r.length > 0
915
915
  self.fill = r[0]
@@ -926,6 +926,9 @@ class Java::JavafxSceneShape::SVGPath
926
926
  end
927
927
  class Java::JavafxSceneText::Text
928
928
  include JRubyFX::DSL
929
+ def text_alignment=(rbenum)
930
+ java_send "setTextAlignment", [Java::JavafxSceneText::TextAlignment], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneText::TextAlignment)
931
+ end
929
932
  def bounds_type=(rbenum)
930
933
  java_send "setBoundsType", [Java::JavafxSceneText::TextBoundsType], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneText::TextBoundsType)
931
934
  end
@@ -935,9 +938,6 @@ class Java::JavafxSceneText::Text
935
938
  def text_origin=(rbenum)
936
939
  java_send "setTextOrigin", [Java::JavafxGeometry::VPos], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxGeometry::VPos)
937
940
  end
938
- def text_alignment=(rbenum)
939
- java_send "setTextAlignment", [Java::JavafxSceneText::TextAlignment], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneText::TextAlignment)
940
- end
941
941
  end
942
942
  class Java::JavafxSceneWeb::WebView
943
943
  include JRubyFX::DSL
@@ -1317,6 +1317,13 @@ class Java::JavafxConcurrent::Task
1317
1317
  end
1318
1318
  class Java::JavafxConcurrent::Service
1319
1319
  include JRubyFX::DSL
1320
+ def on_ready(&block)
1321
+ if block_given?
1322
+ setOnReady block
1323
+ else
1324
+ getOnReady
1325
+ end
1326
+ end
1320
1327
  def on_cancelled(&block)
1321
1328
  if block_given?
1322
1329
  setOnCancelled block
@@ -1352,13 +1359,6 @@ class Java::JavafxConcurrent::Service
1352
1359
  getOnSucceeded
1353
1360
  end
1354
1361
  end
1355
- def on_ready(&block)
1356
- if block_given?
1357
- setOnReady block
1358
- else
1359
- getOnReady
1360
- end
1361
- end
1362
1362
  end
1363
1363
  class Java::JavafxSceneControl::ContextMenu
1364
1364
  include JRubyFX::DSL
@@ -1550,6 +1550,20 @@ class Java::JavafxSceneMedia::Media
1550
1550
  end
1551
1551
  class Java::JavafxSceneMedia::MediaPlayer
1552
1552
  include JRubyFX::DSL
1553
+ def on_ready(&block)
1554
+ if block_given?
1555
+ setOnReady block
1556
+ else
1557
+ getOnReady
1558
+ end
1559
+ end
1560
+ def on_error(&block)
1561
+ if block_given?
1562
+ setOnError block
1563
+ else
1564
+ getOnError
1565
+ end
1566
+ end
1553
1567
  def on_end_of_media(&block)
1554
1568
  if block_given?
1555
1569
  setOnEndOfMedia block
@@ -1606,20 +1620,6 @@ class Java::JavafxSceneMedia::MediaPlayer
1606
1620
  getOnStopped
1607
1621
  end
1608
1622
  end
1609
- def on_error(&block)
1610
- if block_given?
1611
- setOnError block
1612
- else
1613
- getOnError
1614
- end
1615
- end
1616
- def on_ready(&block)
1617
- if block_given?
1618
- setOnReady block
1619
- else
1620
- getOnReady
1621
- end
1622
- end
1623
1623
  end
1624
1624
  class Java::JavafxSceneMedia::MediaView
1625
1625
  include JRubyFX::DSL
@@ -28,6 +28,8 @@ module JRubyFX
28
28
  include JRubyFX::FXImports
29
29
 
30
30
  ##
31
+ # DEPRECATED: Please include JRubyFX::DSLControl instead of this method.
32
+ #
31
33
  # Register your own type for use in the DSL.
32
34
  #
33
35
  # class MyFooWidget < Region
@@ -37,10 +39,15 @@ module JRubyFX
37
39
  # register_type(MyFooWidget)
38
40
  # register_type(MyFooWidget, "aliased_name")
39
41
  #
42
+ # class MyOtherWidget < Region
43
+ # register_type
44
+ # end
45
+ #
46
+ #
40
47
  # Note, this also makes it possible to override existing definitions
41
48
  # of built-in components.
42
49
  #
43
- def register_type(type, name=nil)
50
+ def register_type(type=self, name=nil)
44
51
  name = type.name.snake_case unless name
45
52
  JRubyFX::DSL::NAME_TO_CLASSES[name.to_s] = type
46
53
  end
@@ -83,7 +90,7 @@ module JRubyFX
83
90
  clazz = NAME_TO_CLASSES[fixed_name]
84
91
  unless clazz
85
92
  clazz = NAME_TO_CLASS_NAME[fixed_name]
86
- clazz = (NAME_TO_CLASSES[fixed_name] = clazz.constantize_by) if clazz
93
+ clazz = (NAME_TO_CLASSES[fixed_name] = clazz.constantize_by("::")) if clazz
87
94
  end
88
95
 
89
96
  unless clazz
@@ -0,0 +1,28 @@
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 'java'
18
+ require 'jrubyfx/dsl'
19
+
20
+ module JRubyFX
21
+ # If you want a control to be registered with the dsl calling syntax
22
+ # you should indicate it by including this module.
23
+ module DSLControl
24
+ def self.included(mod)
25
+ JRubyFX::DSL::ClassUtils.register_type mod
26
+ end
27
+ end
28
+ end
@@ -178,6 +178,7 @@ module JRubyFX
178
178
  'key_code' => "Java::JavafxSceneInput::KeyCode",
179
179
  'key_event' => "Java::JavafxSceneInput::KeyEvent",
180
180
  'mnemonic' => "Java::JavafxSceneInput::Mnemonic",
181
+ 'mouse_button' => "Java::JavafxSceneInput::MouseButton",
181
182
  'mouse_drag_event' => "Java::JavafxSceneInput::MouseDragEvent",
182
183
  'mouse_event' => "Java::JavafxSceneInput::MouseEvent",
183
184
  'rotate_event' => "Java::JavafxSceneInput::RotateEvent",
@@ -38,6 +38,10 @@ begin
38
38
  jre[:version].to_f < 1.8 or
39
39
  (jre[:version].to_f == 1.8 and jre[:release] == 'ea' and jre[:build].to_i < 75)
40
40
 
41
+ # Java 8 at some point requires explicit toolkit/platform initialization
42
+ # before any controls can be loaded.
43
+ JRubyFX.load_fx
44
+
41
45
  # Attempt to load a javafx class
42
46
  Java.javafx.application.Application
43
47
  rescue LoadError, NameError
@@ -215,6 +219,7 @@ LOCAL_NAME_MAP = {
215
219
  :KeyCode => "javafx.scene.input.KeyCode",
216
220
  :KeyEvent => "javafx.scene.input.KeyEvent",
217
221
  :Mnemonic => "javafx.scene.input.Mnemonic",
222
+ :MouseButton => "javafx.scene.input.MouseButton",
218
223
  :MouseDragEvent => "javafx.scene.input.MouseDragEvent",
219
224
  :MouseEvent => "javafx.scene.input.MouseEvent",
220
225
  :RotateEvent => "javafx.scene.input.RotateEvent",
@@ -79,12 +79,6 @@ module JavaFXImpl #:nodoc: all
79
79
  end
80
80
 
81
81
  def self.launch_app_from_thread(application_class, args)
82
- #platformImpl startup?
83
- CountDownLatch.new(1).tap do |latch|
84
- PlatformImpl.startup { latch.countDown }
85
- latch.await
86
- end
87
-
88
82
  begin
89
83
  launch_app_after_platform(application_class, args)
90
84
  rescue => ex
@@ -167,6 +167,9 @@ module JRubyFX
167
167
  end
168
168
  return instance_variable_get("@#{symbol_name}")
169
169
  end
170
+ send(:define_method, pname.snake_case) do
171
+ send(pname)
172
+ end
170
173
  add_method_signature pname, [ptype]
171
174
  add_method_signature "set" + camel, [java.lang.Void, type]
172
175
  add_method_signature "get" + camel, [type]
@@ -38,6 +38,10 @@ begin
38
38
  jre[:version].to_f < 1.8 or
39
39
  (jre[:version].to_f == 1.8 and jre[:release] == 'ea' and jre[:build].to_i < 75)
40
40
 
41
+ # Java 8 at some point requires explicit toolkit/platform initialization
42
+ # before any controls can be loaded.
43
+ JRubyFX.load_fx
44
+
41
45
  # Attempt to load a javafx class
42
46
  Java.javafx.application.Application
43
47
  rescue LoadError, NameError
@@ -90,7 +94,7 @@ module JRubyFX
90
94
  InnerShadow Lighting MotionBlur PerspectiveTransform Reflection SepiaTone Shadow],
91
95
  :image => %w[Image ImageView PixelReader PixelWriter],
92
96
  :input => %w[Clipboard ClipboardContent ContextMenuEvent DragEvent GestureEvent InputEvent InputMethodEvent KeyCode KeyEvent
93
- Mnemonic MouseDragEvent MouseEvent RotateEvent ScrollEvent SwipeEvent TouchEvent TransferMode ZoomEvent],
97
+ Mnemonic MouseButton MouseDragEvent MouseEvent RotateEvent ScrollEvent SwipeEvent TouchEvent TransferMode ZoomEvent],
94
98
  :layout => %w[AnchorPane BorderPane ColumnConstraints FlowPane GridPane HBox Pane Priority RowConstraints StackPane TilePane VBox],
95
99
  :media => %w[AudioClip AudioEqualizer AudioTrack EqualizerBand Media MediaException
96
100
  MediaErrorEvent MediaMarkerEvent MediaPlayer MediaView VideoTrack],
@@ -63,3 +63,14 @@ module Enumerable
63
63
  end]
64
64
  end
65
65
  end
66
+
67
+ module JRubyFX
68
+ def self.load_fx(force=false)
69
+ return if @already_loaded_fx and !force
70
+ @already_loaded_fx = true
71
+ java.util.concurrent.CountDownLatch.new(1).tap do |latch|
72
+ com.sun.javafx.application.PlatformImpl.startup { latch.countDown }
73
+ latch.await
74
+ end
75
+ end
76
+ end
@@ -140,6 +140,9 @@ module JRubyFX
140
140
  },
141
141
  :color => lambda { |value|
142
142
  new_value = NAME_TO_COLORS[value.to_s.gsub(/_/, "")]
143
+ if !new_value && value.kind_of?(Symbol)
144
+ raise ArgumentError.new("No such color: #{value.to_s}")
145
+ end
143
146
  new_value ? new_value : value
144
147
  },
145
148
  :rectangle2d => lambda { |value|
@@ -0,0 +1,48 @@
1
+ class String
2
+
3
+ # steal handy methods from activesupport
4
+ # Tries to find a constant with the name specified in the argument string.
5
+ #
6
+ # 'Module'.constantize # => Module
7
+ # 'Test::Unit'.constantize # => Test::Unit
8
+ #
9
+ # The name is assumed to be the one of a top-level constant, no matter
10
+ # whether it starts with "::" or not. No lexical context is taken into
11
+ # account:
12
+ #
13
+ # C = 'outside'
14
+ # module M
15
+ # C = 'inside'
16
+ # C # => 'inside'
17
+ # 'C'.constantize # => 'outside', same as ::C
18
+ # end
19
+ #
20
+ # NameError is raised when the name is not in CamelCase or the constant is
21
+ # unknown.
22
+ def constantize_by(splitter="::")
23
+ camel_cased_word = self
24
+ names = camel_cased_word.split(splitter)
25
+ names.shift if names.empty? || names.first.empty?
26
+
27
+ names.inject(Object) do |constant, name|
28
+ if constant == Object
29
+ constant.const_get(name)
30
+ else
31
+ candidate = constant.const_get(name)
32
+ next candidate if constant.const_defined?(name, false)
33
+ next candidate unless Object.const_defined?(name)
34
+
35
+ # Go down the ancestors to check it it's owned
36
+ # directly before we reach Object or the end of ancestors.
37
+ constant = constant.ancestors.inject do |const, ancestor|
38
+ break const if ancestor == Object
39
+ break ancestor if ancestor.const_defined?(name, false)
40
+ const
41
+ end
42
+
43
+ # owner is in Object, so raise
44
+ constant.const_get(name, false)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,4 +1,4 @@
1
1
  module JRubyFX
2
2
  # Current gem version. Used in rake task.
3
- VERSION='1.1.0'
3
+ VERSION='1.1.1'
4
4
  end
@@ -26,14 +26,14 @@ module JRubyFX
26
26
  module Tasks
27
27
  extend Rake::DSL
28
28
  # Base URL of JRuby-complete.jar download location
29
- BASE_URL='http://repository.codehaus.org/org/jruby/jruby-complete'
29
+ BASE_URL='http://jruby.org.s3.amazonaws.com/downloads'
30
30
 
31
31
  ##
32
32
  # Downloads the jruby-complete jar file for `jruby_version` and save in
33
33
  # ~/.jruby-jar/jruby-complete.jar unless it already exits. If the jar is
34
34
  # corrupt or an older version, set force to true to delete and re-download
35
35
  def download_jruby(jruby_version, force=false)
36
- dist = "#{ENV['HOME']}/.jruby-jar"
36
+ dist = "#{Dir.home}/.jruby-jar"
37
37
  unless force || (File.exists?("#{dist}/jruby-complete-#{jruby_version}.jar") && File.size("#{dist}/jruby-complete-#{jruby_version}.jar") > 0)
38
38
  mkdir_p dist
39
39
  base_dir = Dir.pwd
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jrubyfx
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.0
4
+ version: 1.1.1
6
5
  platform: java
7
6
  authors:
8
7
  - Patrick Plenefisch
@@ -12,7 +11,7 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-09-28 00:00:00.000000000 Z
14
+ date: 2014-11-05 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: rake
@@ -21,13 +20,11 @@ dependencies:
21
20
  - - '>='
22
21
  - !ruby/object:Gem::Version
23
22
  version: '0'
24
- none: false
25
23
  requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - '>='
28
26
  - !ruby/object:Gem::Version
29
27
  version: '0'
30
- none: false
31
28
  prerelease: false
32
29
  type: :development
33
30
  - !ruby/object:Gem::Dependency
@@ -37,13 +34,11 @@ dependencies:
37
34
  - - '>='
38
35
  - !ruby/object:Gem::Version
39
36
  version: '0'
40
- none: false
41
37
  requirement: !ruby/object:Gem::Requirement
42
38
  requirements:
43
39
  - - '>='
44
40
  - !ruby/object:Gem::Version
45
41
  version: '0'
46
- none: false
47
42
  prerelease: false
48
43
  type: :development
49
44
  - !ruby/object:Gem::Dependency
@@ -52,14 +47,12 @@ dependencies:
52
47
  requirements:
53
48
  - - '>='
54
49
  - !ruby/object:Gem::Version
55
- version: '0.3'
56
- none: false
50
+ version: '0.4'
57
51
  requirement: !ruby/object:Gem::Requirement
58
52
  requirements:
59
53
  - - '>='
60
54
  - !ruby/object:Gem::Version
61
- version: '0.3'
62
- none: false
55
+ version: '0.4'
63
56
  prerelease: false
64
57
  type: :runtime
65
58
  description: Enables JavaFX with FXML controllers and application in pure ruby
@@ -77,52 +70,56 @@ extra_rdoc_files: []
77
70
  files:
78
71
  - lib/jrubyfx.rb
79
72
  - lib/jrubyfx_tasks.rb
80
- - lib/jrubyfx/part_imports.rb
81
- - lib/jrubyfx/dsl.rb
82
- - lib/jrubyfx/version.rb
83
- - lib/jrubyfx/controller.rb
84
- - lib/jrubyfx/compiler_app.rb
85
- - lib/jrubyfx/dsl_map.rb
86
73
  - lib/jrubyfx/imports.rb
87
- - lib/jrubyfx/module.rb
74
+ - lib/jrubyfx/dsl_map.rb
88
75
  - lib/jrubyfx/application.rb
76
+ - lib/jrubyfx/compiler_app.rb
77
+ - lib/jrubyfx/controller.rb
78
+ - lib/jrubyfx/dsl.rb
79
+ - lib/jrubyfx/dsl_control.rb
89
80
  - lib/jrubyfx/java_fx_impl.rb
81
+ - lib/jrubyfx/part_imports.rb
90
82
  - lib/jrubyfx/utils.rb
91
- - lib/jrubyfx/core_ext/grid_pane.rb
92
- - lib/jrubyfx/core_ext/media_player.rb
83
+ - lib/jrubyfx/version.rb
84
+ - lib/jrubyfx/module.rb
85
+ - lib/jrubyfx/core_ext/border_pane.rb
86
+ - lib/jrubyfx/core_ext/column_constraints.rb
87
+ - lib/jrubyfx/core_ext/drag_event.rb
93
88
  - lib/jrubyfx/core_ext/duration.rb
94
89
  - lib/jrubyfx/core_ext/effects.rb
95
- - lib/jrubyfx/core_ext/transition.rb
90
+ - lib/jrubyfx/core_ext/image_view.rb
91
+ - lib/jrubyfx/core_ext/media_player.rb
96
92
  - lib/jrubyfx/core_ext/pagination.rb
97
- - lib/jrubyfx/core_ext/drag_event.rb
93
+ - lib/jrubyfx/core_ext/progress_indicator.rb
94
+ - lib/jrubyfx/core_ext/radial_gradient.rb
98
95
  - lib/jrubyfx/core_ext/region.rb
99
- - lib/jrubyfx/core_ext/image_view.rb
100
- - lib/jrubyfx/core_ext/tree_view.rb
96
+ - lib/jrubyfx/core_ext/rotate.rb
97
+ - lib/jrubyfx/core_ext/stage.rb
101
98
  - lib/jrubyfx/core_ext/table_view.rb
102
- - lib/jrubyfx/core_ext/file_chooser.rb
103
- - lib/jrubyfx/core_ext/geometry.rb
99
+ - lib/jrubyfx/core_ext/timeline.rb
100
+ - lib/jrubyfx/core_ext/transition.rb
101
+ - lib/jrubyfx/core_ext/tree_view.rb
104
102
  - lib/jrubyfx/core_ext/xy_chart.rb
105
- - lib/jrubyfx/core_ext/rotate.rb
103
+ - lib/jrubyfx/core_ext/precompiled.rb
106
104
  - lib/jrubyfx/core_ext/exts.yml
107
- - lib/jrubyfx/core_ext/column_constraints.rb
105
+ - lib/jrubyfx/core_ext/file_chooser.rb
106
+ - lib/jrubyfx/core_ext/geometry.rb
107
+ - lib/jrubyfx/core_ext/grid_pane.rb
108
108
  - lib/jrubyfx/core_ext/observable_value.rb
109
- - lib/jrubyfx/core_ext/precompiled.rb
110
- - lib/jrubyfx/core_ext/stage.rb
111
- - lib/jrubyfx/core_ext/border_pane.rb
112
- - lib/jrubyfx/core_ext/timeline.rb
113
- - lib/jrubyfx/core_ext/radial_gradient.rb
114
- - lib/jrubyfx/core_ext/progress_indicator.rb
115
109
  - lib/jrubyfx/core_ext/path.rb
110
+ - lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb
116
111
  - lib/jrubyfx/utils/common_utils.rb
117
112
  - lib/jrubyfx/utils/common_converters.rb
118
- - lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb
113
+ - lib/jrubyfx/utils/string_utils.rb
119
114
  - LICENSE
120
115
  - README.md
121
116
  - bin/jrubyfx-generator
122
117
  - bin/jrubyfx-jarify
123
118
  - bin/jrubyfx-compile
124
119
  homepage: https://github.com/jruby/jrubyfx
125
- licenses: []
120
+ licenses:
121
+ - Apache-2.0
122
+ metadata: {}
126
123
  post_install_message:
127
124
  rdoc_options: []
128
125
  require_paths:
@@ -132,23 +129,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
129
  - - '>='
133
130
  - !ruby/object:Gem::Version
134
131
  version: '0'
135
- segments:
136
- - 0
137
- hash: 2
138
- none: false
139
132
  required_rubygems_version: !ruby/object:Gem::Requirement
140
133
  requirements:
141
134
  - - '>='
142
135
  - !ruby/object:Gem::Version
143
136
  version: '0'
144
- segments:
145
- - 0
146
- hash: 2
147
- none: false
148
137
  requirements: []
149
138
  rubyforge_project: jrubyfx
150
- rubygems_version: 1.8.24
139
+ rubygems_version: 2.1.9
151
140
  signing_key:
152
- specification_version: 3
141
+ specification_version: 4
153
142
  summary: JavaFX for JRuby with FXML
154
143
  test_files: []