glimmer-dsl-opal 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +290 -53
  4. data/VERSION +1 -1
  5. data/lib/display.rb +31 -0
  6. data/lib/file.rb +29 -0
  7. data/lib/glimmer-dsl-opal.rb +30 -1
  8. data/lib/glimmer-dsl-opal/ext/date.rb +1 -1
  9. data/lib/glimmer-dsl-opal/ext/struct.rb +37 -0
  10. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
  11. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +1 -1
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +46 -0
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +7 -7
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +5 -5
  16. data/lib/glimmer-dsl-swt.rb +20 -35
  17. data/lib/glimmer/data_binding/table_items_binding.rb +6 -4
  18. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -0
  19. data/lib/glimmer/dsl/opal/widget_expression.rb +6 -2
  20. data/lib/glimmer/swt/combo_proxy.rb +40 -1
  21. data/lib/glimmer/swt/composite_proxy.rb +5 -1
  22. data/lib/glimmer/swt/control_editor.rb +54 -0
  23. data/lib/glimmer/swt/date_time_proxy.rb +66 -1
  24. data/lib/glimmer/swt/font_proxy.rb +4 -4
  25. data/lib/glimmer/swt/grid_layout_proxy.rb +20 -12
  26. data/lib/glimmer/swt/label_proxy.rb +11 -3
  27. data/lib/glimmer/swt/layout_data_proxy.rb +10 -7
  28. data/lib/glimmer/swt/layout_proxy.rb +1 -1
  29. data/lib/glimmer/swt/message_box_proxy.rb +2 -10
  30. data/lib/glimmer/swt/table_column_proxy.rb +9 -0
  31. data/lib/glimmer/swt/table_editor.rb +65 -0
  32. data/lib/glimmer/swt/table_item_proxy.rb +36 -0
  33. data/lib/glimmer/swt/table_proxy.rb +375 -17
  34. data/lib/glimmer/swt/text_proxy.rb +1 -1
  35. data/lib/glimmer/swt/widget_proxy.rb +99 -21
  36. data/lib/glimmer/ui/custom_shell.rb +9 -7
  37. data/lib/os.rb +36 -0
  38. metadata +25 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15339e6707f761011f074d030dc58a41733c3ea249da444745c1c6696ab90468
4
- data.tar.gz: 440722c63a85a92c02dac9a0955bcb5b26d620be1338727521674d63a3d5c9b6
3
+ metadata.gz: c18e541c8e9442edb881c4a2209b920ec5891c770901cd4474d93875d6a9d785
4
+ data.tar.gz: aadee7ddedd9a598e32784105d408b619c8503ef7aeb58d18253d1a505115e8a
5
5
  SHA512:
