glimmer-dsl-opal 0.7.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/README.md +745 -82
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +14 -1
- data/lib/glimmer-dsl-opal/ext/class.rb +10 -0
- data/lib/{file.rb → glimmer-dsl-opal/ext/file.rb} +0 -0
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +30 -0
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
- data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +24 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +46 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +7 -7
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +62 -32
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +47 -22
- data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +241 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +37 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +84 -0
- data/lib/glimmer/data_binding/observable_element.rb +1 -1
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -0
- data/lib/glimmer/dsl/opal/dsl.rb +2 -0
- data/lib/glimmer/dsl/opal/menu_bar_expression.rb +54 -0
- data/lib/glimmer/dsl/opal/menu_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +0 -4
- data/lib/glimmer/dsl/opal/widget_expression.rb +3 -2
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +2 -2
- data/lib/glimmer/swt/custom/checkbox_group.rb +2 -2
- data/lib/glimmer/swt/custom/radio_group.rb +2 -2
- data/lib/glimmer/swt/date_time_proxy.rb +5 -4
- data/lib/glimmer/swt/display_proxy.rb +4 -4
- data/lib/glimmer/swt/event_listener_proxy.rb +14 -4
- data/lib/glimmer/swt/font_proxy.rb +4 -4
- data/lib/glimmer/swt/grid_layout_proxy.rb +21 -12
- data/lib/glimmer/swt/label_proxy.rb +17 -6
- data/lib/glimmer/swt/latest_message_box_proxy.rb +20 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +6 -6
- data/lib/glimmer/swt/list_proxy.rb +15 -0
- data/lib/glimmer/swt/menu_item_proxy.rb +174 -0
- data/lib/glimmer/swt/menu_proxy.rb +273 -0
- data/lib/glimmer/swt/message_box_proxy.rb +57 -72
- data/lib/glimmer/swt/property_owner.rb +2 -0
- data/lib/glimmer/swt/radio_proxy.rb +1 -1
- data/lib/glimmer/swt/shell_proxy.rb +34 -189
- data/lib/glimmer/swt/tab_folder_proxy.rb +43 -0
- data/lib/glimmer/swt/table_column_proxy.rb +3 -2
- data/lib/glimmer/swt/table_editor.rb +1 -1
- data/lib/glimmer/swt/table_item_proxy.rb +7 -5
- data/lib/glimmer/swt/table_proxy.rb +14 -10
- data/lib/glimmer/swt/widget_proxy.rb +327 -33
- data/lib/glimmer/ui/custom_shell.rb +9 -7
- data/lib/glimmer/ui/custom_widget.rb +3 -3
- metadata +36 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f0f0793d8e8128a47664c70eefee97fb797f61cbb8026937c3f88e00004a3b2
|
4
|
+
data.tar.gz: 7482911470d0ea4c87273622642b0d544f94bd0154913d2836e81e07e6d27da9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c6dd0b2de545158edfac2173cf7793415ad6046c650650b6b371a4e0704cd7de2cb78fc11ec05d653b266856c676350a224752417954a304ef9a2a95186439f
|
7
|
+
data.tar.gz: a3bb54ba72e3d55f9352e4ea660d14497212c058cd7f463464dacef05093d74dfabbcee2997d150c00b64923a1a71f592ae706e4155a57280a9f12dfb9fb8d9c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,46 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.9.0
|
4
|
+
|
5
|
+
- Support `menu_bar`
|
6
|
+
- Hello, Menu Bar! Sample
|
7
|
+
- Remove the need to call Document.ready? before opening a Glimmer shell
|
8
|
+
- Support opening a message_box before creating a shell
|
9
|
+
|
10
|
+
## 0.8.0
|
11
|
+
|
12
|
+
- Hello, Pop Up Context Menu! Sample
|
13
|
+
- Hello Message Box!
|
14
|
+
- Update hello list samples
|
15
|
+
- Support context menus `menu`/`menu_item` directly under a widget (using jQuery UI)
|
16
|
+
- Support generating new lines when entering `label` `text` with \n (auto-converting to <br />)
|
17
|
+
- Support generating new lines when entering `message_box` `message` with \n (auto-converting to <br />)
|
18
|
+
- Support having any widget contribute static CSS to ShellProxy
|
19
|
+
- Add Kernel#include_package shim to allow running JRuby include_package from Glimmer DSL for SWT without failing
|
20
|
+
- Add WidgetProxy#swt_widget to allow running include_package from Glimmer DSL for SWT without failing
|
21
|
+
|
22
|
+
## 0.7.5
|
23
|
+
|
24
|
+
- Update login sample from Glimmer DSL for SWT's latest changes
|
25
|
+
- Update contact_manager sample from Glimmer DSL for SWT's latest changes
|
26
|
+
- Fixed issue regarding unavailable localStorage data when accessed by custom_widget_expression in hello_checkbox_group, hello_radio_group, and hello_custom_widget
|
27
|
+
|
28
|
+
## 0.7.4
|
29
|
+
|
30
|
+
- Hello, Button! Sample
|
31
|
+
- Fix issue with aligning label as :left, :center, or :right via style style when fill_layout is used
|
32
|
+
- Fix Hello, Browser sample by accessing https ssl website
|
33
|
+
- Fix issue with filling space horizontally when using grid layout
|
34
|
+
- Fix broken embedded `calendar` widget data-binding for hello_date_time.rb sample
|
35
|
+
- Fix broken message_box after opening multiple shells
|
36
|
+
- Fix issue with opening custom shells in new tabs/windows when CustomShell subclass is required conditionally
|
37
|
+
|
38
|
+
## 0.7.3
|
39
|
+
|
40
|
+
- Refactor to use to_collection gem
|
41
|
+
- Fix issue with breaking `date`/`date_drop_down` data-binding as table editor on focus lost
|
42
|
+
- Fix issue with requiring OS, File, and Display class after they've been extracted out
|
43
|
+
|
3
44
|
## 0.7.2
|
4
45
|
|
5
46
|
- `date_drop_down` `table_column` `editor`
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
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 Opal 0.
|
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 Opal 0.9.0 (Pure Ruby Web GUI)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
|
3
3
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
4
|
|
5
5
|
### You can finally live in pure Ruby land on the web!
|
6
6
|
|
7
|
-
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Opal](https://opalrb.com/) is an alpha [gem](https://rubygems.org/gems/glimmer-dsl-opal) that enables building web GUI in pure Ruby via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/).
|
7
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Opal](https://opalrb.com/) is an **alpha** [gem](https://rubygems.org/gems/glimmer-dsl-opal) that enables building web GUI in pure Ruby via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/).
|
8
8
|
|
9
9
|
Use in one of two ways:
|
10
10
|
- **Direct:** build the GUI of web apps with the same friendly desktop GUI Ruby syntax as [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt), thus requiring a lot less code than web technologies that is in pure Ruby and avoiding opaque web concepts like 'render' and 'reactive'. No HTML/JS/CSS skills are even required. Web designers may be involved with CSS styling only if needed.
|
@@ -20,7 +20,7 @@ Add the following require statement to `app/assets/javascripts/application.rb` i
|
|
20
20
|
require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
|
21
21
|
```
|
22
22
|
|
23
|
-
Glimmer GUI code from [glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb](glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb):
|
23
|
+
Glimmer GUI code from [glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb](lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb):
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
# ...
|
@@ -52,15 +52,17 @@ Tic Tac Toe on the web (using the [glimmer-dsl-opal](https://rubygems.org/gems/g
|
|
52
52
|
![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
|
53
53
|
![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
|
54
54
|
|
55
|
-
Tic Tac Toe on the desktop with the same exact code (using the [
|
55
|
+
Tic Tac Toe on the desktop with the same exact code (using the [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
56
56
|
|
57
57
|
![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
|
58
58
|
![Glimmer DSL for SWT Tic Tac Toe In Progress](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-in-progress.png)
|
59
59
|
![Glimmer DSL for SWT Tic Tac Toe Game Over](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-game-over.png)
|
60
60
|
|
61
|
-
NOTE:
|
61
|
+
NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
62
62
|
|
63
|
-
|
63
|
+
**Alpha Version** 0.9.0 only supports bare-minimum capabilities for the following [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)):
|
64
|
+
|
65
|
+
[Hello samples](#hello-samples):
|
64
66
|
|
65
67
|
- [Hello, World!](#hello-world)
|
66
68
|
- [Hello, Combo!](#hello-combo)
|
@@ -78,8 +80,12 @@ Hello:
|
|
78
80
|
- [Hello, Checkbox Group!](#hello-checkbox-group)
|
79
81
|
- [Hello, Date Time!](#hello-date-time)
|
80
82
|
- [Hello, Table!](#hello-table)
|
83
|
+
- [Hello, Button!](#hello-button)
|
84
|
+
- [Hello, Message Box!](#hello-message-box)
|
85
|
+
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
86
|
+
- [Hello, Menu Bar!](#hello-menu-bar)
|
81
87
|
|
82
|
-
Elaborate:
|
88
|
+
[Elaborate samples](#elaborate-samples):
|
83
89
|
|
84
90
|
- [Login](#login)
|
85
91
|
- [Tic Tac Toe](#tic-tac-toe)
|
@@ -100,17 +106,32 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
100
106
|
The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have partial support in Opal:
|
101
107
|
|
102
108
|
Widgets:
|
103
|
-
- `shell`
|
104
|
-
- `label`
|
105
|
-
- `combo`
|
106
109
|
- `button`
|
107
|
-
- `
|
110
|
+
- `browser`
|
111
|
+
- `calendar`
|
112
|
+
- `checkbox`
|
113
|
+
- `checkbox_group`
|
114
|
+
- `combo`
|
108
115
|
- `composite`
|
109
|
-
- `
|
116
|
+
- `date`
|
117
|
+
- `date_drop_down`
|
118
|
+
- `group`
|
119
|
+
- `label`
|
120
|
+
- `list` (w/ optional `:multi` SWT style)
|
121
|
+
- `menu`
|
122
|
+
- `menu_bar`
|
123
|
+
- `menu_item`
|
124
|
+
- `message_box`
|
125
|
+
- `radio`
|
126
|
+
- `radio_group`
|
127
|
+
- `scrolled_composite`
|
128
|
+
- `shell`
|
110
129
|
- `tab_folder`
|
111
130
|
- `tab_item`
|
112
131
|
- `table`
|
113
132
|
- `table_column`
|
133
|
+
- `text`
|
134
|
+
- `time`
|
114
135
|
- `message_box`
|
115
136
|
- Glimmer::UI::CustomWidget: ability to define any keyword as a custom widget
|
116
137
|
- Glimmer::UI::CustomShell: ability to define any keyword as a custom shell (aka custom window) that opens in a new browser window (tab) automatically unless there is no shell open in the current browser window (tab)
|
@@ -121,20 +142,34 @@ Layouts:
|
|
121
142
|
- `fill_layout`
|
122
143
|
- `layout_data`
|
123
144
|
|
124
|
-
Graphics:
|
145
|
+
Graphics/Style:
|
125
146
|
- `color`
|
126
147
|
- `font`
|
148
|
+
- `Point` class used in setting location on widgets
|
149
|
+
- `swt` and `SWT` class to set SWT styles on widgets
|
127
150
|
|
128
151
|
Data-Binding/Observers:
|
129
152
|
- `bind`
|
130
153
|
- `observe`
|
131
154
|
- `on_widget_selected`
|
132
155
|
- `on_modify_text`
|
156
|
+
- `on_key_pressed` (and SWT alias `on_swt_keydown`)
|
157
|
+
- `on_key_released` (and SWT alias `on_swt_keyup`)
|
158
|
+
- `on_mouse_down` (and SWT alias `on_swt_mousedown`)
|
159
|
+
- `on_mouse_up` (and SWT alias `on_swt_mouseup`)
|
133
160
|
|
134
161
|
Event loop:
|
135
162
|
- `display`
|
136
163
|
- `async_exec`
|
137
164
|
|
165
|
+
## Principles
|
166
|
+
|
167
|
+
- **Live purely in Rubyland via the Glimmer GUI DSL**, completely oblivious to web browser technologies.
|
168
|
+
- **Forget Routers!** Glimmer DSL for Opal supports auto-routing of custom shells (windows), which are opened as separate tabs in a web browser with automatically generated routes and bookmarkable URLs.
|
169
|
+
- **HTML is strictly made for creating documents not interactive applications**. As such, software engineers can avoid it and focus on creating web applications more productively with Glimmer DSL for Opal in pure Ruby instead (just like they do in desktop development) while content creators and web designers can be the ones responsible for creating HTML documents for web content purposes only as HTML was originally intended. That way, Glimmer web GUI is used and embedded in web pages when providing users with applications while the rest of the web pages are maintained by non-engineers as pure HTML. This achieves a correct separation of responsibilities and better productivity and maintainability.
|
170
|
+
- **Approximate styles by developers via the Glimmer GUI DSL. Perfect styles by designers via pure CSS**. Developers can simply build GUI with approximate styling similar to desktop GUI without worrying about pixel-perfect aethetics. Web designers can take styling further with pure CSS since every HTML element auto-generated by Glimmer DSL for Opal has a predictable ID and CSS class. This achieves a proper separation of responsibilities between developers and designers.
|
171
|
+
- **Web servers are used just like servers in traditional client/server architecture**, meaning they simply provide RMI services to enable centralizing some of the application logic and data in the cloud to make available everywhere and enable data-sharing with others.
|
172
|
+
|
138
173
|
## Background
|
139
174
|
|
140
175
|
The original idea behind Glimmer DSL for Opal was that you start by having a [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) desktop app that communicates with a Rails API for any web/cloud concerns. The pure Ruby [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) is very simple, so it is more productive to build GUI in it since it does not go through a server/client request/response cycle and can be iterated on locally with a much shorter feedback cycle. Once the GUI and the rest of the app is built. You simply embed it in a Rails app as a one line require statement after adding the Glimmer DSL for Opal gem, and BOOM, it just works on the web inside a web browser with the same server/client communication you had in the desktop app (I am working on adding minimal support for net/http in Opal so that desktop apps that use it continue to work in a web browser. Until then, just use [Opal-jQuery](https://github.com/opal/opal-jquery) http support). That way, you get two apps for one: desktop and web.
|
@@ -155,7 +190,7 @@ Alternatively, web developers may directly use [Glimmer DSL for Opal](https://ru
|
|
155
190
|
|
156
191
|
## Setup
|
157
192
|
|
158
|
-
(NOTE:
|
193
|
+
(NOTE: Keep in mind this is a very early experimental and incomplete **alpha**. If you run into issues, try to go back to a [previous revision](https://rubygems.org/gems/glimmer-dsl-opal/versions). Also, there is a slight chance any issues you encounter are fixed in master or some other branch that you could check out instead)
|
159
194
|
|
160
195
|
The [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem is a Rails Engine gem that includes assets.
|
161
196
|
|
@@ -179,7 +214,7 @@ Add the following to `Gemfile`:
|
|
179
214
|
gem 'opal-rails', '~> 1.1.2'
|
180
215
|
gem 'opal-async', '~> 1.2.0'
|
181
216
|
gem 'opal-jquery', '~> 0.4.4'
|
182
|
-
gem 'glimmer-dsl-opal', '~> 0.
|
217
|
+
gem 'glimmer-dsl-opal', '~> 0.9.0'
|
183
218
|
gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
|
184
219
|
gem 'glimmer-dsl-css', '~> 1.1.0', require: false
|
185
220
|
|
@@ -248,11 +283,19 @@ end
|
|
248
283
|
|
249
284
|
Follow the instructions below to try out [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) samples webified via [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal)
|
250
285
|
|
251
|
-
|
286
|
+
The [Hello samples](#hello-samples) demonstrate tiny building blocks (widgets) for building full fledged applications.
|
252
287
|
|
253
|
-
[
|
288
|
+
The [Elaborate samples](#elaborate-samples) demonstrate more advanced sample applications that assemble multiple building blocks.
|
254
289
|
|
255
|
-
|
290
|
+
This external sample app contains all the samples mentioned below configured inside a Rails [Opal](https://opalrb.com/) app with all the pre-requisites ready to go for convenience:
|
291
|
+
|
292
|
+
[https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails-app](https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails-app)
|
293
|
+
|
294
|
+
You may visit a Heroku hosted version at:
|
295
|
+
|
296
|
+
https://sample-glimmer-dsl-opal-app.herokuapp.com/
|
297
|
+
|
298
|
+
Note: Some of the screenshots might be out of date with updates done to samples in both [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) and [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal).
|
256
299
|
|
257
300
|
### Hello Samples
|
258
301
|
|
@@ -559,44 +602,53 @@ require 'glimmer-dsl-opal/samples/hello/hello_list_multi_selection'
|
|
559
602
|
Or add the Glimmer code directly if you prefer to play around with it:
|
560
603
|
|
561
604
|
```ruby
|
562
|
-
class Person
|
563
|
-
attr_accessor :provinces, :provinces_options
|
564
|
-
|
565
|
-
def initialize
|
566
|
-
self.provinces_options=[
|
567
|
-
"",
|
568
|
-
"Quebec",
|
569
|
-
"Ontario",
|
570
|
-
"Manitoba",
|
571
|
-
"Saskatchewan",
|
572
|
-
"Alberta",
|
573
|
-
"British Columbia",
|
574
|
-
"Nova Skotia",
|
575
|
-
"Newfoundland"
|
576
|
-
]
|
577
|
-
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
578
|
-
end
|
579
|
-
|
580
|
-
def reset_provinces
|
581
|
-
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
582
|
-
end
|
583
|
-
end
|
584
|
-
|
585
605
|
class HelloListMultiSelection
|
606
|
+
class Person
|
607
|
+
attr_accessor :provinces, :provinces_options
|
608
|
+
|
609
|
+
def initialize
|
610
|
+
self.provinces_options = [
|
611
|
+
'',
|
612
|
+
'Alberta',
|
613
|
+
'British Columbia',
|
614
|
+
'Manitoba',
|
615
|
+
'New Brunswick',
|
616
|
+
'Newfoundland and Labrador',
|
617
|
+
'Northwest Territories',
|
618
|
+
'Nova Scotia',
|
619
|
+
'Nunavut',
|
620
|
+
'Ontario',
|
621
|
+
'Prince Edward Island',
|
622
|
+
'Quebec',
|
623
|
+
'Saskatchewan',
|
624
|
+
'Yukon'
|
625
|
+
]
|
626
|
+
reset_provinces
|
627
|
+
end
|
628
|
+
|
629
|
+
def reset_provinces
|
630
|
+
self.provinces = ['Quebec', 'Manitoba', 'Alberta']
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
586
634
|
include Glimmer
|
635
|
+
|
587
636
|
def launch
|
588
637
|
person = Person.new
|
638
|
+
|
589
639
|
shell {
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
640
|
+
grid_layout
|
641
|
+
|
642
|
+
text 'Hello, List Multi Selection!'
|
643
|
+
|
644
|
+
list(:multi) {
|
645
|
+
selection bind(person, :provinces)
|
646
|
+
}
|
647
|
+
|
648
|
+
button {
|
649
|
+
text 'Reset Selections To Default Values'
|
650
|
+
|
651
|
+
on_widget_selected { person.reset_provinces }
|
600
652
|
}
|
601
653
|
}.open
|
602
654
|
end
|
@@ -809,6 +861,10 @@ You should see "Hello, Custom Widget!"
|
|
809
861
|
|
810
862
|
#### Hello, Custom Shell!
|
811
863
|
|
864
|
+
This sample demonstrates Glimmer DSL for Opal's ability to open multiple shells (windows) as web browser tabs.
|
865
|
+
|
866
|
+
It automatically handles routing so that tab URLs are bookmarkable. Web developers do not have to do any routing configuration manually.
|
867
|
+
|
812
868
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
813
869
|
|
814
870
|
```ruby
|
@@ -1539,7 +1595,7 @@ You should see "Hello, Date Time!"
|
|
1539
1595
|
|
1540
1596
|
#### Hello, Table!
|
1541
1597
|
|
1542
|
-
Note: This [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) sample has near-complete support, but is missing table context menus
|
1598
|
+
Note: This [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) sample has near-complete support, but is missing table context menus at the moment.
|
1543
1599
|
|
1544
1600
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
1545
1601
|
|
@@ -1738,23 +1794,28 @@ class HelloTable
|
|
1738
1794
|
text 'Game Date'
|
1739
1795
|
width 150
|
1740
1796
|
sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
|
1797
|
+
editor :date_drop_down, property: :date_time
|
1741
1798
|
}
|
1742
1799
|
table_column {
|
1743
1800
|
text 'Game Time'
|
1744
1801
|
width 150
|
1745
1802
|
sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
|
1803
|
+
editor :time, property: :date_time
|
1746
1804
|
}
|
1747
1805
|
table_column {
|
1748
1806
|
text 'Ballpark'
|
1749
1807
|
width 180
|
1808
|
+
editor :none
|
1750
1809
|
}
|
1751
1810
|
table_column {
|
1752
1811
|
text 'Home Team'
|
1753
1812
|
width 150
|
1813
|
+
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
|
1754
1814
|
}
|
1755
1815
|
table_column {
|
1756
1816
|
text 'Away Team'
|
1757
1817
|
width 150
|
1818
|
+
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
|
1758
1819
|
}
|
1759
1820
|
table_column {
|
1760
1821
|
text 'Promotion'
|
@@ -1803,6 +1864,39 @@ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObt
|
|
1803
1864
|
|
1804
1865
|
![Glimmer DSL for SWT Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table.png)
|
1805
1866
|
|
1867
|
+
Hello, Table! Editing Game Date
|
1868
|
+
|
1869
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-game-date.png)
|
1870
|
+
|
1871
|
+
Hello, Table! Editing Game Time
|
1872
|
+
|
1873
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-game-time.png)
|
1874
|
+
|
1875
|
+
Hello, Table! Editing Home Team
|
1876
|
+
|
1877
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-home-team.png)
|
1878
|
+
|
1879
|
+
Hello, Table! Sorted Game Date Ascending
|
1880
|
+
|
1881
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-sorted-game-date-ascending.png)
|
1882
|
+
|
1883
|
+
Hello, Table! Sorted Game Date Descending
|
1884
|
+
|
1885
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-sorted-game-date-descending.png)
|
1886
|
+
|
1887
|
+
Hello, Table! Playoff Type Combo
|
1888
|
+
|
1889
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-playoff-type-combo.png)
|
1890
|
+
|
1891
|
+
Hello, Table! Playoff Type Changed
|
1892
|
+
|
1893
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-playoff-type-changed.png)
|
1894
|
+
|
1895
|
+
Hello, Table! Game Booked
|
1896
|
+
|
1897
|
+
![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-game-booked.png)
|
1898
|
+
|
1899
|
+
|
1806
1900
|
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1807
1901
|
|
1808
1902
|
Start the Rails server:
|
@@ -1816,6 +1910,532 @@ You should see "Hello, Date Time!"
|
|
1816
1910
|
|
1817
1911
|
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table.png)
|
1818
1912
|
|
1913
|
+
Hello, Table! Editing Game Date
|
1914
|
+
|
1915
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-date.png)
|
1916
|
+
|
1917
|
+
Hello, Table! Editing Game Time
|
1918
|
+
|
1919
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-time.png)
|
1920
|
+
|
1921
|
+
Hello, Table! Editing Home Team
|
1922
|
+
|
1923
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-home-team.png)
|
1924
|
+
|
1925
|
+
Hello, Table! Sorted Game Date Ascending
|
1926
|
+
|
1927
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-ascending.png)
|
1928
|
+
|
1929
|
+
Hello, Table! Sorted Game Date Descending
|
1930
|
+
|
1931
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-descending.png)
|
1932
|
+
|
1933
|
+
Hello, Table! Playoff Type Combo
|
1934
|
+
|
1935
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-combo.png)
|
1936
|
+
|
1937
|
+
Hello, Table! Playoff Type Changed
|
1938
|
+
|
1939
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-changed.png)
|
1940
|
+
|
1941
|
+
Hello, Table! Game Booked
|
1942
|
+
|
1943
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-game-booked.png)
|
1944
|
+
|
1945
|
+
#### Hello, Button!
|
1946
|
+
|
1947
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
1948
|
+
|
1949
|
+
```ruby
|
1950
|
+
require 'glimmer-dsl-opal/samples/hello/hello_button'
|
1951
|
+
```
|
1952
|
+
|
1953
|
+
Or add the Glimmer code directly if you prefer to play around with it:
|
1954
|
+
|
1955
|
+
```ruby
|
1956
|
+
class HelloButton
|
1957
|
+
include Glimmer
|
1958
|
+
|
1959
|
+
attr_accessor :count
|
1960
|
+
|
1961
|
+
def initialize
|
1962
|
+
@count = 0
|
1963
|
+
end
|
1964
|
+
|
1965
|
+
def launch
|
1966
|
+
shell {
|
1967
|
+
text 'Hello, Button!'
|
1968
|
+
|
1969
|
+
button {
|
1970
|
+
text bind(self, :count) {|value| "Click To Increment: #{value} "}
|
1971
|
+
|
1972
|
+
on_widget_selected {
|
1973
|
+
self.count += 1
|
1974
|
+
}
|
1975
|
+
}
|
1976
|
+
}.open
|
1977
|
+
end
|
1978
|
+
end
|
1979
|
+
|
1980
|
+
HelloButton.new.launch
|
1981
|
+
```
|
1982
|
+
|
1983
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1984
|
+
|
1985
|
+
![Glimmer DSL for SWT Hello Button](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-button.png)
|
1986
|
+
![Glimmer DSL for SWT Hello Button](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-button-incremented.png)
|
1987
|
+
|
1988
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1989
|
+
|
1990
|
+
Start the Rails server:
|
1991
|
+
```
|
1992
|
+
rails s
|
1993
|
+
```
|
1994
|
+
|
1995
|
+
Visit `http://localhost:3000`
|
1996
|
+
|
1997
|
+
You should see "Hello, Button!"
|
1998
|
+
|
1999
|
+
![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button.png)
|
2000
|
+
![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button-incremented.png)
|
2001
|
+
|
2002
|
+
#### Hello, Message Box!
|
2003
|
+
|
2004
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2005
|
+
|
2006
|
+
```ruby
|
2007
|
+
require 'glimmer-dsl-opal/samples/hello/hello_message_box'
|
2008
|
+
```
|
2009
|
+
|
2010
|
+
Or add the Glimmer code directly if you prefer to play around with it:
|
2011
|
+
|
2012
|
+
```ruby
|
2013
|
+
include Glimmer
|
2014
|
+
|
2015
|
+
shell {
|
2016
|
+
text 'Hello, Message Box!'
|
2017
|
+
|
2018
|
+
button {
|
2019
|
+
text 'Please Click To Win a Surprise'
|
2020
|
+
|
2021
|
+
on_widget_selected {
|
2022
|
+
message_box {
|
2023
|
+
text 'Surprise'
|
2024
|
+
message "Congratulations!\n\nYou won $1,000,000!"
|
2025
|
+
}.open
|
2026
|
+
}
|
2027
|
+
}
|
2028
|
+
}.open
|
2029
|
+
```
|
2030
|
+
|
2031
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2032
|
+
|
2033
|
+
![Glimmer DSL for SWT Message Box](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-message-box.png)
|
2034
|
+
![Glimmer DSL for SWT Message Box Dialog](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-message-box-dialog.png)
|
2035
|
+
|
2036
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2037
|
+
|
2038
|
+
Start the Rails server:
|
2039
|
+
```
|
2040
|
+
rails s
|
2041
|
+
```
|
2042
|
+
|
2043
|
+
Visit `http://localhost:3000`
|
2044
|
+
|
2045
|
+
You should see "Hello, Message Box!"
|
2046
|
+
|
2047
|
+
![Glimmer DSL for Opal Hello Message Box](images/glimmer-dsl-opal-hello-message-box.png)
|
2048
|
+
![Glimmer DSL for Opal Hello Message Box Dialog](images/glimmer-dsl-opal-hello-message-box-dialog.png)
|
2049
|
+
|
2050
|
+
#### Hello, Pop Up Context Menu!
|
2051
|
+
|
2052
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2053
|
+
|
2054
|
+
```ruby
|
2055
|
+
require 'glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu'
|
2056
|
+
```
|
2057
|
+
|
2058
|
+
Or add the Glimmer code directly if you prefer to play around with it:
|
2059
|
+
|
2060
|
+
```ruby
|
2061
|
+
include Glimmer
|
2062
|
+
|
2063
|
+
shell {
|
2064
|
+
grid_layout {
|
2065
|
+
margin_width 0
|
2066
|
+
margin_height 0
|
2067
|
+
}
|
2068
|
+
|
2069
|
+
text 'Hello, Pop Up Context Menu!'
|
2070
|
+
|
2071
|
+
label {
|
2072
|
+
text "Right-Click on the Text to\nPop Up a Context Menu"
|
2073
|
+
font height: 50
|
2074
|
+
|
2075
|
+
menu {
|
2076
|
+
menu {
|
2077
|
+
text '&History'
|
2078
|
+
menu {
|
2079
|
+
text '&Recent'
|
2080
|
+
menu_item {
|
2081
|
+
text 'File 1'
|
2082
|
+
on_widget_selected {
|
2083
|
+
message_box {
|
2084
|
+
text 'File 1'
|
2085
|
+
message 'File 1 Contents'
|
2086
|
+
}.open
|
2087
|
+
}
|
2088
|
+
}
|
2089
|
+
menu_item {
|
2090
|
+
text 'File 2'
|
2091
|
+
on_widget_selected {
|
2092
|
+
message_box {
|
2093
|
+
text 'File 2'
|
2094
|
+
message 'File 2 Contents'
|
2095
|
+
}.open
|
2096
|
+
}
|
2097
|
+
}
|
2098
|
+
}
|
2099
|
+
menu {
|
2100
|
+
text '&Archived'
|
2101
|
+
menu_item {
|
2102
|
+
text 'File 3'
|
2103
|
+
on_widget_selected {
|
2104
|
+
message_box {
|
2105
|
+
text 'File 3'
|
2106
|
+
message 'File 3 Contents'
|
2107
|
+
}.open
|
2108
|
+
}
|
2109
|
+
}
|
2110
|
+
menu_item {
|
2111
|
+
text 'File 4'
|
2112
|
+
on_widget_selected {
|
2113
|
+
message_box {
|
2114
|
+
text 'File 4'
|
2115
|
+
message 'File 4 Contents'
|
2116
|
+
}.open
|
2117
|
+
}
|
2118
|
+
}
|
2119
|
+
}
|
2120
|
+
}
|
2121
|
+
}
|
2122
|
+
}
|
2123
|
+
}.open
|
2124
|
+
```
|
2125
|
+
|
2126
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2127
|
+
|
2128
|
+
![Glimmer DSL for SWT Hello Pop Up Context Menu Popped Up](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-pop-up-context-menu.png)
|
2129
|
+
![Glimmer DSL for SWT Hello Pop Up Context Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-pop-up-context-menu-popped-up.png)
|
2130
|
+
|
2131
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2132
|
+
|
2133
|
+
Start the Rails server:
|
2134
|
+
```
|
2135
|
+
rails s
|
2136
|
+
```
|
2137
|
+
|
2138
|
+
Visit `http://localhost:3000`
|
2139
|
+
|
2140
|
+
You should see "Hello, Pop Up Context Menu!"
|
2141
|
+
|
2142
|
+
![Glimmer DSL for Opal Hello Pop Up Context Menu](images/glimmer-dsl-opal-hello-pop-up-context-menu.png)
|
2143
|
+
![Glimmer DSL for Opal Hello Pop Up Context Menu Popped Up](images/glimmer-dsl-opal-hello-pop-up-context-menu-popped-up.png)
|
2144
|
+
|
2145
|
+
#### Hello, Menu Bar!
|
2146
|
+
|
2147
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2148
|
+
|
2149
|
+
```ruby
|
2150
|
+
require 'glimmer-dsl-opal/samples/hello/hello_menu_bar'
|
2151
|
+
```
|
2152
|
+
|
2153
|
+
Or add the Glimmer code directly if you prefer to play around with it:
|
2154
|
+
|
2155
|
+
```ruby
|
2156
|
+
include Glimmer
|
2157
|
+
|
2158
|
+
COLORS = [:white, :red, :yellow, :green, :blue, :magenta, :gray, :black]
|
2159
|
+
|
2160
|
+
shell {
|
2161
|
+
grid_layout {
|
2162
|
+
margin_width 0
|
2163
|
+
margin_height 0
|
2164
|
+
}
|
2165
|
+
|
2166
|
+
text 'Hello, Menu Bar!'
|
2167
|
+
|
2168
|
+
@label = label(:center) {
|
2169
|
+
font height: 50
|
2170
|
+
text 'Check Out The Menu Bar Above!'
|
2171
|
+
}
|
2172
|
+
|
2173
|
+
menu_bar {
|
2174
|
+
menu {
|
2175
|
+
text '&File'
|
2176
|
+
menu_item {
|
2177
|
+
text '&New'
|
2178
|
+
accelerator :command, :N
|
2179
|
+
|
2180
|
+
on_widget_selected {
|
2181
|
+
message_box {
|
2182
|
+
text 'New'
|
2183
|
+
message 'New file created.'
|
2184
|
+
}.open
|
2185
|
+
}
|
2186
|
+
}
|
2187
|
+
menu_item {
|
2188
|
+
text '&Open...'
|
2189
|
+
accelerator :command, :O
|
2190
|
+
|
2191
|
+
on_widget_selected {
|
2192
|
+
message_box {
|
2193
|
+
text 'Open'
|
2194
|
+
message 'Opening File...'
|
2195
|
+
}.open
|
2196
|
+
}
|
2197
|
+
}
|
2198
|
+
menu {
|
2199
|
+
text 'Open &Recent'
|
2200
|
+
menu_item {
|
2201
|
+
text 'File 1'
|
2202
|
+
on_widget_selected {
|
2203
|
+
message_box {
|
2204
|
+
text 'File 1'
|
2205
|
+
message 'File 1 Contents'
|
2206
|
+
}.open
|
2207
|
+
}
|
2208
|
+
}
|
2209
|
+
menu_item {
|
2210
|
+
text 'File 2'
|
2211
|
+
on_widget_selected {
|
2212
|
+
message_box {
|
2213
|
+
text 'File 2'
|
2214
|
+
message 'File 2 Contents'
|
2215
|
+
}.open
|
2216
|
+
}
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
menu_item(:separator)
|
2220
|
+
menu_item {
|
2221
|
+
text 'E&xit'
|
2222
|
+
|
2223
|
+
on_widget_selected {
|
2224
|
+
exit(0)
|
2225
|
+
}
|
2226
|
+
}
|
2227
|
+
}
|
2228
|
+
menu {
|
2229
|
+
text '&Edit'
|
2230
|
+
menu_item {
|
2231
|
+
text 'Cut'
|
2232
|
+
accelerator :command, :X
|
2233
|
+
}
|
2234
|
+
menu_item {
|
2235
|
+
text 'Copy'
|
2236
|
+
accelerator :command, :C
|
2237
|
+
}
|
2238
|
+
menu_item {
|
2239
|
+
text 'Paste'
|
2240
|
+
accelerator :command, :V
|
2241
|
+
}
|
2242
|
+
}
|
2243
|
+
menu {
|
2244
|
+
text '&Options'
|
2245
|
+
|
2246
|
+
menu_item(:radio) {
|
2247
|
+
text '&Enabled'
|
2248
|
+
|
2249
|
+
on_widget_selected {
|
2250
|
+
@select_one_menu.enabled = true
|
2251
|
+
@select_multiple_menu.enabled = true
|
2252
|
+
}
|
2253
|
+
}
|
2254
|
+
@select_one_menu = menu {
|
2255
|
+
text '&Select One'
|
2256
|
+
enabled false
|
2257
|
+
|
2258
|
+
menu_item(:radio) {
|
2259
|
+
text 'Option 1'
|
2260
|
+
}
|
2261
|
+
menu_item(:radio) {
|
2262
|
+
text 'Option 2'
|
2263
|
+
}
|
2264
|
+
menu_item(:radio) {
|
2265
|
+
text 'Option 3'
|
2266
|
+
}
|
2267
|
+
}
|
2268
|
+
@select_multiple_menu = menu {
|
2269
|
+
text '&Select Multiple'
|
2270
|
+
enabled false
|
2271
|
+
|
2272
|
+
menu_item(:check) {
|
2273
|
+
text 'Option 4'
|
2274
|
+
}
|
2275
|
+
menu_item(:check) {
|
2276
|
+
text 'Option 5'
|
2277
|
+
}
|
2278
|
+
menu_item(:check) {
|
2279
|
+
text 'Option 6'
|
2280
|
+
}
|
2281
|
+
}
|
2282
|
+
}
|
2283
|
+
menu {
|
2284
|
+
text '&Format'
|
2285
|
+
menu {
|
2286
|
+
text '&Background Color'
|
2287
|
+
COLORS.each { |color_style|
|
2288
|
+
menu_item(:radio) {
|
2289
|
+
text color_style.to_s.split('_').map(&:capitalize).join(' ')
|
2290
|
+
|
2291
|
+
on_widget_selected {
|
2292
|
+
@label.background = color_style
|
2293
|
+
}
|
2294
|
+
}
|
2295
|
+
}
|
2296
|
+
}
|
2297
|
+
menu {
|
2298
|
+
text 'Foreground &Color'
|
2299
|
+
COLORS.each { |color_style|
|
2300
|
+
menu_item(:radio) {
|
2301
|
+
text color_style.to_s.split('_').map(&:capitalize).join(' ')
|
2302
|
+
|
2303
|
+
on_widget_selected {
|
2304
|
+
@label.foreground = color_style
|
2305
|
+
}
|
2306
|
+
}
|
2307
|
+
}
|
2308
|
+
}
|
2309
|
+
}
|
2310
|
+
menu {
|
2311
|
+
text '&View'
|
2312
|
+
menu_item(:radio) {
|
2313
|
+
text 'Small'
|
2314
|
+
|
2315
|
+
on_widget_selected {
|
2316
|
+
@label.font = {height: 25}
|
2317
|
+
@label.parent.pack
|
2318
|
+
}
|
2319
|
+
}
|
2320
|
+
menu_item(:radio) {
|
2321
|
+
text 'Medium'
|
2322
|
+
selection true
|
2323
|
+
|
2324
|
+
on_widget_selected {
|
2325
|
+
@label.font = {height: 50}
|
2326
|
+
@label.parent.pack
|
2327
|
+
}
|
2328
|
+
}
|
2329
|
+
menu_item(:radio) {
|
2330
|
+
text 'Large'
|
2331
|
+
|
2332
|
+
on_widget_selected {
|
2333
|
+
@label.font = {height: 75}
|
2334
|
+
@label.parent.pack
|
2335
|
+
}
|
2336
|
+
}
|
2337
|
+
}
|
2338
|
+
menu {
|
2339
|
+
text '&Help'
|
2340
|
+
menu_item {
|
2341
|
+
text '&Manual'
|
2342
|
+
accelerator :command, :shift, :M
|
2343
|
+
|
2344
|
+
on_widget_selected {
|
2345
|
+
message_box {
|
2346
|
+
text 'Manual'
|
2347
|
+
message 'Manual Contents'
|
2348
|
+
}.open
|
2349
|
+
}
|
2350
|
+
}
|
2351
|
+
menu_item {
|
2352
|
+
text '&Tutorial'
|
2353
|
+
accelerator :command, :shift, :T
|
2354
|
+
|
2355
|
+
on_widget_selected {
|
2356
|
+
message_box {
|
2357
|
+
text 'Tutorial'
|
2358
|
+
message 'Tutorial Contents'
|
2359
|
+
}.open
|
2360
|
+
}
|
2361
|
+
}
|
2362
|
+
menu_item(:separator)
|
2363
|
+
menu_item {
|
2364
|
+
text '&Report an Issue...'
|
2365
|
+
|
2366
|
+
on_widget_selected {
|
2367
|
+
message_box {
|
2368
|
+
text 'Report an Issue'
|
2369
|
+
message 'Reporting an issue...'
|
2370
|
+
}.open
|
2371
|
+
}
|
2372
|
+
}
|
2373
|
+
}
|
2374
|
+
}
|
2375
|
+
}.open
|
2376
|
+
```
|
2377
|
+
|
2378
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2379
|
+
|
2380
|
+
![Hello Menu Bar](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar.png)
|
2381
|
+
|
2382
|
+
![Hello Menu Bar File Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-file-menu.png)
|
2383
|
+
|
2384
|
+
![Hello Menu Bar Edit Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-edit-menu.png)
|
2385
|
+
|
2386
|
+
![Hello Menu Bar Options Menu Disabled](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-options-menu-disabled.png)
|
2387
|
+
|
2388
|
+
![Hello Menu Bar Options Menu Select One](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-options-menu-select-one.png)
|
2389
|
+
|
2390
|
+
![Hello Menu Bar Options Menu Select Multiple](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-options-menu-select-multiple.png)
|
2391
|
+
|
2392
|
+
![Hello Menu Bar Format Menu Background Color](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-format-menu-background-color.png)
|
2393
|
+
|
2394
|
+
![Hello Menu Bar Format Menu Foreground Color](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-format-menu-foreground-color.png)
|
2395
|
+
|
2396
|
+
![Hello Menu Bar View Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-menu.png)
|
2397
|
+
|
2398
|
+
![Hello Menu Bar View Small](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-small.png)
|
2399
|
+
|
2400
|
+
![Hello Menu Bar View Large](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-large.png)
|
2401
|
+
|
2402
|
+
![Hello Menu Bar Help Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-help-menu.png)
|
2403
|
+
|
2404
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2405
|
+
|
2406
|
+
Start the Rails server:
|
2407
|
+
```
|
2408
|
+
rails s
|
2409
|
+
```
|
2410
|
+
|
2411
|
+
Visit `http://localhost:3000`
|
2412
|
+
|
2413
|
+
You should see "Hello, Menu Bar!"
|
2414
|
+
|
2415
|
+
![Hello Menu Bar](images/glimmer-dsl-opal-hello-menu-bar.png)
|
2416
|
+
|
2417
|
+
![Hello Menu Bar File Menu](images/glimmer-dsl-opal-hello-menu-bar-file-menu.png)
|
2418
|
+
|
2419
|
+
![Hello Menu Bar Edit Menu](images/glimmer-dsl-opal-hello-menu-bar-edit-menu.png)
|
2420
|
+
|
2421
|
+
![Hello Menu Bar Options Menu Disabled](images/glimmer-dsl-opal-hello-menu-bar-options-menu-disabled.png)
|
2422
|
+
|
2423
|
+
![Hello Menu Bar Options Menu Select One](images/glimmer-dsl-opal-hello-menu-bar-options-menu-select-one.png)
|
2424
|
+
|
2425
|
+
![Hello Menu Bar Options Menu Select Multiple](images/glimmer-dsl-opal-hello-menu-bar-options-menu-select-multiple.png)
|
2426
|
+
|
2427
|
+
![Hello Menu Bar Format Menu Background Color](images/glimmer-dsl-opal-hello-menu-bar-format-menu-background-color.png)
|
2428
|
+
|
2429
|
+
![Hello Menu Bar Format Menu Foreground Color](images/glimmer-dsl-opal-hello-menu-bar-format-menu-foreground-color.png)
|
2430
|
+
|
2431
|
+
![Hello Menu Bar View Menu](images/glimmer-dsl-opal-hello-menu-bar-view-menu.png)
|
2432
|
+
|
2433
|
+
![Hello Menu Bar View Small](images/glimmer-dsl-opal-hello-menu-bar-view-small.png)
|
2434
|
+
|
2435
|
+
![Hello Menu Bar View Large](images/glimmer-dsl-opal-hello-menu-bar-view-large.png)
|
2436
|
+
|
2437
|
+
![Hello Menu Bar Help Menu](images/glimmer-dsl-opal-hello-menu-bar-help-menu.png)
|
2438
|
+
|
1819
2439
|
### Elaborate Samples
|
1820
2440
|
|
1821
2441
|
#### Login
|
@@ -1831,7 +2451,6 @@ Or add the Glimmer code directly if you prefer to play around with it:
|
|
1831
2451
|
```ruby
|
1832
2452
|
require "observer"
|
1833
2453
|
|
1834
|
-
#Presents login screen data
|
1835
2454
|
class LoginPresenter
|
1836
2455
|
|
1837
2456
|
attr_accessor :user_name
|
@@ -1847,10 +2466,13 @@ class LoginPresenter
|
|
1847
2466
|
def status=(status)
|
1848
2467
|
@status = status
|
1849
2468
|
|
1850
|
-
#TODO add feature to bind dependent properties to master property (2017-07-25 nested data binding)
|
1851
2469
|
notify_observers("logged_in")
|
1852
2470
|
notify_observers("logged_out")
|
1853
2471
|
end
|
2472
|
+
|
2473
|
+
def valid?
|
2474
|
+
!@user_name.to_s.strip.empty? && !@password.to_s.strip.empty?
|
2475
|
+
end
|
1854
2476
|
|
1855
2477
|
def logged_in
|
1856
2478
|
self.status == "Logged In"
|
@@ -1861,6 +2483,7 @@ class LoginPresenter
|
|
1861
2483
|
end
|
1862
2484
|
|
1863
2485
|
def login
|
2486
|
+
return unless valid?
|
1864
2487
|
self.status = "Logged In"
|
1865
2488
|
end
|
1866
2489
|
|
@@ -1872,7 +2495,6 @@ class LoginPresenter
|
|
1872
2495
|
|
1873
2496
|
end
|
1874
2497
|
|
1875
|
-
#Login screen
|
1876
2498
|
class Login
|
1877
2499
|
include Glimmer
|
1878
2500
|
|
@@ -1884,15 +2506,21 @@ class Login
|
|
1884
2506
|
grid_layout 2, false #two columns with differing widths
|
1885
2507
|
|
1886
2508
|
label { text "Username:" } # goes in column 1
|
1887
|
-
text {
|
2509
|
+
@user_name_text = text { # goes in column 2
|
1888
2510
|
text bind(presenter, :user_name)
|
1889
2511
|
enabled bind(presenter, :logged_out)
|
2512
|
+
on_key_pressed { |event|
|
2513
|
+
@password_text.set_focus if event.keyCode == swt(:cr)
|
2514
|
+
}
|
1890
2515
|
}
|
1891
2516
|
|
1892
2517
|
label { text "Password:" }
|
1893
|
-
text(:password, :border) {
|
2518
|
+
@password_text = text(:password, :border) {
|
1894
2519
|
text bind(presenter, :password)
|
1895
2520
|
enabled bind(presenter, :logged_out)
|
2521
|
+
on_key_pressed { |event|
|
2522
|
+
presenter.login if event.keyCode == swt(:cr)
|
2523
|
+
}
|
1896
2524
|
}
|
1897
2525
|
|
1898
2526
|
label { text "Status:" }
|
@@ -1902,12 +2530,21 @@ class Login
|
|
1902
2530
|
text "Login"
|
1903
2531
|
enabled bind(presenter, :logged_out)
|
1904
2532
|
on_widget_selected { presenter.login }
|
2533
|
+
on_key_pressed { |event|
|
2534
|
+
presenter.login if event.keyCode == swt(:cr)
|
2535
|
+
}
|
1905
2536
|
}
|
1906
2537
|
|
1907
2538
|
button {
|
1908
2539
|
text "Logout"
|
1909
2540
|
enabled bind(presenter, :logged_in)
|
1910
2541
|
on_widget_selected { presenter.logout }
|
2542
|
+
on_key_pressed { |event|
|
2543
|
+
if event.keyCode == swt(:cr)
|
2544
|
+
presenter.logout
|
2545
|
+
@user_name_text.set_focus
|
2546
|
+
end
|
2547
|
+
}
|
1911
2548
|
}
|
1912
2549
|
}
|
1913
2550
|
}
|
@@ -2390,41 +3027,76 @@ class ContactManager
|
|
2390
3027
|
shell {
|
2391
3028
|
text "Contact Manager"
|
2392
3029
|
composite {
|
2393
|
-
|
2394
|
-
grid_layout
|
2395
|
-
|
3030
|
+
group {
|
3031
|
+
grid_layout(2, false) {
|
3032
|
+
margin_width 0
|
3033
|
+
margin_height 0
|
3034
|
+
}
|
3035
|
+
layout_data :fill, :center, true, false
|
3036
|
+
text 'Lookup Contacts'
|
3037
|
+
font height: 24
|
3038
|
+
|
3039
|
+
label {
|
3040
|
+
layout_data :right, :center, false, false
|
3041
|
+
text "First &Name: "
|
3042
|
+
font height: 16
|
3043
|
+
}
|
2396
3044
|
text {
|
3045
|
+
layout_data :fill, :center, true, false
|
2397
3046
|
text bind(@contact_manager_presenter, :first_name)
|
2398
3047
|
on_key_pressed {|key_event|
|
2399
|
-
@contact_manager_presenter.find if key_event.keyCode ==
|
3048
|
+
@contact_manager_presenter.find if key_event.keyCode == swt(:cr)
|
2400
3049
|
}
|
2401
3050
|
}
|
2402
|
-
|
3051
|
+
|
3052
|
+
label {
|
3053
|
+
layout_data :right, :center, false, false
|
3054
|
+
text "&Last Name: "
|
3055
|
+
font height: 16
|
3056
|
+
}
|
2403
3057
|
text {
|
3058
|
+
layout_data :fill, :center, true, false
|
2404
3059
|
text bind(@contact_manager_presenter, :last_name)
|
2405
3060
|
on_key_pressed {|key_event|
|
2406
|
-
@contact_manager_presenter.find if key_event.keyCode ==
|
3061
|
+
@contact_manager_presenter.find if key_event.keyCode == swt(:cr)
|
2407
3062
|
}
|
2408
3063
|
}
|
2409
|
-
|
3064
|
+
|
3065
|
+
label {
|
3066
|
+
layout_data :right, :center, false, false
|
3067
|
+
text "&Email: "
|
3068
|
+
font height: 16
|
3069
|
+
}
|
2410
3070
|
text {
|
3071
|
+
layout_data :fill, :center, true, false
|
2411
3072
|
text bind(@contact_manager_presenter, :email)
|
2412
3073
|
on_key_pressed {|key_event|
|
2413
|
-
@contact_manager_presenter.find if key_event.keyCode ==
|
3074
|
+
@contact_manager_presenter.find if key_event.keyCode == swt(:cr)
|
2414
3075
|
}
|
2415
3076
|
}
|
3077
|
+
|
2416
3078
|
composite {
|
2417
|
-
|
3079
|
+
row_layout {
|
3080
|
+
margin_width 0
|
3081
|
+
margin_height 0
|
3082
|
+
}
|
3083
|
+
layout_data(:right, :center, false, false) {
|
3084
|
+
horizontal_span 2
|
3085
|
+
}
|
3086
|
+
|
2418
3087
|
button {
|
2419
3088
|
text "&Find"
|
2420
|
-
on_widget_selected {
|
2421
|
-
|
3089
|
+
on_widget_selected { @contact_manager_presenter.find }
|
3090
|
+
on_key_pressed {|key_event|
|
3091
|
+
@contact_manager_presenter.find if key_event.keyCode == swt(:cr)
|
2422
3092
|
}
|
2423
3093
|
}
|
3094
|
+
|
2424
3095
|
button {
|
2425
3096
|
text "&List All"
|
2426
|
-
on_widget_selected {
|
2427
|
-
|
3097
|
+
on_widget_selected { @contact_manager_presenter.list }
|
3098
|
+
on_key_pressed {|key_event|
|
3099
|
+
@contact_manager_presenter.list if key_event.keyCode == swt(:cr)
|
2428
3100
|
}
|
2429
3101
|
}
|
2430
3102
|
}
|
@@ -2441,26 +3113,18 @@ class ContactManager
|
|
2441
3113
|
table_column {
|
2442
3114
|
text "First Name"
|
2443
3115
|
width 80
|
2444
|
-
on_widget_selected {
|
2445
|
-
@contact_manager_presenter.toggle_sort(:first_name)
|
2446
|
-
}
|
2447
3116
|
}
|
2448
3117
|
table_column {
|
2449
3118
|
text "Last Name"
|
2450
3119
|
width 80
|
2451
|
-
on_widget_selected {
|
2452
|
-
@contact_manager_presenter.toggle_sort(:last_name)
|
2453
|
-
}
|
2454
3120
|
}
|
2455
3121
|
table_column {
|
2456
3122
|
text "Email"
|
2457
3123
|
width 200
|
2458
|
-
on_widget_selected {
|
2459
|
-
@contact_manager_presenter.toggle_sort(:email)
|
2460
|
-
}
|
2461
3124
|
}
|
2462
|
-
items bind(@contact_manager_presenter, :results),
|
2463
|
-
|
3125
|
+
items bind(@contact_manager_presenter, :results),
|
3126
|
+
column_properties(:first_name, :last_name, :email)
|
3127
|
+
on_mouse_up { |event|
|
2464
3128
|
table_proxy.edit_table_item(event.table_item, event.column_index)
|
2465
3129
|
}
|
2466
3130
|
}
|
@@ -2470,7 +3134,6 @@ class ContactManager
|
|
2470
3134
|
end
|
2471
3135
|
|
2472
3136
|
ContactManager.new.launch
|
2473
|
-
|
2474
3137
|
```
|
2475
3138
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2476
3139
|
|