glimmer-dsl-swt 4.20.0.5 → 4.20.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +13 -7
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +5 -2
  6. data/glimmer-dsl-swt.gemspec +0 -0
  7. data/lib/glimmer-dsl-swt.rb +1 -0
  8. data/lib/glimmer/data_binding/table_items_binding.rb +2 -2
  9. data/lib/glimmer/data_binding/tree_items_binding.rb +2 -2
  10. data/lib/glimmer/dsl/swt/bind_expression.rb +5 -25
  11. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
  12. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +1 -1
  13. data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +6 -5
  14. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +2 -2
  15. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +17 -12
  16. data/lib/glimmer/rake_task/scaffold.rb +2 -2
  17. data/lib/glimmer/swt/custom/animation.rb +6 -0
  18. data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
  19. data/lib/glimmer/swt/custom/radio_group.rb +2 -1
  20. data/lib/glimmer/swt/proxy_properties.rb +7 -6
  21. data/lib/glimmer/swt/table_proxy.rb +15 -8
  22. data/lib/glimmer/swt/widget_proxy.rb +4 -1
  23. data/lib/glimmer/ui/custom_shape.rb +1 -1
  24. data/lib/glimmer/ui/custom_widget.rb +1 -1
  25. data/samples/elaborate/calculator.rb +1 -1
  26. data/samples/elaborate/contact_manager.rb +2 -2
  27. data/samples/elaborate/meta_sample.rb +5 -5
  28. data/samples/elaborate/tetris.rb +2 -2
  29. data/samples/elaborate/tetris/view/bevel.rb +11 -11
  30. data/samples/elaborate/tetris/view/block.rb +1 -1
  31. data/samples/elaborate/tetris/view/high_score_dialog.rb +4 -4
  32. data/samples/elaborate/tetris/view/score_lane.rb +3 -3
  33. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +9 -9
  34. data/samples/elaborate/timer.rb +8 -8
  35. data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
  36. data/samples/hello/hello_checkbox_group.rb +1 -1
  37. data/samples/hello/hello_code_text.rb +3 -3
  38. data/samples/hello/hello_cool_bar.rb +1 -1
  39. data/samples/hello/hello_cursor.rb +1 -1
  40. data/samples/hello/hello_custom_shell.rb +1 -1
  41. data/samples/hello/hello_directory_dialog.rb +1 -1
  42. data/samples/hello/hello_radio_group.rb +2 -2
  43. data/samples/hello/hello_table.rb +4 -4
  44. data/samples/hello/hello_tool_bar.rb +1 -1
  45. data/samples/hello/hello_tree.rb +11 -11
  46. metadata +44 -25
  47. data/lib/glimmer/data_binding/shine.rb +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b539c452b30e337ec632c8e4e034a2ef0585000eb7fdad70afe77ec5851f2d49
4
- data.tar.gz: a562eca963b5d39cbb8c7b56219dae2bc23ad93e2f8b76cb1853c38077e07c93
3
+ metadata.gz: db094d1b82d81c288c534731f7ea4e43427928f72aee2199d82add75356d382d
4
+ data.tar.gz: 7e4c4616df9aa65d9850b629d6c710318000b6e6fbcc567891a7bc0ab18aeb54
5
5
  SHA512:
6
- metadata.gz: cea713cd788b554522e83e7e72da27e942f962fb3996a415ed2d06b803f6a95345265a7e81d9fcd3dc7e6567b4951fdee1dbeedb908ecb146cdcfb70f17c6f7f
7
- data.tar.gz: 4a15d50266466f54713a440f563d203137c5ea9a2f290d2f6f2e44f752a70ddcc772d901152aeb6fc31957b7d7d9cf6ef04df82f45db4a3964c14ed467a32c94
6
+ metadata.gz: 856fd6405d5b996acc9804123a463ab03894c7b4c417fdbd0ddef2d214fa4f4b00de023d13d62d7107baa18d0d02e847bfe9960459ee7c1003cab487c5fa72a9
7
+ data.tar.gz: 400bdaea578f97d159c6773f58977b18a3776681c33a714b1a25aa2f66e236d6e1af7111b349ff222d2d8408cfe40148ecabc4459a9d4e6de5d78c93967ca241
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.3.0
4
+
5
+ - Shine data-binding support for `custom widgets`, `custom shells`, and `custom shapes`
6
+ - Update remaining samples with `bind` keyword to switch to Shine data-binding syntax
7
+ - Switch scaffolded classes' data-binding to Shine
8
+ - Fix `table` Shine syntax support for unidirectional (one-way) data-binding
9
+
10
+ ### 4.20.2.1
11
+
12
+ - Shine data-binding support for `animation` (also supporting `#content {}` method in `Animation`)
13
+ - Update Hello, Custom Shell! to use Shine data-binding syntax
14
+ - Fix `table` automatic sorting support when using one-way Shine data-binding syntax (which was disabling reads)
15
+
16
+ ### 4.20.2.0
17
+
18
+ - Shine data-binding syntax support for `tree` widget
19
+ - Use Shine syntax in Hello, Tree! sample
20
+
21
+ ### 4.20.1.0
22
+
23
+ - Shine data-binding syntax support for `table` widget
24
+ - Use Shine syntax in Hello, Table! and Contact Manager samples
25
+
3
26
  ### 4.20.0.5
4
27
 
5
28
  - Hello, Text! sample
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.20.0.5
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.20.3.0
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)
@@ -15,9 +15,9 @@
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.0.5 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.3.0 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
19
19
 
20
- **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 (keep in mind that it is still an early alpha, so default back to `bind` whenever needed).
20
+ **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 (keep in mind that it is still a beta, so default back to `bind` whenever needed).
21
21
 
