glimmer-dsl-opal 0.7.0 → 0.7.5
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 +4 -4
- data/CHANGELOG.md +41 -0
- data/README.md +290 -53
- data/VERSION +1 -1
- data/lib/display.rb +31 -0
- data/lib/file.rb +29 -0
- data/lib/glimmer-dsl-opal.rb +30 -1
- data/lib/glimmer-dsl-opal/ext/date.rb +1 -1
- data/lib/glimmer-dsl-opal/ext/struct.rb +37 -0
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
- data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +46 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +7 -7
- data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +5 -5
- data/lib/glimmer-dsl-swt.rb +20 -35
- data/lib/glimmer/data_binding/table_items_binding.rb +6 -4
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -0
- data/lib/glimmer/dsl/opal/widget_expression.rb +6 -2
- data/lib/glimmer/swt/combo_proxy.rb +40 -1
- data/lib/glimmer/swt/composite_proxy.rb +5 -1
- data/lib/glimmer/swt/control_editor.rb +54 -0
- data/lib/glimmer/swt/date_time_proxy.rb +66 -1
- data/lib/glimmer/swt/font_proxy.rb +4 -4
- data/lib/glimmer/swt/grid_layout_proxy.rb +20 -12
- data/lib/glimmer/swt/label_proxy.rb +11 -3
- data/lib/glimmer/swt/layout_data_proxy.rb +10 -7
- data/lib/glimmer/swt/layout_proxy.rb +1 -1
- data/lib/glimmer/swt/message_box_proxy.rb +2 -10
- data/lib/glimmer/swt/table_column_proxy.rb +9 -0
- data/lib/glimmer/swt/table_editor.rb +65 -0
- data/lib/glimmer/swt/table_item_proxy.rb +36 -0
- data/lib/glimmer/swt/table_proxy.rb +375 -17
- data/lib/glimmer/swt/text_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +99 -21
- data/lib/glimmer/ui/custom_shell.rb +9 -7
- data/lib/os.rb +36 -0
- metadata +25 -3
@@ -29,7 +29,10 @@ module Glimmer
|
|
29
29
|
include Glimmer
|
30
30
|
include PropertyOwner
|
31
31
|
|
32
|
-
attr_reader :parent, :args, :path, :children, :enabled, :foreground, :background, :font, :focus
|
32
|
+
attr_reader :parent, :args, :path, :children, :enabled, :foreground, :background, :font, :focus, :disposed?, :rendered
|
33
|
+
alias isDisposed disposed?
|
34
|
+
alias is_disposed disposed?
|
35
|
+
alias rendered? rendered
|
33
36
|
|
34
37
|
class << self
|
35
38
|
# Factory Method that translates a Glimmer DSL keyword into a WidgetProxy object
|
@@ -103,6 +106,7 @@ module Glimmer
|
|
103
106
|
@block = block
|
104
107
|
@children = Set.new # TODO consider moving to composite
|
105
108
|
@enabled = true
|
109
|
+
@data = {}
|
106
110
|
DEFAULT_INITIALIZERS[self.class.underscored_widget_name(self)]&.call(self)
|
107
111
|
@parent.post_initialize_child(self) # TODO rename to post_initialize_child to be closer to glimmer-dsl-swt terminology
|
108
112
|
end
|
@@ -113,17 +117,52 @@ module Glimmer
|
|
113
117
|
child.render
|
114
118
|
end
|
115
119
|
|
120
|
+
# Executes for the parent of a child that just got disposed
|
121
|
+
def post_dispose_child(child)
|
122
|
+
@children&.delete(child)
|
123
|
+
end
|
124
|
+
|
116
125
|
# Executes at the closing of a parent widget curly braces after all children/properties have been added/set
|
117
126
|
def post_add_content
|
118
127
|
# No Op by default
|
119
128
|
end
|
120
129
|
|
130
|
+
def set_data(key=nil, value)
|
131
|
+
@data[key] = value
|
132
|
+
end
|
133
|
+
alias setData set_data
|
134
|
+
alias data= set_data
|
135
|
+
|
136
|
+
def get_data(key=nil)
|
137
|
+
@data[key]
|
138
|
+
end
|
139
|
+
alias getData get_data
|
140
|
+
alias data get_data
|
141
|
+
|
121
142
|
def css_classes
|
122
143
|
dom_element.attr('class').to_s.split
|
123
144
|
end
|
124
145
|
|
125
146
|
def dispose
|
147
|
+
remove_all_listeners
|
126
148
|
Document.find(path).remove
|
149
|
+
parent&.post_dispose_child(self)
|
150
|
+
# TODO fire on_widget_disposed listener
|
151
|
+
@disposed = true
|
152
|
+
end
|
153
|
+
|
154
|
+
def remove_all_listeners
|
155
|
+
effective_observation_request_to_event_mapping.keys.each do |keyword|
|
156
|
+
effective_observation_request_to_event_mapping[keyword].to_collection.each do |mapping|
|
157
|
+
observation_requests[keyword].to_a.each do |event_listener|
|
158
|
+
event = mapping[:event]
|
159
|
+
event_handler = mapping[:event_handler]
|
160
|
+
event_element_css_selector = mapping[:event_element_css_selector]
|
161
|
+
the_listener_dom_element = event_element_css_selector ? Element[event_element_css_selector] : listener_dom_element
|
162
|
+
the_listener_dom_element.off(event)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
127
166
|
end
|
128
167
|
|
129
168
|
def path
|
@@ -172,31 +211,52 @@ module Glimmer
|
|
172
211
|
@parent.path
|
173
212
|
end
|
174
213
|
|
175
|
-
def
|
214
|
+
def parent_dom_element
|
215
|
+
Document.find(parent_path)
|
216
|
+
end
|
217
|
+
|
218
|
+
def render(custom_parent_dom_element = nil)
|
219
|
+
the_parent_dom_element = custom_parent_dom_element || parent_dom_element
|
176
220
|
old_element = dom_element
|
177
221
|
brand_new = @dom.nil? || old_element.empty?
|
178
|
-
build_dom
|
222
|
+
build_dom(!custom_parent_dom_element) # TODO handle custom parent layout by passing parent instead of parent dom element
|
179
223
|
if brand_new
|
180
|
-
|
224
|
+
the_parent_dom_element.append(@dom)
|
181
225
|
else
|
182
226
|
old_element.replace_with(@dom)
|
183
227
|
end
|
184
|
-
|
228
|
+
observation_requests&.clone&.each do |keyword, event_listener_set|
|
185
229
|
event_listener_set.each do |event_listener|
|
186
|
-
|
230
|
+
observation_requests[keyword].delete(event_listener) # TODO look into the implications of this and if it's needed.
|
187
231
|
handle_observation_request(keyword, &event_listener)
|
188
232
|
end
|
189
233
|
end
|
190
234
|
children.each do |child|
|
191
235
|
child.render
|
192
236
|
end
|
237
|
+
@rendered = true
|
238
|
+
content_on_render_blocks.each { |content_block| content(&content_block) }
|
193
239
|
end
|
194
240
|
alias redraw render
|
195
241
|
|
196
|
-
def
|
242
|
+
def content_on_render_blocks
|
243
|
+
@content_on_render_blocks ||= []
|
244
|
+
end
|
245
|
+
|
246
|
+
def add_content_on_render(&content_block)
|
247
|
+
if rendered?
|
248
|
+
content_block.call
|
249
|
+
else
|
250
|
+
content_on_render_blocks << content_block
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def build_dom(layout=true)
|
255
|
+
# TODO consider passing parent element instead and having table item include a table cell widget only for opal
|
197
256
|
@dom = nil
|
198
257
|
@dom = dom
|
199
258
|
@dom = @parent.layout.dom(@dom) if @parent.respond_to?(:layout) && @parent.layout
|
259
|
+
@dom
|
200
260
|
end
|
201
261
|
|
202
262
|
def content(&block)
|
@@ -208,6 +268,21 @@ module Glimmer
|
|
208
268
|
{}
|
209
269
|
end
|
210
270
|
|
271
|
+
def effective_observation_request_to_event_mapping
|
272
|
+
default_observation_request_to_event_mapping.merge(observation_request_to_event_mapping)
|
273
|
+
end
|
274
|
+
|
275
|
+
def default_observation_request_to_event_mapping
|
276
|
+
{
|
277
|
+
'on_focus_gained' => {
|
278
|
+
event: 'focus',
|
279
|
+
},
|
280
|
+
'on_focus_lost' => {
|
281
|
+
event: 'blur',
|
282
|
+
},
|
283
|
+
}
|
284
|
+
end
|
285
|
+
|
211
286
|
def name
|
212
287
|
self.class.name.split('::').last.underscore.sub(/_proxy$/, '').gsub('_', '-')
|
213
288
|
end
|
@@ -271,10 +346,6 @@ module Glimmer
|
|
271
346
|
element
|
272
347
|
end
|
273
348
|
|
274
|
-
def parent_dom_element
|
275
|
-
Document.find(parent_path)
|
276
|
-
end
|
277
|
-
|
278
349
|
def listener_path
|
279
350
|
path
|
280
351
|
end
|
@@ -296,14 +367,17 @@ module Glimmer
|
|
296
367
|
end
|
297
368
|
end
|
298
369
|
|
299
|
-
def
|
300
|
-
return unless observation_request_to_event_mapping.keys.include?(keyword)
|
370
|
+
def observation_requests
|
301
371
|
@observation_requests ||= {}
|
302
|
-
|
372
|
+
end
|
373
|
+
|
374
|
+
def handle_observation_request(keyword, &event_listener)
|
375
|
+
return unless effective_observation_request_to_event_mapping.keys.include?(keyword)
|
303
376
|
event = nil
|
304
377
|
delegate = nil
|
305
|
-
[
|
306
|
-
|
378
|
+
effective_observation_request_to_event_mapping[keyword].to_collection.each do |mapping|
|
379
|
+
observation_requests[keyword] ||= Set.new
|
380
|
+
observation_requests[keyword] << event_listener
|
307
381
|
event = mapping[:event]
|
308
382
|
event_handler = mapping[:event_handler]
|
309
383
|
event_element_css_selector = mapping[:event_element_css_selector]
|
@@ -334,6 +408,14 @@ module Glimmer
|
|
334
408
|
super(attribute_name, *args) # PropertyOwner
|
335
409
|
end
|
336
410
|
|
411
|
+
def method_missing(method, *args, &block)
|
412
|
+
if method.to_s.start_with?('on_')
|
413
|
+
handle_observation_request(method, &block)
|
414
|
+
else
|
415
|
+
super(method, *args, &block)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
337
419
|
def apply_property_type_converters(attribute_name, args)
|
338
420
|
if args.count == 1
|
339
421
|
value = args.first
|
@@ -491,11 +573,7 @@ module Glimmer
|
|
491
573
|
TableProxy => {
|
492
574
|
:selection => lambda do |observer|
|
493
575
|
on_widget_selected { |selection_event|
|
494
|
-
|
495
|
-
observer.call(selection.map(&:get_data))
|
496
|
-
else
|
497
|
-
observer.call(selection.first&.get_data)
|
498
|
-
end
|
576
|
+
observer.call(selection_event.table_item.get_data) # TODO ensure selection doesn't conflict with editing
|
499
577
|
}
|
500
578
|
end,
|
501
579
|
},
|
@@ -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
|
@@ -31,8 +31,10 @@ module Glimmer
|
|
31
31
|
class << self
|
32
32
|
def included(klass)
|
33
33
|
klass.extend(CustomWidget::ClassMethods)
|
34
|
-
klass.include(Glimmer)
|
34
|
+
klass.include(Glimmer)
|
35
35
|
Glimmer::UI::CustomWidget.add_custom_widget_namespaces_for(klass)
|
36
|
+
keyword = klass.name.split(':').last.underscore
|
37
|
+
`localStorage[#{keyword}] = #{$LOADED_FEATURES.last}`
|
36
38
|
end
|
37
39
|
|
38
40
|
def request_parameter_string
|
@@ -44,12 +46,12 @@ module Glimmer
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def requested_and_not_handled?
|
47
|
-
requested? && !request_parameter_string.include?('custom_shell_handled=true')
|
48
|
-
end
|
49
|
+
requested? && !request_parameter_string.include?('custom_shell_handled=true')
|
50
|
+
end
|
49
51
|
|
50
52
|
def requested?
|
51
53
|
request_parameter_string.include?('custom_shell=')
|
52
|
-
end
|
54
|
+
end
|
53
55
|
end
|
54
56
|
|
55
57
|
def initialize(parent, args, options, &content)
|
data/lib/os.rb
ADDED
@@ -0,0 +1,36 @@
|
|
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
|
+
class OS
|
23
|
+
class << self
|
24
|
+
def windows?
|
25
|
+
# No Op in Opal
|
26
|
+
end
|
27
|
+
|
28
|
+
def mac?
|
29
|
+
# No Op in Opal
|
30
|
+
end
|
31
|
+
|
32
|
+
def linux?
|
33
|
+
# No Op in Opal
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.2.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: to_collection
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.0.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.0.1
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: puts_debuggerer
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +210,8 @@ dependencies:
|
|
196
210
|
- - "~>"
|
197
211
|
- !ruby/object:Gem::Version
|
198
212
|
version: 0.4.4
|
199
|
-
description: Glimmer DSL for Opal (Web GUI
|
213
|
+
description: Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop
|
214
|
+
Apps Running via Opal on Rails)
|
200
215
|
email: andy.am@gmail.com
|
201
216
|
executables: []
|
202
217
|
extensions: []
|
@@ -222,9 +237,12 @@ files:
|
|
222
237
|
- app/assets/stylesheets/glimmer/jquery-ui.structure.css
|
223
238
|
- app/assets/stylesheets/glimmer/jquery-ui.theme.css
|
224
239
|
- app/assets/stylesheets/glimmer/jquery.ui.timepicker.css
|
240
|
+
- lib/display.rb
|
241
|
+
- lib/file.rb
|
225
242
|
- lib/glimmer-dsl-opal.rb
|
226
243
|
- lib/glimmer-dsl-opal/ext/date.rb
|
227
244
|
- lib/glimmer-dsl-opal/ext/exception.rb
|
245
|
+
- lib/glimmer-dsl-opal/ext/struct.rb
|
228
246
|
- lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb
|
229
247
|
- lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact.rb
|
230
248
|
- lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_manager_presenter.rb
|
@@ -234,6 +252,7 @@ files:
|
|
234
252
|
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/board.rb
|
235
253
|
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/cell.rb
|
236
254
|
- lib/glimmer-dsl-opal/samples/hello/hello_browser.rb
|
255
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_button.rb
|
237
256
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb
|
238
257
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb
|
239
258
|
- lib/glimmer-dsl-opal/samples/hello/hello_combo.rb
|
@@ -311,6 +330,7 @@ files:
|
|
311
330
|
- lib/glimmer/swt/color_proxy.rb
|
312
331
|
- lib/glimmer/swt/combo_proxy.rb
|
313
332
|
- lib/glimmer/swt/composite_proxy.rb
|
333
|
+
- lib/glimmer/swt/control_editor.rb
|
314
334
|
- lib/glimmer/swt/custom/checkbox_group.rb
|
315
335
|
- lib/glimmer/swt/custom/radio_group.rb
|
316
336
|
- lib/glimmer/swt/date_time_proxy.rb
|
@@ -338,6 +358,7 @@ files:
|
|
338
358
|
- lib/glimmer/swt/tab_folder_proxy.rb
|
339
359
|
- lib/glimmer/swt/tab_item_proxy.rb
|
340
360
|
- lib/glimmer/swt/table_column_proxy.rb
|
361
|
+
- lib/glimmer/swt/table_editor.rb
|
341
362
|
- lib/glimmer/swt/table_item_proxy.rb
|
342
363
|
- lib/glimmer/swt/table_proxy.rb
|
343
364
|
- lib/glimmer/swt/text_proxy.rb
|
@@ -346,6 +367,7 @@ files:
|
|
346
367
|
- lib/glimmer/ui/custom_widget.rb
|
347
368
|
- lib/glimmer/util/proc_tracker.rb
|
348
369
|
- lib/net/http.rb
|
370
|
+
- lib/os.rb
|
349
371
|
- lib/uri.rb
|
350
372
|
homepage: http://github.com/AndyObtiva/glimmer-dsl-opal
|
351
373
|
licenses:
|