glimmer 0.1.9.470 → 0.1.10.470
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +2 -3
- data/README.markdown +86 -22
- data/{lib/command_handlers/RELEASE.md → RELEASE.md} +2 -2
- data/Rakefile +19 -13
- data/VERSION +1 -1
- data/glimmer.gemspec +14 -15
- data/lib/command_handlers/bind_command_handler.rb +11 -3
- data/lib/command_handlers/data_binding_command_handler.rb +7 -1
- data/lib/command_handlers/models/model_observer.rb +5 -5
- data/lib/command_handlers/models/widget_observer.rb +4 -4
- data/lib/glimmer_application.rb +10 -10
- data/samples/contactmanager/contact.rb +2 -2
- data/samples/hellocomputed/contact.rb +19 -0
- data/samples/hellocomputed/hello_computed.rb +68 -0
- data/spec/lib/glimmer__data_binding__spec.rb +51 -1
- metadata +12 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2743000710bdc46b908035ea211c466ff52e32df467e3c0e33298751c15c35d1
|
4
|
+
data.tar.gz: a5ec8756834000ff7be8efdfdf0d083c3635971a5fe9927b199d10f01526a4ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f16cd9964a83cf1de59bb2ed56a7c526486b99fa7d38fb48f154295699fe86ee36acfe556e375e12113f8f34a069da7c5de894ebb89aff75d3b3decdac8809e
|
7
|
+
data.tar.gz: 6e2bf4e9bd8f7bc39765a7fca70d78dcf705edf663bb465d504b581d0a35a9e4284c557f997c7376cd391f76ef36642df4adac3a6f542b26d4ae17f289a0197d
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby-9.
|
1
|
+
jruby-9.2.9.0
|
data/Gemfile
CHANGED
@@ -7,9 +7,8 @@ group :development do
|
|
7
7
|
gem "rspec-mocks", "~> 3.5.0"
|
8
8
|
gem "rspec", "~> 3.5.0"
|
9
9
|
gem "rdoc", "~> 2.3.0"
|
10
|
-
gem "
|
11
|
-
gem "jeweler", "~> 2.3.0"
|
10
|
+
gem "jeweler", "~> 2.3.9"
|
12
11
|
gem "coveralls", "= 0.8.5", require: false
|
13
12
|
gem "simplecov", "~> 0.10.0", require: nil
|
14
|
-
gem "puts_debuggerer", "~> 0.
|
13
|
+
gem "puts_debuggerer", "~> 0.8.1"
|
15
14
|
end
|
data/README.markdown
CHANGED
@@ -18,6 +18,25 @@ You may learn more by reading this article: [Eclipse Zone Tutorial](http://eclip
|
|
18
18
|
}.open
|
19
19
|
```
|
20
20
|
|
21
|
+
## Resources
|
22
|
+
|
23
|
+
* [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer)
|
24
|
+
* [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
|
25
|
+
* [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
|
26
|
+
* [Code Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
|
27
|
+
|
28
|
+
## Pre-requisites
|
29
|
+
|
30
|
+
JRuby 9.2.9.0 (supporting Ruby 2.5.0 syntax)
|
31
|
+
|
32
|
+
Easiest way to obtain is through [RVM](http://rvm.io)
|
33
|
+
|
34
|
+
With RVM installed on your system, please run this command to install JRuby:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
rvm install jruby-9.2.9.0
|
38
|
+
```
|
39
|
+
|
21
40
|
## Setup
|
22
41
|
|
23
42
|
Please follow these instructions to make the `glimmer` command available on your system.
|
@@ -26,7 +45,7 @@ Please follow these instructions to make the `glimmer` command available on your
|
|
26
45
|
|
27
46
|
Add the following to `Gemfile`:
|
28
47
|
```
|
29
|
-
gem 'glimmer', '~> 0.1.
|
48
|
+
gem 'glimmer', '~> 0.1.10.470'
|
30
49
|
```
|
31
50
|
|
32
51
|
And, then run:
|
@@ -38,27 +57,69 @@ bundle install
|
|
38
57
|
|
39
58
|
Run this command to get directly:
|
40
59
|
```
|
41
|
-
gem install glimmer -v 0.1.
|
60
|
+
gem install glimmer -v 0.1.10.470
|
42
61
|
```
|
43
62
|
|
44
63
|
## Usage
|
45
64
|
|
46
|
-
Usage:
|
65
|
+
Usage:
|
66
|
+
```
|
67
|
+
glimmer [--setup] [application_ruby_file_path.rb]
|
68
|
+
```
|
69
|
+
|
70
|
+
Example 1:
|
71
|
+
```
|
72
|
+
glimmer hello_combo.rb
|
73
|
+
```
|
74
|
+
This runs the Glimmer application `hello_combo.rb` (if the SWT Jar is missing, it downloads it and sets it up first.)
|
47
75
|
|
48
|
-
Example
|
49
|
-
|
50
|
-
|
76
|
+
Example 2:
|
77
|
+
```
|
78
|
+
glimmer --setup hello_combo.rb
|
79
|
+
```
|
80
|
+
This performs setup and then runs the Glimmer application `hello_combo.rb` (downloads and sets up the SWT jar whether present or not)
|
81
|
+
|
82
|
+
Example 3:
|
83
|
+
```
|
84
|
+
glimmer --setup
|
85
|
+
```
|
86
|
+
This just downloads and sets up the SWT jar even if already present.
|
51
87
|
|
52
|
-
|
53
|
-
This performs setup and then runs the Glimmer application hello_combo.rb
|
54
|
-
It downloads and sets up the SWT jar whether missing or not.
|
88
|
+
## Syntax
|
55
89
|
|
56
|
-
|
57
|
-
|
90
|
+
Check out the SWT library API for a list of available widgets:
|
91
|
+
https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fwidgets%2Fpackage-summary.html
|
92
|
+
|
93
|
+
In Glimmer DSL, SWT widgets are declared with lowercase underscored naming.
|
94
|
+
|
95
|
+
Widget examples:
|
96
|
+
- `button` for `org.eclipse.swt.widgets.Button`
|
97
|
+
- `label` for `org.eclipse.swt.widgets.Label`
|
98
|
+
- `table_column` for `org.eclipse.swt.widgets.TableColumn`
|
99
|
+
|
100
|
+
The `shell` widget is always the outermost widget containing all others in a desktop windowed application.
|
101
|
+
|
102
|
+
Widget properties may be set with methods matching their names in lower snakecase.
|
103
|
+
|
104
|
+
Widget property examples:
|
105
|
+
- `text` to set text value of a `label`
|
106
|
+
- `gridData` to set grid data of a `composite`
|
107
|
+
|
108
|
+
Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
|
109
|
+
|
110
|
+
Data-binding examples:
|
111
|
+
- `text bind(contact, :first_name)`
|
112
|
+
- `text bind(contact, :name, computed_by: [:first_name, :last_name])`
|
113
|
+
|
114
|
+
The first example binds the text property of a widget like `label` to the first name of a contact model.
|
115
|
+
|
116
|
+
The second example demonstrates computed value data binding whereby the value of `name` depends on changes to both `first_name` and `last_name`
|
117
|
+
|
118
|
+
You may learn more about Glimmer's syntax by reading the Eclipse Zone Tutorial mentioned in resources and opening up the samples under the `samples` folder.
|
58
119
|
|
59
120
|
## Girb (Glimmer irb)
|
60
121
|
|
61
|
-
|
122
|
+
With Glimmer installed, you may run want to run `girb` instead of standard `irb` to have SWT preloaded and the Glimmer library required and included for quick Glimmer coding/testing.
|
62
123
|
|
63
124
|
## Samples
|
64
125
|
|
@@ -96,28 +157,31 @@ D, [2017-07-21T19:23:12.878798 #35707] DEBUG -- : widget styles are: [:multi]
|
|
96
157
|
|
97
158
|
## Mac Support
|
98
159
|
|
99
|
-
|
160
|
+
Mac is well supported with the `glimmer` command.
|
161
|
+
|
162
|
+
If there is a reason to use the raw jruby command on the Mac, you need to pass an extra option to JRuby. For example:
|
100
163
|
`jruby -J-XstartOnFirstThread samples/hello_world.rb`
|
101
164
|
|
165
|
+
## Windows Support
|
166
|
+
|
167
|
+
Windows is supported by JRuby and the Eclipse SWT library Glimmer runs on. However, the `glimmer` command has not been confirmed to be working on Windows yet. Please feel free to share experiences and provide help in ensuring support for Windows.
|
168
|
+
|
169
|
+
## Linux Support
|
170
|
+
|
171
|
+
Same as Windows
|
172
|
+
|
102
173
|
## Contributing to Glimmer
|
103
174
|
|
104
175
|
Please follow these instructions if you would like to help us develop Glimmer:
|
105
176
|
|
106
177
|
1. Download and extract the ["SWT binary and source"](http://download.eclipse.org/eclipse/downloads/drops4/R-4.7-201706120950/#SWT).
|
107
178
|
2. Add swt.jar to your Java CLASSPATH environment (e.g. `export CLASSPATH="$CLASSPATH:/path_to_swt_jar/swt.jar"`)
|
108
|
-
3. Download and setup jRuby 1.5.6 (`rvm install jruby-9.
|
179
|
+
3. Download and setup jRuby 1.5.6 (`rvm install jruby-9.2.9.0`)
|
109
180
|
4. Install bundler (gem install bundler)
|
110
181
|
5. Install project required gems (bundle install)
|
111
182
|
6. Write a program that requires the file "lib/glimmer.rb" (or glimmer gem) and has the UI class (view) include the Glimmer module
|
112
183
|
7. Run your program with `bin/glimmer` or jruby (pass `-J-XstartOnFirstThread` option if on the Mac)
|
113
184
|
|
114
|
-
## Resources
|
115
|
-
|
116
|
-
* [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer)
|
117
|
-
* [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
|
118
|
-
* [RubyConf 2008 Video](http://rubyconf2008.confreaks.com/desktop-development-with-glimmer.html)
|
119
|
-
* [Code Painter Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
|
120
|
-
|
121
185
|
## Contributors
|
122
186
|
|
123
187
|
* Annas "Andy" Al Maleh (Founder)
|
@@ -125,5 +189,5 @@ Please follow these instructions if you would like to help us develop Glimmer:
|
|
125
189
|
|
126
190
|
## License
|
127
191
|
|
128
|
-
Copyright (c) 2007-
|
192
|
+
Copyright (c) 2007-2019 Annas "Andy" Al Maleh.
|
129
193
|
See LICENSE.txt for further details.
|
data/Rakefile
CHANGED
@@ -11,20 +11,26 @@ rescue Bundler::BundlerError => e
|
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
begin
|
15
|
+
jeweler_required = require 'jeweler'
|
16
|
+
rescue Exception
|
17
|
+
jeweler_required = nil
|
18
|
+
end
|
19
|
+
unless jeweler_required.nil?
|
20
|
+
Jeweler::Tasks.new do |gem|
|
21
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
22
|
+
gem.name = "glimmer"
|
23
|
+
gem.homepage = "http://github.com/AndyObtiva/glimmer"
|
24
|
+
gem.license = "MIT"
|
25
|
+
gem.summary = %Q{Desktop application development library}
|
26
|
+
gem.description = %Q{JRuby Desktop UI DSL + Data-Binding library that enables easy and efficient authoring of user-interfaces using the robust platform-independent Eclipse SWT library}
|
27
|
+
gem.email = "andy.am@gmail.com"
|
28
|
+
gem.authors = ["AndyMaleh"]
|
29
|
+
gem.executables = ['glimmer', 'girb']
|
30
|
+
# dependencies defined in Gemfile
|
31
|
+
end
|
32
|
+
Jeweler::RubygemsDotOrgTasks.new
|
26
33
|
end
|
27
|
-
Jeweler::RubygemsDotOrgTasks.new
|
28
34
|
|
29
35
|
require 'rspec/core'
|
30
36
|
require 'rspec/core/rake_task'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10.470
|
data/glimmer.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer 0.1.
|
5
|
+
# stub: glimmer 0.1.10.470 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer".freeze
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.10.470"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["AndyMaleh".freeze]
|
14
|
-
s.date = "
|
15
|
-
s.description = "JRuby DSL that enables easy and efficient authoring of user-interfaces using the robust platform-independent Eclipse SWT library".freeze
|
14
|
+
s.date = "2019-11-27"
|
15
|
+
s.description = "JRuby Desktop UI DSL + Data-Binding library that enables easy and efficient authoring of user-interfaces using the robust platform-independent Eclipse SWT library".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.executables = ["glimmer".freeze, "girb".freeze]
|
18
18
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"Gemfile",
|
28
28
|
"LICENSE.txt",
|
29
29
|
"README.markdown",
|
30
|
+
"RELEASE.md",
|
30
31
|
"Rakefile",
|
31
32
|
"TODO.md",
|
32
33
|
"VERSION",
|
@@ -39,7 +40,6 @@ Gem::Specification.new do |s|
|
|
39
40
|
"lib/command_handler_chain_factory.rb",
|
40
41
|
"lib/command_handler_chain_link.rb",
|
41
42
|
"lib/command_handlers.rb",
|
42
|
-
"lib/command_handlers/RELEASE.md",
|
43
43
|
"lib/command_handlers/bind_command_handler.rb",
|
44
44
|
"lib/command_handlers/combo_selection_data_binding_command_handler.rb",
|
45
45
|
"lib/command_handlers/data_binding_command_handler.rb",
|
@@ -92,6 +92,8 @@ Gem::Specification.new do |s|
|
|
92
92
|
"samples/hello_list_single_selection.rb",
|
93
93
|
"samples/hello_tab.rb",
|
94
94
|
"samples/hello_world.rb",
|
95
|
+
"samples/hellocomputed/contact.rb",
|
96
|
+
"samples/hellocomputed/hello_computed.rb",
|
95
97
|
"samples/login.rb",
|
96
98
|
"samples/tictactoe/tic_tac_toe.rb",
|
97
99
|
"samples/tictactoe/tic_tac_toe_board.rb",
|
@@ -114,7 +116,7 @@ Gem::Specification.new do |s|
|
|
114
116
|
]
|
115
117
|
s.homepage = "http://github.com/AndyObtiva/glimmer".freeze
|
116
118
|
s.licenses = ["MIT".freeze]
|
117
|
-
s.rubygems_version = "2.
|
119
|
+
s.rubygems_version = "2.7.10".freeze
|
118
120
|
s.summary = "Desktop application development library".freeze
|
119
121
|
|
120
122
|
if s.respond_to? :specification_version then
|
@@ -126,22 +128,20 @@ Gem::Specification.new do |s|
|
|
126
128
|
s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
127
129
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
128
130
|
s.add_development_dependency(%q<rdoc>.freeze, ["~> 2.3.0"])
|
129
|
-
s.add_development_dependency(%q<
|
130
|
-
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3.0"])
|
131
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3.9"])
|
131
132
|
s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.5"])
|
132
133
|
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.10.0"])
|
133
|
-
s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.
|
134
|
+
s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.8.1"])
|
134
135
|
else
|
135
136
|
s.add_dependency(%q<facets>.freeze, ["= 3.1.0"])
|
136
137
|
s.add_dependency(%q<os>.freeze, ["= 1.0.0"])
|
137
138
|
s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
138
139
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
139
140
|
s.add_dependency(%q<rdoc>.freeze, ["~> 2.3.0"])
|
140
|
-
s.add_dependency(%q<
|
141
|
-
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.0"])
|
141
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.9"])
|
142
142
|
s.add_dependency(%q<coveralls>.freeze, ["= 0.8.5"])
|
143
143
|
s.add_dependency(%q<simplecov>.freeze, ["~> 0.10.0"])
|
144
|
-
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.
|
144
|
+
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.8.1"])
|
145
145
|
end
|
146
146
|
else
|
147
147
|
s.add_dependency(%q<facets>.freeze, ["= 3.1.0"])
|
@@ -149,11 +149,10 @@ Gem::Specification.new do |s|
|
|
149
149
|
s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
150
150
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
151
151
|
s.add_dependency(%q<rdoc>.freeze, ["~> 2.3.0"])
|
152
|
-
s.add_dependency(%q<
|
153
|
-
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.0"])
|
152
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.9"])
|
154
153
|
s.add_dependency(%q<coveralls>.freeze, ["= 0.8.5"])
|
155
154
|
s.add_dependency(%q<simplecov>.freeze, ["~> 0.10.0"])
|
156
|
-
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.
|
155
|
+
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.8.1"])
|
157
156
|
end
|
158
157
|
end
|
159
158
|
|
@@ -26,7 +26,13 @@ class BindCommandHandler
|
|
26
26
|
(
|
27
27
|
(args.size == 3) and
|
28
28
|
(args[1].is_a?(Symbol) or args[1].is_a?(String)) and
|
29
|
-
(args[2].is_a?(Symbol) or args[2].is_a?(String))
|
29
|
+
(args[2].is_a?(Symbol) or args[2].is_a?(String) or args[2].is_a?(Hash))
|
30
|
+
) or
|
31
|
+
(
|
32
|
+
(args.size == 4) and
|
33
|
+
(args[1].is_a?(Symbol) or args[1].is_a?(String)) and
|
34
|
+
(args[2].is_a?(Symbol) or args[2].is_a?(String)) and
|
35
|
+
(args[3].is_a?(Hash))
|
30
36
|
)
|
31
37
|
) and
|
32
38
|
block == nil
|
@@ -34,8 +40,10 @@ class BindCommandHandler
|
|
34
40
|
end
|
35
41
|
|
36
42
|
def do_handle(parent, command_symbol, *args, &block)
|
37
|
-
property_type = args[2] if (args.size == 3)
|
38
|
-
|
43
|
+
property_type = args[2] if (args.size == 3) && !args[2].is_a?(Hash)
|
44
|
+
observer_options = args[2] if args[2].is_a?(Hash)
|
45
|
+
observer_options = args[3] if args[3].is_a?(Hash)
|
46
|
+
ModelObserver.new(args[0], args[1].to_s, property_type, observer_options)
|
39
47
|
end
|
40
48
|
|
41
49
|
end
|
@@ -55,11 +55,17 @@ class DataBindingCommandHandler
|
|
55
55
|
|
56
56
|
def do_handle(parent, command_symbol, *args, &block)
|
57
57
|
model_observer = args[0]
|
58
|
-
|
58
|
+
widget_observer_parameters = [parent, command_symbol.to_s]
|
59
|
+
widget_observer_parameters << proc {|value| model_observer.evaluate_property} if model_observer.observer_options.has_key?(:computed_by)
|
60
|
+
widget_observer = WidgetObserver.new(*widget_observer_parameters)
|
59
61
|
widget_observer.update(model_observer.evaluate_property)
|
60
62
|
model = model_observer.model
|
61
63
|
model.extend ObservableModel unless model.is_a?(ObservableModel)
|
62
64
|
model.add_observer(model_observer.property_name, widget_observer)
|
65
|
+
computed_by_property_names = model_observer.observer_options[:computed_by]
|
66
|
+
computed_by_property_names&.each do |computed_by_property_name|
|
67
|
+
model.add_observer(computed_by_property_name, widget_observer)
|
68
|
+
end
|
63
69
|
widget_data_binder_map = @@widget_data_binders[parent.widget.class]
|
64
70
|
widget_data_binder = widget_data_binder_map[command_symbol.to_s.to_sym] if widget_data_binder_map
|
65
71
|
widget_data_binder.call(parent, model_observer) if widget_data_binder
|
@@ -1,15 +1,16 @@
|
|
1
1
|
class ModelObserver
|
2
|
-
attr_reader :model, :property_name, :property_type
|
2
|
+
attr_reader :model, :property_name, :property_type, :observer_options
|
3
3
|
@@property_type_converters = {
|
4
|
-
:undefined => lambda { |value| value },
|
4
|
+
:undefined => lambda { |value| value },
|
5
5
|
:fixnum => lambda { |value| value.to_i },
|
6
6
|
:array => lambda { |value| value.to_a }
|
7
7
|
}
|
8
|
-
def initialize(model, property_name, property_type = :undefined)
|
8
|
+
def initialize(model, property_name, property_type = :undefined, observer_options = nil)
|
9
9
|
property_type = :undefined if property_type.nil?
|
10
10
|
@model = model
|
11
11
|
@property_name = property_name
|
12
12
|
@property_type = property_type
|
13
|
+
@observer_options = observer_options || {}
|
13
14
|
end
|
14
15
|
def update(value)
|
15
16
|
converted_value = @@property_type_converters[@property_type].call(value)
|
@@ -22,7 +23,6 @@ class ModelObserver
|
|
22
23
|
@model.send(@property_name + "_options")
|
23
24
|
end
|
24
25
|
def options_property_name
|
25
|
-
self.property_name + "_options"
|
26
|
+
self.property_name + "_options"
|
26
27
|
end
|
27
28
|
end
|
28
|
-
|
@@ -4,18 +4,18 @@ class WidgetObserver
|
|
4
4
|
:text => Proc.new { |value| value.to_s },
|
5
5
|
:items => Proc.new { |value| value.to_java :string}
|
6
6
|
}
|
7
|
-
def initialize
|
7
|
+
def initialize(model, property, translator = nil)
|
8
8
|
@widget = model
|
9
9
|
@property = property
|
10
|
+
@translator = translator || proc {|value| value}
|
10
11
|
end
|
11
12
|
def update(value)
|
12
|
-
converted_value = value
|
13
|
+
converted_value = translated_value = @translator.call(value)
|
13
14
|
converter = @@property_type_converters[@property.to_sym]
|
14
|
-
converted_value = converter.call(
|
15
|
+
converted_value = converter.call(translated_value) if converter
|
15
16
|
@widget.widget.send("set#{@property.camelcase(:upper)}", converted_value) unless evaluate_property == converted_value
|
16
17
|
end
|
17
18
|
def evaluate_property
|
18
19
|
@widget.widget.send(@property)
|
19
20
|
end
|
20
21
|
end
|
21
|
-
|
data/lib/glimmer_application.rb
CHANGED
@@ -42,19 +42,19 @@ class GlimmerApplication
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def usage
|
45
|
-
puts
|
46
|
-
|
45
|
+
puts <<-MULTILINE
|
46
|
+
Usage: glimmer [--setup] [application_ruby_file_path.rb]
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
Example 1: glimmer hello_combo.rb
|
49
|
+
This runs the Glimmer application hello_combo.rb
|
50
|
+
If the SWT Jar is missing, it downloads it and sets it up first.
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
Example 2: glimmer --setup hello_combo.rb
|
53
|
+
This performs setup and then runs the Glimmer application hello_combo.rb
|
54
|
+
It downloads and sets up the SWT jar whether missing or not.
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
Example 3: glimmer --setup
|
57
|
+
This downloads and sets up the SWT jar whether missing or not.
|
58
58
|
MULTILINE
|
59
59
|
end
|
60
60
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Contact
|
2
|
+
attr_accessor :first_name, :last_name, :year_of_birth
|
3
|
+
|
4
|
+
def initialize(attribute_map)
|
5
|
+
@first_name = attribute_map[:first_name]
|
6
|
+
@last_name = attribute_map[:last_name]
|
7
|
+
@year_of_birth = attribute_map[:year_of_birth]
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
"#{last_name}, #{first_name}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def age
|
15
|
+
Time.now.year - year_of_birth.to_i
|
16
|
+
rescue
|
17
|
+
0
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative "../../lib/glimmer"
|
2
|
+
require_relative "contact"
|
3
|
+
|
4
|
+
class HelloComputed
|
5
|
+
extend Glimmer
|
6
|
+
|
7
|
+
include_package 'org.eclipse.swt'
|
8
|
+
include_package 'org.eclipse.swt.widgets'
|
9
|
+
include_package 'org.eclipse.swt.layout'
|
10
|
+
|
11
|
+
contact = Contact.new(
|
12
|
+
first_name: "Barry",
|
13
|
+
last_name: "McKibbin",
|
14
|
+
year_of_birth: 1985
|
15
|
+
)
|
16
|
+
|
17
|
+
shell {
|
18
|
+
text "Hello Computed"
|
19
|
+
composite {
|
20
|
+
layout (
|
21
|
+
GridLayout.new(2, true).tap {|layout|
|
22
|
+
layout.horizontalSpacing = 20
|
23
|
+
layout.verticalSpacing = 10
|
24
|
+
}
|
25
|
+
)
|
26
|
+
label {text "First &Name: "}
|
27
|
+
text {
|
28
|
+
text bind(contact, :first_name)
|
29
|
+
layoutData GridData.new.tap { |data|
|
30
|
+
data.horizontalAlignment = GridData::FILL
|
31
|
+
data.grabExcessHorizontalSpace = true
|
32
|
+
}
|
33
|
+
}
|
34
|
+
label {text "&Last Name: "}
|
35
|
+
text {
|
36
|
+
text bind(contact, :last_name)
|
37
|
+
layoutData GridData.new.tap { |data|
|
38
|
+
data.horizontalAlignment = GridData::FILL
|
39
|
+
data.grabExcessHorizontalSpace = true
|
40
|
+
}
|
41
|
+
}
|
42
|
+
label {text "&Year of Birth: "}
|
43
|
+
text {
|
44
|
+
text bind(contact, :year_of_birth)
|
45
|
+
layoutData GridData.new.tap { |data|
|
46
|
+
data.horizontalAlignment = GridData::FILL
|
47
|
+
data.grabExcessHorizontalSpace = true
|
48
|
+
}
|
49
|
+
}
|
50
|
+
label {text "Name: "}
|
51
|
+
label {
|
52
|
+
text bind(contact, :name, computed_by: [:first_name, :last_name])
|
53
|
+
layoutData GridData.new.tap { |data|
|
54
|
+
data.horizontalAlignment = GridData::FILL
|
55
|
+
data.grabExcessHorizontalSpace = true
|
56
|
+
}
|
57
|
+
}
|
58
|
+
label {text "Age: "}
|
59
|
+
label {
|
60
|
+
text bind(contact, :age, :fixnum, computed_by: [:year_of_birth])
|
61
|
+
layoutData GridData.new.tap { |data|
|
62
|
+
data.horizontalAlignment = GridData::FILL
|
63
|
+
data.grabExcessHorizontalSpace = true
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}.open
|
68
|
+
end
|
@@ -21,6 +21,16 @@ describe "Glimmer Data Binding" do
|
|
21
21
|
attr_accessor :name, :age, :adult
|
22
22
|
end
|
23
23
|
|
24
|
+
class PersonWithComputedValues
|
25
|
+
attr_accessor :first_name, :last_name, :year_of_birth
|
26
|
+
def name
|
27
|
+
"#{last_name}, #{first_name}"
|
28
|
+
end
|
29
|
+
def age
|
30
|
+
Time.now.year - year_of_birth
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
it "tests text widget data binding string property" do
|
25
35
|
person = Person.new
|
26
36
|
person.name = "Bruce Ting"
|
@@ -63,7 +73,7 @@ describe "Glimmer Data Binding" do
|
|
63
73
|
expect(person.age).to eq(30)
|
64
74
|
end
|
65
75
|
|
66
|
-
|
76
|
+
it "tests label widget data binding string property" do
|
67
77
|
person = Person.new
|
68
78
|
person.name = "Bruce Ting"
|
69
79
|
|
@@ -81,6 +91,46 @@ describe "Glimmer Data Binding" do
|
|
81
91
|
expect(@label.widget.getText).to eq("Lady Butterfly")
|
82
92
|
end
|
83
93
|
|
94
|
+
it "tests label widget computed value data binding string property" do
|
95
|
+
person = PersonWithComputedValues.new
|
96
|
+
person.first_name = "Marty"
|
97
|
+
person.last_name = "McFly"
|
98
|
+
|
99
|
+
@target = shell {
|
100
|
+
composite {
|
101
|
+
@label = label {
|
102
|
+
text bind(person, :name, computed_by: [:first_name, :last_name])
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
expect(@label.widget.getText).to eq("McFly, Marty")
|
108
|
+
|
109
|
+
person.first_name = "Martin"
|
110
|
+
expect(@label.widget.getText).to eq("McFly, Martin")
|
111
|
+
|
112
|
+
person.last_name = "MacFly"
|
113
|
+
expect(@label.widget.getText).to eq("MacFly, Martin")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "tests label widget computed value data binding fixnum property" do
|
117
|
+
person = PersonWithComputedValues.new
|
118
|
+
person.year_of_birth = Time.now.year - 40 #TODO TimeCop gem ?
|
119
|
+
|
120
|
+
@target = shell {
|
121
|
+
composite {
|
122
|
+
@label = label {
|
123
|
+
text bind(person, :age, :fixnum, computed_by: [:year_of_birth])
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
expect(@label.widget.getText).to eq("40")
|
129
|
+
|
130
|
+
person.year_of_birth = Time.now.year - 41
|
131
|
+
expect(@label.widget.getText).to eq("41")
|
132
|
+
end
|
133
|
+
|
84
134
|
it "tests checkbox widget data binding boolean property" do
|
85
135
|
person = Person.new
|
86
136
|
person.adult = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10.470
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,21 +85,7 @@ dependencies:
|
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
89
|
-
name: bundler
|
90
|
-
prerelease: false
|
91
|
-
type: :development
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 2.3.0
|
88
|
+
version: 2.3.9
|
103
89
|
name: jeweler
|
104
90
|
prerelease: false
|
105
91
|
type: :development
|
@@ -107,7 +93,7 @@ dependencies:
|
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.3.
|
96
|
+
version: 2.3.9
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
requirement: !ruby/object:Gem::Requirement
|
113
99
|
requirements:
|
@@ -141,7 +127,7 @@ dependencies:
|
|
141
127
|
requirements:
|
142
128
|
- - "~>"
|
143
129
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.
|
130
|
+
version: 0.8.1
|
145
131
|
name: puts_debuggerer
|
146
132
|
prerelease: false
|
147
133
|
type: :development
|
@@ -149,9 +135,9 @@ dependencies:
|
|
149
135
|
requirements:
|
150
136
|
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
153
|
-
description: JRuby DSL that enables easy and efficient
|
154
|
-
using the robust platform-independent Eclipse SWT library
|
138
|
+
version: 0.8.1
|
139
|
+
description: JRuby Desktop UI DSL + Data-Binding library that enables easy and efficient
|
140
|
+
authoring of user-interfaces using the robust platform-independent Eclipse SWT library
|
155
141
|
email: andy.am@gmail.com
|
156
142
|
executables:
|
157
143
|
- glimmer
|
@@ -168,6 +154,7 @@ files:
|
|
168
154
|
- Gemfile
|
169
155
|
- LICENSE.txt
|
170
156
|
- README.markdown
|
157
|
+
- RELEASE.md
|
171
158
|
- Rakefile
|
172
159
|
- TODO.md
|
173
160
|
- VERSION
|
@@ -180,7 +167,6 @@ files:
|
|
180
167
|
- lib/command_handler_chain_factory.rb
|
181
168
|
- lib/command_handler_chain_link.rb
|
182
169
|
- lib/command_handlers.rb
|
183
|
-
- lib/command_handlers/RELEASE.md
|
184
170
|
- lib/command_handlers/bind_command_handler.rb
|
185
171
|
- lib/command_handlers/combo_selection_data_binding_command_handler.rb
|
186
172
|
- lib/command_handlers/data_binding_command_handler.rb
|
@@ -233,6 +219,8 @@ files:
|
|
233
219
|
- samples/hello_list_single_selection.rb
|
234
220
|
- samples/hello_tab.rb
|
235
221
|
- samples/hello_world.rb
|
222
|
+
- samples/hellocomputed/contact.rb
|
223
|
+
- samples/hellocomputed/hello_computed.rb
|
236
224
|
- samples/login.rb
|
237
225
|
- samples/tictactoe/tic_tac_toe.rb
|
238
226
|
- samples/tictactoe/tic_tac_toe_board.rb
|
@@ -272,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
260
|
version: '0'
|
273
261
|
requirements: []
|
274
262
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.
|
263
|
+
rubygems_version: 2.7.10
|
276
264
|
signing_key:
|
277
265
|
specification_version: 4
|
278
266
|
summary: Desktop application development library
|