glimmer-dsl-opal 0.0.7 → 0.3.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 +56 -0
- data/README.md +815 -76
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +45 -8
- data/lib/glimmer-dsl-opal/ext/date.rb +13 -0
- data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
- data/lib/glimmer-dsl-opal/missing/net/http.rb +17 -0
- data/lib/glimmer-dsl-opal/missing/uri.rb +64 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +2 -3
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
- data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
- data/lib/glimmer/data_binding/element_binding.rb +1 -1
- data/lib/glimmer/data_binding/ext/observable_model.rb +6 -6
- data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +70 -0
- data/lib/glimmer/dsl/opal/async_exec_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
- data/lib/glimmer/dsl/opal/column_properties_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +77 -0
- data/lib/glimmer/dsl/opal/dsl.rb +15 -14
- data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
- data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/layout_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
- data/lib/glimmer/dsl/opal/message_box_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/property_expression.rb +5 -2
- data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +18 -2
- data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
- data/lib/glimmer/dsl/opal/{composite_expression.rb → table_column_expression.rb} +3 -3
- data/lib/glimmer/dsl/opal/{list_expression.rb → table_expression.rb} +3 -3
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +29 -0
- data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
- data/lib/glimmer/swt.rb +499 -0
- data/lib/glimmer/swt/browser_proxy.rb +27 -0
- data/lib/glimmer/swt/button_proxy.rb +40 -0
- data/lib/glimmer/swt/color_proxy.rb +119 -0
- data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +24 -19
- data/lib/glimmer/swt/composite_proxy.rb +31 -0
- data/lib/glimmer/{opal → swt}/display_proxy.rb +6 -4
- data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
- data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
- data/lib/glimmer/swt/font_proxy.rb +79 -0
- data/lib/glimmer/swt/grid_layout_proxy.rb +71 -0
- data/lib/glimmer/swt/label_proxy.rb +34 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +87 -0
- data/lib/glimmer/swt/layout_proxy.rb +63 -0
- data/lib/glimmer/{opal → swt}/list_proxy.rb +31 -23
- data/lib/glimmer/swt/message_box_proxy.rb +143 -0
- data/lib/glimmer/{opal → swt}/point.rb +1 -1
- data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
- data/lib/glimmer/swt/row_layout_proxy.rb +105 -0
- data/lib/glimmer/swt/shell_proxy.rb +246 -0
- data/lib/glimmer/swt/style_constantizable.rb +154 -0
- data/lib/glimmer/swt/swt_proxy.rb +53 -0
- data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +21 -15
- data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
- data/lib/glimmer/swt/table_column_proxy.rb +56 -0
- data/lib/glimmer/swt/table_item_proxy.rb +147 -0
- data/lib/glimmer/swt/table_proxy.rb +159 -0
- data/lib/glimmer/swt/text_proxy.rb +46 -0
- data/lib/glimmer/swt/widget_proxy.rb +490 -0
- data/lib/glimmer/ui/custom_shell.rb +91 -0
- data/lib/glimmer/ui/custom_widget.rb +291 -0
- data/lib/glimmer/util/proc_tracker.rb +39 -0
- metadata +131 -76
- data/lib/glimmer/config.rb +0 -22
- data/lib/glimmer/dsl/engine.rb +0 -193
- data/lib/glimmer/dsl/expression.rb +0 -42
- data/lib/glimmer/dsl/expression_handler.rb +0 -48
- data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
- data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/text_expression.rb +0 -22
- data/lib/glimmer/dsl/parent_expression.rb +0 -12
- data/lib/glimmer/dsl/static_expression.rb +0 -36
- data/lib/glimmer/dsl/top_level_expression.rb +0 -7
- data/lib/glimmer/error.rb +0 -6
- data/lib/glimmer/invalid_keyword_error.rb +0 -6
- data/lib/glimmer/opal/div_proxy.rb +0 -22
- data/lib/glimmer/opal/document_proxy.rb +0 -178
- data/lib/glimmer/opal/element_proxy.rb +0 -287
- data/lib/glimmer/opal/grid_layout_proxy.rb +0 -54
- data/lib/glimmer/opal/iframe_proxy.rb +0 -23
- data/lib/glimmer/opal/input_proxy.rb +0 -45
- data/lib/glimmer/opal/label_proxy.rb +0 -25
- data/lib/glimmer/opal/layout_data_proxy.rb +0 -31
- data/lib/glimmer/opal/modal.rb +0 -94
- data/lib/glimmer/opal/tab_item.rb +0 -98
- data/lib/samples/elaborate/launch +0 -6
- data/lib/samples/hello/hello_combo.rb +0 -34
- data/lib/samples/hello/hello_tab.rb +0 -24
- data/lib/samples/hello/hello_world.rb +0 -8
- data/lib/samples/hello/launch +0 -10
- data/lib/samples/launch +0 -4
@@ -0,0 +1,91 @@
|
|
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/ui/custom_widget'
|
23
|
+
require 'glimmer/error'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module UI
|
27
|
+
module CustomShell
|
28
|
+
include Glimmer::UI::CustomWidget
|
29
|
+
|
30
|
+
class << self
|
31
|
+
def included(klass)
|
32
|
+
klass.extend(CustomWidget::ClassMethods)
|
33
|
+
klass.include(Glimmer)
|
34
|
+
Glimmer::UI::CustomWidget.add_custom_widget_namespaces_for(klass)
|
35
|
+
end
|
36
|
+
|
37
|
+
def request_parameter_string
|
38
|
+
URI.decode_www_form_component(`document.location.href`.match(/\?(.*)$/).to_a[1].to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
def encoded_request_parameter_string
|
42
|
+
`document.location.href`.match(/\?(.*)$/).to_a[1].to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def requested_and_not_handled?
|
46
|
+
requested? && !request_parameter_string.include?('custom_shell_handled=true')
|
47
|
+
end
|
48
|
+
|
49
|
+
def requested?
|
50
|
+
request_parameter_string.include?('custom_shell=')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize(parent, args, options, &content)
|
55
|
+
super(parent, args, options, &content)
|
56
|
+
raise Error, 'Invalid custom shell body root! Must be a shell or another custom shell.' unless body_root.is_a?(Glimmer::SWT::ShellProxy)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Classes may override
|
60
|
+
def open
|
61
|
+
# TODO consider the idea of delaying rendering till the open method
|
62
|
+
body_root.open
|
63
|
+
end
|
64
|
+
|
65
|
+
# DO NOT OVERRIDE. JUST AN ALIAS FOR `#open`. OVERRIDE `#open` INSTEAD.
|
66
|
+
def show
|
67
|
+
open
|
68
|
+
end
|
69
|
+
|
70
|
+
def close
|
71
|
+
body_root.close
|
72
|
+
end
|
73
|
+
|
74
|
+
def hide
|
75
|
+
body_root.hide
|
76
|
+
end
|
77
|
+
|
78
|
+
def visible?
|
79
|
+
body_root.visible?
|
80
|
+
end
|
81
|
+
|
82
|
+
def center
|
83
|
+
body_root.center
|
84
|
+
end
|
85
|
+
|
86
|
+
def start_event_loop
|
87
|
+
body_root.start_event_loop
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,291 @@
|
|
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'
|
23
|
+
require 'glimmer/error'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
require 'glimmer/util/proc_tracker'
|
26
|
+
require 'glimmer/data_binding/observer'
|
27
|
+
require 'glimmer/data_binding/observable_model'
|
28
|
+
|
29
|
+
module Glimmer
|
30
|
+
module UI
|
31
|
+
module CustomWidget
|
32
|
+
include DataBinding::ObservableModel
|
33
|
+
|
34
|
+
module ClassMethods
|
35
|
+
# Allows defining convenience option accessors for an array of option names
|
36
|
+
# Example: `options :color1, :color2` defines `#color1` and `#color2`
|
37
|
+
# where they return the instance values `options[:color1]` and `options[:color2]`
|
38
|
+
# respectively.
|
39
|
+
# Can be called multiple times to set more options additively.
|
40
|
+
# When passed no arguments, it returns list of all option names captured so far
|
41
|
+
def options(*new_options)
|
42
|
+
new_options = new_options.compact.map(&:to_s).map(&:to_sym)
|
43
|
+
if new_options.empty?
|
44
|
+
@options ||= {} # maps options to defaults
|
45
|
+
else
|
46
|
+
new_options = new_options.reduce({}) {|new_options_hash, new_option| new_options_hash.merge(new_option => nil)}
|
47
|
+
@options = options.merge(new_options)
|
48
|
+
def_option_attr_accessors(new_options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def option(new_option, default: nil)
|
53
|
+
new_option = new_option.to_s.to_sym
|
54
|
+
new_options = {new_option => default}
|
55
|
+
'@options = options.merge(new_options)'
|
56
|
+
@options = options.merge(new_options)
|
57
|
+
'def_option_attr_accessors(new_options)'
|
58
|
+
def_option_attr_accessors(new_options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def def_option_attr_accessors(new_options)
|
62
|
+
new_options.each do |option, default|
|
63
|
+
# TODO fix this in Opal by switching to define_method
|
64
|
+
define_method(option) do
|
65
|
+
options[:"#{option}"]
|
66
|
+
end
|
67
|
+
define_method("#{option}=") do |option_value|
|
68
|
+
self.options[:"#{option}"] = option_value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def before_body(&block)
|
74
|
+
@before_body_blocks ||= []
|
75
|
+
@before_body_blocks << block
|
76
|
+
end
|
77
|
+
|
78
|
+
def body(&block)
|
79
|
+
@body_block = block
|
80
|
+
end
|
81
|
+
|
82
|
+
def after_body(&block)
|
83
|
+
@after_body_blocks ||= []
|
84
|
+
@after_body_blocks << block
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class << self
|
89
|
+
def included(klass)
|
90
|
+
klass.extend(ClassMethods)
|
91
|
+
unless klass.name.include?('Glimmer::UI::CustomShell')
|
92
|
+
klass.include(Glimmer)
|
93
|
+
Glimmer::UI::CustomWidget.add_custom_widget_namespaces_for(klass)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def for(underscored_custom_widget_name)
|
98
|
+
extracted_namespaces = underscored_custom_widget_name.
|
99
|
+
to_s.
|
100
|
+
split(/__/).map do |namespace|
|
101
|
+
namespace.camelcase(:upper)
|
102
|
+
end
|
103
|
+
custom_widget_namespaces.each do |base|
|
104
|
+
extracted_namespaces.reduce(base) do |result, namespace|
|
105
|
+
if !result.constants.include?(namespace)
|
106
|
+
namespace = result.constants.detect {|c| c.to_s.upcase == namespace.to_s.upcase } || namespace
|
107
|
+
end
|
108
|
+
begin
|
109
|
+
constant = result.const_get(namespace)
|
110
|
+
return constant if constant.ancestors.include?(Glimmer::UI::CustomWidget)
|
111
|
+
constant
|
112
|
+
rescue => e
|
113
|
+
# Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
|
114
|
+
result
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
raise "#{underscored_custom_widget_name} has no custom widget class!"
|
119
|
+
rescue => e
|
120
|
+
Glimmer::Config.logger.debug {e.message}
|
121
|
+
Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def add_custom_widget_namespaces_for(klass)
|
126
|
+
Glimmer::UI::CustomWidget.namespaces_for_class(klass).drop(1).each do |namespace|
|
127
|
+
Glimmer::UI::CustomWidget.custom_widget_namespaces << namespace
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def namespaces_for_class(m)
|
132
|
+
return [m] if m.name.nil?
|
133
|
+
namespace_constants = m.name.split(/::/).map(&:to_sym)
|
134
|
+
namespace_constants.reduce([Object]) do |output, namespace_constant|
|
135
|
+
output += [output.last.const_get(namespace_constant)]
|
136
|
+
end[1..-1].uniq.reverse
|
137
|
+
end
|
138
|
+
|
139
|
+
def custom_widget_namespaces
|
140
|
+
@custom_widget_namespaces ||= reset_custom_widget_namespaces
|
141
|
+
end
|
142
|
+
|
143
|
+
def reset_custom_widget_namespaces
|
144
|
+
@custom_widget_namespaces = Set[Object, Glimmer::UI]
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
# <- end of class methods
|
149
|
+
|
150
|
+
|
151
|
+
attr_reader :body_root, :parent, :options, :swt_style
|
152
|
+
|
153
|
+
def initialize(parent, args, options, &content)
|
154
|
+
@parent = parent
|
155
|
+
options = args.delete_at(-1) if options.nil? && args.is_a?(Array) && args.last.is_a?(Hash)
|
156
|
+
if args.is_a?(Hash)
|
157
|
+
options = args
|
158
|
+
args = []
|
159
|
+
end
|
160
|
+
args = options.delete('swt_style').split(',').map(&:to_sym) if options['swt_style']
|
161
|
+
@args = args
|
162
|
+
@swt_style = SWT::SWTProxy[*@args]
|
163
|
+
options ||= {}
|
164
|
+
@options = self.class.options.merge(options)
|
165
|
+
@content = Util::ProcTracker.new(content) if content
|
166
|
+
execute_hooks('before_body')
|
167
|
+
body_block = self.class.instance_variable_get("@body_block")
|
168
|
+
raise Glimmer::Error, 'Invalid custom widget for having no body! Please define body block!' if body_block.nil?
|
169
|
+
@body_root = instance_exec(&body_block)
|
170
|
+
raise Glimmer::Error, 'Invalid custom widget for having an empty body! Please fill body block!' if @body_root.nil?
|
171
|
+
execute_hooks('after_body')
|
172
|
+
end
|
173
|
+
|
174
|
+
# Subclasses may override to perform post initialization work on an added child
|
175
|
+
def post_initialize_child(child)
|
176
|
+
# No Op by default
|
177
|
+
end
|
178
|
+
|
179
|
+
def can_handle_observation_request?(observation_request)
|
180
|
+
observation_request = observation_request.to_s
|
181
|
+
result = false
|
182
|
+
if observation_request.start_with?('on_updated_')
|
183
|
+
property = observation_request.sub(/^on_updated_/, '')
|
184
|
+
result = can_add_observer?(property)
|
185
|
+
end
|
186
|
+
result || body_root&.can_handle_observation_request?(observation_request)
|
187
|
+
end
|
188
|
+
|
189
|
+
def handle_observation_request(observation_request, &block)
|
190
|
+
observation_request = observation_request.to_s
|
191
|
+
if observation_request.start_with?('on_updated_')
|
192
|
+
property = observation_request.sub(/^on_updated_/, '') # TODO look into eliminating duplication from above
|
193
|
+
add_observer(DataBinding::Observer.proc(&block), property) if can_add_observer?(property)
|
194
|
+
else
|
195
|
+
body_root.handle_observation_request(observation_request, &block)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def can_add_observer?(attribute_name)
|
200
|
+
has_instance_method?(attribute_name) || has_instance_method?("#{attribute_name}?") || @body_root.can_add_observer?(attribute_name)
|
201
|
+
end
|
202
|
+
|
203
|
+
def add_observer(observer, attribute_name)
|
204
|
+
if has_instance_method?(attribute_name)
|
205
|
+
super
|
206
|
+
else
|
207
|
+
@body_root.add_observer(observer, attribute_name)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def has_attribute?(attribute_name, *args)
|
212
|
+
has_instance_method?(attribute_setter(attribute_name)) ||
|
213
|
+
@body_root.has_attribute?(attribute_name, *args)
|
214
|
+
end
|
215
|
+
|
216
|
+
def set_attribute(attribute_name, *args)
|
217
|
+
if has_instance_method?(attribute_setter(attribute_name))
|
218
|
+
send(attribute_setter(attribute_name), *args)
|
219
|
+
else
|
220
|
+
@body_root.set_attribute(attribute_name, *args)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# This method ensures it has an instance method not coming from Glimmer DSL
|
225
|
+
def has_instance_method?(method_name)
|
226
|
+
respond_to?(method_name) and
|
227
|
+
!body_root&.respond_to?(method_name) and
|
228
|
+
!method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
|
229
|
+
!method(method_name)&.source_location&.first&.include?('glimmer/swt/widget_proxy.rb')
|
230
|
+
end
|
231
|
+
|
232
|
+
def get_attribute(attribute_name)
|
233
|
+
if has_instance_method?(attribute_name)
|
234
|
+
send(attribute_name)
|
235
|
+
else
|
236
|
+
@body_root.get_attribute(attribute_name)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def attribute_setter(attribute_name)
|
241
|
+
"#{attribute_name}="
|
242
|
+
end
|
243
|
+
|
244
|
+
def has_style?(symbol)
|
245
|
+
@args.include?(symbol) # not a very solid implementation. Bring SWT constants eventually
|
246
|
+
end
|
247
|
+
|
248
|
+
def async_exec(&block)
|
249
|
+
SWT::DisplayProxy.instance.async_exec(&block)
|
250
|
+
end
|
251
|
+
|
252
|
+
# sync_exec kept for API compatibility reasons
|
253
|
+
def sync_exec(&block)
|
254
|
+
SWT::DisplayProxy.instance.async_exec(&block)
|
255
|
+
end
|
256
|
+
|
257
|
+
# Returns content block if used as an attribute reader (no args)
|
258
|
+
# Otherwise, if a block is passed, it adds it as content to this custom widget
|
259
|
+
def content(&block)
|
260
|
+
if block_given?
|
261
|
+
body_root.content(&block)
|
262
|
+
else
|
263
|
+
@content
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def method_missing(method, *args, &block)
|
268
|
+
if can_handle_observation_request?(method)
|
269
|
+
handle_observation_request(method, &block)
|
270
|
+
else
|
271
|
+
body_root.send(method, *args, &block)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
alias local_respond_to? respond_to?
|
276
|
+
def respond_to?(method, *args, &block)
|
277
|
+
super or
|
278
|
+
can_handle_observation_request?(method) or
|
279
|
+
body_root.respond_to?(method, *args, &block)
|
280
|
+
end
|
281
|
+
|
282
|
+
private
|
283
|
+
|
284
|
+
def execute_hooks(hook_name)
|
285
|
+
self.class.instance_variable_get("@#{hook_name}_blocks")&.each do |hook_block|
|
286
|
+
instance_exec(&hook_block)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
@@ -0,0 +1,39 @@
|
|
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 'delegate'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module Util
|
26
|
+
class ProcTracker < DelegateClass(Proc)
|
27
|
+
def initialize(proc)
|
28
|
+
super(proc)
|
29
|
+
end
|
30
|
+
def call(*args)
|
31
|
+
__getobj__.call(*args)
|
32
|
+
@called = true
|
33
|
+
end
|
34
|
+
def called?
|
35
|
+
!!@called
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -16,42 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 1.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 1.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: glimmer-dsl-xml
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: glimmer-dsl-css
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
47
|
+
version: 1.1.0
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: opal-async
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: puts_debuggerer
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +100,20 @@ dependencies:
|
|
86
100
|
- - "<"
|
87
101
|
- !ruby/object:Gem::Version
|
88
102
|
version: 14.0.0
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rake-tui
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
89
117
|
- !ruby/object:Gem::Dependency
|
90
118
|
name: jeweler
|
91
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,28 +160,42 @@ dependencies:
|
|
132
160
|
requirements:
|
133
161
|
- - "~>"
|
134
162
|
- !ruby/object:Gem::Version
|
135
|
-
version: 0.
|
163
|
+
version: 0.8.0.alpha2
|
164
|
+
type: :development
|
165
|
+
prerelease: false
|
166
|
+
version_requirements: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 0.8.0.alpha2
|
171
|
+
- !ruby/object:Gem::Dependency
|
172
|
+
name: opal-rails
|
173
|
+
requirement: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: 1.1.2
|
136
178
|
type: :development
|
137
179
|
prerelease: false
|
138
180
|
version_requirements: !ruby/object:Gem::Requirement
|
139
181
|
requirements:
|
140
182
|
- - "~>"
|
141
183
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
184
|
+
version: 1.1.2
|
143
185
|
- !ruby/object:Gem::Dependency
|
144
|
-
name: opal-
|
186
|
+
name: opal-jquery
|
145
187
|
requirement: !ruby/object:Gem::Requirement
|
146
188
|
requirements:
|
147
189
|
- - "~>"
|
148
190
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.
|
191
|
+
version: 0.4.4
|
150
192
|
type: :development
|
151
193
|
prerelease: false
|
152
194
|
version_requirements: !ruby/object:Gem::Requirement
|
153
195
|
requirements:
|
154
196
|
- - "~>"
|
155
197
|
- !ruby/object:Gem::Version
|
156
|
-
version: 0.
|
198
|
+
version: 0.4.4
|
157
199
|
description: Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
|
158
200
|
email: andy.am@gmail.com
|
159
201
|
executables: []
|
@@ -168,82 +210,95 @@ files:
|
|
168
210
|
- README.md
|
169
211
|
- VERSION
|
170
212
|
- lib/glimmer-dsl-opal.rb
|
171
|
-
- lib/glimmer/
|
213
|
+
- lib/glimmer-dsl-opal/ext/date.rb
|
214
|
+
- lib/glimmer-dsl-opal/ext/exception.rb
|
215
|
+
- lib/glimmer-dsl-opal/missing/net/http.rb
|
216
|
+
- lib/glimmer-dsl-opal/missing/uri.rb
|
217
|
+
- lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb
|
218
|
+
- lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact.rb
|
219
|
+
- lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_manager_presenter.rb
|
220
|
+
- lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_repository.rb
|
221
|
+
- lib/glimmer-dsl-opal/samples/elaborate/login.rb
|
222
|
+
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb
|
223
|
+
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/board.rb
|
224
|
+
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/cell.rb
|
225
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_browser.rb
|
226
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_combo.rb
|
227
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_computed.rb
|
228
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb
|
229
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb
|
230
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb
|
231
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb
|
232
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb
|
233
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_tab.rb
|
234
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_world.rb
|
235
|
+
- lib/glimmer-dsl-opal/vendor/jquery.js
|
172
236
|
- lib/glimmer/data_binding/element_binding.rb
|
173
237
|
- lib/glimmer/data_binding/ext/observable_model.rb
|
174
238
|
- lib/glimmer/data_binding/list_selection_binding.rb
|
175
239
|
- lib/glimmer/data_binding/observable_element.rb
|
176
|
-
- lib/glimmer/
|
177
|
-
- lib/glimmer/dsl/expression.rb
|
178
|
-
- lib/glimmer/dsl/expression_handler.rb
|
240
|
+
- lib/glimmer/data_binding/table_items_binding.rb
|
179
241
|
- lib/glimmer/dsl/opal/async_exec_expression.rb
|
180
242
|
- lib/glimmer/dsl/opal/bind_expression.rb
|
181
|
-
- lib/glimmer/dsl/opal/
|
182
|
-
- lib/glimmer/dsl/opal/
|
183
|
-
- lib/glimmer/dsl/opal/combo_expression.rb
|
243
|
+
- lib/glimmer/dsl/opal/color_expression.rb
|
244
|
+
- lib/glimmer/dsl/opal/column_properties_expression.rb
|
184
245
|
- lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb
|
185
|
-
- lib/glimmer/dsl/opal/
|
246
|
+
- lib/glimmer/dsl/opal/custom_widget_expression.rb
|
186
247
|
- lib/glimmer/dsl/opal/data_binding_expression.rb
|
187
248
|
- lib/glimmer/dsl/opal/dsl.rb
|
188
|
-
- lib/glimmer/dsl/opal/
|
189
|
-
- lib/glimmer/dsl/opal/label_expression.rb
|
249
|
+
- lib/glimmer/dsl/opal/font_expression.rb
|
190
250
|
- lib/glimmer/dsl/opal/layout_data_expression.rb
|
191
|
-
- lib/glimmer/dsl/opal/
|
251
|
+
- lib/glimmer/dsl/opal/layout_expression.rb
|
192
252
|
- lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb
|
193
253
|
- lib/glimmer/dsl/opal/message_box_expression.rb
|
194
254
|
- lib/glimmer/dsl/opal/observe_expression.rb
|
195
255
|
- lib/glimmer/dsl/opal/property_expression.rb
|
256
|
+
- lib/glimmer/dsl/opal/rgb_expression.rb
|
257
|
+
- lib/glimmer/dsl/opal/rgba_expression.rb
|
196
258
|
- lib/glimmer/dsl/opal/shell_expression.rb
|
197
|
-
- lib/glimmer/dsl/opal/
|
198
|
-
- lib/glimmer/dsl/opal/
|
199
|
-
- lib/glimmer/dsl/opal/
|
259
|
+
- lib/glimmer/dsl/opal/swt_expression.rb
|
260
|
+
- lib/glimmer/dsl/opal/table_column_expression.rb
|
261
|
+
- lib/glimmer/dsl/opal/table_expression.rb
|
262
|
+
- lib/glimmer/dsl/opal/table_items_data_binding_expression.rb
|
263
|
+
- lib/glimmer/dsl/opal/widget_expression.rb
|
200
264
|
- lib/glimmer/dsl/opal/widget_listener_expression.rb
|
201
|
-
- lib/glimmer/
|
202
|
-
- lib/glimmer/
|
203
|
-
- lib/glimmer/
|
204
|
-
- lib/glimmer/
|
205
|
-
- lib/glimmer/
|
206
|
-
- lib/glimmer/
|
207
|
-
- lib/glimmer/
|
208
|
-
- lib/glimmer/
|
209
|
-
- lib/glimmer/
|
210
|
-
- lib/glimmer/
|
211
|
-
- lib/glimmer/
|
212
|
-
- lib/glimmer/
|
213
|
-
- lib/glimmer/
|
214
|
-
- lib/glimmer/
|
215
|
-
- lib/glimmer/
|
216
|
-
- lib/glimmer/
|
217
|
-
- lib/glimmer/
|
218
|
-
- lib/glimmer/
|
219
|
-
- lib/glimmer/
|
220
|
-
- lib/glimmer/
|
221
|
-
- lib/glimmer/
|
222
|
-
- lib/glimmer/
|
223
|
-
- lib/
|
224
|
-
- lib/
|
225
|
-
- lib/
|
226
|
-
- lib/
|
227
|
-
- lib/
|
228
|
-
- lib/
|
229
|
-
- lib/
|
230
|
-
- lib/
|
231
|
-
- lib/
|
232
|
-
- lib/
|
233
|
-
- lib/samples/hello/hello_combo.rb
|
234
|
-
- lib/samples/hello/hello_computed.rb
|
235
|
-
- lib/samples/hello/hello_computed/contact.rb
|
236
|
-
- lib/samples/hello/hello_list_multi_selection.rb
|
237
|
-
- lib/samples/hello/hello_list_single_selection.rb
|
238
|
-
- lib/samples/hello/hello_tab.rb
|
239
|
-
- lib/samples/hello/hello_world.rb
|
240
|
-
- lib/samples/hello/launch
|
241
|
-
- lib/samples/launch
|
265
|
+
- lib/glimmer/swt.rb
|
266
|
+
- lib/glimmer/swt/browser_proxy.rb
|
267
|
+
- lib/glimmer/swt/button_proxy.rb
|
268
|
+
- lib/glimmer/swt/color_proxy.rb
|
269
|
+
- lib/glimmer/swt/combo_proxy.rb
|
270
|
+
- lib/glimmer/swt/composite_proxy.rb
|
271
|
+
- lib/glimmer/swt/display_proxy.rb
|
272
|
+
- lib/glimmer/swt/event_listener_proxy.rb
|
273
|
+
- lib/glimmer/swt/fill_layout_proxy.rb
|
274
|
+
- lib/glimmer/swt/font_proxy.rb
|
275
|
+
- lib/glimmer/swt/grid_layout_proxy.rb
|
276
|
+
- lib/glimmer/swt/label_proxy.rb
|
277
|
+
- lib/glimmer/swt/layout_data_proxy.rb
|
278
|
+
- lib/glimmer/swt/layout_proxy.rb
|
279
|
+
- lib/glimmer/swt/list_proxy.rb
|
280
|
+
- lib/glimmer/swt/message_box_proxy.rb
|
281
|
+
- lib/glimmer/swt/point.rb
|
282
|
+
- lib/glimmer/swt/property_owner.rb
|
283
|
+
- lib/glimmer/swt/row_layout_proxy.rb
|
284
|
+
- lib/glimmer/swt/shell_proxy.rb
|
285
|
+
- lib/glimmer/swt/style_constantizable.rb
|
286
|
+
- lib/glimmer/swt/swt_proxy.rb
|
287
|
+
- lib/glimmer/swt/tab_folder_proxy.rb
|
288
|
+
- lib/glimmer/swt/tab_item_proxy.rb
|
289
|
+
- lib/glimmer/swt/table_column_proxy.rb
|
290
|
+
- lib/glimmer/swt/table_item_proxy.rb
|
291
|
+
- lib/glimmer/swt/table_proxy.rb
|
292
|
+
- lib/glimmer/swt/text_proxy.rb
|
293
|
+
- lib/glimmer/swt/widget_proxy.rb
|
294
|
+
- lib/glimmer/ui/custom_shell.rb
|
295
|
+
- lib/glimmer/ui/custom_widget.rb
|
296
|
+
- lib/glimmer/util/proc_tracker.rb
|
242
297
|
homepage: http://github.com/AndyObtiva/glimmer-dsl-opal
|
243
298
|
licenses:
|
244
299
|
- MIT
|
245
300
|
metadata: {}
|
246
|
-
post_install_message:
|
301
|
+
post_install_message:
|
247
302
|
rdoc_options: []
|
248
303
|
require_paths:
|
249
304
|
- lib
|
@@ -258,8 +313,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
313
|
- !ruby/object:Gem::Version
|
259
314
|
version: '0'
|
260
315
|
requirements: []
|
261
|
-
rubygems_version: 3.1.
|
262
|
-
signing_key:
|
316
|
+
rubygems_version: 3.1.4
|
317
|
+
signing_key:
|
263
318
|
specification_version: 4
|
264
319
|
summary: Glimmer DSL for Opal
|
265
320
|
test_files: []
|