glimmer-dsl-opal 0.6.0 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -0
  3. data/README.md +428 -18
  4. data/VERSION +1 -1
  5. data/app/assets/stylesheets/{glimmer.css → glimmer/glimmer.css} +1 -1
  6. data/lib/display.rb +31 -0
  7. data/lib/file.rb +29 -0
  8. data/lib/glimmer-dsl-opal.rb +33 -5
  9. data/lib/glimmer-dsl-opal/ext/date.rb +11 -0
  10. data/lib/glimmer-dsl-opal/ext/struct.rb +37 -0
  11. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +23 -0
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +283 -0
  13. data/lib/glimmer-dsl-swt.rb +20 -35
  14. data/lib/glimmer/data_binding/table_items_binding.rb +32 -19
  15. data/lib/glimmer/dsl/opal/block_property_expression.rb +41 -0
  16. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +1 -1
  17. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  18. data/lib/glimmer/dsl/opal/widget_expression.rb +7 -3
  19. data/lib/glimmer/engine.rb +1 -1
  20. data/lib/glimmer/swt/button_proxy.rb +5 -5
  21. data/lib/glimmer/swt/color_proxy.rb +45 -45
  22. data/lib/glimmer/swt/combo_proxy.rb +42 -3
  23. data/lib/glimmer/swt/composite_proxy.rb +7 -3
  24. data/lib/glimmer/swt/control_editor.rb +54 -0
  25. data/lib/glimmer/swt/date_time_proxy.rb +71 -5
  26. data/lib/glimmer/swt/display_proxy.rb +6 -2
  27. data/lib/glimmer/swt/fill_layout_proxy.rb +1 -1
  28. data/lib/glimmer/swt/font_proxy.rb +4 -4
  29. data/lib/glimmer/swt/label_proxy.rb +2 -2
  30. data/lib/glimmer/swt/layout_data_proxy.rb +13 -10
  31. data/lib/glimmer/swt/layout_proxy.rb +5 -5
  32. data/lib/glimmer/swt/list_proxy.rb +2 -2
  33. data/lib/glimmer/swt/message_box_proxy.rb +4 -2
  34. data/lib/glimmer/swt/property_owner.rb +2 -2
  35. data/lib/glimmer/swt/shell_proxy.rb +8 -0
  36. data/lib/glimmer/swt/tab_folder_proxy.rb +2 -2
  37. data/lib/glimmer/swt/tab_item_proxy.rb +7 -7
  38. data/lib/glimmer/swt/table_column_proxy.rb +71 -12
  39. data/lib/glimmer/swt/table_editor.rb +65 -0
  40. data/lib/glimmer/swt/table_item_proxy.rb +50 -7
  41. data/lib/glimmer/swt/table_proxy.rb +581 -14
  42. data/lib/glimmer/swt/text_proxy.rb +49 -1
  43. data/lib/glimmer/swt/widget_proxy.rb +120 -22
  44. data/lib/glimmer/ui/custom_widget.rb +8 -8
  45. data/lib/net/http.rb +1 -5
  46. data/lib/os.rb +36 -0
  47. data/lib/uri.rb +3 -3
  48. metadata +31 -10
  49. data/lib/glimmer/data_binding/ext/observable_model.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c73ae51d66f5e2955bd4c4c8b639d6081a8445594699d4a2f2b71244903d3277
4
- data.tar.gz: bff8c03439d137acd926baece557b609e0805adbf28b822984cd70f7b63666fc
3
+ metadata.gz: 267d755e70aa2465ba671e499fcdccb7059de89658f381dafee9480a095e9bf5
4
+ data.tar.gz: 8b5a6ae6d22fef47f7623755810b47dad3b1b25d6ce76bdadde4f89ec8da976c
5
5
  SHA512:
6
- metadata.gz: 1bfba5a1bc6d5f6267e0622d3376d1567c40b5c06a7fcb49a8e7f3c5845a8b66214eaa897b2ebf9a8cb68d2a5cfbf5a83d3c4870250e6d9d901c39bbe9bf7d59
7
- data.tar.gz: 285627b7e3d843d9c3f54ef169d96463e4abe3047580a92eacb314d0b302675e9b5799b92e2be02c73f8af039743f35610b4d25ce84cabf4c60d826c797dd150
6
+ metadata.gz: a3a5a6621c062459650d83f707cc76819ca9c8abfe50c59a1d5b657648453fa2187ee0faabad2090593192304eabd2454ef4ab3f8c27d5658bba4ae4b8f07c2d
7
+ data.tar.gz: f49a05966c477fb1c38886dc772a50b1f8b9e6249741776a82a3ebc836ec879e8906df2e5c8528246e73b9b349401b3548c97db2af6e42545ece54d6fb334c28
@@ -1,5 +1,55 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.3
4
+
5
+ - Refactor to use to_collection gem
6
+ - Fix issue with breaking `date`/`date_drop_down` data-binding as table editor on focus lost
7
+ - Fix issue with requiring OS, File, and Display class after they've been extracted out
8
+
9
+ ## 0.7.2
10
+
11
+ - `date_drop_down` `table_column` `editor`
12
+ - `date` `table_column` `editor`
13
+ - `time` `table_column` `editor`
14
+ - Implement `on_focus_gained`, `on_focus_lost` universally on all widgets
15
+ - Add support for Struct keyword_init to Opal
16
+ - Fix issue with hello_table button/combo not being centered (yet stretched)
17
+ - Fix issue with table item selection for booking not working after editing has been added
18
+ - Fix escape keyboard event handling for combo table editor
19
+
20
+ ## 0.7.1
21
+
22
+ - Combo table editor (enabled in Hello, Table! sample)
23
+ - Fix issue with table cell selection for editing not working
24
+ - Remove widget from parent upon dispose
25
+ - Remove listeners upon widget dispose
26
+
27
+ ## 0.7.0
28
+
29
+ - Hello, Table! Sample
30
+ - `table` :editable style to enable auto-editing
31
+ - `table` `header_visible` property to hide header when false
32
+ - `table` `item_count` property to set minimum item count (fill empty rows when below in table items)
33
+ - `table` selection data-binding
34
+ - `table` built-in sorting support
35
+ - `table_column` left text alignment and padding of 5px by default
36
+ - `table` sort property and direction in GUI
37
+ - `table_column` sort_property
38
+ - `table_column` sort_by block
39
+ - `table_column` sort block
40
+ - `table` default sort via property, compare block, and property block
41
+ - `table` additional sort properties
42
+ - Prevent `table` unnecessary updates by comparing data to previous data and not updating when it's the same
43
+ - Contact Manager sample support for on_key_pressed in text widgets upon hitting ENTER
44
+ - Fix issue with edit table item error on sorting table
45
+
46
+ ## 0.6.1
47
+
48
+ - Fix issue with rendering date_time without a block
49
+ - Made listener event handling async to improve performance when triggering multiple events
50
+ - Brought Tic Tac Toe sample up-to-date with changes in Glimmer DSL for SWT
51
+ - Fixed silent error encountered in rendering custom widgets
52
+
3
53
  ## 0.6.0
4
54
 
5
55
  - Hello, Date Time! Sample
@@ -101,3 +151,4 @@
101
151
 
102
152
  - Initial support for webifying Glimmer SWT apps
103
153
  - Support for Shell and Label widgets (text property only).
