jrubyfx 1.2.0-java → 2.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +21 -10
- data/lib/jrubyfx/application.rb +2 -2
- data/lib/jrubyfx/controller.rb +62 -31
- 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 +1185 -175
- data/lib/jrubyfx/dsl.rb +3 -0
- data/lib/jrubyfx/dsl_map.rb +486 -9
- data/lib/jrubyfx/fxml_helper.rb +134 -0
- data/lib/jrubyfx/imports.rb +498 -26
- data/lib/jrubyfx/module.rb +28 -0
- data/lib/jrubyfx/part_imports.rb +63 -52
- data/lib/jrubyfx/utils.rb +6 -1
- data/lib/jrubyfx/version.rb +1 -1
- data/lib/jrubyfx.rb +6 -5
- data/lib/jrubyfx_tasks.rb +3 -1
- metadata +4 -19
- data/lib/jrubyfx/java_fx_impl.rb +0 -137
data/lib/jrubyfx/module.rb
CHANGED
@@ -17,6 +17,7 @@ limitations under the License.
|
|
17
17
|
|
18
18
|
require_relative 'utils/common_utils'
|
19
19
|
|
20
|
+
|
20
21
|
# This module contains useful methods for defining JavaFX code. Include it in your
|
21
22
|
# class to use it, and the JRubyFX::FXImports. JRubyFX::Application and JRubyFX::Controller already include it.
|
22
23
|
module JRubyFX
|
@@ -116,15 +117,20 @@ module JRubyFX
|
|
116
117
|
end
|
117
118
|
camel = symbol_name.id2name
|
118
119
|
camel = camel[0].upcase + camel[1..-1]
|
120
|
+
jcn = type.java_class.name
|
121
|
+
java_signature "void set" + camel + "(#{jcn} f)"
|
119
122
|
send(:define_method, "set" + camel) do |val|
|
120
123
|
instance_variable_set("@#{symbol_name}", val)
|
121
124
|
end
|
125
|
+
java_signature "#{jcn} get" + camel + "()"
|
122
126
|
send(:define_method, "get" + camel) do
|
123
127
|
instance_variable_get("@#{symbol_name}")
|
124
128
|
end
|
129
|
+
java_signature "java.lang.Class " + symbol_name.id2name + "GetType()"
|
125
130
|
send(:define_method, symbol_name.id2name + "GetType") do
|
126
131
|
return type.java_class
|
127
132
|
end
|
133
|
+
java_field "@javafx.fxml.FXML #{type.java_class.name} #{symbol_name}", instance_variable: true
|
128
134
|
end
|
129
135
|
def fxml_accessor(symbol_name,ptype=Java::javafx.beans.property.SimpleStringProperty, type=nil)
|
130
136
|
# TODO: RDoc
|
@@ -175,4 +181,26 @@ module JRubyFX
|
|
175
181
|
add_method_signature "get" + camel, [type]
|
176
182
|
end
|
177
183
|
end
|
184
|
+
|
185
|
+
# FXML requires loading both ruby and java classes.
|
186
|
+
# JRuby has no such single classloader builtin, so we proxy them all
|
187
|
+
# This is a minimal classloader only for classes, resources not supported
|
188
|
+
class PolyglotClassLoader < java.lang.ClassLoader
|
189
|
+
def initialize()
|
190
|
+
super(JRuby.runtime.jruby_class_loader)
|
191
|
+
@prefix = File.basename(fxml_root) + "."
|
192
|
+
end
|
193
|
+
java_signature "java.lang.Class findClass(java.lang.String name)"
|
194
|
+
def findClass(a)
|
195
|
+
return nil unless a.start_with? @prefix or a[0].upcase == a[0]
|
196
|
+
a = a[@prefix.length..-1] unless a[0].upcase == a[0]
|
197
|
+
begin # TODO: become_java! idempotent?
|
198
|
+
return a.constantize_by(/[.$]/).tap{|x| x.become_java!}.java_class
|
199
|
+
rescue NameError
|
200
|
+
raise java.lang.ClassNotFoundException.new("Could not find Ruby or Java class '#{a.gsub(/[.$]/, "::")}' or '#{a}'") # Must be a java CNF, not a Ruby Name Error
|
201
|
+
end
|
202
|
+
end
|
203
|
+
become_java!
|
204
|
+
end
|
205
|
+
|
178
206
|
end
|
data/lib/jrubyfx/part_imports.rb
CHANGED
@@ -21,23 +21,17 @@ require_relative 'utils'
|
|
21
21
|
begin
|
22
22
|
if ENV['JFX_DIR']
|
23
23
|
$LOAD_PATH << ENV['JFX_DIR']
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
# add OpenJFX support if follow instruction from https://openjfx.io
|
27
|
+
if ENV['JFX_DIR']
|
28
|
+
require 'jfxrt.jar'
|
29
|
+
elsif ENV['PATH_TO_FX'] # support the OpenJFX installation as in https://openjfx.io/openjfx-docs/#install-javafx as of 15th May 2020
|
30
|
+
Dir.glob(File.join(ENV['PATH_TO_FX'],"*.jar")).each do |jar|
|
31
|
+
require jar
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
# Java 8 (after ea-b75) and above has JavaFX as part of the normal distib, only require it if we are 7 or below
|
36
|
-
jre = ENV_JAVA["java.runtime.version"].match %r{^(?<version>(?<major>\d+)\.(?<minor>\d+))\.(?<patch>\d+)(_\d+)?-?(?<release>ea|u\d)?(-?b(?<build>\d+))?}
|
37
|
-
require 'jfxrt.jar' if ENV['JFX_DIR'] or
|
38
|
-
jre[:version].to_f < 1.8 or
|
39
|
-
(jre[:version].to_f == 1.8 and jre[:release] == 'ea' and jre[:build].to_i < 75)
|
40
|
-
|
41
35
|
# Java 8 at some point requires explicit toolkit/platform initialization
|
42
36
|
# before any controls can be loaded.
|
43
37
|
JRubyFX.load_fx
|
@@ -45,8 +39,9 @@ begin
|
|
45
39
|
# Attempt to load a javafx class
|
46
40
|
Java.javafx.application.Application
|
47
41
|
rescue LoadError, NameError
|
48
|
-
|
49
|
-
puts "
|
42
|
+
# Advice user too about the OpenJFX support
|
43
|
+
puts "JavaFX runtime not found. Please install Java 8 or newer, set environment variable JFX_DIR to the folder that contains jfxrt.jar or set the environment variable PATH_TO_FX that points to the OpenJFX libraries"
|
44
|
+
puts "If you have Java 8 or later, this is a bug. Please report to the issue tracker on github. Include your OS version, 32/64bit, and architecture (x86, ARM, PPC, etc)"
|
50
45
|
exit -1
|
51
46
|
end
|
52
47
|
|
@@ -67,49 +62,65 @@ module JRubyFX
|
|
67
62
|
# classes by using either `Hash.flat_tree_inject` from jrubyfx/utils.rb or
|
68
63
|
# writing your own traversal function
|
69
64
|
#
|
70
|
-
JFX_CLASS_HIERARCHY = {
|
71
|
-
|
72
|
-
PauseTransition RotateTransition ScaleTransition SequentialTransition StrokeTransition Timeline Transition TranslateTransition],
|
73
|
-
:application => [
|
65
|
+
JFX_CLASS_HIERARCHY = {
|
66
|
+
:javafx => {
|
67
|
+
:animation => %w[Animation AnimationTimer FadeTransition FillTransition Interpolatable Interpolator KeyFrame KeyValue ParallelTransition PathTransition PauseTransition RotateTransition ScaleTransition SequentialTransition StrokeTransition Timeline Transition TranslateTransition],
|
68
|
+
:application => %w[Application ConditionalFeature HostServices Platform Preloader],
|
74
69
|
:beans => {
|
75
|
-
:
|
76
|
-
|
77
|
-
:
|
70
|
+
:binding => %w[Binding Bindings BooleanBinding BooleanExpression DoubleBinding DoubleExpression FloatBinding FloatExpression IntegerBinding IntegerExpression ListBinding ListExpression LongBinding LongExpression MapBinding MapExpression NumberBinding NumberExpression NumberExpressionBase ObjectBinding ObjectExpression SetBinding SetExpression StringBinding StringExpression When],
|
71
|
+
'' => %w[DefaultProperty InvalidationListener NamedArg Observable WeakInvalidationListener WeakListener],
|
72
|
+
:property => {
|
73
|
+
:adapter => %w[JavaBeanBooleanProperty JavaBeanBooleanPropertyBuilder JavaBeanDoubleProperty JavaBeanDoublePropertyBuilder JavaBeanFloatProperty JavaBeanFloatPropertyBuilder JavaBeanIntegerProperty JavaBeanIntegerPropertyBuilder JavaBeanLongProperty JavaBeanLongPropertyBuilder JavaBeanObjectProperty JavaBeanObjectPropertyBuilder JavaBeanProperty JavaBeanStringProperty JavaBeanStringPropertyBuilder ReadOnlyJavaBeanBooleanProperty ReadOnlyJavaBeanBooleanPropertyBuilder ReadOnlyJavaBeanDoubleProperty ReadOnlyJavaBeanDoublePropertyBuilder ReadOnlyJavaBeanFloatProperty ReadOnlyJavaBeanFloatPropertyBuilder ReadOnlyJavaBeanIntegerProperty ReadOnlyJavaBeanIntegerPropertyBuilder ReadOnlyJavaBeanLongProperty ReadOnlyJavaBeanLongPropertyBuilder ReadOnlyJavaBeanObjectProperty ReadOnlyJavaBeanObjectPropertyBuilder ReadOnlyJavaBeanProperty ReadOnlyJavaBeanStringProperty ReadOnlyJavaBeanStringPropertyBuilder],
|
74
|
+
'' => %w[BooleanProperty BooleanPropertyBase DoubleProperty DoublePropertyBase FloatProperty FloatPropertyBase IntegerProperty IntegerPropertyBase ListProperty ListPropertyBase LongProperty LongPropertyBase MapProperty MapPropertyBase ObjectProperty ObjectPropertyBase Property ReadOnlyBooleanProperty ReadOnlyBooleanPropertyBase ReadOnlyBooleanWrapper ReadOnlyDoubleProperty ReadOnlyDoublePropertyBase ReadOnlyDoubleWrapper ReadOnlyFloatProperty ReadOnlyFloatPropertyBase ReadOnlyFloatWrapper ReadOnlyIntegerProperty ReadOnlyIntegerPropertyBase ReadOnlyIntegerWrapper ReadOnlyListProperty ReadOnlyListPropertyBase ReadOnlyListWrapper ReadOnlyLongProperty ReadOnlyLongPropertyBase ReadOnlyLongWrapper ReadOnlyMapProperty ReadOnlyMapPropertyBase ReadOnlyMapWrapper ReadOnlyObjectProperty ReadOnlyObjectPropertyBase ReadOnlyObjectWrapper ReadOnlyProperty ReadOnlySetProperty ReadOnlySetPropertyBase ReadOnlySetWrapper ReadOnlyStringProperty ReadOnlyStringPropertyBase ReadOnlyStringWrapper SetProperty SetPropertyBase SimpleBooleanProperty SimpleDoubleProperty SimpleFloatProperty SimpleIntegerProperty SimpleListProperty SimpleLongProperty SimpleMapProperty SimpleObjectProperty SimpleSetProperty SimpleStringProperty StringProperty StringPropertyBase],
|
75
|
+
},
|
76
|
+
:value => %w[ChangeListener ObservableBooleanValue ObservableDoubleValue ObservableFloatValue ObservableIntegerValue ObservableListValue ObservableLongValue ObservableMapValue ObservableNumberValue ObservableObjectValue ObservableSetValue ObservableStringValue ObservableValue ObservableValueBase WeakChangeListener WritableBooleanValue WritableDoubleValue WritableFloatValue WritableIntegerValue WritableListValue WritableLongValue WritableMapValue WritableNumberValue WritableObjectValue WritableSetValue WritableStringValue WritableValue],
|
77
|
+
},
|
78
|
+
:collections => {
|
79
|
+
'' => %w[ArrayChangeListener FXCollections ListChangeListener MapChangeListener ModifiableObservableListBase ObservableArray ObservableArrayBase ObservableFloatArray ObservableIntegerArray ObservableList ObservableListBase ObservableMap ObservableSet SetChangeListener WeakListChangeListener WeakMapChangeListener WeakSetChangeListener],
|
80
|
+
:transformation => %w[FilteredList SortedList TransformationList],
|
78
81
|
},
|
79
|
-
:
|
80
|
-
:
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
:concurrent => %w[ScheduledService Service Task Worker WorkerStateEvent],
|
83
|
+
:css => {
|
84
|
+
'' => %w[CompoundSelector CssMetaData CssParser Declaration FontCssMetaData FontFace Match ParsedValue PseudoClass Rule Selector SimpleSelector SimpleStyleableBooleanProperty SimpleStyleableDoubleProperty SimpleStyleableFloatProperty SimpleStyleableIntegerProperty SimpleStyleableLongProperty SimpleStyleableObjectProperty SimpleStyleableStringProperty Size SizeUnits Style Styleable StyleableBooleanProperty StyleableDoubleProperty StyleableFloatProperty StyleableIntegerProperty StyleableLongProperty StyleableObjectProperty StyleableProperty StyleablePropertyFactory StyleableStringProperty StyleClass StyleConverter StyleOrigin Stylesheet],
|
85
|
+
:converter => %w[BooleanConverter ColorConverter CursorConverter DeriveColorConverter DeriveSizeConverter DurationConverter EffectConverter EnumConverter FontConverter InsetsConverter LadderConverter PaintConverter ShapeConverter SizeConverter StopConverter URLConverter],
|
86
|
+
},
|
87
|
+
:embed => {
|
88
|
+
:swing => %w[JFXPanel SwingFXUtils SwingNode],
|
89
|
+
},
|
90
|
+
:event => %w[ActionEvent Event EventDispatchChain EventDispatcher EventHandler EventTarget EventType WeakEventHandler],
|
91
|
+
:fxml => %w[FXML FXMLLoader Initializable JavaFXBuilderFactory LoadException LoadListener],
|
92
|
+
:geometry => %w[BoundingBox Bounds Dimension2D HorizontalDirection HPos Insets NodeOrientation Orientation Point2D Point3D Pos Rectangle2D Side VerticalDirection VPos],
|
93
|
+
:print => %w[Collation JobSettings PageLayout PageOrientation PageRange Paper PaperSource PrintColor Printer PrinterAttributes PrinterJob PrintQuality PrintResolution PrintSides],
|
84
94
|
:scene => {
|
85
|
-
'' => %w[Group Node Parent Scene],
|
86
|
-
:canvas => [
|
87
|
-
:chart => %w[AreaChart Axis BarChart BubbleChart CategoryAxis Chart LineChart NumberAxis
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
:effect => %w[Blend BlendMode Bloom BlurType BoxBlur ColorAdjust ColorInput DisplacementMap DropShadow GaussianBlur Glow ImageInput
|
94
|
-
|
95
|
-
:
|
96
|
-
:
|
97
|
-
|
98
|
-
:
|
99
|
-
:
|
100
|
-
|
101
|
-
:
|
102
|
-
:
|
103
|
-
|
104
|
-
:text => %w[Font FontPosture FontSmoothingType FontWeight Text TextAlignment TextBoundsType],
|
105
|
-
:transform => %w[Affine Rotate Scale Shear Translate],
|
106
|
-
:web => ['WebView', 'HTMLEditor']
|
95
|
+
'' => %w[AccessibleAction AccessibleAttribute AccessibleRole AmbientLight CacheHint Camera Cursor DepthTest Group ImageCursor LightBase Node ParallelCamera Parent PerspectiveCamera PointLight Scene SceneAntialiasing SnapshotParameters SnapshotResult SubScene],
|
96
|
+
:canvas => %w[Canvas GraphicsContext],
|
97
|
+
:chart => %w[AreaChart Axis BarChart BubbleChart CategoryAxis Chart LineChart NumberAxis PieChart ScatterChart StackedAreaChart StackedBarChart ValueAxis XYChart],
|
98
|
+
:control => {
|
99
|
+
'' => %w[Accordion Alert Button ButtonBar ButtonBase ButtonType Cell CheckBox CheckBoxTreeItem CheckMenuItem ChoiceBox ChoiceDialog ColorPicker ComboBox ComboBoxBase ContentDisplay ContextMenu Control CustomMenuItem DateCell DatePicker Dialog DialogEvent DialogPane FocusModel Hyperlink IndexedCell IndexRange Label Labeled ListCell ListView Menu MenuBar MenuButton MenuItem MultipleSelectionModel OverrunStyle Pagination PasswordField PopupControl ProgressBar ProgressIndicator RadioButton RadioMenuItem ResizeFeaturesBase ScrollBar ScrollPane ScrollToEvent SelectionMode SelectionModel Separator SeparatorMenuItem SingleSelectionModel Skin SkinBase Skinnable Slider SortEvent Spinner SpinnerValueFactory SplitMenuButton SplitPane Tab TableCell TableColumn TableColumnBase TableFocusModel TablePosition TablePositionBase TableRow TableSelectionModel TableView TabPane TextArea TextField TextFormatter TextInputControl TextInputDialog TitledPane Toggle ToggleButton ToggleGroup ToolBar Tooltip TreeCell TreeItem TreeSortMode TreeTableCell TreeTableColumn TreeTablePosition TreeTableRow TreeTableView TreeView],
|
100
|
+
:cell => %w[CheckBoxListCell CheckBoxTableCell CheckBoxTreeCell CheckBoxTreeTableCell ChoiceBoxListCell ChoiceBoxTableCell ChoiceBoxTreeCell ChoiceBoxTreeTableCell ComboBoxListCell ComboBoxTableCell ComboBoxTreeCell ComboBoxTreeTableCell MapValueFactory ProgressBarTableCell ProgressBarTreeTableCell PropertyValueFactory TextFieldListCell TextFieldTableCell TextFieldTreeCell TextFieldTreeTableCell TreeItemPropertyValueFactory],
|
101
|
+
:skin => %w[AccordionSkin ButtonBarSkin ButtonSkin CellSkinBase CheckBoxSkin ChoiceBoxSkin ColorPickerSkin ComboBoxBaseSkin ComboBoxListViewSkin ComboBoxPopupControl ContextMenuSkin DateCellSkin DatePickerSkin HyperlinkSkin LabeledSkinBase LabelSkin ListCellSkin ListViewSkin MenuBarSkin MenuButtonSkin MenuButtonSkinBase NestedTableColumnHeader PaginationSkin ProgressBarSkin ProgressIndicatorSkin RadioButtonSkin ScrollBarSkin ScrollPaneSkin SeparatorSkin SliderSkin SpinnerSkin SplitMenuButtonSkin SplitPaneSkin TableCellSkin TableCellSkinBase TableColumnHeader TableHeaderRow TableRowSkin TableRowSkinBase TableViewSkin TableViewSkinBase TabPaneSkin TextAreaSkin TextFieldSkin TextInputControlSkin TitledPaneSkin ToggleButtonSkin ToolBarSkin TooltipSkin TreeCellSkin TreeTableCellSkin TreeTableRowSkin TreeTableViewSkin TreeViewSkin VirtualContainerBase VirtualFlow],
|
102
|
+
},
|
103
|
+
:effect => %w[Blend BlendMode Bloom BlurType BoxBlur ColorAdjust ColorInput DisplacementMap DropShadow Effect FloatMap GaussianBlur Glow ImageInput InnerShadow Light Lighting MotionBlur PerspectiveTransform Reflection SepiaTone Shadow],
|
104
|
+
:image => %w[Image ImageView PixelFormat PixelReader PixelWriter WritableImage WritablePixelFormat],
|
105
|
+
:input => %w[Clipboard ClipboardContent ContextMenuEvent DataFormat Dragboard DragEvent GestureEvent InputEvent InputMethodEvent InputMethodHighlight InputMethodRequests InputMethodTextRun KeyCharacterCombination KeyCode KeyCodeCombination KeyCombination KeyEvent Mnemonic MouseButton MouseDragEvent MouseEvent PickResult RotateEvent ScrollEvent SwipeEvent TouchEvent TouchPoint TransferMode ZoomEvent],
|
106
|
+
:layout => %w[AnchorPane Background BackgroundFill BackgroundImage BackgroundPosition BackgroundRepeat BackgroundSize Border BorderImage BorderPane BorderRepeat BorderStroke BorderStrokeStyle BorderWidths ColumnConstraints ConstraintsBase CornerRadii FlowPane GridPane HBox Pane Priority Region RowConstraints StackPane TilePane VBox],
|
107
|
+
:media => %w[AudioClip AudioEqualizer AudioSpectrumListener AudioTrack EqualizerBand Media MediaErrorEvent MediaException MediaMarkerEvent MediaPlayer MediaView SubtitleTrack Track VideoTrack],
|
108
|
+
:paint => %w[Color CycleMethod ImagePattern LinearGradient Material Paint PhongMaterial RadialGradient Stop],
|
109
|
+
:robot => %w[Robot],
|
110
|
+
:shape => %w[Arc ArcTo ArcType Box Circle ClosePath CubicCurve CubicCurveTo CullFace Cylinder DrawMode Ellipse FillRule HLineTo Line LineTo Mesh MeshView MoveTo ObservableFaceArray Path PathElement Polygon Polyline QuadCurve QuadCurveTo Rectangle Shape Shape3D Sphere StrokeLineCap StrokeLineJoin StrokeType SVGPath TriangleMesh VertexFormat VLineTo],
|
111
|
+
:text => %w[Font FontPosture FontSmoothingType FontWeight HitInfo Text TextAlignment TextBoundsType TextFlow],
|
112
|
+
:transform => %w[Affine MatrixType NonInvertibleTransformException Rotate Scale Shear Transform TransformChangedEvent Translate],
|
113
|
+
:web => %w[HTMLEditor HTMLEditorSkin PopupFeatures PromptData WebEngine WebErrorEvent WebEvent WebHistory WebView],
|
107
114
|
},
|
108
115
|
:stage => %w[DirectoryChooser FileChooser Modality Popup PopupWindow Screen Stage StageStyle Window WindowEvent],
|
109
|
-
:util =>
|
110
|
-
|
116
|
+
:util => {
|
117
|
+
'' => %w[Builder BuilderFactory Callback Duration FXPermission Pair StringConverter],
|
118
|
+
:converter => %w[BigDecimalStringConverter BigIntegerStringConverter BooleanStringConverter ByteStringConverter CharacterStringConverter CurrencyStringConverter DateStringConverter DateTimeStringConverter DefaultStringConverter DoubleStringConverter FloatStringConverter FormatStringConverter IntegerStringConverter LocalDateStringConverter LocalDateTimeStringConverter LocalTimeStringConverter LongStringConverter NumberStringConverter PercentageStringConverter ShortStringConverter TimeStringConverter],
|
119
|
+
},
|
120
|
+
},
|
111
121
|
}
|
112
122
|
|
123
|
+
|
113
124
|
$WRITE_OUT << <<HERE
|
114
125
|
def const_missing(c)
|
115
126
|
if LOCAL_NAME_MAP.has_key? c
|
data/lib/jrubyfx/utils.rb
CHANGED
@@ -79,7 +79,12 @@ module JRubyFX
|
|
79
79
|
return if @already_loaded_fx and !force
|
80
80
|
@already_loaded_fx = true
|
81
81
|
java.util.concurrent.CountDownLatch.new(1).tap do |latch|
|
82
|
-
|
82
|
+
platform = unless javafx.application.Platform.respond_to? :startup
|
83
|
+
com.sun.javafx.application.PlatformImpl
|
84
|
+
else
|
85
|
+
javafx.application.Platform
|
86
|
+
end
|
87
|
+
platform.startup { latch.countDown }
|
83
88
|
latch.await
|
84
89
|
end
|
85
90
|
end
|
data/lib/jrubyfx/version.rb
CHANGED
data/lib/jrubyfx.rb
CHANGED
@@ -15,12 +15,13 @@ See the License for the specific language governing permissions and
|
|
15
15
|
limitations under the License.
|
16
16
|
=end
|
17
17
|
|
18
|
-
if
|
19
|
-
puts "JRubyFX requires JRuby
|
18
|
+
if !JRUBY_VERSION
|
19
|
+
puts "JRubyFX requires JRuby"
|
20
20
|
exit -2
|
21
21
|
end
|
22
|
-
if Gem::Version.new(JRUBY_VERSION) < Gem::Version.new("
|
23
|
-
puts "
|
22
|
+
if Gem::Version.new(JRUBY_VERSION) < Gem::Version.new("9.3.4.0")
|
23
|
+
puts "JRubyFX 2.0 requires JRuby 9.3.4.0 or later. Use JRubyFX 1.x for earlier versions."
|
24
|
+
exit -2
|
24
25
|
end
|
25
26
|
|
26
27
|
require 'java' # for java_import
|
@@ -36,6 +37,6 @@ require_relative 'jrubyfx/module'
|
|
36
37
|
require_relative 'jrubyfx/dsl'
|
37
38
|
require_relative 'jrubyfx/dsl_control'
|
38
39
|
JRubyFX::DSL.load_dsl # load it after we require the dsl package to not loop around
|
40
|
+
require_relative 'jrubyfx/fxml_helper'
|
39
41
|
require_relative 'jrubyfx/application'
|
40
42
|
require_relative 'jrubyfx/controller'
|
41
|
-
require_relative 'jrubyfx/java_fx_impl'
|
data/lib/jrubyfx_tasks.rb
CHANGED
@@ -69,6 +69,8 @@ module JRubyFX
|
|
69
69
|
FileList[src].each do |iv_srv|
|
70
70
|
cp_r iv_srv, "#{target}/#{File.basename(iv_srv)}" if (main_script == nil || main_script != iv_srv) && opts[:file_filter].call(iv_srv)
|
71
71
|
end
|
72
|
+
cp_r "./.jrubyfx_cache", "#{target}/.jrubyfx_cache"
|
73
|
+
|
72
74
|
cp main_script, "#{target}/jar-bootstrap.rb" unless main_script == nil
|
73
75
|
|
74
76
|
unless File.exists? "#{target}/jar-bootstrap.rb"
|
@@ -105,7 +107,7 @@ module JRubyFX
|
|
105
107
|
# edit the jar
|
106
108
|
base_dir = Dir.pwd
|
107
109
|
cd target
|
108
|
-
sh "#{opts[:jar]} ufe '#{output_jar}' org.jruby.JarBootstrapMain *"
|
110
|
+
sh "#{opts[:jar]} ufe '#{output_jar}' org.jruby.JarBootstrapMain * .jr*"
|
109
111
|
chmod 0775, output_jar
|
110
112
|
cd base_dir
|
111
113
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jrubyfx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Patrick Plenefisch
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-04-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,20 +41,6 @@ dependencies:
|
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '0.4'
|
50
|
-
name: jrubyfx-fxmlloader
|
51
|
-
prerelease: false
|
52
|
-
type: :runtime
|
53
|
-
version_requirements: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '0.4'
|
58
44
|
description: Enables JavaFX with FXML controllers and application in pure ruby
|
59
45
|
email:
|
60
46
|
- simonpatp@gmail.com
|
@@ -105,8 +91,8 @@ files:
|
|
105
91
|
- lib/jrubyfx/dsl.rb
|
106
92
|
- lib/jrubyfx/dsl_control.rb
|
107
93
|
- lib/jrubyfx/dsl_map.rb
|
94
|
+
- lib/jrubyfx/fxml_helper.rb
|
108
95
|
- lib/jrubyfx/imports.rb
|
109
|
-
- lib/jrubyfx/java_fx_impl.rb
|
110
96
|
- lib/jrubyfx/module.rb
|
111
97
|
- lib/jrubyfx/part_imports.rb
|
112
98
|
- lib/jrubyfx/utils.rb
|
@@ -135,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
121
|
- !ruby/object:Gem::Version
|
136
122
|
version: '0'
|
137
123
|
requirements: []
|
138
|
-
|
139
|
-
rubygems_version: 2.6.8
|
124
|
+
rubygems_version: 3.2.29
|
140
125
|
signing_key:
|
141
126
|
specification_version: 4
|
142
127
|
summary: JavaFX for JRuby with FXML
|
data/lib/jrubyfx/java_fx_impl.rb
DELETED
@@ -1,137 +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
|
-
begin
|
83
|
-
launch_app_after_platform(application_class, args)
|
84
|
-
rescue => ex
|
85
|
-
puts "Error running Application:"
|
86
|
-
p ex
|
87
|
-
puts ex.backtrace
|
88
|
-
end
|
89
|
-
|
90
|
-
PlatformImpl.tkExit # kill the toolkit and exit
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.launch_app_after_platform(application_class, args)
|
94
|
-
#listeners - for the end
|
95
|
-
finished_latch = CountDownLatch.new(1)
|
96
|
-
|
97
|
-
# register for shutdown
|
98
|
-
PlatformImpl.addListener(FinisherInterface.new {
|
99
|
-
# this is called when the stage exits
|
100
|
-
finished_latch.countDown
|
101
|
-
})
|
102
|
-
|
103
|
-
application = application_class.new
|
104
|
-
|
105
|
-
unless application.is_a? Java::javafx.application.Application
|
106
|
-
raise "Invalid type: cannot launch non-Application"
|
107
|
-
end
|
108
|
-
|
109
|
-
ParametersImpl.registerParameters(application, ParametersImpl.new(args))
|
110
|
-
|
111
|
-
application.init
|
112
|
-
|
113
|
-
error = false
|
114
|
-
#RUN! and hope it works!
|
115
|
-
PlatformImpl.runAndWait do
|
116
|
-
begin
|
117
|
-
stage = Stage.new
|
118
|
-
stage.impl_setPrimary(true)
|
119
|
-
application.start(stage)
|
120
|
-
# no countDown here because its up top... yes I know
|
121
|
-
rescue => ex
|
122
|
-
puts "Exception running Application:"
|
123
|
-
p ex
|
124
|
-
puts ex.backtrace
|
125
|
-
error = true
|
126
|
-
finished_latch.countDown # but if we fail, we need to unlatch it
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
#wait for stage exit
|
131
|
-
finished_latch.await
|
132
|
-
|
133
|
-
# call stop on the interface
|
134
|
-
application.stop unless error
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|