glimmer-dsl-swt 4.24.4.3 → 4.24.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b47f7d900d7e9e17d688b2a87f6996e2a4e23f2aec2139b7d5efc03fc1837d7
4
- data.tar.gz: 0dd67034463fa4193ebbb4c064f6d2dccfd26dde29d326fef69b8a12b80a04a6
3
+ metadata.gz: 529a6e52ee5f12439588d4e74d7cb71cf571dc5708c0f30d4a8212fc93bbcd94
4
+ data.tar.gz: beee81b79e38eb8c4f06efae74cbcf449284dcfdc012662529b304272cd2c959
5
5
  SHA512:
6
- metadata.gz: 5737d7b9ad280998dfe94b4e4df7879ee48ff805c2abb0bb1626a3d688684371c2aca03c0da8eb27e2011a4ab26e58f3e4c3a44154056d7197a66acfb89ef4c1
7
- data.tar.gz: 05e8484a449adcbd19a4f1b4ba8644614032a272ec957770bbbc1c11cdbea8299fdeaed0ebcbf42df493280782d6b425ec4d967dca8f967a6fc1a1a95dbaeff2
6
+ metadata.gz: 955e339c7ee47be0f1d2a400a83689b71a7a3c1737a0738ef58cd779f6ac2c805609bf81f462bb3b1dfcf6bfe421e31f18037b2a7139c5bf0877d7ae776d4377
7
+ data.tar.gz: ce4943970d11b34972bafe1138a0878431d5e5f5b6c5943edfa8b51f5591540f781c86eef1150e7ee4306d8ba3a38f4e3ca75e6dfa57b424dc13d37b1845921b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.24.4.5
4
+
5
+ - Support `refined_table` `:editable` SWT style and `model_array` bidirectional data-binding
6
+ - Update Hello, Refined Table! to allow editing the table
7
+ - Support `Glimmer::UI::CustomWidget`/`Glimmer::UI::CustomShell` support for `swt_style_symbols` read-only attribute to access array of SWT style symbols (works better than `swt_style` because some widgets support custom Glimmer-only SWT style symbols not originally supported by SWT)
8
+
9
+ ## 4.24.4.4
10
+
11
+ - Support `refined_table` `selection` data-binding
12
+ - Remove extra horizontal/vertical margins in `refined_table` pagination area
13
+ - Update Hello, Refined Table! to support booking a game with right-click pop up context menu
14
+ - Have `Glimmer::UI::CustomWidget` better delegate listners and data-binding observers to `@children_owner` when set
15
+
3
16
  ## 4.24.4.3
4
17
 
5
18
  - Fix issue with failed `table` extra property data-binding (e.g. foreground color, background color) due to asynchronous multi-threading optimization (now it works).
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.24.4.3
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.24.4.5
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -21,7 +21,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
21
21
 