6
- metadata.gz: 7daddcebb68f6d612c011f2d99c3af01073f3740a3fb82bd9a4a1bd96c748db358c61c6d3ad1502aa23f5061fb8041921c680a729bf39d0fa971cfa55059e4d7
7
- data.tar.gz: 15cea650eacfb8dbb05dc4892754b160cd0ad5ec0d5e5c0a5c87636e1fbc69f43d9a3fcc250edd3c9febc2bae1ab0a3ecf9fe47f295363de9b13cc47e86debc3
6
+ metadata.gz: 3d0efad3abf372c53a9f214fe6e9ad2a9b4a4f18413acded585411742f1eb0fdd3dff3939bb2e64e905f55c59c5c0c686e7715fd2f01ed70c7f6a4005e67ac3a
7
+ data.tar.gz: 247c8c74ca777009bee85b89eb8ba137d5a389a55cb6f845f70d49b6b331184e625196c9dd1b07797730bc1c853ba87f7eae437356ef2e56fa26240854d5c706
@@ -1,5 +1,45 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.5
4
+
5
+ - Update login sample from Glimmer DSL for SWT's latest changes
6
+ - Update contact_manager sample from Glimmer DSL for SWT's latest changes
7
+ - Fixed issue regarding unavailable localStorage data when accessed by custom_widget_expression in hello_checkbox_group, hello_radio_group, and hello_custom_widget
8
+
9
+ ## 0.7.4
10
+
11
+ - Hello, Button! Sample
12
+ - Fix issue with aligning label as :left, :center, or :right via style style when fill_layout is used
13
+ - Fix Hello, Browser sample by accessing https ssl website
14
+ - Fix issue with filling space horizontally when using grid layout
15
+ - Fix broken embedded `calendar` widget data-binding for hello_date_time.rb sample
16
+ - Fix broken message_box after opening multiple shells
17
+ - Fix issue with opening custom shells in new tabs/windows when CustomShell subclass is required conditionally
18
+
19
+ ## 0.7.3
20
+
21
+ - Refactor to use to_collection gem
22
+ - Fix issue with breaking `date`/`date_drop_down` data-binding as table editor on focus lost
23
+ - Fix issue with requiring OS, File, and Display class after they've been extracted out
24
+
25
+ ## 0.7.2
26
+
27
+ - `date_drop_down` `table_column` `editor`
28
+ - `date` `table_column` `editor`
29
+ - `time` `table_column` `editor`
30
+ - Implement `on_focus_gained`, `on_focus_lost` universally on all widgets
31
+ - Add support for Struct keyword_init to Opal
32
+ - Fix issue with hello_table button/combo not being centered (yet stretched)
33
+ - Fix issue with table item selection for booking not working after editing has been added
34
+ - Fix escape keyboard event handling for combo table editor
35
+
36
+ ## 0.7.1
37
+
38
+ - Combo table editor (enabled in Hello, Table! sample)
39
+ - Fix issue with table cell selection for editing not working
40
+ - Remove widget from parent upon dispose
41
+ - Remove listeners upon widget dispose
42
+
3
43
  ## 0.7.0
4
44
 
5
45
  - Hello, Table! Sample
@@ -127,3 +167,4 @@
127
167
 
128
168
  - Initial support for webifying Glimmer SWT apps
129
169
  - Support for Shell and Label widgets (text property only).
170
+ - Hello, World! sample support
data/README.md CHANGED
@@ -1,20 +1,66 @@
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.7.0 (Pure Ruby Web GUI)
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.7.5 (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.
11
- - **Adapter:** Auto-webify [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps (i.e. apps built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)) via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/) without changing a line of code. Apps may then be custom-styled by web designers for the web with standard CSS.
11
+ - **Adapter:** auto-webify [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps (i.e. apps built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)) via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/) without changing a line of code. Just insert them as a single require statement in a Rails app, and BOOM! They're running on the web! Apps may then optionally be custom-styled for the web by web designers with standard CSS if needed.
12
12
 