22
22
  Please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) better by providing feedback and [contributing](#contributing) whenever possible. Any feature suggestions that are accepted could be implemented within weeks if not days.
23
23
 
@@ -286,10 +286,16 @@ Thanks to Java and JRuby, Glimmer apps can be packaged as cross-platform JAR fil
286
286
 
287
287
  The Java Virtual Machine already supports OS-native threads, so Glimmer apps can have multiple things running in parallel with no problem.
288
288
 
289
- SWT supports Canvas graphics drawing, and Glimmer takes that further by provding a Canvas Shape/Transform/Animation DSL, making it very simple to decorate any existing widgets or add new widgets with a completely custom look and feel if needed for branding or entertainment (gaming) purposes.
289
+ SWT supports Canvas graphics drawing, and Glimmer takes that further by provding a Canvas Shape/Transform/Animation DSL, making it very simple to decorate any existing widgets or add new widgets with a completely custom look and feel if needed for branding purposes.
290
290
 
291
291
  Audio is supported via the Java Sound library in a cross-platform approach and video is supported via a Glimmer custom widget, so any Glimmer app can be enhanced with audio and video where needed.
292
292
 
293
+ ### Remaining Challenges
294
+
295
+ Startup time is long. Thankfully, [there are work-arounds](https://andymaleh.blogspot.com/2021/03/glimmer-dsl-for-swt-41900-halved.html) that could make apps start as fast as instantly.
296
+
297
+ Contributors who appreciate Glimmer's ultra-high productivity, maintainability, and extensibility might want to help report and resolve remaining challenges in its software architecture.
298
+
293
299
  ## Platform Support
294
300
 
295
301
  Glimmer runs on the following platforms:
@@ -341,7 +347,7 @@ jgem install glimmer-dsl-swt
341
347
 
342
348
  Or this command if you want a specific version:
343
349
  ```
344
- jgem install glimmer-dsl-swt -v 4.20.0.5
350
+ jgem install glimmer-dsl-swt -v 4.20.3.0
345
351
  ```
346
352
 
347
353
  `jgem` is JRuby's version of `gem` command.
@@ -369,7 +375,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
369
375
 
370
376
  Add the following to `Gemfile`:
371
377
  ```
372
- gem 'glimmer-dsl-swt', '~> 4.20.0.5'
378
+ gem 'glimmer-dsl-swt', '~> 4.20.3.0'
373
379
  ```
374
380
 
375
381
  And, then run:
@@ -390,7 +396,7 @@ glimmer
390
396
  ```
391
397
 
392
398
  ```
393
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.0.5
399
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.3.0
394
400
 
395
401
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
396
402
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.20.0.5
1
+ 4.20.4.0
@@ -2278,13 +2278,16 @@ Example from [samples/hello/hello_combo.rb](samples/hello_combo.rb) sample (you
2278
2278
 
2279
2279
  #### Shine
2280
2280
 
2281
- **(EARLY ALPHA FEATURE)**
2281
+ **(BETA FEATURE)**
2282
2282
 
2283
2283
  The new Shine syntax for View/Model Attribute Mapping allows data-binding visually with simple arrow operators in Ruby.
2284
2284
 
2285
2285
  Use `<=> [model, attribute, options]` for bidirectional (two-way) data-binding instead of `bind(model, attribute, options)`.
2286
2286
  Use `<= [model, attribute, options]` for unidirectional (one-way) data-binding instead of `bind(model, attribute, read_only: true, more_options)`
2287
2287
 
2288
+ One thing special with the `table` widget is that `<=`, which makes data-binding unidirectional, stops the `table` from supporting automatic sorting by default since that involves modifying the model collection ordering (albeit not the content).
2289
+ To enable automatic sorting in a `table`, but still not permit edit actions to the data itself, you simply use `<=>` for bidirectional data-binding, but without passing the `:editable` style to the `table`.
2290
+
2288
2291
  Examples:
2289
2292
 
2290
2293
  ```ruby
@@ -2299,7 +2302,7 @@ text <=> [@contact, :last_name]
2299
2302
  text <= [@contact, :name, computed_by: [:first_name, :last_name]]
2300
2303
  ```
2301
2304
 
2302
- Note that `table`, `tree`, custom widgets, custom shapes, and animations are not supported by Shine syntax for data-binding yet, so continue to use `bind` with them for the time being.
2305
+ Given that Shine is new, if you encounter any issues, you can use `bind` instead.
2303
2306
 
2304
2307
  Check out [sample code](/samples) for more examples of Shine syntax in action, such as [Hello, Computed!](/docs/reference/GLIMMER_SAMPLES.md#hello-computed).
2305
2308
 
Binary file
@@ -30,6 +30,7 @@ if !['', 'false'].include?(ENV['GLIMMER_BUNDLER_SETUP'].to_s.strip.downcase)
30
30
  end
31
31
  require 'java'
32
32
  require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
33
+ require 'concurrent-ruby' # ensures glimmer relies on Concurrent data-structure classes (e.g. Concurrent::Array)
33
34
  require 'glimmer'
34
35
  require 'logging'
35
36
  require 'nested_inherited_jruby_include_package'
@@ -34,11 +34,11 @@ module Glimmer
34
34
  include_package 'org.eclipse.swt'
35
35
  include_package 'org.eclipse.swt.widgets'
36
36
 
37
- def initialize(parent, model_binding, column_properties)
37
+ def initialize(parent, model_binding, column_properties = nil)
38
38
  @table = parent
39
39
  @model_binding = model_binding
40
40
  @read_only_sort = @model_binding.binding_options[:read_only_sort]
41
- @column_properties = column_properties
41
+ @column_properties = @model_binding.binding_options[:column_properties] || @model_binding.binding_options[:column_attributes] || column_properties
42
42
  if @table.respond_to?(:column_properties=)
43
43
  @table.column_properties = @column_properties
44
44
  else # assume custom widget
@@ -34,10 +34,10 @@ module Glimmer
34
34
  include_package 'org.eclipse.swt'
35
35
  include_package 'org.eclipse.swt.widgets'
36
36
 
37
- def initialize(parent, model_binding, tree_properties)
37
+ def initialize(parent, model_binding, tree_properties = nil)
38
38
  @tree = parent
39
39
  @model_binding = model_binding
40
- @tree_properties = [tree_properties].flatten.first.to_h
40
+ @tree_properties = @model_binding.binding_options[:tree_properties] || @model_binding.binding_options[:tree_attributes] || [tree_properties].compact.flatten.first.to_h
41
41
  if @tree.respond_to?(:tree_properties=)
42
42
  @tree.tree_properties = @tree_properties
43
43
  else # assume custom widget
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 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
@@ -20,6 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/dsl/static_expression'
23
+ require 'glimmer/dsl/bind_expression'
23
24
  require 'glimmer/data_binding/model_binding'
24
25
 
25
26
  module Glimmer
@@ -30,28 +31,7 @@ module Glimmer
30
31
  # DataBindingCommandHandler for text and selection properties on Text and Spinner
31
32
  # or TableItemsDataBindingCommandHandler for items in a Table
32
33
  class BindExpression < StaticExpression
33
- def can_interpret?(parent, keyword, *args, &block)
34
- (
35
- keyword == 'bind' and
36
- (
37
- (
38
- (args.size == 2) and
39
- textual?(args[1])
40
- ) ||
41
- (
42
- (args.size == 3) and
43
- textual?(args[1]) and
44
- (args[2].is_a?(Hash))
45
- )
46
- )
47
- )
48
- end
49
-
50
- def interpret(parent, keyword, *args, &block)
51
- binding_options = args[2] || {}
52
- binding_options[:on_read] = binding_options.delete(:on_read) || binding_options.delete('on_read') || block
53
- DataBinding::ModelBinding.new(args[0], args[1].to_s, binding_options)
54
- end
34
+ include Glimmer::DSL::BindExpression
55
35
  end
56
36
  end
57
37
  end
@@ -54,7 +54,7 @@ module Glimmer
54
54
  def add_content(parent, keyword, *args, &block)
55
55
  # TODO consider avoiding source_location
56
56
  return if block&.parameters&.count == 2
57
- if block.source_location == parent.content&.__getobj__.source_location
57
+ if block.source_location == parent.content&.__getobj__&.source_location
58
58
  parent.content.call(parent) unless parent.content.called?
59
59
  else
60
60
  super
@@ -52,7 +52,7 @@ module Glimmer
52
52
  widget_binding.call(model_binding.evaluate_property)
53
53
  widget_binding.observe(model_binding)
54
54
 
55
- raise(Glimmer::Error, "No radios found! Make sure radio selection is data-bound to a property having property_options as non-empty array!") if parent.items.empty?
55
+ raise(Glimmer::Error, "No radios found! Make sure radio selection is data-bound to a property having property_options as non-empty array!") if parent.get_items.empty?
56
56
  Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: model_binding.binding_options[:sync_exec], override_async_exec: model_binding.binding_options[:async_exec]) do
57
57
  parent.on_widget_selected do
58
58
  model_binding.call(widget_binding.evaluate_property)
@@ -29,14 +29,15 @@ module Glimmer
29
29
  module DSL
30
30
  module SWT
31
31
  class ShineDataBindingExpression < Expression
32
+ include_package 'org.eclipse.swt.widgets'
33
+
32
34
  def can_interpret?(parent, keyword, *args, &block)
33
35
  args.size == 0 and
34
36
  block.nil? and
35
- parent.respond_to?(:set_attribute) and
36
- parent.respond_to?(:has_attribute?) and
37
- parent.has_attribute?(keyword, *args) and
38
- !parent.is_a?(Glimmer::UI::CustomWidget) and
39
- !parent.is_a?(Glimmer::UI::CustomShape) and
37
+ (
38
+ (parent.respond_to?(:has_attribute?) and parent.has_attribute?(keyword)) or
39
+ (parent.respond_to?(:swt_widget) and (parent.swt_widget.is_a?(Table) or parent.swt_widget.is_a?(Tree)))
40
+ ) and
40
41
  !(parent.respond_to?(:swt_widget) && parent.swt_widget.class == org.eclipse.swt.widgets.Canvas && keyword == 'image')
41
42
  end
42
43
 
@@ -35,10 +35,10 @@ module Glimmer
35
35
  block.nil? and
36
36
  parent.respond_to?(:swt_widget) and
37
37
  parent.swt_widget.is_a?(Table) and
38
- args.size == 2 and
38
+ args.size.between?(1, 2) and
39
39
  args[0].is_a?(DataBinding::ModelBinding) and
40
40
  args[0].evaluate_property.is_a?(Array) and
41
- args[1].is_a?(Array)
41
+ (args[1].nil? or args[1].is_a?(Array))
42
42
  end
43
43
 
44
44
  def interpret(parent, keyword, *args, &block)
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 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
@@ -30,15 +30,20 @@ module Glimmer
30
30
  include_package 'org.eclipse.swt.widgets'
31
31
 
32
32
  def can_interpret?(parent, keyword, *args, &block)
33
- initial_condition = ((keyword == "items") and block.nil? and parent.respond_to?(:swt_widget) and parent.swt_widget.is_a?(Tree))
34
- return false unless initial_condition
35
- raise Glimmer::Error, 'Tree items args must be 2' unless args.size == 2
36
- raise Glimmer::Error, 'Tree items first arg must be a bind expression' unless args[0].is_a?(DataBinding::ModelBinding)
37
- raise Glimmer::Error, 'Tree items data-binding initial value must not be an array yet a single item representing tree root' unless !args[0].evaluate_property.is_a?(Array)
38
- raise Glimmer::Error, 'Tree items second arg must be an array' unless args[1].is_a?(Array)
39
- raise Glimmer::Error, 'Tree items second arg must not be empty' unless !args[1].empty?
40
- raise Glimmer::Error, 'Tree items second arg array elements must be of type hash' unless args[1].first.is_a?(Hash)
41
- true
33
+ keyword == 'items' and
34
+ block.nil? and
35
+ parent.respond_to?(:swt_widget) and
36
+ parent.swt_widget.is_a?(Tree) and
37
+ args.size.between?(1, 2)
38
+ # TODO delete these checks if they are too granular
39
+ # return false unless initial_condition
40
+ # raise Glimmer::Error, 'Tree items args must be 1 or 2' unless args.size.between?(1, 2)
41
+ # raise Glimmer::Error, 'Tree items first arg must be a bind expression' unless args[0].is_a?(DataBinding::ModelBinding)
42
+ # raise Glimmer::Error, 'Tree items data-binding initial value must not be an array yet a single item representing tree root' unless !args[0].evaluate_property.is_a?(Array)
43
+ # raise Glimmer::Error, 'Tree items second arg must be an array' unless args[1].is_a?(Array)
44
+ # raise Glimmer::Error, 'Tree items second arg must not be empty' unless !args[1].empty?
45
+ # raise Glimmer::Error, 'Tree items second arg array elements must be of type hash' unless args[1].first.is_a?(Hash)
46
+ # true
42
47
  end
43
48
 
44
49
  def interpret(parent, keyword, *args, &block)
@@ -642,7 +642,7 @@ module Glimmer
642
642
  custom_shell_file_content += <<-MULTI_LINE_STRING
643
643
  grid_layout
644
644
  label(:center) {
645
- text bind(self, :greeting)
645
+ text <= [self, :greeting]
646
646
  font height: 40
647
647
  layout_data :fill, :center, true, true
648
648
  }
@@ -712,7 +712,7 @@ module Glimmer
712
712
  ].each do |greeting_text|
713
713
  button(:radio) {
714
714
  text greeting_text
715
- selection bind(self, :greeting) { |g| g == greeting_text }
715
+ selection <= [self, :greeting, on_read: ->(g) { g == greeting_text }]
716
716
  layout_data {
717
717
  width 160
718
718
  }
@@ -99,6 +99,12 @@ module Glimmer
99
99
  end
100
100
  end
101
101
 
102
+ def content(&block)
103
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
104
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::AnimationExpression.new, 'animation', &block)
105
+ end
106
+ end
107
+
102
108
  # Starts an animation that is indefinite or has never been started before (i.e. having `started: false` option).
103
109
  # Otherwise, resumes a stopped animation that has not been completed.
104
110
  def start
@@ -29,7 +29,7 @@ module Glimmer
29
29
  include Glimmer::UI::CustomWidget
30
30
 
31
31
  body {
32
- composite # just an empty composite to hold checkboxs upon data-binding `selection`
32
+ composite {} # just an empty composite to hold checkboxs upon data-binding `selection`
33
33
  }
34
34
 
35
35
  def items=(text_array)
@@ -29,7 +29,7 @@ module Glimmer
29
29
  include Glimmer::UI::CustomWidget
30
30
 
31
31
  body {
32
- composite # just an empty composite to hold radios upon data-binding `selection`
32
+ composite {} # just an empty composite to hold radios upon data-binding `selection`
33
33
  }
34
34
 
35
35
  def items=(text_array)
@@ -41,6 +41,7 @@ module Glimmer
41
41
  def items
42
42
  @items || []
43
43
  end
44
+ alias get_items items
44
45
 
45
46
  def selection=(text)
46
47
  radios.count.times do |index|
@@ -33,6 +33,7 @@ module Glimmer
33
33
  # default implementation of attribute setters/getters
34
34
  # It tries swt_widget, swt_display, swt_image, and swt_dialog by default.
35
35
  def proxy_source_object
36
+ # TODO the logic here should not be needed if derived with polymorphism. Consider removing.
36
37
  if respond_to?(:swt_widget)
37
38
  swt_widget
38
39
  elsif respond_to?(:swt_display)
@@ -62,7 +63,7 @@ module Glimmer
62
63
 
63
64
  def has_attribute?(attribute_name, *args)
64
65
  Glimmer::SWT::DisplayProxy.instance.auto_exec do
65
- proxy_source_object&.respond_to?(attribute_setter(attribute_name), args) ||
66
+ proxy_source_object&.respond_to?(attribute_setter(attribute_name), args) or
66
67
  respond_to?(ruby_attribute_setter(attribute_name), args)
67
68
  end
68
69
  end
@@ -80,7 +81,7 @@ module Glimmer
80
81
  end
81
82
  end
82
83
  unless swt_widget_operation
83
- result = send(ruby_attribute_setter(attribute_name), args)
84
+ result = send(ruby_attribute_setter(attribute_name), args) if respond_to?(ruby_attribute_setter(attribute_name), args)
84
85
  end
85
86
  result
86
87
  end
@@ -101,10 +102,10 @@ module Glimmer
101
102
  end
102
103
  end
103
104
  unless swt_widget_operation
104
- result = if respond_to?(ruby_attribute_getter(attribute_name))
105
- send(ruby_attribute_getter(attribute_name))
106
- else
107
- send(attribute_name)
105
+ if respond_to?(ruby_attribute_getter(attribute_name))
106
+ result = send(ruby_attribute_getter(attribute_name))
107
+ elsif respond_to?(attribute_name)
108
+ result = send(attribute_name)
108
109
  end
109
110
  end
110
111
  result
@@ -250,19 +250,13 @@ module Glimmer
250
250
  alias editable? editable
251
251
 
252
252
  def initialize(underscored_widget_name, parent, args)
253
- @editable = args.delete(:editable)
253
+ editable_style = args.delete(:editable)
254
254
  super
255
255
  @table_editor = TableEditor.new(swt_widget)
256
256
  @table_editor.horizontalAlignment = SWTProxy[:left]
257
257
  @table_editor.grabHorizontal = true
258
258
  @table_editor.minimumHeight = 20
259
- if editable?
260
- content {
261
- on_mouse_up { |event|
262
- edit_table_item(event.table_item, event.column_index)
263
- }
264
- }
265
- end
259
+ self.editable = editable_style
266
260
  end
267
261
 
268
262
  def items
@@ -283,6 +277,19 @@ module Glimmer
283
277
  end
284
278
  end
285
279
 
280
+ def editable=(value)
281
+ @editable = value
282
+ if @editable
283
+ content {
284
+ @editable_on_mouse_up = on_mouse_up { |event|
285
+ edit_table_item(event.table_item, event.column_index)
286
+ }
287
+ }
288
+ else
289
+ @editable_on_mouse_up.deregister if @editable_on_mouse_up
290
+ end
291
+ end
292
+
286
293
  def sort_block=(comparator)
287
294
  @sort_block = comparator
288
295
  end