22
22
  ![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
23
23
 
24
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.24.4.3 includes [SWT 4.24](https://download.eclipse.org/eclipse/downloads/drops4/R-4.24-202206070700/), which was released on June 7, 2022. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
24
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.24.4.5 includes [SWT 4.24](https://download.eclipse.org/eclipse/downloads/drops4/R-4.24-202206070700/), which was released on June 7, 2022. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
25
25
 
26
26
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword. That was [originally conceived back in 2007](https://andymaleh.blogspot.com/2007/12/data-shining-in-glimmer.html).
27
27
 
@@ -338,7 +338,7 @@ jgem install glimmer-dsl-swt
338
338
 
339
339
  Or this command if you want a specific version:
340
340
  ```
341
- jgem install glimmer-dsl-swt -v 4.24.4.3
341
+ jgem install glimmer-dsl-swt -v 4.24.4.5
342
342
  ```
343
343
 
344
344
  `jgem` is JRuby's version of `gem` command.
@@ -366,7 +366,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
366
366
 
367
367
  Add the following to `Gemfile`:
368
368
  ```
369
- gem 'glimmer-dsl-swt', '~> 4.24.4.3'
369
+ gem 'glimmer-dsl-swt', '~> 4.24.4.5'
370
370
  ```
371
371
 
372
372
  And, then run:
@@ -389,7 +389,7 @@ glimmer
389
389
  ```
390
390
 
391
391
  ```
392
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.4.3
392
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.4.5
393
393
 
394
394
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
395
395
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.24.4.3
1
+ 4.24.4.5
@@ -3732,7 +3732,7 @@ shell {
3732
3732
 
3733
3733
  Screenshot:
3734
3734
 
3735
- ![Canvas Animation Example](/images/glimmer-example-canvas-animation.png)
3735
+ ![Canvas Animation Example](/images/glimmer-example-canvas-animation.gif)
3736
3736
 
3737
3737
  Keywords:
3738
3738
  - `animation` declares an animation under a canvas, which renders frames using a frame block indefinitely or finitely depending on (cycle_count/frame_count) properties
@@ -4320,37 +4320,53 @@ Options:
4320
4320
  - `page` (default: `1` if table is filled and `0` otherwise): specifies initial page
4321
4321
  - `query` (default: `''`): specifies filter query term (empty shows all results)
4322
4322
 
4323
- Note that currently `refined_table` only supports displaying a **read-only** table (meaning it can read updates from the model, but it cannot write back to the model through `TableEditor` cells). Also, it does not support selection or sorting by clicking columns yet.
4323
+ Note that currently `refined_table` does not support sorting by clicking columns yet.
4324
4324
 
4325
4325
  Example taken from [Hello, Refined Table!](/docs/reference/GLIMMER_SAMPLES.md#hello-refined-table):
4326
4326
 
4327
4327
  ![hello refined table](/images/glimmer-hello-refined-table.png)
4328
4328
 
4329
4329
  ```ruby
4330
- #... more code precedes
4331
-
4332
- refined_table(per_page: 20) {
4330
+ #...
4331
+ refined_table(:editable, :border, per_page: 20) { # also `page: 1` by default
4333
4332
  table_column {
4334
4333
  width 100
4335
4334
  text 'Date'
4335
+ editor :date_drop_down
4336
4336
  }
4337
4337
  table_column {
4338
4338
  width 200
4339
4339
  text 'Ballpark'
4340
+ editor :none
4340
4341
  }
4341
4342
  table_column {
4342
4343
  width 150
4343
4344
  text 'Home Team'
4345
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
4344
4346
  }
4345
4347
  table_column {
4346
4348
  width 150
4347
4349
  text 'Away Team'
4350
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
4351
+ }
4352
+
4353
+ menu {
4354
+ menu_item {
4355
+ text 'Book'
4356
+
4357
+ on_widget_selected do
4358
+ message_box {
4359
+ text 'Game Booked!'
4360
+ message "The game \"#{@baseball_season.selected_game}\" has been booked!"
4361
+ }.open
4362
+ end
4363
+ }
4348
4364
  }
4349
4365
 
4350
- model_array <= [@baseball_season, :games, column_attributes: {'Home Team' => :home_team_name, 'Away Team' => :away_team_name}]
4366
+ model_array <=> [@baseball_season, :games, column_attributes: {'Home Team' => :home_team_name, 'Away Team' => :away_team_name}]
4367
+ selection <=> [@baseball_season, :selected_game]
4351
4368
  }
4352
-
4353
- #...more code follows
4369
+ #...
4354
4370
  ```
4355
4371
 
4356
4372
  #### Tree
@@ -793,6 +793,14 @@ Hello, Refined Table!
793
793
 
794
794
  ![Hello Refined Table](/images/glimmer-hello-refined-table.png)
795
795
 
796
+ Hello, Refined Table! Booking Menu
797
+
798
+ ![Hello Refined Table](/images/glimmer-hello-refined-table-booking-menu.png)
799
+
800
+ Hello, Refined Table! Game Booked
801
+
802
+ ![Hello Refined Table](/images/glimmer-hello-refined-table-game-booked.png)
803
+
796
804
  #### Hello, Link!
797
805
 
798
806
  This sample demonstrates the use of the `link` widget in Glimmer, including identifying which link was clicked and performing an action (displaying help) based on its location.
Binary file
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2022 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
@@ -149,7 +149,7 @@ module Glimmer
149
149
  @composite = composite {
150
150
  grid_layout(2, false)
151
151
 
152
- @line_numbers_styled_text_proxy = styled_text(swt(swt(swt_style), :h_scroll!, :v_scroll!)) {
152
+ @line_numbers_styled_text_proxy = styled_text(swt(swt(@swt_style), :h_scroll!, :v_scroll!)) {
153
153
  layout_data(:right, :fill, false, true)
154
154
 
155
155
  text <= [self, :styled_text_proxy_text,
@@ -186,7 +186,7 @@ module Glimmer
186
186
  }
187
187
 
188
188
  def code_text_widget
189
- @styled_text_proxy = styled_text(swt_style) {
189
+ @styled_text_proxy = styled_text(@swt_style) {
190
190
  # custom_widget_property_owner # TODO implement to route properties here without declaring method_missing
191
191
  layout_data :fill, :fill, true, true if lines
192
192
 
@@ -54,7 +54,7 @@ module Glimmer
54
54
  filter_and_paginate
55
55
  end
56
56
  @table_proxy.content {
57
- items(dsl: true) <=> [self, :refined_model_array, model_binding.binding_options.merge(read_only: true)]
57
+ items <=> [self, :refined_model_array, model_binding.binding_options]
58
58
  }
59
59
  filter_and_paginate
60
60
  end
@@ -72,7 +72,7 @@ module Glimmer
72
72
 
73
73
  pagination
74
74
 
75
- @children_owner = @table_proxy = table(swt_style) {
75
+ @children_owner = @table_proxy = table(*swt_style_symbols) {
76
76
  layout_data(:fill, :fill, true, true)
77
77
  }
78
78
  }
@@ -82,7 +82,10 @@ module Glimmer
82
82
  composite {
83
83
  layout_data(:fill, :center, true, false)
84
84
 
85
- fill_layout(:horizontal)
85
+ fill_layout(:horizontal) {
86
+ margin_width 0
87
+ margin_height 0
88
+ }
86
89
 
87
90
  @first_button_proxy = button {
88
91
  text '<<'
@@ -169,29 +172,7 @@ module Glimmer
169
172
  def last_button_block=(block)
170
173
  @last_button_proxy.content(&block)
171
174
  end
172
-
173
- def method_missing(method_name, *args, &block)
174
- dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
175
- if dsl_mode
176
- args.pop if args.last.is_a?(Hash) && args.last[:dsl]
177
- super(method_name, *args, &block)
178
- elsif @table_proxy&.respond_to?(method_name, *args, &block)
179
- @table_proxy&.send(method_name, *args, &block)
180
- else
181
- super
182
- end
183
- end
184
-
185
- def respond_to?(method_name, *args, &block)
186
- dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
187
- if dsl_mode
188
- args = args[0...-1] if args.last.is_a?(Hash) && args.last[:dsl]
189
- super(method_name, *args, &block)
190
- else
191
- super || @table_proxy&.respond_to?(method_name, *args, &block)
192
- end
193
- end
194
-
175
+
195
176
  def page_count
196
177
  (filtered_model_array && (filtered_model_array.count / per_page.to_f).ceil) || 0
197
178
  end
@@ -57,6 +57,7 @@ module Glimmer
57
57
 
58
58
  swt_widget_class = self.class.swt_widget_class_for('menu')
59
59
  if parent.swt_widget.is_a?(Menu)
60
+ # TODO support CustomWidget children_owner
60
61
  @menu_item_proxy = SWT::WidgetProxy.new('menu_item', parent, [:cascade] + [index].compact)
61
62
  @swt_menu_item = @menu_item_proxy.swt_widget
62
63
  @swt_widget = swt_widget_class.new(@menu_item_proxy.swt_widget)
@@ -64,6 +65,7 @@ module Glimmer
64
65
  elsif parent.swt_widget.is_a?(Shell)
65
66
  @swt_widget = swt_widget_class.new(parent.swt_widget, style('menu', styles))
66
67
  elsif parent.swt_widget.is_a?(TrayItem)
68
+ # TODO support CustomWidget children_owner
67
69
  @swt_widget = swt_widget_class.new(parent.shell_proxy.swt_widget, style('menu', styles))
68
70
  parent.menu_proxy = self
69
71
  else
@@ -159,8 +159,7 @@ module Glimmer
159
159
  @parent_proxy = parent
160
160
  styles, extra_options = extract_args(underscored_widget_name, args)
161
161
  swt_widget_class = self.class.swt_widget_class_for(underscored_widget_name)
162
- swt_widget_producer = @parent_proxy.respond_to?(:children_owner) ? @parent_proxy.children_owner : @parent_proxy
163
- @swt_widget = swt_widget_class.new(swt_widget_producer.swt_widget, style(underscored_widget_name, styles), *extra_options)
162
+ @swt_widget = swt_widget_class.new(@parent_proxy.swt_widget, style(underscored_widget_name, styles), *extra_options)
164
163
  else
165
164
  @swt_widget = swt_widget
166
165
  underscored_widget_name = self.class.underscored_widget_name(@swt_widget)
@@ -40,13 +40,21 @@ module Glimmer
40
40
 
41
41
  def initialize(parent, *swt_constants, options, &content)
42
42
  super
43
- auto_exec do
44
- @swt_widget.set_data('custom_shell', self)
45
- @swt_widget.set_data('custom_window', self)
46
- end
47
43
  raise Error, 'Invalid custom shell (window) body root! Must be a shell (window) or another custom shell (window).' unless body_root.swt_widget.is_a?(org.eclipse.swt.widgets.Shell)
48
44
  end
49
45
 
46
+ def swt_widget
47
+ if @swt_widget.nil? && children_owner
48
+ @swt_widget = children_owner.swt_widget
49
+ auto_exec do
50
+ @swt_widget.set_data('custom_widget', self)
51
+ @swt_widget.set_data('custom_shell', self)
52
+ @swt_widget.set_data('custom_window', self)
53
+ end
54
+ end
55
+ @swt_widget
56
+ end
57
+
50
58
  # Classes may override
51
59
  def open
52
60
  body_root.open
@@ -161,13 +161,13 @@ module Glimmer
161
161
  end
162
162
  end
163
163
 
164
- attr_reader :body_root, :swt_widget, :parent, :parent_proxy, :swt_style, :options
164
+ attr_reader :body_root, :parent, :parent_proxy, :swt_style_symbols, :options
165
165
 
166
- def initialize(parent, *swt_constants, options, &content)
166
+ def initialize(parent, *swt_style_symbols, options, &content)
167
167
  SWT::DisplayProxy.current_custom_widgets_and_shapes << self
168
168
  @parent_proxy = @parent = parent
169
169
  @parent_proxy = @parent&.get_data('proxy') if @parent.respond_to?(:get_data) && @parent.get_data('proxy')
170
- @swt_style = SWT::SWTProxy[*swt_constants]
170
+ @swt_style_symbols = swt_style_symbols
171
171
  options ||= {}
172
172
  @options = self.class.options.merge(options)
173
173
  @content = Util::ProcTracker.new(content) if content
@@ -176,9 +176,8 @@ module Glimmer
176
176
  raise Glimmer::Error, 'Invalid custom widget for having no body! Please define body block!' if body_block.nil?
177
177
  @body_root = auto_exec { instance_exec(&body_block) }
178
178
  raise Glimmer::Error, 'Invalid custom widget for having an empty body! Please fill body block!' if @body_root.nil?
179
- @swt_widget = @body_root.swt_widget
180
179
  auto_exec do
181
- @swt_widget.set_data('custom_widget', self)
180
+ @body_root.set_data('custom_widget', self)
182
181
  end
183
182
  auto_exec { execute_hook('after_body') }
184
183
  auto_exec do
@@ -192,15 +191,34 @@ module Glimmer
192
191
  post_add_content if content.nil?
193
192
  end
194
193
 
194
+ # Calls post_initialize_child on children_owner by default
195
195
  # Subclasses may override to perform post initialization work on an added child
196
196
  def post_initialize_child(child)
197
- # No Op by default
197
+ children_owner.post_initialize_child(child)
198
198
  end
199
199
 
200
200
  def post_add_content
201
201
  SWT::DisplayProxy.current_custom_widgets_and_shapes.delete(self)
202
202
  end
203
203
 
204
+ def swt_widget
205
+ if @swt_widget.nil? && children_owner
206
+ @swt_widget = children_owner.swt_widget
207
+ auto_exec do
208
+ @swt_widget.set_data('custom_widget', self)
209
+ end
210
+ end
211
+ @swt_widget
212
+ end
213
+
214
+ # returns calculated SWT style integer value from swt_style_symbols
215
+ # keep in mind that it would not work when using glimmer-only
216
+ # custom swt_style_symbols like :editable for table
217
+ # In that case, just reference swt_style_symbols array instead
218
+ def swt_style
219
+ @swt_style ||= SWT::SWTProxy[*@swt_style_symbols]
220
+ end
221
+
204
222
  def observer_registrations
205
223
  @observer_registrations ||= []
206
224
  end
@@ -212,7 +230,9 @@ module Glimmer
212
230
  property = observation_request.sub(/^on_updated_/, '')
213
231
  result = can_add_observer?(property)
214
232
  end
215
- result || body_root&.can_handle_observation_request?(observation_request)
233
+ result ||
234
+ (children_owner != body_root && children_owner&.can_handle_observation_request?(observation_request)) ||
235
+ body_root&.can_handle_observation_request?(observation_request)
216
236
  end
217
237
 
218
238
  def handle_observation_request(observation_request, &block)
@@ -220,18 +240,25 @@ module Glimmer
220
240
  if observation_request.start_with?('on_updated_')
221
241
  property = observation_request.sub(/^on_updated_/, '') # TODO look into eliminating duplication from above
222
242
  add_observer(DataBinding::Observer.proc(&block), property) if can_add_observer?(property)
243
+ elsif children_owner != body_root && children_owner&.can_handle_observation_request?(observation_request)
244
+ children_owner.handle_observation_request(observation_request, &block)
223
245
  else
224
246
  body_root.handle_observation_request(observation_request, &block)
225
247
  end
226
248
  end
227
249
 
228
250
  def can_add_observer?(attribute_name)
229
- has_instance_method?(attribute_name) || has_instance_method?("#{attribute_name}?") || @body_root.can_add_observer?(attribute_name)
251
+ has_instance_method?(attribute_name) ||
252
+ has_instance_method?("#{attribute_name}?") ||
253
+ (children_owner != @body_root && children_owner.can_add_observer?(attribute_name)) ||
254
+ @body_root.can_add_observer?(attribute_name)
230
255
  end
231
256
 
232
257
  def add_observer(observer, attribute_name)
233
258
  if has_instance_method?(attribute_name)
234
259
  super
260
+ elsif children_owner != @body_root && children_owner.can_add_observer?(attribute_name)
261
+ children_owner.add_observer(observer, attribute_name)
235
262
  else
236
263
  @body_root.add_observer(observer, attribute_name)
237
264
  end
@@ -239,12 +266,15 @@ module Glimmer
239
266
 
240
267
  def has_attribute?(attribute_name, *args)
241
268
  has_instance_method?(attribute_setter(attribute_name)) ||
269
+ (children_owner != @body_root && children_owner.has_attribute?(attribute_name, *args)) ||
242
270
  @body_root.has_attribute?(attribute_name, *args)
243
271
  end
244
272
 
245
273
  def set_attribute(attribute_name, *args)
246
274
  if has_instance_method?(attribute_setter(attribute_name))
247
275
  send(attribute_setter(attribute_name), *args)
276
+ elsif (children_owner != @body_root && children_owner.has_attribute?(attribute_name, *args))
277
+ children_owner.set_attribute(attribute_name, *args)
248
278
  else
249
279
  @body_root.set_attribute(attribute_name, *args)
250
280
  end
@@ -262,6 +292,8 @@ module Glimmer
262
292
  def get_attribute(attribute_name)
263
293
  if has_instance_method?(attribute_name)
264
294
  send(attribute_name)
295
+ elsif children_owner != @body_root && children_owner.has_attribute?(attribute_name)
296
+ children_owner.get_attribute(attribute_name)
265
297
  else
266
298
  @body_root.get_attribute(attribute_name)
267
299
  end
@@ -317,6 +349,8 @@ module Glimmer
317
349
  # but fail the glimmer DSL for the right reason to avoid seeing noise in the log output
318
350
  if block && can_handle_observation_request?(method)
319
351
  handle_observation_request(method, &block)
352
+ elsif children_owner != @body_root && children_owner.respond_to?(method, *args, &block)
353
+ children_owner.send(method, *args, &block)
320
354
  else
321
355
  body_root.send(method, *args, &block)
322
356
  end
@@ -326,6 +360,7 @@ module Glimmer
326
360
  def respond_to?(method, *args, &block)
327
361
  super or
328
362
  can_handle_observation_request?(method) or
363
+ children_owner.respond_to?(method, *args, &block) or
329
364
  body_root.respond_to?(method, *args, &block)
330
365
  end
331
366
 
@@ -36,12 +36,13 @@ class EmailShell
36
36
  option :to, default: '"John Irwin" <john.irwin@example.com>'
37
37
 
38
38
  before_body do
39
- @swt_style |= swt(:shell_trim, :modeless)
39
+ # build a custom swt_style based on passed in swt style symbols (built-in CustomShell attribute)
40
+ @swt_style = swt(:shell_trim, :modeless, *swt_style_symbols)
40
41
  end
41
42
 
42
43
  body {
43
- # pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
44
- shell(parent_shell, swt_style) {
44
+ # pass received @swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
45
+ shell(parent_shell, @swt_style) {
45
46
  grid_layout(2, false)
46
47
 
47
48
  text subject
@@ -65,8 +65,8 @@ class GreetingLabel
65
65
  end
66
66
 
67
67
  body {
68
- # pass received swt_style through to label to customize (e.g. :center to center text)
69
- label(swt_style) {
68
+ # pass received swt style symbols through to label to customize (e.g. :center to center text)
69
+ label(*swt_style_symbols) {
70
70
  text "#{greeting}, #{name}!"
71
71
  font @font
72
72
  foreground <=> [self, :label_color]
@@ -59,6 +59,10 @@ class HelloRefinedTable
59
59
  {town: 'San Francisco', name: 'Giants', ballpark: 'Oracle Park'},
60
60
  ].map {|team_kwargs| new(team_kwargs)}
61
61
  end
62
+
63
+ def all_team_names
64
+ @all_team_names ||= BaseballTeam.all.map {|t| t[:name]}
65
+ end
62
66
  end
63
67
 
64
68
  def complete_name
@@ -71,16 +75,44 @@ class HelloRefinedTable
71
75
  home_team.complete_name
72
76
  end
73
77
 
78
+ def home_team_name=(new_name)
79
+ new_home_team = BaseballTeam.all.find {|t| t[:name] == new_name}
80
+ self.home_team = new_home_team if new_home_team
81
+ end
82
+
83
+ def home_team_name_options
84
+ BaseballTeam.all_team_names
85
+ end
86
+
74
87
  def away_team_name
75
88
  away_team.complete_name
76
89
  end
77
90
 
91
+ def away_team_name=(new_name)
92
+ new_away_team = BaseballTeam.all.find {|t| t[:name] == new_name}
93
+ self.away_team = new_away_team if new_away_team
94
+ end
95
+
96
+ def away_team_name_options
97
+ BaseballTeam.all_team_names
98
+ end
99
+
78
100
  def ballpark
79
101
  home_team.ballpark
80
102
  end
103
+
104
+ def date=(new_date)
105
+ self['date'] = new_date.respond_to?(:to_date) ? new_date.to_date : new_date
106
+ end
107
+
108
+ def to_s
109
+ "#{home_team_name} vs #{away_team_name} at #{ballpark}"
110
+ end
81
111
  end
82
112
 
83
113
  BaseballSeason = Struct.new(:year) do
114
+ attr_accessor :selected_game
115
+
84
116
  def games
85
117
  if @games.nil?
86
118
  @games = []
@@ -131,25 +163,43 @@ class HelloRefinedTable
131
163
  shell {
132
164
  text 'Hello, Refined Table!'
133
165
 
134
- refined_table(per_page: 20) { # also `page: 1` by default
166
+ refined_table(:editable, :border, per_page: 20) { # also `page: 1` by default
135
167
  table_column {
136
168
  width 100
137
169
  text 'Date'
170
+ editor :date_drop_down
138
171
  }
139
172
  table_column {
140
173
  width 200
141
174
  text 'Ballpark'
175
+ editor :none
142
176
  }
143
177
  table_column {
144
178
  width 150
145
179
  text 'Home Team'
180
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
146
181
  }
147
182
  table_column {
148
183
  width 150
149
184
  text 'Away Team'
185
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
186
+ }
187
+
188
+ menu {
189
+ menu_item {
190
+ text 'Book'
191
+
192
+ on_widget_selected do
193
+ message_box {
194
+ text 'Game Booked!'
195
+ message "The game \"#{@baseball_season.selected_game}\" has been booked!"
196
+ }.open
197
+ end
198
+ }
150
199
  }
151
200
 
152
- model_array <= [@baseball_season, :games, column_attributes: {'Home Team' => :home_team_name, 'Away Team' => :away_team_name}]
201
+ model_array <=> [@baseball_season, :games, column_attributes: {'Home Team' => :home_team_name, 'Away Team' => :away_team_name}]
202
+ selection <=> [@baseball_season, :selected_game]
153
203
  }
154
204
  }
155
205
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.24.4.3
4
+ version: 4.24.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-13 00:00:00.000000000 Z
11
+ date: 2022-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement