glimmer-dsl-opal 0.0.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/README.md +995 -74
  4. data/VERSION +1 -1
  5. data/lib/glimmer-dsl-opal.rb +42 -7
  6. data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
  7. data/lib/glimmer-dsl-opal/missing/net/http.rb +17 -0
  8. data/lib/glimmer-dsl-opal/missing/uri.rb +26 -0
  9. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +2 -3
  10. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
  11. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
  12. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
  13. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -1
  14. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +5 -5
  15. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
  16. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
  17. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
  19. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
  20. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
  23. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
  24. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
  25. data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
  26. data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
  27. data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
  28. data/lib/glimmer/data_binding/element_binding.rb +1 -1
  29. data/lib/glimmer/data_binding/ext/observable_model.rb +40 -0
  30. data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
  31. data/lib/glimmer/data_binding/table_items_binding.rb +70 -0
  32. data/lib/glimmer/dsl/opal/async_exec_expression.rb +17 -0
  33. data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
  34. data/lib/glimmer/dsl/opal/column_properties_expression.rb +22 -0
  35. data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
  36. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +57 -0
  37. data/lib/glimmer/dsl/opal/dsl.rb +17 -14
  38. data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
  39. data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
  40. data/lib/glimmer/dsl/opal/{text_expression.rb → layout_expression.rb} +5 -5
  41. data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
  42. data/lib/glimmer/dsl/opal/message_box_expression.rb +20 -0
  43. data/lib/glimmer/dsl/opal/observe_expression.rb +32 -0
  44. data/lib/glimmer/dsl/opal/property_expression.rb +5 -2
  45. data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
  46. data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
  47. data/lib/glimmer/dsl/opal/shell_expression.rb +2 -2
  48. data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
  49. data/lib/glimmer/dsl/opal/{composite_expression.rb → table_column_expression.rb} +3 -3
  50. data/lib/glimmer/dsl/opal/{list_expression.rb → table_expression.rb} +3 -3
  51. data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +29 -0
  52. data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
  53. data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
  54. data/lib/glimmer/swt.rb +499 -0
  55. data/lib/glimmer/swt/browser_proxy.rb +27 -0
  56. data/lib/glimmer/swt/button_proxy.rb +40 -0
  57. data/lib/glimmer/swt/color_proxy.rb +119 -0
  58. data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +24 -19
  59. data/lib/glimmer/swt/composite_proxy.rb +31 -0
  60. data/lib/glimmer/swt/display_proxy.rb +25 -0
  61. data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
  62. data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
  63. data/lib/glimmer/swt/font_proxy.rb +79 -0
  64. data/lib/glimmer/swt/grid_layout_proxy.rb +71 -0
  65. data/lib/glimmer/swt/label_proxy.rb +34 -0
  66. data/lib/glimmer/swt/layout_data_proxy.rb +52 -0
  67. data/lib/glimmer/swt/layout_proxy.rb +62 -0
  68. data/lib/glimmer/{opal → swt}/list_proxy.rb +31 -23
  69. data/lib/glimmer/swt/message_box_proxy.rb +143 -0
  70. data/lib/glimmer/{opal → swt}/point.rb +1 -1
  71. data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
  72. data/lib/glimmer/swt/row_layout_proxy.rb +105 -0
  73. data/lib/glimmer/swt/shell_proxy.rb +245 -0
  74. data/lib/glimmer/swt/style_constantizable.rb +154 -0
  75. data/lib/glimmer/swt/swt_proxy.rb +53 -0
  76. data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +21 -15
  77. data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
  78. data/lib/glimmer/swt/table_column_proxy.rb +56 -0
  79. data/lib/glimmer/swt/table_item_proxy.rb +147 -0
  80. data/lib/glimmer/swt/table_proxy.rb +159 -0
  81. data/lib/glimmer/swt/text_proxy.rb +46 -0
  82. data/lib/glimmer/swt/widget_proxy.rb +490 -0
  83. data/lib/glimmer/ui/custom_shell.rb +73 -0
  84. data/lib/glimmer/ui/custom_widget.rb +290 -0
  85. data/lib/glimmer/util/proc_tracker.rb +39 -0
  86. metadata +134 -74
  87. data/lib/glimmer/config.rb +0 -22
  88. data/lib/glimmer/dsl/engine.rb +0 -193
  89. data/lib/glimmer/dsl/expression.rb +0 -42
  90. data/lib/glimmer/dsl/expression_handler.rb +0 -48
  91. data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
  92. data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
  93. data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
  94. data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
  95. data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
  96. data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
  97. data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
  98. data/lib/glimmer/dsl/parent_expression.rb +0 -12
  99. data/lib/glimmer/dsl/static_expression.rb +0 -36
  100. data/lib/glimmer/dsl/top_level_expression.rb +0 -7
  101. data/lib/glimmer/error.rb +0 -6
  102. data/lib/glimmer/invalid_keyword_error.rb +0 -6
  103. data/lib/glimmer/opal/div_proxy.rb +0 -22
  104. data/lib/glimmer/opal/document_proxy.rb +0 -128
  105. data/lib/glimmer/opal/element_proxy.rb +0 -281
  106. data/lib/glimmer/opal/grid_layout_proxy.rb +0 -53
  107. data/lib/glimmer/opal/iframe_proxy.rb +0 -23
  108. data/lib/glimmer/opal/input_proxy.rb +0 -41
  109. data/lib/glimmer/opal/label_proxy.rb +0 -25
  110. data/lib/glimmer/opal/layout_data_proxy.rb +0 -31
  111. data/lib/glimmer/opal/tab_item.rb +0 -98
  112. data/lib/samples/elaborate/launch +0 -6
  113. data/lib/samples/hello/hello_combo.rb +0 -34
  114. data/lib/samples/hello/hello_tab.rb +0 -24
  115. data/lib/samples/hello/hello_world.rb +0 -8
  116. data/lib/samples/hello/launch +0 -10
  117. data/lib/samples/launch +0 -4