13
13
  Glimmer DSL for Opal successfully reuses the entire [Glimmer](https://github.com/AndyObtiva/glimmer) core DSL engine in [Opal Ruby](https://opalrb.com/) inside a web browser, and as such inherits the full range of powerful Glimmer desktop [data-binding](https://github.com/AndyObtiva/glimmer#data-binding) capabilities for the web.
14
14
 
15
- NOTE: Alpha Version 0.7.0 only supports bare-minimum capabilities for the following [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) [samples](https://github.com/AndyObtiva/glimmer#samples):
15
+ #### Tic Tac Toe Sample
16
16
 
17
- Hello:
17
+ Add the following require statement to `app/assets/javascripts/application.rb` in a [Glimmer setup](#setup) Rails app:
18
+
19
+ ```ruby
20
+ require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
21
+ ```
22
+
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
+
25
+ ```ruby
26
+ # ...
27
+ @shell = shell {
28
+ text "Tic-Tac-Toe"
29
+ minimum_size 150, 178
30
+ composite {
31
+ grid_layout 3, true
32
+ (1..3).each { |row|
33
+ (1..3).each { |column|
34
+ button {
35
+ layout_data :fill, :fill, true, true
36
+ text bind(@tic_tac_toe_board[row, column], :sign)
37
+ enabled bind(@tic_tac_toe_board[row, column], :empty)
38
+ font style: :bold, height: 20
39
+ on_widget_selected {
40
+ @tic_tac_toe_board.mark(row, column)
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ # ...
48
+ ```
49
+ Tic Tac Toe on the web (using the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem):
50
+
51
+ ![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
52
+ ![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
53
+ ![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
54
+
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
+
57
+ ![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
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
+ ![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
+
61
+ NOTE: **Alpha Version** 0.7.5 only supports bare-minimum capabilities for the following [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally made for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)):
62
+
63
+ [Hello samples](#hello-samples):
18
64
 
19
65
  - [Hello, World!](#hello-world)
20
66
  - [Hello, Combo!](#hello-combo)
@@ -32,8 +78,9 @@ Hello:
32
78
  - [Hello, Checkbox Group!](#hello-checkbox-group)
33
79
  - [Hello, Date Time!](#hello-date-time)
34
80
  - [Hello, Table!](#hello-table)
81
+ - [Hello, Button!](#hello-button)
35
82
 
36
- Elaborate:
83
+ [Elaborate samples](#elaborate-samples):
37
84
 
38
85
  - [Login](#login)
39
86
  - [Tic Tac Toe](#tic-tac-toe)
@@ -49,16 +96,6 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
49
96
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
50
97
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
51
98
 
52
- ## Background
53
-
54
- 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 GUI DSL is very simple in Glimmer DSL for SWT. Once 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).
55
-
56
- Part of the idea is that web browsers just render GUI widgets similar to those of a desktop app (after all a web browser is a desktop app), so whether you run your GUI on the desktop or on the web should just be a low-level concern, hopefully automated completely with Glimmer DSL for Opal.
57
-
58
- Last but not least, you would likely want some special branding on the web, so you can push that off to a web designer who would be more than happy to do the web graphic design and customize the look and feel with pure CSS (no need for programming with Ruby or JavaScript). This enables a clean separation of concerns and distribution of tasks among developers and designers, let alone saving effort on the web GUI by reusing the desktop GUI as a base right off the bat.
59
-
60
- Alternatively, web developers may directly use [Glimmer DSL for Opal](https://rubygems.org/gems/glimmer-dsl-opal) to build the GUI of web apps since it is as simple as desktop development, thus requiring a lot less code that is in pure Ruby only (as demonstrated in examples below) and avoiding opaque web concepts like 'render' and 'reactive' due to treating GUI as persistent just like desktop apps do. No HTML/JS/CSS skills are even required. Still, web designers may be involved with CSS only if needed, thanks to the clean semantic markup [Glimmer DSL for Opal](https://rubygems.org/gems/glimmer-dsl-opal) produces.
61
-
62
99
  ## Supported Glimmer DSL Keywords
63
100
 
64
101
  The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have partial support in Opal:
@@ -99,6 +136,23 @@ Event loop:
99
136
  - `display`
100
137
  - `async_exec`
101
138
 
139
+ ## Principles
140
+
141
+ - **Live purely in Rubyland via the Glimmer GUI DSL**, completely oblivious to web browser technologies.
142
+ - **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.
143
+ - **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 (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. Web designers may also style Glimmer DSL for Opal applications since they auto-generate symantic markup. That way, Glimmer web GUI is used and embedded in web pages that provide users with applications while the rest of the web pages are maintained by non-engineers. This achieves a correct separation of responsibilities and better productivity and maintainability.
144
+ - **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.
145
+
146
+ ## Background
147
+
148
+ 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.
149
+
150
+ Part of the idea is that web browsers just render GUI widgets similar to those of a desktop app (after all a web browser is a desktop app), so whether you run your GUI on the desktop or on the web should just be a low-level concern, hopefully automated completely with Glimmer DSL for Opal.
151
+
152
+ Last but not least, you would likely want some special branding on the web, so you can push that off to a web designer who would be more than happy to do the web graphic design and customize the look and feel with pure CSS (no need for programming with Ruby or JavaScript). This enables a clean separation of concerns and distribution of tasks among developers and designers, let alone saving effort on the web GUI by reusing the desktop GUI as a base right off the bat.
153
+
154
+ Alternatively, web developers may directly use [Glimmer DSL for Opal](https://rubygems.org/gems/glimmer-dsl-opal) to build the GUI of web apps since it is as simple as desktop development, thus requiring a lot less code that is in pure Ruby only (as demonstrated in examples below) and avoiding opaque web concepts like 'render' and 'reactive' due to treating GUI as persistent just like desktop apps do. No HTML/JS/CSS skills are even required. Still, web designers may be involved with CSS only if needed, thanks to the clean semantic markup [Glimmer DSL for Opal](https://rubygems.org/gems/glimmer-dsl-opal) automatically produces.
155
+
102
156
  ## Pre-requisites
103
157
 
104
158
  - Rails 5: [https://github.com/rails/rails/tree/5-2-stable](https://github.com/rails/rails/tree/5-2-stable)
@@ -109,7 +163,7 @@ Event loop:
109
163
 
110
164
  ## Setup
111
165
 
112
- (NOTE: if you run into issues, keep in mind this is a very early experimental and incomplete alpha. Also, there is a slight chance any issues you encounter are fixed in master or some other branch that you could check out instead)
166
+ (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)
113
167
 
114
168
  The [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem is a Rails Engine gem that includes assets.
115
169
 
@@ -133,7 +187,7 @@ Add the following to `Gemfile`:
133
187
  gem 'opal-rails', '~> 1.1.2'
134
188
  gem 'opal-async', '~> 1.2.0'
135
189
  gem 'opal-jquery', '~> 0.4.4'
136
- gem 'glimmer-dsl-opal', '~> 0.7.0'
190
+ gem 'glimmer-dsl-opal', '~> 0.7.5'
137
191
  gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
138
192
  gem 'glimmer-dsl-css', '~> 1.1.0', require: false
139
193
 
@@ -170,7 +224,9 @@ Edit `app/views/layouts/application.html.erb` and add the following below other
170
224
  <%= stylesheet_link_tag 'glimmer/glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
171
225
  ```
172
226
 
173
- Open a `Document.ready?` block and add inside it Glimmer GUI DSL code or a require statement for one of the samples below.
227
+ Clear the file `app/views/welcomes/index.html.erb` from any content.
228
+
229
+ Open `app/assets/javascripts/application.rb`, add a `Document.ready?` block, and add inside it Glimmer GUI DSL code or a require statement for one of the samples below.
174
230
 
175
231
  ```ruby
176
232
  Document.ready? do
@@ -200,11 +256,17 @@ end
200
256
 
201
257
  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)
202
258
 
203
- Also, this external sample app contains all the samples mentioned below configured inside a Rails 5 [Opal](https://opalrb.com/) app with all the pre-requisites ready to go for convenience:
259
+ The [Hello samples](#hello-samples) demonstrate tiny building blocks for building full fledged applications. The [Elaborate samples](#elaborate-samples) demonstrate more advanced sample applications that assemble multiple building blocks.
260
+
261
+ 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:
262
+
263
+ [https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails-app](https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails-app)
204
264
 
205
- [https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails5-app](https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails5-app)
265
+ You may visit a Heroku hosted version at:
206
266
 
207
- 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).
267
+ https://sample-glimmer-dsl-opal-app.herokuapp.com/
268
+
269
+ 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).
208
270
 
209
271
  ### Hello Samples
210
272
 
@@ -761,6 +823,10 @@ You should see "Hello, Custom Widget!"
761
823
 
762
824
  #### Hello, Custom Shell!
763
825
 
826
+ This sample demonstrates Glimmer DSL for Opal's ability to open multiple shells (windows) as web browser tabs.
827
+
828
+ It automatically handles routing so that tab URLs are bookmarkable. Web developers do not have to do any routing configuration manually.
829
+
764
830
  Add the following require statement to `app/assets/javascripts/application.rb`
765
831
 
766
832
  ```ruby
@@ -1491,7 +1557,7 @@ You should see "Hello, Date Time!"
1491
1557
 
1492
1558
  #### Hello, Table!
1493
1559
 
1494
- Note: This [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) sample has near-complete support, but is missing table context menus and table editing at the moment.
1560
+ 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.
1495
1561
 
1496
1562
  Add the following require statement to `app/assets/javascripts/application.rb`
1497
1563
 
@@ -1690,23 +1756,28 @@ class HelloTable
1690
1756
  text 'Game Date'
1691
1757
  width 150
1692
1758
  sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
1759
+ editor :date_drop_down, property: :date_time
1693
1760
  }
1694
1761
  table_column {
1695
1762
  text 'Game Time'
1696
1763
  width 150
1697
1764
  sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
1765
+ editor :time, property: :date_time
1698
1766
  }
1699
1767
  table_column {
1700
1768
  text 'Ballpark'
1701
1769
  width 180
1770
+ editor :none
1702
1771
  }
1703
1772
  table_column {
1704
1773
  text 'Home Team'
1705
1774
  width 150
1775
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
1706
1776
  }
1707
1777
  table_column {
1708
1778
  text 'Away Team'
1709
1779
  width 150
1780
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
1710
1781
  }
1711
1782
  table_column {
1712
1783
  text 'Promotion'
@@ -1755,6 +1826,39 @@ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObt
1755
1826
 
1756
1827
  ![Glimmer DSL for SWT Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table.png)
1757
1828
 
1829
+ Hello, Table! Editing Game Date
1830
+
1831
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-game-date.png)
1832
+
1833
+ Hello, Table! Editing Game Time
1834
+
1835
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-game-time.png)
1836
+
1837
+ Hello, Table! Editing Home Team
1838
+
1839
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-home-team.png)
1840
+
1841
+ Hello, Table! Sorted Game Date Ascending
1842
+
1843
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-sorted-game-date-ascending.png)
1844
+
1845
+ Hello, Table! Sorted Game Date Descending
1846
+
1847
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-sorted-game-date-descending.png)
1848
+
1849
+ Hello, Table! Playoff Type Combo
1850
+
1851
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-playoff-type-combo.png)
1852
+
1853
+ Hello, Table! Playoff Type Changed
1854
+
1855
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-playoff-type-changed.png)
1856
+
1857
+ Hello, Table! Game Booked
1858
+
1859
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-game-booked.png)
1860
+
1861
+
1758
1862
  Glimmer app on the web (using `glimmer-dsl-opal` gem):
1759
1863
 
1760
1864
  Start the Rails server:
@@ -1768,6 +1872,96 @@ You should see "Hello, Date Time!"
1768
1872
 
1769
1873
  ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table.png)
1770
1874
 
1875
+ Hello, Table! Editing Game Date
1876
+
1877
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-date.png)
1878
+
1879
+ Hello, Table! Editing Game Time
1880
+
1881
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-time.png)
1882
+
1883
+ Hello, Table! Editing Home Team
1884
+
1885
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-home-team.png)
1886
+
1887
+ Hello, Table! Sorted Game Date Ascending
1888
+
1889
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-ascending.png)
1890
+
1891
+ Hello, Table! Sorted Game Date Descending
1892
+
1893
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-descending.png)
1894
+
1895
+ Hello, Table! Playoff Type Combo
1896
+
1897
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-combo.png)
1898
+
1899
+ Hello, Table! Playoff Type Changed
1900
+
1901
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-changed.png)
1902
+
1903
+ Hello, Table! Game Booked
1904
+
1905
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-game-booked.png)
1906
+
1907
+ #### Hello, Button!
1908
+
1909
+ Add the following require statement to `app/assets/javascripts/application.rb`
1910
+
1911
+ ```ruby
1912
+ require 'glimmer-dsl-opal/samples/hello/hello_button'
1913
+ ```
1914
+
1915
+ Or add the Glimmer code directly if you prefer to play around with it:
1916
+
1917
+ ```ruby
1918
+ class HelloButton
1919
+ include Glimmer
1920
+
1921
+ attr_accessor :count
1922
+
1923
+ def initialize
1924
+ @count = 0
1925
+ end
1926
+
1927
+ def launch
1928
+ shell {
1929
+ text 'Hello, Button!'
1930
+
1931
+ button {
1932
+ text bind(self, :count) {|value| "Click To Increment: #{value} "}
1933
+
1934
+ on_widget_selected {
1935
+ self.count += 1
1936
+ }
1937
+ }
1938
+ }.open
1939
+ end
1940
+ end
1941
+
1942
+ HelloButton.new.launch
1943
+ ```
1944
+
1945
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1946
+
1947
+ ![Glimmer DSL for SWT Hello Button](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-button.png)
1948
+ ![Glimmer DSL for SWT Hello Button](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-button-incremented.png)
1949
+
1950
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1951
+
1952
+ Start the Rails server:
1953
+ ```
1954
+ rails s
1955
+ ```
1956
+
1957
+ Visit `http://localhost:3000`
1958
+
1959
+ You should see "Hello, Button!"
1960
+
1961
+ ![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button.png)
1962
+ ![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button-incremented.png)
1963
+
1964
+
1771
1965
  ### Elaborate Samples
1772
1966
 
1773
1967
  #### Login
@@ -1783,7 +1977,6 @@ Or add the Glimmer code directly if you prefer to play around with it:
1783
1977
  ```ruby
1784
1978
  require "observer"
1785
1979
 
1786
- #Presents login screen data
1787
1980
  class LoginPresenter
1788
1981
 
1789
1982
  attr_accessor :user_name
@@ -1799,10 +1992,13 @@ class LoginPresenter
1799
1992
  def status=(status)
1800
1993
  @status = status
1801
1994
 
1802
- #TODO add feature to bind dependent properties to master property (2017-07-25 nested data binding)
1803
1995
  notify_observers("logged_in")
1804
1996
  notify_observers("logged_out")
1805
1997
  end
1998
+
1999
+ def valid?
2000
+ !@user_name.to_s.strip.empty? && !@password.to_s.strip.empty?
2001
+ end
1806
2002
 
1807
2003
  def logged_in
1808
2004
  self.status == "Logged In"
@@ -1813,6 +2009,7 @@ class LoginPresenter
1813
2009
  end
1814
2010
 
1815
2011
  def login
2012
+ return unless valid?
1816
2013
  self.status = "Logged In"
1817
2014
  end
1818
2015
 
@@ -1824,7 +2021,6 @@ class LoginPresenter
1824
2021
 
1825
2022
  end
1826
2023
 
1827
- #Login screen
1828
2024
  class Login
1829
2025
  include Glimmer
1830
2026
 
@@ -1836,15 +2032,21 @@ class Login
1836
2032
  grid_layout 2, false #two columns with differing widths
1837
2033
 
1838
2034
  label { text "Username:" } # goes in column 1
1839
- text { # goes in column 2
2035
+ @user_name_text = text { # goes in column 2
1840
2036
  text bind(presenter, :user_name)
1841
2037
  enabled bind(presenter, :logged_out)
2038
+ on_key_pressed { |event|
2039
+ @password_text.set_focus if event.keyCode == swt(:cr)
2040
+ }
1842
2041
  }
1843
2042
 
1844
2043
  label { text "Password:" }
1845
- text(:password, :border) {
2044
+ @password_text = text(:password, :border) {
1846
2045
  text bind(presenter, :password)
1847
2046
  enabled bind(presenter, :logged_out)
2047
+ on_key_pressed { |event|
2048
+ presenter.login if event.keyCode == swt(:cr)
2049
+ }
1848
2050
  }
1849
2051
 
1850
2052
  label { text "Status:" }
@@ -1854,12 +2056,21 @@ class Login
1854
2056
  text "Login"
1855
2057
  enabled bind(presenter, :logged_out)
1856
2058
  on_widget_selected { presenter.login }
2059
+ on_key_pressed { |event|
2060
+ presenter.login if event.keyCode == swt(:cr)
2061
+ }
1857
2062
  }
1858
2063
 
1859
2064
  button {
1860
2065
  text "Logout"
1861
2066
  enabled bind(presenter, :logged_in)
1862
2067
  on_widget_selected { presenter.logout }
2068
+ on_key_pressed { |event|
2069
+ if event.keyCode == swt(:cr)
2070
+ presenter.logout
2071
+ @user_name_text.set_focus
2072
+ end
2073
+ }
1863
2074
  }
1864
2075
  }
1865
2076
  }
@@ -2342,41 +2553,76 @@ class ContactManager
2342
2553
  shell {
2343
2554
  text "Contact Manager"
2344
2555
  composite {
2345
- composite {
2346
- grid_layout 2, false
2347
- label {text "First &Name: "}
2556
+ group {
2557
+ grid_layout(2, false) {
2558
+ margin_width 0
2559
+ margin_height 0
2560
+ }
2561
+ layout_data :fill, :center, true, false
2562
+ text 'Lookup Contacts'
2563
+ font height: 24
2564
+
2565
+ label {
2566
+ layout_data :right, :center, false, false
2567
+ text "First &Name: "
2568
+ font height: 16
2569
+ }
2348
2570
  text {
2571
+ layout_data :fill, :center, true, false
2349
2572
  text bind(@contact_manager_presenter, :first_name)
2350
2573
  on_key_pressed {|key_event|
2351
- @contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
2574
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2352
2575
  }
2353
2576
  }
2354
- label {text "&Last Name: "}
2577
+
2578
+ label {
2579
+ layout_data :right, :center, false, false
2580
+ text "&Last Name: "
2581
+ font height: 16
2582
+ }
2355
2583
  text {
2584
+ layout_data :fill, :center, true, false
2356
2585
  text bind(@contact_manager_presenter, :last_name)
2357
2586
  on_key_pressed {|key_event|
2358
- @contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
2587
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2359
2588
  }
2360
2589
  }
2361
- label {text "&Email: "}
2590
+
2591
+ label {
2592
+ layout_data :right, :center, false, false
2593
+ text "&Email: "
2594
+ font height: 16
2595
+ }
2362
2596
  text {
2597
+ layout_data :fill, :center, true, false
2363
2598
  text bind(@contact_manager_presenter, :email)
2364
2599
  on_key_pressed {|key_event|
2365
- @contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
2600
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2366
2601
  }
2367
2602
  }
2603
+
2368
2604
  composite {
2369
- grid_layout 2, false
2605
+ row_layout {
2606
+ margin_width 0
2607
+ margin_height 0
2608
+ }
2609
+ layout_data(:right, :center, false, false) {
2610
+ horizontal_span 2
2611
+ }
2612
+
2370
2613
  button {
2371
2614
  text "&Find"
2372
- on_widget_selected {
2373
- @contact_manager_presenter.find
2615
+ on_widget_selected { @contact_manager_presenter.find }
2616
+ on_key_pressed {|key_event|
2617
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2374
2618
  }
2375
2619
  }
2620
+
2376
2621
  button {
2377
2622
  text "&List All"
2378
- on_widget_selected {
2379
- @contact_manager_presenter.list
2623
+ on_widget_selected { @contact_manager_presenter.list }
2624
+ on_key_pressed {|key_event|
2625
+ @contact_manager_presenter.list if key_event.keyCode == swt(:cr)
2380
2626
  }
2381
2627
  }
2382
2628
  }
@@ -2393,26 +2639,18 @@ class ContactManager
2393
2639
  table_column {
2394
2640
  text "First Name"
2395
2641
  width 80
2396
- on_widget_selected {
2397
- @contact_manager_presenter.toggle_sort(:first_name)
2398
- }
2399
2642
  }
2400
2643
  table_column {
2401
2644
  text "Last Name"
2402
2645
  width 80
2403
- on_widget_selected {
2404
- @contact_manager_presenter.toggle_sort(:last_name)
2405
- }
2406
2646
  }
2407
2647
  table_column {
2408
2648
  text "Email"
2409
2649
  width 200
2410
- on_widget_selected {
2411
- @contact_manager_presenter.toggle_sort(:email)
2412
- }
2413
2650
  }
2414
- items bind(@contact_manager_presenter, :results), column_properties(:first_name, :last_name, :email)
2415
- on_mouse_down { |event|
2651
+ items bind(@contact_manager_presenter, :results),
2652
+ column_properties(:first_name, :last_name, :email)
2653
+ on_mouse_up { |event|
2416
2654
  table_proxy.edit_table_item(event.table_item, event.column_index)
2417
2655
  }
2418
2656
  }
@@ -2422,7 +2660,6 @@ class ContactManager
2422
2660
  end
2423
2661
 
2424
2662
  ContactManager.new.launch
2425
-
2426
2663
  ```
2427
2664
  Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2428
2665