154
+ - Hello, World! sample support
data/README.md CHANGED
@@ -1,14 +1,64 @@
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.6.0 (Auto-Webify Desktop Apps)
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.3 (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 experimental proof-of-concept web GUI adapter for [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps (i.e. apps built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)). It webifies them via [Rails](https://rubyonrails.org/), allowing Ruby desktop apps to run on the web via [Opal Ruby](https://opalrb.com/) without changing a line of code. Apps may then be custom-styled by web designers for the web with standard CSS.
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
+
9
+ Use in one of two ways:
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. 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.
8
12
 
9
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.
10
14
 
11
- NOTE: Alpha Version 0.6.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
+
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.3 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):
12
62
 
13
63
  Hello:
14
64
 
@@ -27,6 +77,7 @@ Hello:
27
77
  - [Hello, Checkbox!](#hello-checkbox)
28
78
  - [Hello, Checkbox Group!](#hello-checkbox-group)
29
79
  - [Hello, Date Time!](#hello-date-time)
80
+ - [Hello, Table!](#hello-table)
30
81
 
31
82
  Elaborate:
32
83
 
@@ -44,14 +95,6 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
44
95
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
45
96
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
46
97
 
47
- ## Background
48
-
49
- The idea behind Glimmer DSL for Opal is 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).
50
-
51
- 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.
52
-
53
- 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.
54
-
55
98
  ## Supported Glimmer DSL Keywords
56
99
 
57
100
  The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have partial support in Opal:
@@ -92,6 +135,16 @@ Event loop:
92
135
  - `display`
93
136
  - `async_exec`
94
137
 
138
+ ## Background
139
+
140
+ 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.
141
+
142
+ 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.
143
+
144
+ 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.
145
+
146
+ 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.
147
+
95
148
  ## Pre-requisites
96
149
 
97
150
  - Rails 5: [https://github.com/rails/rails/tree/5-2-stable](https://github.com/rails/rails/tree/5-2-stable)
@@ -102,9 +155,13 @@ Event loop:
102
155
 
103
156
  ## Setup
104
157
 
105
- (NOTE: if you run into issues, keep in mind this is a very early experimental and incomplete alpha. Also, there is a slight chance issues you encounter are fixed in master or some other branch that you could check out instead)
158
+ (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)
106
159
 
107
- Please install a Rails 5 gem:
160
+ The [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem is a Rails Engine gem that includes assets.
161
+
162
+ Please follow the following steps to setup.
163
+
164
+ Install a Rails 5 gem:
108
165
 
109
166
  ```
110
167
  gem install rails -v5.2.4.4
@@ -122,7 +179,7 @@ Add the following to `Gemfile`:
122
179
  gem 'opal-rails', '~> 1.1.2'
123
180
  gem 'opal-async', '~> 1.2.0'
124
181
  gem 'opal-jquery', '~> 0.4.4'
125
- gem 'glimmer-dsl-opal', '~> 0.6.0'
182
+ gem 'glimmer-dsl-opal', '~> 0.7.3'
126
183
  gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
127
184
  gem 'glimmer-dsl-css', '~> 1.1.0', require: false
128
185
 
@@ -156,10 +213,12 @@ require 'glimmer-dsl-opal' # brings opal and other dependencies automatically
156
213
  Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
157
214
 
158
215
  ```erb
159
- <%= stylesheet_link_tag 'glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
216
+ <%= stylesheet_link_tag 'glimmer/glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
160
217
  ```
161
218
 
162
- Open a `Document.ready?` block and add inside it Glimmer GUI DSL code or a require statement for one of the samples below.
219
+ Clear the file `app/views/welcomes/index.html.erb` from any content.
220
+
221
+ 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.
163
222
 
164
223
  ```ruby
165
224
  Document.ready? do
@@ -1478,6 +1537,355 @@ You should see "Hello, Date Time!"
1478
1537
 
1479
1538
  ![Glimmer DSL for Opal Hello Date Time](images/glimmer-dsl-opal-hello-date-time.png)
1480
1539
 
1540
+ #### Hello, Table!
1541
+
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 at the moment.
1543
+
1544
+ Add the following require statement to `app/assets/javascripts/application.rb`
1545
+
1546
+ ```ruby
1547
+ require 'glimmer-dsl-opal/samples/hello/hello_table'
1548
+ ```
1549
+
1550
+ Or add the Glimmer code directly if you prefer to play around with it:
1551
+
1552
+ ```ruby
1553
+ class HelloTable
1554
+ class BaseballGame
1555
+ class << self
1556
+ attr_accessor :selected_game
1557
+
1558
+ def all_playoff_games
1559
+ @all_playoff_games ||= {
1560
+ 'NLDS' => [
1561
+ new(Time.new(2037, 10, 6, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers', 'Free Bobblehead'),
1562
+ new(Time.new(2037, 10, 7, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers'),
1563
+ new(Time.new(2037, 10, 8, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs'),
1564
+ new(Time.new(2037, 10, 9, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs'),
1565
+ new(Time.new(2037, 10, 10, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 'Free Umbrella'),
1566
+ new(Time.new(2037, 10, 6, 18, 0), 'Cincinnati Reds', 'St Louis Cardinals', 'Free Bobblehead'),
1567
+ new(Time.new(2037, 10, 7, 18, 0), 'Cincinnati Reds', 'St Louis Cardinals'),
1568
+ new(Time.new(2037, 10, 8, 18, 0), 'St Louis Cardinals', 'Cincinnati Reds'),
1569
+ new(Time.new(2037, 10, 9, 18, 0), 'St Louis Cardinals', 'Cincinnati Reds'),
1570
+ new(Time.new(2037, 10, 10, 18, 0), 'St Louis Cardinals', 'Cincinnati Reds', 'Free Umbrella'),
1571
+ ],
1572
+ 'ALDS' => [
1573
+ new(Time.new(2037, 10, 6, 12, 0), 'New York Yankees', 'Boston Red Sox', 'Free Bobblehead'),
1574
+ new(Time.new(2037, 10, 7, 12, 0), 'New York Yankees', 'Boston Red Sox'),
1575
+ new(Time.new(2037, 10, 8, 12, 0), 'Boston Red Sox', 'New York Yankees'),
1576
+ new(Time.new(2037, 10, 9, 12, 0), 'Boston Red Sox', 'New York Yankees'),
1577
+ new(Time.new(2037, 10, 10, 12, 0), 'Boston Red Sox', 'New York Yankees', 'Free Umbrella'),
1578
+ new(Time.new(2037, 10, 6, 18, 0), 'Houston Astros', 'Cleveland Indians', 'Free Bobblehead'),
1579
+ new(Time.new(2037, 10, 7, 18, 0), 'Houston Astros', 'Cleveland Indians'),
1580
+ new(Time.new(2037, 10, 8, 18, 0), 'Cleveland Indians', 'Houston Astros'),
1581
+ new(Time.new(2037, 10, 9, 18, 0), 'Cleveland Indians', 'Houston Astros'),
1582
+ new(Time.new(2037, 10, 10, 18, 0), 'Cleveland Indians', 'Houston Astros', 'Free Umbrella'),
1583
+ ],
1584
+ 'NLCS' => [
1585
+ new(Time.new(2037, 10, 12, 12, 0), 'Chicago Cubs', 'Cincinnati Reds', 'Free Towel'),
1586
+ new(Time.new(2037, 10, 13, 12, 0), 'Chicago Cubs', 'Cincinnati Reds'),
1587
+ new(Time.new(2037, 10, 14, 12, 0), 'Cincinnati Reds', 'Chicago Cubs'),
1588
+ new(Time.new(2037, 10, 15, 18, 0), 'Cincinnati Reds', 'Chicago Cubs'),
1589
+ new(Time.new(2037, 10, 16, 18, 0), 'Cincinnati Reds', 'Chicago Cubs'),
1590
+ new(Time.new(2037, 10, 17, 18, 0), 'Chicago Cubs', 'Cincinnati Reds'),
1591
+ new(Time.new(2037, 10, 18, 12, 0), 'Chicago Cubs', 'Cincinnati Reds', 'Free Poncho'),
1592
+ ],
1593
+ 'ALCS' => [
1594
+ new(Time.new(2037, 10, 12, 12, 0), 'Houston Astros', 'Boston Red Sox', 'Free Towel'),
1595
+ new(Time.new(2037, 10, 13, 12, 0), 'Houston Astros', 'Boston Red Sox'),
1596
+ new(Time.new(2037, 10, 14, 12, 0), 'Boston Red Sox', 'Houston Astros'),
1597
+ new(Time.new(2037, 10, 15, 18, 0), 'Boston Red Sox', 'Houston Astros'),
1598
+ new(Time.new(2037, 10, 16, 18, 0), 'Boston Red Sox', 'Houston Astros'),
1599
+ new(Time.new(2037, 10, 17, 18, 0), 'Houston Astros', 'Boston Red Sox'),
1600
+ new(Time.new(2037, 10, 18, 12, 0), 'Houston Astros', 'Boston Red Sox', 'Free Poncho'),
1601
+ ],
1602
+ 'World Series' => [
1603
+ new(Time.new(2037, 10, 20, 18, 0), 'Chicago Cubs', 'Boston Red Sox', 'Free Baseball Cap'),
1604
+ new(Time.new(2037, 10, 21, 18, 0), 'Chicago Cubs', 'Boston Red Sox'),
1605
+ new(Time.new(2037, 10, 22, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
1606
+ new(Time.new(2037, 10, 23, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
1607
+ new(Time.new(2037, 10, 24, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
1608
+ new(Time.new(2037, 10, 25, 18, 0), 'Chicago Cubs', 'Boston Red Sox'),
1609
+ new(Time.new(2037, 10, 26, 18, 0), 'Chicago Cubs', 'Boston Red Sox', 'Free World Series Polo'),
1610
+ ]
1611
+ }
1612
+ end
1613
+
1614
+ def playoff_type
1615
+ @playoff_type ||= 'World Series'
1616
+ end
1617
+
1618
+ def playoff_type=(new_playoff_type)
1619
+ @playoff_type = new_playoff_type
1620
+ self.schedule=(all_playoff_games[@playoff_type])
1621
+ end
1622
+
1623
+ def playoff_type_options
1624
+ all_playoff_games.keys
1625
+ end
1626
+
1627
+ def schedule
1628
+ @schedule ||= all_playoff_games[playoff_type]
1629
+ end
1630
+
1631
+ def schedule=(new_schedule)
1632
+ @schedule = new_schedule
1633
+ end
1634
+ end
1635
+
1636
+ include Glimmer
1637
+ include Glimmer::DataBinding::ObservableModel
1638
+
1639
+ TEAM_BALLPARKS = {
1640
+ 'Boston Red Sox' => 'Fenway Park',
1641
+ 'Chicago Cubs' => 'Wrigley Field',
1642
+ 'Cincinnati Reds' => 'Great American Ball Park',
1643
+ 'Cleveland Indians' => 'Progressive Field',
1644
+ 'Houston Astros' => 'Minute Maid Park',
1645
+ 'Milwaukee Brewers' => 'Miller Park',
1646
+ 'New York Yankees' => 'Yankee Stadium',
1647
+ 'St Louis Cardinals' => 'Busch Stadium',
1648
+ }
1649
+
1650
+ attr_accessor :date_time, :home_team, :away_team, :ballpark, :promotion
1651
+
1652
+ def initialize(date_time, home_team, away_team, promotion = 'N/A')
1653
+ self.date_time = date_time
1654
+ self.home_team = home_team
1655
+ self.away_team = away_team
1656
+ self.promotion = promotion
1657
+ observe(self, :date_time) do |new_value|
1658
+ notify_observers(:game_date)
1659
+ notify_observers(:game_time)
1660
+ end
1661
+ end
1662
+
1663
+ def home_team=(home_team_value)
1664
+ if home_team_value != away_team
1665
+ @home_team = home_team_value
1666
+ self.ballpark = TEAM_BALLPARKS[@home_team]
1667
+ end
1668
+ end
1669
+
1670
+ def away_team=(away_team_value)
1671
+ if away_team_value != home_team
1672
+ @away_team = away_team_value
1673
+ end
1674
+ end
1675
+
1676
+ def date
1677
+ Date.new(date_time.year, date_time.month, date_time.day)
1678
+ end
1679
+
1680
+ def time
1681
+ Time.new(0, 1, 1, date_time.hour, date_time.min, date_time.sec, '+00:00')
1682
+ end
1683
+
1684
+ def game_date
1685
+ date_time.strftime("%m/%d/%Y")
1686
+ end
1687
+
1688
+ def game_time
1689
+ date_time.strftime("%I:%M %p")
1690
+ end
1691
+
1692
+ def home_team_options
1693
+ TEAM_BALLPARKS.keys
1694
+ end
1695
+
1696
+ def away_team_options
1697
+ TEAM_BALLPARKS.keys
1698
+ end
1699
+
1700
+ def ballpark_options
1701
+ [TEAM_BALLPARKS[@home_team], TEAM_BALLPARKS[@away_team]]
1702
+ end
1703
+
1704
+ def to_s
1705
+ "#{home_team} vs #{away_team} at #{ballpark} on #{game_date} #{game_time}"
1706
+ end
1707
+
1708
+ def book!
1709
+ "Thank you for booking #{to_s}"
1710
+ end
1711
+ end
1712
+
1713
+ include Glimmer
1714
+
1715
+ def launch
1716
+ shell {
1717
+ grid_layout
1718
+
1719
+ text 'Hello, Table!'
1720
+
1721
+ label {
1722
+ layout_data :center, :center, true, false
1723
+
1724
+ text 'Baseball Playoff Schedule'
1725
+ font height: 30, style: :bold
1726
+ }
1727
+
1728
+ combo(:read_only) {
1729
+ layout_data :center, :center, true, false
1730
+ selection bind(BaseballGame, :playoff_type)
1731
+ font height: 16
1732
+ }
1733
+
1734
+ table(:editable) { |table_proxy|
1735
+ layout_data :fill, :fill, true, true
1736
+
1737
+ table_column {
1738
+ text 'Game Date'
1739
+ width 150
1740
+ sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
1741
+ editor :date_drop_down, property: :date_time
1742
+ }
1743
+ table_column {
1744
+ text 'Game Time'
1745
+ width 150
1746
+ sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
1747
+ editor :time, property: :date_time
1748
+ }
1749
+ table_column {
1750
+ text 'Ballpark'
1751
+ width 180
1752
+ editor :none
1753
+ }
1754
+ table_column {
1755
+ text 'Home Team'
1756
+ width 150
1757
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
1758
+ }
1759
+ table_column {
1760
+ text 'Away Team'
1761
+ width 150
1762
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
1763
+ }
1764
+ table_column {
1765
+ text 'Promotion'
1766
+ width 150
1767
+ # default text editor is used here
1768
+ }
1769
+
1770
+ # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
1771
+ items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
1772
+
1773
+ # Data-bind table selection
1774
+ selection bind(BaseballGame, :selected_game)
1775
+
1776
+ # Default initial sort property
1777
+ sort_property :date
1778
+
1779
+ # Sort by these additional properties after handling sort by the column the user clicked
1780
+ additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
1781
+ }
1782
+
1783
+ button {
1784
+ text 'Book Selected Game'
1785
+ layout_data :center, :center, true, false
1786
+ font height: 16
1787
+ enabled bind(BaseballGame, :selected_game)
1788
+
1789
+ on_widget_selected {
1790
+ book_selected_game
1791
+ }
1792
+ }
1793
+ }.open
1794
+ end
1795
+
1796
+ def book_selected_game
1797
+ message_box {
1798
+ text 'Baseball Game Booked!'
1799
+ message BaseballGame.selected_game.book!
1800
+ }.open
1801
+ end
1802
+ end
1803
+
1804
+ HelloTable.new.launch
1805
+ ```
1806
+
1807
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1808
+
1809
+ ![Glimmer DSL for SWT Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table.png)
1810
+
1811
+ Hello, Table! Editing Game Date
1812
+
1813
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-game-date.png)
1814
+
1815
+ Hello, Table! Editing Game Time
1816
+
1817
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-game-time.png)
1818
+
1819
+ Hello, Table! Editing Home Team
1820
+
1821
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-editing-home-team.png)
1822
+
1823
+ Hello, Table! Sorted Game Date Ascending
1824
+
1825
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-sorted-game-date-ascending.png)
1826
+
1827
+ Hello, Table! Sorted Game Date Descending
1828
+
1829
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-sorted-game-date-descending.png)
1830
+
1831
+ Hello, Table! Playoff Type Combo
1832
+
1833
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-playoff-type-combo.png)
1834
+
1835
+ Hello, Table! Playoff Type Changed
1836
+
1837
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-playoff-type-changed.png)
1838
+
1839
+ Hello, Table! Game Booked
1840
+
1841
+ ![Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table-game-booked.png)
1842
+
1843
+
1844
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1845
+
1846
+ Start the Rails server:
1847
+ ```
1848
+ rails s
1849
+ ```
1850
+
1851
+ Visit `http://localhost:3000`
1852
+
1853
+ You should see "Hello, Date Time!"
1854
+
1855
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table.png)
1856
+
1857
+ Hello, Table! Editing Game Date
1858
+
1859
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-date.png)
1860
+
1861
+ Hello, Table! Editing Game Time
1862
+
1863
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-time.png)
1864
+
1865
+ Hello, Table! Editing Home Team
1866
+
1867
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-home-team.png)
1868
+
1869
+ Hello, Table! Sorted Game Date Ascending
1870
+
1871
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-ascending.png)
1872
+
1873
+ Hello, Table! Sorted Game Date Descending
1874
+
1875
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-descending.png)
1876
+
1877
+ Hello, Table! Playoff Type Combo
1878
+
1879
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-combo.png)
1880
+
1881
+ Hello, Table! Playoff Type Changed
1882
+
1883
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-changed.png)
1884
+
1885
+ Hello, Table! Game Booked
1886
+
1887
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-game-booked.png)
1888
+
1481
1889
  ### Elaborate Samples
