glimmer-dsl-swt 4.20.2.1 → 4.20.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +6 -6
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +5 -2
- data/docs/reference/GLIMMER_SAMPLES.md +23 -0
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/data_binding/table_items_binding.rb +1 -0
- data/lib/glimmer/dsl/swt/bind_expression.rb +5 -25
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +0 -2
- data/lib/glimmer/rake_task/scaffold.rb +2 -2
- data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
- data/lib/glimmer/swt/custom/radio_group.rb +2 -1
- data/lib/glimmer/swt/proxy_properties.rb +5 -5
- data/lib/glimmer/swt/widget_proxy.rb +3 -0
- data/lib/glimmer/ui/custom_shape.rb +1 -1
- data/lib/glimmer/ui/custom_widget.rb +1 -1
- data/samples/elaborate/calculator.rb +1 -1
- data/samples/elaborate/contact_manager.rb +1 -1
- data/samples/elaborate/meta_sample.rb +5 -5
- data/samples/elaborate/tetris/view/bevel.rb +11 -11
- data/samples/elaborate/tetris/view/block.rb +1 -1
- data/samples/elaborate/tetris/view/high_score_dialog.rb +3 -3
- data/samples/elaborate/tetris/view/score_lane.rb +3 -3
- data/samples/elaborate/tetris/view/tetris_menu_bar.rb +9 -9
- data/samples/elaborate/timer.rb +9 -9
- data/samples/elaborate/weather.rb +8 -4
- data/samples/hello/hello_c_tab.rb +9 -9
- data/samples/hello/hello_checkbox_group.rb +1 -1
- data/samples/hello/hello_code_text.rb +3 -3
- data/samples/hello/hello_computed.rb +20 -2
- data/samples/hello/hello_cool_bar.rb +1 -1
- data/samples/hello/hello_cursor.rb +1 -1
- data/samples/hello/hello_custom_shell.rb +17 -11
- data/samples/hello/hello_directory_dialog.rb +1 -1
- data/samples/hello/hello_label.rb +194 -0
- data/samples/hello/hello_radio_group.rb +2 -2
- data/samples/hello/hello_table.rb +1 -1
- data/samples/hello/hello_tool_bar.rb +1 -1
- data/samples/hello/{hello_c_tab → images}/denmark.png +0 -0
- data/samples/hello/{hello_c_tab → images}/finland.png +0 -0
- data/samples/hello/{hello_c_tab → images}/france.png +0 -0
- data/samples/hello/{hello_c_tab → images}/germany.png +0 -0
- data/samples/hello/{hello_c_tab → images}/italy.png +0 -0
- data/samples/hello/{hello_c_tab → images}/mexico.png +0 -0
- data/samples/hello/{hello_c_tab → images}/netherlands.png +0 -0
- data/samples/hello/{hello_c_tab → images}/norway.png +0 -0
- data/samples/hello/{hello_c_tab → images}/usa.png +0 -0
- metadata +54 -36
- data/lib/glimmer/data_binding/shine.rb +0 -63
- data/samples/elaborate/timer/alarm1.wav +0 -0
- data/samples/hello/hello_computed/contact.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0bba8c354a9db8c2792672663e9aa7831f38ad7b34fd5a3d928fdb12a64eba3
|
4
|
+
data.tar.gz: 671c5533d419dd32454f3dba595f7887f3b65d0643e89c7ef6db8dba44d3f4f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 448277d9a14e6dc86bb6685c5f6890090246147bdbf9099d9035ec6b9fc294f042cd2d211b107249d648eb002e4d80bd5c5f3d4349647619708ea5cd88a39719
|
7
|
+
data.tar.gz: a98582730c8ec1143e387cadb89cc80432b72aa1d50db2c935f5b3212403f8a13d3b9daa4292b09d9efcb0afceef108d40ccd8eb28bc6e286f3cd14c6cc26ef6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.4.2
|
4
|
+
|
5
|
+
- Hello, Label!
|
6
|
+
|
7
|
+
### 4.20.4.1
|
8
|
+
|
9
|
+
- Ensure a `table` with `:editable` style loses it if `items <= ...` one-way data-binding (having read_only: true option) was setup.
|
10
|
+
- Tweak/refactor/improve samples
|
11
|
+
|
12
|
+
### 4.20.4.0
|
13
|
+
|
14
|
+
- Extracted Shine data-binding syntax and `BindExpression` to Glimmer 2
|
15
|
+
|
16
|
+
### 4.20.3.0
|
17
|
+
|
18
|
+
- Shine data-binding support for `custom widgets`, `custom shells`, and `custom shapes`
|
19
|
+
- Update remaining samples with `bind` keyword to switch to Shine data-binding syntax
|
20
|
+
- Switch scaffolded classes' data-binding to Shine
|
21
|
+
- Fix `table` Shine syntax support for unidirectional (one-way) data-binding
|
22
|
+
|
3
23
|
### 4.20.2.1
|
4
24
|
|
5
25
|
- Shine data-binding support for `animation` (also supporting `#content {}` method in `Animation`)
|
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.2
|
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.4.2
|
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.2
|
18
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.4.2 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
|
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
|
|
@@ -347,7 +347,7 @@ jgem install glimmer-dsl-swt
|
|
347
347
|
|
348
348
|
Or this command if you want a specific version:
|
349
349
|
```
|
350
|
-
jgem install glimmer-dsl-swt -v 4.20.2
|
350
|
+
jgem install glimmer-dsl-swt -v 4.20.4.2
|
351
351
|
```
|
352
352
|
|
353
353
|
`jgem` is JRuby's version of `gem` command.
|
@@ -375,7 +375,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
375
375
|
|
376
376
|
Add the following to `Gemfile`:
|
377
377
|
```
|
378
|
-
gem 'glimmer-dsl-swt', '~> 4.20.2
|
378
|
+
gem 'glimmer-dsl-swt', '~> 4.20.4.2'
|
379
379
|
```
|
380
380
|
|
381
381
|
And, then run:
|
@@ -396,7 +396,7 @@ glimmer
|
|
396
396
|
```
|
397
397
|
|
398
398
|
```
|
399
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.2
|
399
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.4.2
|
400
400
|
|
401
401
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
402
402
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.20.2
|
1
|
+
4.20.4.2
|
@@ -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
|
-
**(
|
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
|
-
|
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
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
- [Hello Samples](#hello-samples)
|
3
3
|
- [Hello, World!](#hello-world)
|
4
4
|
- [Hello, Button!](#hello-button)
|
5
|
+
- [Hello, Label!](#hello-label)
|
5
6
|
- [Hello, Text!](#hello-text)
|
6
7
|
- [Hello, Composite!](#hello-composite)
|
7
8
|
- [Hello, Layout!](#hello-layout)
|
@@ -117,6 +118,28 @@ Hello, Button! Incremented 7 times!
|
|
117
118
|
|
118
119
|
![Hello Button Incremented](/images/glimmer-hello-button-incremented.png)
|
119
120
|
|
121
|
+
#### Hello, Label!
|
122
|
+
|
123
|
+
This sample demonstrates the use of the `label` widget in Glimmer.
|
124
|
+
|
125
|
+
Code:
|
126
|
+
|
127
|
+
[samples/hello/hello_label.rb](/samples/hello/hello_label.rb)
|
128
|
+
|
129
|
+
![Hello Label Left Aligned](/images/glimmer-hello-label-left-aligned.png)
|
130
|
+
|
131
|
+
![Hello Label Center Aligned](/images/glimmer-hello-label-center-aligned.png)
|
132
|
+
|
133
|
+
![Hello Label Right Aligned](/images/glimmer-hello-label-right-aligned.png)
|
134
|
+
|
135
|
+
![Hello Label Images](/images/glimmer-hello-label-images.png)
|
136
|
+
|
137
|
+
![Hello Label Background Images](/images/glimmer-hello-label-background_images.png)
|
138
|
+
|
139
|
+
![Hello Label Horizontal Separator](/images/glimmer-hello-label-horizontal-separator.png)
|
140
|
+
|
141
|
+
![Hello Label Vertical Separator](/images/glimmer-hello-label-vertical-separator.png)
|
142
|
+
|
120
143
|
#### Hello, Text!
|
121
144
|
|
122
145
|
This sample demonstrates the use of the `text` widget in Glimmer, including data-binding (e.g. via the `<=>` operator) and event handling.
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
data/lib/glimmer-dsl-swt.rb
CHANGED
@@ -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'
|
@@ -39,6 +39,7 @@ module Glimmer
|
|
39
39
|
@model_binding = model_binding
|
40
40
|
@read_only_sort = @model_binding.binding_options[:read_only_sort]
|
41
41
|
@column_properties = @model_binding.binding_options[:column_properties] || @model_binding.binding_options[:column_attributes] || column_properties
|
42
|
+
@table.editable = false if @model_binding.binding_options[:read_only]
|
42
43
|
if @table.respond_to?(:column_properties=)
|
43
44
|
@table.column_properties = @column_properties
|
44
45
|
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
|
-
|
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__
|
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.
|
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)
|
@@ -38,8 +38,6 @@ module Glimmer
|
|
38
38
|
(parent.respond_to?(:has_attribute?) and parent.has_attribute?(keyword)) or
|
39
39
|
(parent.respond_to?(:swt_widget) and (parent.swt_widget.is_a?(Table) or parent.swt_widget.is_a?(Tree)))
|
40
40
|
) and
|
41
|
-
!parent.is_a?(Glimmer::UI::CustomWidget) and
|
42
|
-
!parent.is_a?(Glimmer::UI::CustomShape) and
|
43
41
|
!(parent.respond_to?(:swt_widget) && parent.swt_widget.class == org.eclipse.swt.widgets.Canvas && keyword == 'image')
|
44
42
|
end
|
45
43
|
|
@@ -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
|
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
|
715
|
+
selection <= [self, :greeting, on_read: ->(g) { g == greeting_text }]
|
716
716
|
layout_data {
|
717
717
|
width 160
|
718
718
|
}
|
@@ -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|
|
@@ -81,7 +81,7 @@ module Glimmer
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
unless swt_widget_operation
|
84
|
-
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)
|
85
85
|
end
|
86
86
|
result
|
87
87
|
end
|
@@ -102,10 +102,10 @@ module Glimmer
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
unless swt_widget_operation
|
105
|
-
|
106
|
-
send(ruby_attribute_getter(attribute_name))
|
107
|
-
|
108
|
-
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)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
result
|
@@ -232,9 +232,12 @@ module Glimmer
|
|
232
232
|
def has_attribute?(attribute_name, *args)
|
233
233
|
# TODO test that attribute getter responds too
|
234
234
|
widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
|
235
|
+
property_type_converter = property_type_converters[attribute_name.to_s.to_sym]
|
235
236
|
auto_exec do
|
236
237
|
if widget_custom_attribute
|
237
238
|
@swt_widget.respond_to?(widget_custom_attribute[:setter][:name])
|
239
|
+
elsif property_type_converter
|
240
|
+
true
|
238
241
|
else
|
239
242
|
super
|
240
243
|
end
|
@@ -248,7 +248,7 @@ module Glimmer
|
|
248
248
|
# Otherwise, if a block is passed, it adds it as content to this custom shape
|
249
249
|
def content(&block)
|
250
250
|
if block_given?
|
251
|
-
|
251
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::CustomShapeExpression.new, self.class.keyword, &block)
|
252
252
|
else
|
253
253
|
@content
|
254
254
|
end
|
@@ -296,7 +296,7 @@ module Glimmer
|
|
296
296
|
# Otherwise, if a block is passed, it adds it as content to this custom widget
|
297
297
|
def content(&block)
|
298
298
|
if block_given?
|
299
|
-
|
299
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::CustomWidgetExpression.new, self.class.keyword, &block)
|
300
300
|
else
|
301
301
|
@content
|
302
302
|
end
|
@@ -45,7 +45,7 @@ class Calculator
|
|
45
45
|
|
46
46
|
# Setting styled_text to multi in order for alignment options to activate
|
47
47
|
styled_text(:multi, :wrap, :border) {
|
48
|
-
text
|
48
|
+
text <= [@presenter, :result]
|
49
49
|
alignment swt(:right)
|
50
50
|
right_margin 5
|
51
51
|
font height: 40
|
@@ -226,7 +226,7 @@ class MetaSampleApplication
|
|
226
226
|
row_layout(:vertical) {
|
227
227
|
fill true
|
228
228
|
}
|
229
|
-
selection
|
229
|
+
selection <=> [sample_directory, :selected_sample_name]
|
230
230
|
font height: 20
|
231
231
|
}
|
232
232
|
}
|
@@ -242,7 +242,7 @@ class MetaSampleApplication
|
|
242
242
|
button {
|
243
243
|
text 'Launch'
|
244
244
|
font height: 25
|
245
|
-
enabled
|
245
|
+
enabled <= [SampleDirectory, 'selected_sample.launchable']
|
246
246
|
|
247
247
|
on_widget_selected {
|
248
248
|
begin
|
@@ -255,7 +255,7 @@ class MetaSampleApplication
|
|
255
255
|
button {
|
256
256
|
text 'Reset'
|
257
257
|
font height: 25
|
258
|
-
enabled
|
258
|
+
enabled <= [SampleDirectory, 'selected_sample.editable']
|
259
259
|
|
260
260
|
on_widget_selected {
|
261
261
|
SampleDirectory.selected_sample.reset_code!
|
@@ -277,8 +277,8 @@ class MetaSampleApplication
|
|
277
277
|
line_numbers {
|
278
278
|
background :white
|
279
279
|
}
|
280
|
-
text
|
281
|
-
editable
|
280
|
+
text <=> [SampleDirectory, 'selected_sample.code']
|
281
|
+
editable <= [SampleDirectory, 'selected_sample.editable']
|
282
282
|
left_margin 7
|
283
283
|
right_margin 7
|
284
284
|
}
|
@@ -35,44 +35,44 @@ class Tetris
|
|
35
35
|
|
36
36
|
body {
|
37
37
|
rectangle(x, y, size, size) {
|
38
|
-
background
|
38
|
+
background <= [self, :base_color]
|
39
39
|
polygon(0, 0, size, 0, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
40
|
-
background
|
40
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
41
41
|
unless color_value.nil?
|
42
42
|
color = color(color_value)
|
43
43
|
rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
|
44
44
|
end
|
45
|
-
}
|
45
|
+
}]
|
46
46
|
}
|
47
47
|
polygon(size, 0, size - bevel_pixel_size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size, size) {
|
48
|
-
background
|
48
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
49
49
|
unless color_value.nil?
|
50
50
|
color = color(color_value)
|
51
51
|
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
52
52
|
end
|
53
|
-
}
|
53
|
+
}]
|
54
54
|
}
|
55
55
|
polygon(size, size, 0, size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size) {
|
56
|
-
background
|
56
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
57
57
|
unless color_value.nil?
|
58
58
|
color = color(color_value)
|
59
59
|
rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
|
60
60
|
end
|
61
|
-
}
|
61
|
+
}]
|
62
62
|
}
|
63
63
|
polygon(0, 0, 0, size, bevel_pixel_size, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
64
|
-
background
|
64
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
65
65
|
unless color_value.nil?
|
66
66
|
color = color(color_value)
|
67
67
|
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
68
68
|
end
|
69
|
-
}
|
69
|
+
}]
|
70
70
|
}
|
71
71
|
rectangle(0, 0, size, size) {
|
72
|
-
foreground
|
72
|
+
foreground <= [self, :base_color, on_read: ->(color_value) {
|
73
73
|
# use gray instead of white for the border
|
74
74
|
color_value == Model::Block::COLOR_CLEAR ? :gray : color_value
|
75
|
-
}
|
75
|
+
}]
|
76
76
|
}
|
77
77
|
}
|
78
78
|
}
|