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.
- checksums.yaml +7 -0
- data/README.md +21 -10
- data/lib/jrubyfx/application.rb +3 -3
- data/lib/jrubyfx/compiler_app.rb +2 -0
- data/lib/jrubyfx/controller.rb +91 -34
- data/lib/jrubyfx/core_ext/exts.yml +9 -1
- data/lib/jrubyfx/core_ext/observable_value.rb +20 -2
- data/lib/jrubyfx/core_ext/precompiled.rb +1865 -742
- data/lib/jrubyfx/core_ext/stage.rb +1 -1
- data/lib/jrubyfx/dsl.rb +14 -4
- data/lib/jrubyfx/dsl_control.rb +28 -0
- data/lib/jrubyfx/dsl_map.rb +487 -9
- data/lib/jrubyfx/fxml_helper.rb +134 -0
- data/lib/jrubyfx/imports.rb +503 -26
- data/lib/jrubyfx/module.rb +31 -0
- data/lib/jrubyfx/part_imports.rb +67 -52
- data/lib/jrubyfx/utils/common_converters.rb +3 -0
- data/lib/jrubyfx/utils/string_utils.rb +48 -0
- data/lib/jrubyfx/utils.rb +29 -3
- data/lib/jrubyfx/version.rb +1 -1
- data/lib/jrubyfx.rb +7 -5
- data/lib/jrubyfx_tasks.rb +7 -3
- metadata +54 -80
- data/lib/jrubyfx/java_fx_impl.rb +0 -143
data/lib/jrubyfx/java_fx_impl.rb
DELETED
@@ -1,143 +0,0 @@
|
|
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
|
-
#:nodoc: all
|
18
|
-
|
19
|
-
# Due to certain bugs in JRuby 1.7 (namely some newInstance mapping bugs), we
|
20
|
-
# are forced to re-create the Launcher if we want a pure ruby wrapper
|
21
|
-
# I can't wait to delete this. The _ONLY_ code that should use this is
|
22
|
-
# JRubyFX::Application.launch. Do _NOT_ use this code anywhere else.
|
23
|
-
module JavaFXImpl #:nodoc: all
|
24
|
-
java_import 'com.sun.javafx.application.PlatformImpl'
|
25
|
-
java_import 'javafx.stage.Stage'
|
26
|
-
|
27
|
-
#JRuby, you make me have to create real classes!
|
28
|
-
class FinisherInterface
|
29
|
-
include PlatformImpl::FinishListener
|
30
|
-
|
31
|
-
def initialize(&block)
|
32
|
-
@exitBlock = block
|
33
|
-
end
|
34
|
-
|
35
|
-
def idle(someBoolean)
|
36
|
-
@exitBlock.call
|
37
|
-
end
|
38
|
-
|
39
|
-
def exitCalled()
|
40
|
-
@exitBlock.call
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class Launcher
|
45
|
-
java_import 'java.util.concurrent.atomic.AtomicBoolean'
|
46
|
-
java_import 'java.util.concurrent.CountDownLatch'
|
47
|
-
java_import 'java.lang.IllegalStateException'
|
48
|
-
java_import 'com.sun.javafx.application.ParametersImpl'
|
49
|
-
|
50
|
-
@@launchCalled = AtomicBoolean.new(false) # Atomic boolean go boom on bikini
|
51
|
-
|
52
|
-
def self.launch_app(application_class, *args)
|
53
|
-
#prevent multiple!
|
54
|
-
if @@launchCalled.getAndSet(true)
|
55
|
-
throw IllegalStateException.new "Application launch must not be called more than once"
|
56
|
-
end
|
57
|
-
|
58
|
-
begin
|
59
|
-
#create a java thread, and run the real worker, and wait till it exits
|
60
|
-
count_down_latch = CountDownLatch.new(1)
|
61
|
-
thread = Java.java.lang.Thread.new do
|
62
|
-
begin
|
63
|
-
launch_app_from_thread(application_class, args)
|
64
|
-
rescue => ex
|
65
|
-
puts "Exception starting app:"
|
66
|
-
p ex
|
67
|
-
p ex.backtrace
|
68
|
-
end
|
69
|
-
count_down_latch.countDown #always count down
|
70
|
-
end
|
71
|
-
thread.name = "JavaFX-Launcher"
|
72
|
-
thread.start
|
73
|
-
count_down_latch.await
|
74
|
-
rescue => ex
|
75
|
-
puts "Exception launching JavaFX-Launcher thread:"
|
76
|
-
p ex
|
77
|
-
puts ex.backtrace
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
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
|
-
begin
|
89
|
-
launch_app_after_platform(application_class, args)
|
90
|
-
rescue => ex
|
91
|
-
puts "Error running Application:"
|
92
|
-
p ex
|
93
|
-
puts ex.backtrace
|
94
|
-
end
|
95
|
-
|
96
|
-
PlatformImpl.tkExit # kill the toolkit and exit
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.launch_app_after_platform(application_class, args)
|
100
|
-
#listeners - for the end
|
101
|
-
finished_latch = CountDownLatch.new(1)
|
102
|
-
|
103
|
-
# register for shutdown
|
104
|
-
PlatformImpl.addListener(FinisherInterface.new {
|
105
|
-
# this is called when the stage exits
|
106
|
-
finished_latch.countDown
|
107
|
-
})
|
108
|
-
|
109
|
-
application = application_class.new
|
110
|
-
|
111
|
-
unless application.is_a? Java::javafx.application.Application
|
112
|
-
raise "Invalid type: cannot launch non-Application"
|
113
|
-
end
|
114
|
-
|
115
|
-
ParametersImpl.registerParameters(application, ParametersImpl.new(args))
|
116
|
-
|
117
|
-
application.init
|
118
|
-
|
119
|
-
error = false
|
120
|
-
#RUN! and hope it works!
|
121
|
-
PlatformImpl.runAndWait do
|
122
|
-
begin
|
123
|
-
stage = Stage.new
|
124
|
-
stage.impl_setPrimary(true)
|
125
|
-
application.start(stage)
|
126
|
-
# no countDown here because its up top... yes I know
|
127
|
-
rescue => ex
|
128
|
-
puts "Exception running Application:"
|
129
|
-
p ex
|
130
|
-
puts ex.backtrace
|
131
|
-
error = true
|
132
|
-
finished_latch.countDown # but if we fail, we need to unlatch it
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
#wait for stage exit
|
137
|
-
finished_latch.await
|
138
|
-
|
139
|
-
# call stop on the interface
|
140
|
-
application.stop unless error
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|