1482
1890
 
1483
1891
  #### Login
@@ -1769,6 +2177,7 @@ class TicTacToe
1769
2177
  @tic_tac_toe_board = Board.new
1770
2178
  @shell = shell {
1771
2179
  text "Tic-Tac-Toe"
2180
+ minimum_size 150, 178
1772
2181
  composite {
1773
2182
  grid_layout 3, true
1774
2183
  (1..3).each { |row|
@@ -1777,6 +2186,7 @@ class TicTacToe
1777
2186
  layout_data :fill, :fill, true, true
1778
2187
  text bind(@tic_tac_toe_board[row, column], :sign)
1779
2188
  enabled bind(@tic_tac_toe_board[row, column], :empty)
2189
+ font style: :bold, height: 20
1780
2190
  on_widget_selected {
1781
2191
  @tic_tac_toe_board.mark(row, column)
1782
2192
  }
@@ -2217,7 +2627,7 @@ Visit `http://localhost:3000`
2217
2627
 
2218
2628
  You should see "Glimmer Calculator"
2219
2629
 
2220
- ![Glimmer Calculator Opal](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot-opal.png)
2630
+ [![Glimmer Calculator Opal](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot-opal.png)](http://glimmer-cs-calculator-server.herokuapp.com)
2221
2631
 
2222
2632
  Here is an Apple Calculator CSS themed version (with [CSS only](https://github.com/AndyObtiva/glimmer-cs-calculator/blob/master/server/glimmer-cs-calculator-server/app/assets/stylesheets/welcomes_apple.scss), no app code changes):
2223
2633
 
@@ -2225,7 +2635,7 @@ Visit http://glimmer-cs-calculator-server.herokuapp.com/welcomes/apple
2225
2635
 
2226
2636
  You should see "Apple Calculator Theme"
2227
2637
 
2228
- ![Glimmer Calculator Opal Apple Calculator Theme](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot-opal-apple.png)
2638
+ [![Glimmer Calculator Opal Apple Calculator Theme](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot-opal-apple.png)](http://glimmer-cs-calculator-server.herokuapp.com/welcomes/apple)
2229
2639
 
2230
2640
  ## Help
2231
2641