jrubyfx 1.1.0-java → 2.0.0-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.
@@ -72,7 +72,7 @@ class Java::javafx::stage::Stage
72
72
  #
73
73
  def layout_scene(*args, &code)
74
74
  root = code.arity == 1 ? code[node] : instance_eval(&code)
75
- build(Scene, root, *args).tap { |scene| set_scene scene }
75
+ build(Java::JavafxScene::Scene, root, *args).tap { |scene| set_scene scene }
76
76
  end
77
77
 
78
78
  def fxml(source, options={})
data/lib/jrubyfx/dsl.rb CHANGED
@@ -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,11 +39,16 @@ 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)
44
- name = type.name.snake_case unless name
50
+ def register_type(type=self, name=nil)
51
+ name = type.name.snake_case(true) unless name
45
52
  JRubyFX::DSL::NAME_TO_CLASSES[name.to_s] = type
46
53
  end
47
54
  module_function :register_type
@@ -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
@@ -189,7 +196,7 @@ module JRubyFX
189
196
  },
190
197
  rotate: ->(on){
191
198
  " def rotate(*args)
192
- transforms << build(Rotate, *args)
199
+ transforms << build(#{JRubyFX::DSL::NAME_TO_CLASS_NAME['rotate']}, *args)
193
200
  end\n"
194
201
  },
195
202
  method_missing: ->(on, type) {
@@ -235,9 +242,12 @@ module JRubyFX
235
242
  next if defs == "" || defs == nil
236
243
  # TODO: do we need to include the dsl? is this the fastest way to do it?
237
244
  outf<< <<HERDOC
245
+ begin
238
246
  class #{clz}
239
247
  include JRubyFX::DSL
240
248
  #{defs}end
249
+ rescue NameError # ignore, different JDK version likely
250
+ end
241
251
  HERDOC
242
252
  end
243
253
  end
@@ -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