glimmer-dsl-opal 0.2.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +47 -0
- data/README.md +1022 -190
- data/VERSION +1 -1
- data/app/assets/images/glimmer/images/calendar.gif +0 -0
- data/app/assets/images/glimmer/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_444444_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_555555_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_777620_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_777777_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_cc0000_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/assets/stylesheets/glimmer.css +15 -0
- data/app/assets/stylesheets/glimmer/jquery-ui.css +1312 -0
- data/app/assets/stylesheets/glimmer/jquery-ui.structure.css +886 -0
- data/app/assets/stylesheets/glimmer/jquery-ui.theme.css +443 -0
- data/app/assets/stylesheets/glimmer/jquery.ui.timepicker.css +57 -0
- data/lib/glimmer-dsl-opal.rb +23 -8
- data/lib/glimmer-dsl-opal/ext/date.rb +48 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +85 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +68 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +5 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +3 -3
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +3 -3
- data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +63 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +104 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +108 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +84 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt +278 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt +20 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css +57 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.js +1496 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +333 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/LICENSE.txt +43 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +7 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +13 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +5 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +5 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +74 -0
- data/lib/glimmer-dsl-swt.rb +37 -0
- data/lib/glimmer/data_binding/element_binding.rb +2 -1
- data/lib/glimmer/dsl/opal/async_exec_expression.rb +23 -7
- data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +42 -5
- data/lib/glimmer/dsl/opal/display_expression.rb +40 -0
- data/lib/glimmer/dsl/opal/dsl.rb +7 -0
- data/lib/glimmer/dsl/opal/exec_expression.rb +55 -0
- data/lib/glimmer/dsl/opal/layout_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/property_expression.rb +4 -3
- data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +23 -1
- data/lib/glimmer/dsl/opal/swt_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/sync_exec_expression.rb +33 -0
- data/lib/glimmer/dsl/opal/widget_expression.rb +5 -0
- data/lib/glimmer/engine.rb +9 -0
- data/lib/glimmer/swt.rb +3 -3
- data/lib/glimmer/swt/button_proxy.rb +15 -1
- data/lib/glimmer/swt/checkbox_proxy.rb +81 -0
- data/lib/glimmer/swt/combo_proxy.rb +4 -4
- data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
- data/lib/glimmer/swt/custom/radio_group.rb +143 -0
- data/lib/glimmer/swt/date_time_proxy.rb +144 -0
- data/lib/glimmer/swt/display_proxy.rb +55 -1
- data/lib/glimmer/swt/fill_layout_proxy.rb +2 -2
- data/lib/glimmer/swt/grid_layout_proxy.rb +21 -10
- data/lib/glimmer/swt/group_proxy.rb +38 -0
- data/lib/glimmer/swt/label_proxy.rb +27 -7
- data/lib/glimmer/swt/layout_data_proxy.rb +59 -6
- data/lib/glimmer/swt/layout_proxy.rb +2 -1
- data/lib/glimmer/swt/list_proxy.rb +2 -2
- data/lib/glimmer/swt/make_shift_shell_proxy.rb +38 -0
- data/lib/glimmer/swt/message_box_proxy.rb +7 -7
- data/lib/glimmer/swt/radio_proxy.rb +82 -0
- data/lib/glimmer/swt/row_layout_proxy.rb +35 -12
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
- data/lib/glimmer/swt/shell_proxy.rb +25 -10
- data/lib/glimmer/swt/styled_text_proxy.rb +44 -0
- data/lib/glimmer/swt/tab_folder_proxy.rb +3 -3
- data/lib/glimmer/swt/table_proxy.rb +10 -10
- data/lib/glimmer/swt/text_proxy.rb +2 -2
- data/lib/glimmer/swt/widget_proxy.rb +67 -33
- data/lib/glimmer/ui/custom_shell.rb +21 -2
- data/lib/glimmer/ui/custom_widget.rb +3 -1
- data/lib/{glimmer-dsl-opal/missing/net → net}/http.rb +0 -0
- data/lib/uri.rb +64 -0
- metadata +57 -4
- data/lib/glimmer-dsl-opal/missing/uri.rb +0 -26
@@ -0,0 +1,37 @@
|
|
1
|
+
class OS
|
2
|
+
class << self
|
3
|
+
def windows?
|
4
|
+
# No Op in Opal
|
5
|
+
end
|
6
|
+
|
7
|
+
def mac?
|
8
|
+
# No Op in Opal
|
9
|
+
end
|
10
|
+
|
11
|
+
def linux?
|
12
|
+
# No Op in Opal
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class File
|
18
|
+
class << self
|
19
|
+
def read(*args, &block)
|
20
|
+
# TODO implement via asset downloads in the future
|
21
|
+
# No Op in Opal
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Display
|
27
|
+
class << self
|
28
|
+
def setAppName(app_name)
|
29
|
+
# No Op in Opal
|
30
|
+
end
|
31
|
+
def setAppVersion(version)
|
32
|
+
# No Op in Opal
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'glimmer-dsl-opal'
|
@@ -4,6 +4,7 @@ require 'glimmer/data_binding/observer'
|
|
4
4
|
module Glimmer
|
5
5
|
module DataBinding
|
6
6
|
class ElementBinding
|
7
|
+
# TODO consider renaming to WidgetBinding since it's no longer dealing with elements directly yet widgets instead
|
7
8
|
include Glimmer
|
8
9
|
include Observable
|
9
10
|
include Observer
|
@@ -27,7 +28,7 @@ module Glimmer
|
|
27
28
|
@element.set_attribute(@property, converted_value) unless evaluate_property == converted_value
|
28
29
|
end
|
29
30
|
|
30
|
-
def evaluate_property
|
31
|
+
def evaluate_property
|
31
32
|
@element.send(@property)
|
32
33
|
end
|
33
34
|
end
|
@@ -1,16 +1,32 @@
|
|
1
|
+
# Copyright (c) 2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'glimmer/dsl/static_expression'
|
2
|
-
require 'glimmer/dsl/
|
3
|
-
require 'glimmer/swt/display_proxy'
|
23
|
+
require 'glimmer/dsl/opal/exec_expression'
|
4
24
|
|
5
25
|
module Glimmer
|
6
26
|
module DSL
|
7
27
|
module Opal
|
8
28
|
class AsyncExecExpression < StaticExpression
|
9
|
-
include
|
10
|
-
|
11
|
-
def interpret(parent, keyword, *args, &block)
|
12
|
-
Glimmer::SWT::DisplayProxy.instance.async_exec(&block)
|
13
|
-
end
|
29
|
+
include ExecExpression
|
14
30
|
end
|
15
31
|
end
|
16
32
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright (c) 2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/expression'
|
23
|
+
require 'glimmer/data_binding/model_binding'
|
24
|
+
require 'glimmer/data_binding/element_binding'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module DSL
|
28
|
+
module Opal
|
29
|
+
class CheckboxGroupSelectionDataBindingExpression < Expression
|
30
|
+
|
31
|
+
def can_interpret?(parent, keyword, *args, &block)
|
32
|
+
keyword == 'selection' and
|
33
|
+
block.nil? and
|
34
|
+
(parent.is_a?(Glimmer::SWT::Custom::CheckboxGroup) or (parent.is_a?(Glimmer::UI::CustomWidget) and parent.body_root.is_a?(Glimmer::SWT::Custom::CheckboxGroup)) ) and
|
35
|
+
args.size == 1 and
|
36
|
+
args[0].is_a?(DataBinding::ModelBinding) and
|
37
|
+
args[0].evaluate_options_property.is_a?(Array)
|
38
|
+
end
|
39
|
+
|
40
|
+
def interpret(parent, keyword, *args, &block)
|
41
|
+
model_binding = args[0]
|
42
|
+
|
43
|
+
#TODO make this options observer dependent and all similar observers in widget specific data binding handlers
|
44
|
+
# TODO consider delegating some of this work
|
45
|
+
widget_binding = DataBinding::ElementBinding.new(parent, 'items')
|
46
|
+
widget_binding.call(model_binding.evaluate_options_property)
|
47
|
+
model = model_binding.base_model
|
48
|
+
widget_binding.observe(model, model_binding.options_property_name)
|
49
|
+
|
50
|
+
widget_binding = DataBinding::ElementBinding.new(parent, 'selection')
|
51
|
+
widget_binding.call(model_binding.evaluate_property)
|
52
|
+
widget_binding.observe(model, model_binding.property_name_expression)
|
53
|
+
|
54
|
+
parent.on_widget_selected do
|
55
|
+
model_binding.call(widget_binding.evaluate_property)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2020 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -25,6 +25,9 @@ require 'glimmer/dsl/parent_expression'
|
|
25
25
|
require 'glimmer/dsl/top_level_expression'
|
26
26
|
require 'glimmer/ui/custom_widget'
|
27
27
|
require 'glimmer/ui/custom_shell'
|
28
|
+
require 'glimmer/swt/make_shift_shell_proxy'
|
29
|
+
require 'glimmer/swt/custom/radio_group'
|
30
|
+
require 'glimmer/swt/custom/checkbox_group'
|
28
31
|
|
29
32
|
module Glimmer
|
30
33
|
module DSL
|
@@ -39,11 +42,45 @@ module Glimmer
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def interpret(parent, keyword, *args, &block)
|
42
|
-
|
43
|
-
|
45
|
+
custom_widget_class = UI::CustomWidget.for(keyword)
|
46
|
+
# TODO clean code by extracting methods into CustomShell
|
47
|
+
if !Glimmer::UI::CustomShell.requested? && custom_widget_class.ancestors.include?(Glimmer::UI::CustomShell)
|
48
|
+
if Glimmer::SWT::DisplayProxy.instance.shells.empty?
|
49
|
+
custom_widget_class.new(parent, *args, {}, &block)
|
50
|
+
else
|
51
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
52
|
+
options = options.merge('swt_style' => args.join(',')) unless args.join(',').empty?
|
53
|
+
params = {
|
54
|
+
'custom_shell' => keyword
|
55
|
+
}.merge(options)
|
56
|
+
param_string = params.to_a.map {|k, v| "#{k}=#{URI.encode_www_form_component(v)}"}.join('&')
|
57
|
+
url = "#{`document.location.href`}?#{param_string}"
|
58
|
+
`window.open(#{url})`
|
59
|
+
# just a placeholder that has an open method # TODO return an actual CustomShell in the future that does the work happening above in the #open method
|
60
|
+
Glimmer::SWT::MakeShiftShellProxy.new
|
61
|
+
end
|
62
|
+
else
|
63
|
+
if Glimmer::UI::CustomShell.requested_and_not_handled?
|
64
|
+
parameters = Glimmer::UI::CustomShell.request_parameter_string.split("&").map {|str| str.split("=")}.to_h
|
65
|
+
`history.pushState(#{parameters.merge('custom_shell_handled' => 'true')}, document.title, #{"?#{Glimmer::UI::CustomShell.encoded_request_parameter_string}&custom_shell_handled=true"})`
|
66
|
+
custom_shell_keyword = parameters.delete('custom_shell')
|
67
|
+
CustomWidgetExpression.new.interpret(nil, custom_shell_keyword, *[parameters])
|
68
|
+
`history.pushState(#{parameters.reject {|k,v| k == 'custom_shell_handled'}}, document.title, #{"?#{Glimmer::UI::CustomShell.encoded_request_parameter_string.sub('&custom_shell_handled=true', '')}"})`
|
69
|
+
# just a placeholder that has an open method # TODO return an actual CustomShell in the future that does the work happening above in the #open method
|
70
|
+
Glimmer::SWT::MakeShiftShellProxy.new
|
71
|
+
else
|
72
|
+
custom_widget_class&.new(parent, *args, {}, &block)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_content(parent, &content)
|
78
|
+
content.call(parent) if parent.is_a?(Glimmer::SWT::ShellProxy) || parent.is_a?(Glimmer::UI::CustomShell)
|
44
79
|
end
|
80
|
+
|
45
81
|
|
46
82
|
def add_content(parent, &block)
|
83
|
+
return unless parent.is_a?(Glimmer::UI::CustomWidget)
|
47
84
|
# TODO consider avoiding source_location
|
48
85
|
if block.source_location == parent.content&.__getobj__.source_location
|
49
86
|
parent.content.call(parent) unless parent.content.called?
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright (c) 2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/parent_expression'
|
24
|
+
require 'glimmer/dsl/top_level_expression'
|
25
|
+
require 'glimmer/swt/display_proxy'
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module DSL
|
29
|
+
module Opal
|
30
|
+
class DisplayExpression < StaticExpression
|
31
|
+
include TopLevelExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
def interpret(parent, keyword, *args, &block)
|
35
|
+
Glimmer::SWT::DisplayProxy.instance(*args)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/glimmer/dsl/opal/dsl.rb
CHANGED
@@ -5,10 +5,12 @@ require 'glimmer/dsl/opal/widget_expression'
|
|
5
5
|
require 'glimmer/dsl/opal/property_expression'
|
6
6
|
require 'glimmer/dsl/opal/bind_expression'
|
7
7
|
require 'glimmer/dsl/opal/data_binding_expression'
|
8
|
+
require 'glimmer/dsl/opal/display_expression'
|
8
9
|
require 'glimmer/dsl/opal/combo_selection_data_binding_expression'
|
9
10
|
require 'glimmer/dsl/opal/widget_listener_expression'
|
10
11
|
require 'glimmer/dsl/opal/message_box_expression'
|
11
12
|
require 'glimmer/dsl/opal/async_exec_expression'
|
13
|
+
require 'glimmer/dsl/opal/sync_exec_expression'
|
12
14
|
require 'glimmer/dsl/opal/observe_expression'
|
13
15
|
require 'glimmer/dsl/opal/layout_expression'
|
14
16
|
require 'glimmer/dsl/opal/layout_data_expression'
|
@@ -20,6 +22,9 @@ require 'glimmer/dsl/opal/color_expression'
|
|
20
22
|
require 'glimmer/dsl/opal/rgb_expression'
|
21
23
|
require 'glimmer/dsl/opal/rgba_expression'
|
22
24
|
require 'glimmer/dsl/opal/custom_widget_expression'
|
25
|
+
require 'glimmer/dsl/opal/swt_expression'
|
26
|
+
require 'glimmer/dsl/opal/radio_group_selection_data_binding_expression'
|
27
|
+
require 'glimmer/dsl/opal/checkbox_group_selection_data_binding_expression'
|
23
28
|
|
24
29
|
module Glimmer
|
25
30
|
module DSL
|
@@ -32,6 +37,8 @@ module Glimmer
|
|
32
37
|
table_items_data_binding
|
33
38
|
combo_selection_data_binding
|
34
39
|
list_selection_data_binding
|
40
|
+
radio_group_selection_data_binding
|
41
|
+
checkbox_group_selection_data_binding
|
35
42
|
data_binding
|
36
43
|
font
|
37
44
|
layout
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (c) 2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/top_level_expression'
|
23
|
+
require 'glimmer/swt/display_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module DSL
|
27
|
+
module Opal
|
28
|
+
# Mixin for common code in async_exec and sync_exec expressions
|
29
|
+
# Uses name in subclass to auto-derive exec_operation
|
30
|
+
module ExecExpression
|
31
|
+
include TopLevelExpression
|
32
|
+
|
33
|
+
def exec_operation
|
34
|
+
@exec_operation ||= self.class.name.split(/::/).last.sub(/Expression$/, '').underscore
|
35
|
+
end
|
36
|
+
|
37
|
+
def can_interpret?(parent, keyword, *args, &block)
|
38
|
+
keyword == exec_operation and
|
39
|
+
block_given? and
|
40
|
+
args.empty?
|
41
|
+
end
|
42
|
+
|
43
|
+
def interpret(parent, keyword, *args, &block)
|
44
|
+
Glimmer::SWT::DisplayProxy.instance.send(exec_operation) do |*args|
|
45
|
+
begin
|
46
|
+
block.call(*args)
|
47
|
+
rescue => e
|
48
|
+
Glimmer::Config.logger.error e.full_message
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -9,7 +9,7 @@ module Glimmer
|
|
9
9
|
include ParentExpression
|
10
10
|
|
11
11
|
def can_interpret?(parent, keyword, *args, &block)
|
12
|
-
parent.is_a?(Glimmer::SWT::CompositeProxy)
|
12
|
+
(parent.is_a?(Glimmer::SWT::CompositeProxy) or (parent.is_a?(Glimmer::UI::CustomWidget) and parent.body_root.is_a?(Glimmer::SWT::CompositeProxy))) and
|
13
13
|
Glimmer::SWT::LayoutProxy.layout_exists?(keyword)
|
14
14
|
end
|
15
15
|
|
@@ -7,9 +7,10 @@ module Glimmer
|
|
7
7
|
include TopLevelExpression
|
8
8
|
|
9
9
|
def can_interpret?(parent, keyword, *args, &block)
|
10
|
-
parent and
|
11
|
-
parent.respond_to?(:set_attribute) and
|
12
|
-
keyword and
|
10
|
+
parent and
|
11
|
+
parent.respond_to?(:set_attribute) and
|
12
|
+
parent.respond_to?(keyword, *args) and
|
13
|
+
keyword and
|
13
14
|
block.nil?
|
14
15
|
end
|
15
16
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright (c) 2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/expression'
|
23
|
+
require 'glimmer/data_binding/model_binding'
|
24
|
+
require 'glimmer/data_binding/element_binding'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module DSL
|
28
|
+
module Opal
|
29
|
+
class RadioGroupSelectionDataBindingExpression < Expression
|
30
|
+
|
31
|
+
def can_interpret?(parent, keyword, *args, &block)
|
32
|
+
keyword == 'selection' and
|
33
|
+
block.nil? and
|
34
|
+
(parent.is_a?(Glimmer::SWT::Custom::RadioGroup) or (parent.is_a?(Glimmer::UI::CustomWidget) and parent.body_root.is_a?(Glimmer::SWT::Custom::RadioGroup)) ) and
|
35
|
+
args.size == 1 and
|
36
|
+
args[0].is_a?(DataBinding::ModelBinding) and
|
37
|
+
args[0].evaluate_options_property.is_a?(Array)
|
38
|
+
end
|
39
|
+
|
40
|
+
def interpret(parent, keyword, *args, &block)
|
41
|
+
model_binding = args[0]
|
42
|
+
|
43
|
+
#TODO make this options observer dependent and all similar observers in widget specific data binding handlers
|
44
|
+
# TODO consider delegating some of this work
|
45
|
+
widget_binding = DataBinding::ElementBinding.new(parent, 'items')
|
46
|
+
widget_binding.call(model_binding.evaluate_options_property)
|
47
|
+
model = model_binding.base_model
|
48
|
+
widget_binding.observe(model, model_binding.options_property_name)
|
49
|
+
|
50
|
+
widget_binding = DataBinding::ElementBinding.new(parent, 'selection')
|
51
|
+
widget_binding.call(model_binding.evaluate_property)
|
52
|
+
widget_binding.observe(model, model_binding.property_name_expression)
|
53
|
+
|
54
|
+
parent.on_widget_selected do
|
55
|
+
model_binding.call(widget_binding.evaluate_property)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|