@@ -0,0 +1,46 @@
1
+ require 'glimmer/swt/widget_proxy'
2
+
3
+ module Glimmer
4
+ module SWT
5
+ class TextProxy < WidgetProxy
6
+ attr_reader :text
7
+
8
+ def text=(value)
9
+ @text = value
10
+ Document.find(path).value = value
11
+ end
12
+
13
+ def element
14
+ 'input'
15
+ end
16
+
17
+ def observation_request_to_event_mapping
18
+ {
19
+ 'on_modify_text' => {
20
+ event: 'keyup',
21
+ event_handler: -> (event_listener) {
22
+ -> (event) {
23
+ @text = event.target.value
24
+ event_listener.call(event)
25
+ }
26
+ }
27
+ }
28
+ }
29
+ end
30
+
31
+ def dom
32
+ text_text = @text
33
+ text_id = id
34
+ text_style = css
35
+ text_class = name
36
+ # TODO support password field
37
+ options = {type: 'text', id: text_id, style: text_style, class: text_class, value: text_text, style: 'min-width: 27px;'}
38
+ options = options.merge('disabled': 'disabled') unless @enabled
39
+ options = options.merge(type: 'password') if has_style?(:password)
40
+ @dom ||= html {
41
+ input(options)
42
+ }.to_s
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,490 @@
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/swt/event_listener_proxy'
23
+ require 'glimmer/swt/property_owner'
24
+ require 'glimmer/swt/swt_proxy'
25
+
26
+ module Glimmer
27
+ module SWT
28
+ class WidgetProxy
29
+ include Glimmer
30
+ include PropertyOwner
31
+
32
+ attr_reader :parent, :args, :path, :children, :enabled, :foreground, :background, :font
33
+
34
+ class << self
35
+ # Factory Method that translates a Glimmer DSL keyword into a WidgetProxy object
36
+ def for(keyword, parent, args)
37
+ the_widget_class = widget_class(keyword)
38
+ the_widget_class.new(parent, args)
39
+ end
40
+
41
+ def widget_class(keyword)
42
+ class_name_alternative = keyword.camelcase(:upper)
43
+ class_name_main = "#{class_name_alternative}Proxy"
44
+ Glimmer::SWT.const_get(class_name_main.to_sym) rescue Glimmer::SWT.const_get(class_name_alternative.to_sym)
45
+ rescue => e
46
+ puts "Widget #{keyword} was not found!"
47
+ nil
48
+ end
49
+
50
+ def widget_exists?(keyword)
51
+ !!widget_class(keyword)
52
+ end
53
+
54
+ def next_id_number_for(name)
55
+ @max_id_numbers[name] = max_id_number_for(name) + 1
56
+ end
57
+
58
+ def max_id_number_for(name)
59
+ @max_id_numbers[name] = max_id_numbers[name] || 0
60
+ end
61
+
62
+ def max_id_numbers
63
+ @max_id_numbers ||= reset_max_id_numbers!
64
+ end
65
+
66
+ def reset_max_id_numbers!
67
+ @max_id_numbers = {}
68
+ end
69
+
70
+ def underscored_widget_name(widget_proxy)
71
+ widget_proxy.class.name.split(/::|\./).last.sub(/Proxy$/, '').underscore
72
+ end
73
+ end
74
+
75
+ DEFAULT_INITIALIZERS = {
76
+ "composite" => lambda do |composite_proxy|
77
+ if composite_proxy.layout.nil?
78
+ layout = GridLayoutProxy.new(composite_proxy, [])
79
+ composite_proxy.layout = layout
80
+ layout.margin_width = 15
81
+ layout.margin_height = 15
82
+ end
83
+ end,
84
+ # "scrolled_composite" => lambda do |scrolled_composite|
85
+ # scrolled_composite.expand_horizontal = true
86
+ # scrolled_composite.expand_vertical = true
87
+ # end,
88
+ # "table" => lambda do |table|
89
+ # table.setHeaderVisible(true)
90
+ # table.setLinesVisible(true)
91
+ # end,
92
+ "table_column" => lambda do |table_column_proxy|
93
+ table_column_proxy.width = 80
94
+ end,
95
+ # "group" => lambda do |group_proxy|
96
+ # group_proxy.layout = GridLayoutProxy.new(group_proxy, []) if group.layout.nil?
97
+ # end,
98
+ }
99
+
100
+ def initialize(parent, args)
101
+ @parent = parent
102
+ @args = args
103
+ @children = Set.new # TODO consider moving to composite
104
+ @enabled = true
105
+ DEFAULT_INITIALIZERS[self.class.underscored_widget_name(self)]&.call(self)
106
+ @parent.add_child(self) # TODO rename to post_initialize_child to be closer to glimmer-dsl-swt terminology
107
+ end
108
+
109
+ def css_classes
110
+ dom_element.attr('class').to_s.split
111
+ end
112
+
113
+ def dispose
114
+ Document.find(path).remove
115
+ end
116
+
117
+ def path
118
+ "#{parent_path} > #{element}##{id}.#{name}"
119
+ end
120
+
121
+ # Root element representing widget. Must be overridden by subclasses if different from div
122
+ def element
123
+ 'div'
124
+ end
125
+
126
+ def add_child(child)
127
+ @children << child
128
+ child.render
129
+ end
130
+
131
+ def enabled=(value)
132
+ @enabled = value
133
+ dom_element.prop('disabled', !@enabled)
134
+ end
135
+
136
+ def foreground=(value)
137
+ @foreground = value
138
+ dom_element.css('color', foreground.to_css) unless foreground.nil?
139
+ end
140
+
141
+ def background=(value)
142
+ @background = value
143
+ dom_element.css('background-color', background.to_css) unless background.nil?
144
+ end
145
+
146
+ def font=(value)
147
+ @font = value.is_a?(FontProxy) ? value : FontProxy.new(self, value)
148
+ dom_element.css('font-family', @font.name) unless @font.nil?
149
+ dom_element.css('font-style', 'italic') if @font&.style == :italic
150
+ dom_element.css('font-weight', 'bold') if @font&.style == :bold
151
+ dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
152
+ end
153
+
154
+ def parent_path
155
+ @parent.path
156
+ end
157
+
158
+ def render
159
+ old_element = dom_element
160
+ brand_new = @dom.nil? || old_element.empty?
161
+ build_dom
162
+ if brand_new
163
+ Document.find(parent_path).append(@dom)
164
+ else
165
+ old_element.replace_with(@dom)
166
+ end
167
+ @observation_requests&.clone&.each do |keyword, event_listener_set|
168
+ event_listener_set.each do |event_listener|
169
+ @observation_requests[keyword].delete(event_listener)
170
+ handle_observation_request(keyword, &event_listener)
171
+ end
172
+ end
173
+ children.each do |child|
174
+ child.render
175
+ end
176
+ end
177
+ alias redraw render
178
+
179
+ def build_dom
180
+ @dom = nil
181
+ @dom = dom
182
+ @dom = @parent.layout.dom(@dom) if @parent.respond_to?(:layout) && @parent.layout
183
+ end
184
+
185
+ def content(&block)
186
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::WidgetExpression.new, &block)
187
+ end
188
+
189
+ # Subclasses must override with their own mappings
190
+ def observation_request_to_event_mapping
191
+ {}
192
+ end
193
+
194
+ def name
195
+ self.class.name.split('::').last.underscore.sub(/_proxy$/, '').gsub('_', '-')
196
+ end
197
+
198
+ def id
199
+ @id ||= "#{name}-#{WidgetProxy.next_id_number_for(name)}"
200
+ end
201
+
202
+ # Sets id explicitly. Useful in cases of wanting to maintain a stable id
203
+ def id=(value)
204
+ @id = value
205
+ end
206
+
207
+ # Subclasses can override with their own selector
208
+ def selector
209
+ "#{name}##{id}"
210
+ end
211
+
212
+ def add_css_class(css_class)
213
+ dom_element.add_class(css_class)
214
+ end
215
+
216
+ def add_css_classes(css_classes_to_add)
217
+ css_classes_to_add.each {|css_class| add_css_class(css_class)}
218
+ end
219
+
220
+ def remove_css_class(css_class)
221
+ dom_element.remove_class(css_class)
222
+ end
223
+
224
+ def remove_css_classes(css_classes_to_remove)
225
+ css_classes_to_remove.each {|css_class| remove_css_class(css_class)}
226
+ end
227
+
228
+ def clear_css_classes
229
+ css_classes.each {|css_class| remove_css_class(css_class)}
230
+ end
231
+
232
+ def has_style?(symbol)
233
+ @args.include?(symbol) # not a very solid implementation. Bring SWT constants eventually
234
+ end
235
+
236
+ def dom_element
237
+ Document.find(path)
238
+ end
239
+
240
+ def style_element
241
+ style_element_id = "#{id}-style"
242
+ style_element_selector = "style##{style_element_id}"
243
+ element = dom_element.find(style_element_selector)
244
+ if element.empty?
245
+ new_element = Element.new(:style)
246
+ new_element.attr('id', style_element_id)
247
+ new_element.attr('class', "#{name.gsub('_', '-')}-instance-style widget-instance-style")
248
+ dom_element.prepend(new_element)
249
+ element = dom_element.find(style_element_selector)
250
+ end
251
+ element
252
+ end
253
+
254
+ def parent_dom_element
255
+ Document.find(parent_path)
256
+ end
257
+
258
+ def listener_path
259
+ path
260
+ end
261
+
262
+ def can_handle_observation_request?(observation_request)
263
+ # TODO sort this out for Opal
264
+ observation_request = observation_request.to_s
265
+ if observation_request.start_with?('on_swt_')
266
+ constant_name = observation_request.sub(/^on_swt_/, '')
267
+ SWTProxy.has_constant?(constant_name)
268
+ elsif observation_request.start_with?('on_')
269
+ # event = observation_request.sub(/^on_/, '')
270
+ # can_add_listener?(event) || can_handle_drag_observation_request?(observation_request) || can_handle_drop_observation_request?(observation_request)
271
+ true # TODO filter by valid listeners only in the future
272
+ end
273
+ end
274
+
275
+ def handle_observation_request(keyword, &event_listener)
276
+ return unless observation_request_to_event_mapping.keys.include?(keyword)
277
+ @observation_requests ||= {}
278
+ @observation_requests[keyword] ||= Set.new
279
+ event = nil
280
+ delegate = nil
281
+ [observation_request_to_event_mapping[keyword]].flatten.each do |mapping|
282
+ @observation_requests[keyword] << event_listener
283
+ event = mapping[:event]
284
+ event_handler = mapping[:event_handler]
285
+ potential_event_listener = event_handler&.call(event_listener)
286
+ event_listener = potential_event_listener || event_listener
287
+ delegate = Document.find(listener_path).on(event, &event_listener)
288
+ end
289
+ # TODO update code below for new WidgetProxy API
290
+ EventListenerProxy.new(element_proxy: self, event: event, selector: selector, delegate: delegate)
291
+ end
292
+
293
+ def add_observer(observer, property_name)
294
+ property_listener_installers = self.class.ancestors.map {|ancestor| widget_property_listener_installers[ancestor]}.compact
295
+ widget_listener_installers = property_listener_installers.map{|installer| installer[property_name.to_s.to_sym]}.compact if !property_listener_installers.empty?
296
+ widget_listener_installers.to_a.each do |widget_listener_installer|
297
+ widget_listener_installer.call(observer)
298
+ end
299
+ end
300
+
301
+ def set_attribute(attribute_name, *args)
302
+ apply_property_type_converters(attribute_name, args)
303
+ super(attribute_name, *args) # PropertyOwner
304
+ end
305
+
306
+ def apply_property_type_converters(attribute_name, args)
307
+ if args.count == 1
308
+ value = args.first
309
+ converter = property_type_converters[attribute_name.to_sym]
310
+ args[0] = converter.call(value) if converter
311
+ end
312
+ # if args.count == 1 && args.first.is_a?(ColorProxy)
313
+ # g_color = args.first
314
+ # args[0] = g_color.swt_color
315
+ # end
316
+ end
317
+
318
+ def property_type_converters
319
+ color_converter = lambda do |value|
320
+ if value.is_a?(Symbol) || value.is_a?(String)
321
+ ColorProxy.new(value)
322
+ else
323
+ value
324
+ end
325
+ end
326
+ @property_type_converters ||= {
327
+ :background => color_converter,
328
+ # :background_image => lambda do |value|
329
+ # if value.is_a?(String)
330
+ # if value.start_with?('uri:classloader')
331
+ # value = value.sub(/^uri\:classloader\:\//, '')
332
+ # object = java.lang.Object.new
333
+ # value = object.java_class.resource_as_stream(value)
334
+ # value = java.io.BufferedInputStream.new(value)
335
+ # end
336
+ # image_data = ImageData.new(value)
337
+ # on_event_Resize do |resize_event|
338
+ # new_image_data = image_data.scaledTo(@swt_widget.getSize.x, @swt_widget.getSize.y)
339
+ # @swt_widget.getBackgroundImage&.dispose
340
+ # @swt_widget.setBackgroundImage(Image.new(@swt_widget.getDisplay, new_image_data))
341
+ # end
342
+ # Image.new(@swt_widget.getDisplay, image_data)
343
+ # else
344
+ # value
345
+ # end
346
+ # end,
347
+ :foreground => color_converter,
348
+ # :font => lambda do |value|
349
+ # if value.is_a?(Hash)
350
+ # font_properties = value
351
+ # FontProxy.new(self, font_properties).swt_font
352
+ # else
353
+ # value
354
+ # end
355
+ # end,
356
+ # :items => lambda do |value|
357
+ # value.to_java :string
358
+ # end,
359
+ :text => lambda do |value|
360
+ # if swt_widget.is_a?(Browser)
361
+ # value.to_s
362
+ # else
363
+ value.to_s
364
+ # end
365
+ end,
366
+ # :visible => lambda do |value|
367
+ # !!value
368
+ # end,
369
+ }
370
+ end
371
+
372
+ def widget_property_listener_installers
373
+ @swt_widget_property_listener_installers ||= {
374
+ # WidgetProxy => {
375
+ # :focus => lambda do |observer|
376
+ # on_focus_gained { |focus_event|
377
+ # observer.call(true)
378
+ # }
379
+ # on_focus_lost { |focus_event|
380
+ # observer.call(false)
381
+ # }
382
+ # end,
383
+ # },
384
+ TextProxy => {
385
+ :text => lambda do |observer|
386
+ on_modify_text { |modify_event|
387
+ observer.call(text)
388
+ }
389
+ end,
390
+ # :caret_position => lambda do |observer|
391
+ # on_event_keydown { |event|
392
+ # observer.call(getCaretPosition)
393
+ # }
394
+ # on_event_keyup { |event|
395
+ # observer.call(getCaretPosition)
396
+ # }
397
+ # on_event_mousedown { |event|
398
+ # observer.call(getCaretPosition)
399
+ # }
400
+ # on_event_mouseup { |event|
401
+ # observer.call(getCaretPosition)
402
+ # }
403
+ # end,
404
+ # :selection => lambda do |observer|
405
+ # on_event_keydown { |event|
406
+ # observer.call(getSelection)
407
+ # }
408
+ # on_event_keyup { |event|
409
+ # observer.call(getSelection)
410
+ # }
411
+ # on_event_mousedown { |event|
412
+ # observer.call(getSelection)
413
+ # }
414
+ # on_event_mouseup { |event|
415
+ # observer.call(getSelection)
416
+ # }
417
+ # end,
418
+ # :selection_count => lambda do |observer|
419
+ # on_event_keydown { |event|
420
+ # observer.call(getSelectionCount)
421
+ # }
422
+ # on_event_keyup { |event|
423
+ # observer.call(getSelectionCount)
424
+ # }
425
+ # on_event_mousedown { |event|
426
+ # observer.call(getSelectionCount)
427
+ # }
428
+ # on_event_mouseup { |event|
429
+ # observer.call(getSelectionCount)
430
+ # }
431
+ # end,
432
+ # :top_index => lambda do |observer|
433
+ # @last_top_index = getTopIndex
434
+ # on_paint_control { |event|
435
+ # if getTopIndex != @last_top_index
436
+ # @last_top_index = getTopIndex
437
+ # observer.call(@last_top_index)
438
+ # end
439
+ # }
440
+ # end,
441
+ },
442
+ # Java::OrgEclipseSwtCustom::StyledText => {
443
+ # :text => lambda do |observer|
444
+ # on_modify_text { |modify_event|
445
+ # observer.call(getText)
446
+ # }
447
+ # end,
448
+ # },
449
+ # Button => { #radio?
450
+ # :selection => lambda do |observer|
451
+ # on_widget_selected { |selection_event|
452
+ # observer.call(getSelection)
453
+ # }
454
+ # end
455
+ # },
456
+ # Java::OrgEclipseSwtWidgets::MenuItem => {
457
+ # :selection => lambda do |observer|
458
+ # on_widget_selected { |selection_event|
459
+ # observer.call(getSelection)
460
+ # }
461
+ # end
462
+ # },
463
+ # Java::OrgEclipseSwtWidgets::Spinner => {
464
+ # :selection => lambda do |observer|
465
+ # on_widget_selected { |selection_event|
466
+ # observer.call(getSelection)
467
+ # }
468
+ # end
469
+ # },
470
+ }
471
+ end
472
+
473
+ end
474
+ end
475
+ end
476
+
477
+ require 'glimmer/swt/browser_proxy'
478
+ require 'glimmer/swt/button_proxy'
479
+ require 'glimmer/swt/combo_proxy'
480
+ require 'glimmer/swt/composite_proxy'
481
+ require 'glimmer/swt/label_proxy'
482
+ require 'glimmer/swt/list_proxy'
483
+ require 'glimmer/swt/tab_folder_proxy'
484
+ require 'glimmer/swt/tab_item_proxy'
485
+ require 'glimmer/swt/table_column_proxy'
486
+ require 'glimmer/swt/table_item_proxy'
487
+ require 'glimmer/swt/table_proxy'
488
+ require 'glimmer/swt/text_proxy'
489
+
490
+ require 'glimmer/dsl/opal/widget_expression'