glimmer-dsl-opal 0.5.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -0
  3. data/README.md +438 -17
  4. data/VERSION +1 -1
  5. data/app/assets/images/glimmer/images/calendar.gif +0 -0
  6. data/app/assets/images/glimmer/images/ui-icons_222222_256x240.png +0 -0
  7. data/app/assets/images/glimmer/images/ui-icons_444444_256x240.png +0 -0
  8. data/app/assets/images/glimmer/images/ui-icons_555555_256x240.png +0 -0
  9. data/app/assets/images/glimmer/images/ui-icons_777620_256x240.png +0 -0
  10. data/app/assets/images/glimmer/images/ui-icons_777777_256x240.png +0 -0
  11. data/app/assets/images/glimmer/images/ui-icons_cc0000_256x240.png +0 -0
  12. data/app/assets/images/glimmer/images/ui-icons_ffffff_256x240.png +0 -0
  13. data/app/assets/stylesheets/glimmer/glimmer.css +15 -0
  14. data/app/assets/stylesheets/glimmer/jquery-ui.css +1312 -0
  15. data/app/assets/stylesheets/glimmer/jquery-ui.structure.css +886 -0
  16. data/app/assets/stylesheets/glimmer/jquery-ui.theme.css +443 -0
  17. data/app/assets/stylesheets/glimmer/jquery.ui.timepicker.css +57 -0
  18. data/lib/display.rb +31 -0
  19. data/lib/file.rb +29 -0
  20. data/lib/glimmer-dsl-opal.rb +40 -8
  21. data/lib/glimmer-dsl-opal/ext/date.rb +49 -3
  22. data/lib/glimmer-dsl-opal/ext/struct.rb +37 -0
  23. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +23 -0
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +63 -0
  25. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +283 -0
  26. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt +278 -0
  27. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt +20 -0
  28. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css +57 -0
  29. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.js +1496 -0
  30. data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +333 -0
  31. data/lib/glimmer-dsl-opal/vendor/jquery-ui/LICENSE.txt +43 -0
  32. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
  33. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
  34. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
  35. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
  36. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
  37. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
  38. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +7 -0
  39. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +13 -0
  40. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +5 -0
  41. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +5 -0
  42. data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +74 -0
  43. data/lib/glimmer-dsl-swt.rb +20 -35
  44. data/lib/glimmer/data_binding/table_items_binding.rb +32 -19
  45. data/lib/glimmer/dsl/opal/block_property_expression.rb +41 -0
  46. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +1 -1
  47. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  48. data/lib/glimmer/dsl/opal/shell_expression.rb +7 -2
  49. data/lib/glimmer/dsl/opal/widget_expression.rb +10 -1
  50. data/lib/glimmer/engine.rb +9 -0
  51. data/lib/glimmer/swt.rb +3 -3
  52. data/lib/glimmer/swt/button_proxy.rb +5 -5
  53. data/lib/glimmer/swt/checkbox_proxy.rb +1 -0
  54. data/lib/glimmer/swt/color_proxy.rb +45 -45
  55. data/lib/glimmer/swt/combo_proxy.rb +42 -3
  56. data/lib/glimmer/swt/composite_proxy.rb +7 -3
  57. data/lib/glimmer/swt/control_editor.rb +54 -0
  58. data/lib/glimmer/swt/date_time_proxy.rb +209 -0
  59. data/lib/glimmer/swt/display_proxy.rb +6 -2
  60. data/lib/glimmer/swt/fill_layout_proxy.rb +1 -1
  61. data/lib/glimmer/swt/label_proxy.rb +2 -2
  62. data/lib/glimmer/swt/layout_data_proxy.rb +13 -10
  63. data/lib/glimmer/swt/layout_proxy.rb +5 -5
  64. data/lib/glimmer/swt/list_proxy.rb +2 -2
  65. data/lib/glimmer/swt/make_shift_shell_proxy.rb +4 -4
  66. data/lib/glimmer/swt/message_box_proxy.rb +10 -8
  67. data/lib/glimmer/swt/property_owner.rb +2 -2
  68. data/lib/glimmer/swt/radio_proxy.rb +1 -0
  69. data/lib/glimmer/swt/shell_proxy.rb +8 -0
  70. data/lib/glimmer/swt/tab_folder_proxy.rb +5 -5
  71. data/lib/glimmer/swt/tab_item_proxy.rb +7 -7
  72. data/lib/glimmer/swt/table_column_proxy.rb +71 -12
  73. data/lib/glimmer/swt/table_editor.rb +65 -0
  74. data/lib/glimmer/swt/table_item_proxy.rb +50 -7
  75. data/lib/glimmer/swt/table_proxy.rb +595 -22
  76. data/lib/glimmer/swt/text_proxy.rb +51 -3
  77. data/lib/glimmer/swt/widget_proxy.rb +141 -27
  78. data/lib/glimmer/ui/custom_widget.rb +8 -8
  79. data/lib/net/http.rb +1 -5
  80. data/lib/os.rb +36 -0
  81. data/lib/uri.rb +3 -3
  82. metadata +49 -9
  83. 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: f61cb014521b4590b70cfebc52264117af31b9d7e234d940988695d03925c2be
4
- data.tar.gz: 9b13c946b176527cc7d6f6ff7b946994da3c64dd19c9bac205539edfe80ef8e4
3
+ metadata.gz: 8a9e35ef70d7e6aae911e0b4be468617f0efd5c5ee2b31ad9b6aef191b52681f
4
+ data.tar.gz: 3a7624376ee038d5419b993911d6f0ec59f94780425c10306f5c7928572ad4de
5
5
  SHA512:
6
- metadata.gz: fb7d7f17cd91c006417cb2a396298bc2b165f5d57bf685a4867e5bc3868f54589d8b3c7387fc3b242fd874265336874c7ea0fb35734f4e1980a6cab8ce13afd6
7
- data.tar.gz: 0da099a76842cbcd97e44bcf756afced145283f40901a611eb7a711d6ad5c1585ef92f49e4af289fd43b35e81595d3b348c4ccd5da5174efbcc98448095452f4
6
+ metadata.gz: 8a98ce6e0b97501d3f78b5e589ada5e65d31c94d75ddcfa7e7f1abee3aa15e03bd51d7c3167f395778b458fd1a55e6fb630704aae33ea7ef633d1a7e603f952a
7
+ data.tar.gz: 9c602827b6d2da600ac68ad77b2f9d5faa01f29f9b7f0a0b843878950579836de0f2eb1f35a6e7d8681b63dc14afc429cdd0c0420d01a561683b600d13e07e4a
@@ -1,5 +1,57 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.2
4
+
5
+ - `date_drop_down` `table_column` `editor`
6
+ - `date` `table_column` `editor`
7
+ - `time` `table_column` `editor`
8
+ - Implement `on_focus_gained`, `on_focus_lost` universally on all widgets
9
+ - Add support for Struct keyword_init to Opal
10
+ - Fix issue with hello_table button/combo not being centered (yet stretched)
11
+ - Fix issue with table item selection for booking not working after editing has been added
12
+ - Fix escape keyboard event handling for combo table editor
13
+
14
+ ## 0.7.1
15
+
16
+ - Combo table editor (enabled in Hello, Table! sample)
17
+ - Fix issue with table cell selection for editing not working
18
+ - Remove widget from parent upon dispose
19
+ - Remove listeners upon widget dispose
20
+
21
+ ## 0.7.0
22
+
23
+ - Hello, Table! Sample
24
+ - `table` :editable style to enable auto-editing
25
+ - `table` `header_visible` property to hide header when false
26
+ - `table` `item_count` property to set minimum item count (fill empty rows when below in table items)
27
+ - `table` selection data-binding
28
+ - `table` built-in sorting support
29
+ - `table_column` left text alignment and padding of 5px by default
30
+ - `table` sort property and direction in GUI
31
+ - `table_column` sort_property
32
+ - `table_column` sort_by block
33
+ - `table_column` sort block
34
+ - `table` default sort via property, compare block, and property block
35
+ - `table` additional sort properties
36
+ - Prevent `table` unnecessary updates by comparing data to previous data and not updating when it's the same
37
+ - Contact Manager sample support for on_key_pressed in text widgets upon hitting ENTER
38
+ - Fix issue with edit table item error on sorting table
39
+
40
+ ## 0.6.1
41
+
42
+ - Fix issue with rendering date_time without a block
43
+ - Made listener event handling async to improve performance when triggering multiple events
44
+ - Brought Tic Tac Toe sample up-to-date with changes in Glimmer DSL for SWT
45
+ - Fixed silent error encountered in rendering custom widgets
46
+
47
+ ## 0.6.0
48
+
49
+ - Hello, Date Time! Sample
50
+ - Support `date_time`, `date`, `date_drop_down`, `time`, `calendar` keywords
51
+ - Format Date/Time correctly as per SWT implementation by default
52
+ - Make glimmer-dsl-opal gem into a Rails engine to support importing default static assets like CSS styles and images
53
+ - Show drop down icon next to `date_drop_down` and `time`
54
+
3
55
  ## 0.5.1
4
56
 
5
57
  - Fixed issue with Hello, Combo!, Hello, List...! samples
@@ -93,3 +145,4 @@
93
145
 
94
146
  - Initial support for webifying Glimmer SWT apps
95
147
  - Support for Shell and Label widgets (text property only).
148
+ - 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.5.1 (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.2 (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.5.1 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](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.2 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
 
@@ -26,6 +76,8 @@ Hello:
26
76
  - [Hello, Group!](#hello-group)
27
77
  - [Hello, Checkbox!](#hello-checkbox)
28
78
  - [Hello, Checkbox Group!](#hello-checkbox-group)
79
+ - [Hello, Date Time!](#hello-date-time)
80
+ - [Hello, Table!](#hello-table)
29
81
 
30
82
  Elaborate:
31
83
 
@@ -43,14 +95,6 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
43
95
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
44
96
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
45
97
 
46
- ## Background
47
-
48
- 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).
49
-
50
- 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.
51
-
52
- 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.
53
-
54
98
  ## Supported Glimmer DSL Keywords
55
99
 
56
100
  The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have partial support in Opal:
@@ -91,17 +135,33 @@ Event loop:
91
135
  - `display`
92
136
  - `async_exec`
93
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
+
94
148
  ## Pre-requisites
95
149
 
96
150
  - Rails 5: [https://github.com/rails/rails/tree/5-2-stable](https://github.com/rails/rails/tree/5-2-stable)
97
151
  - Opal 1: [https://github.com/opal/opal-rails](https://github.com/opal/opal-rails)
98
152
  - jQuery 3: [https://code.jquery.com/](https://code.jquery.com/) (jQuery 3.5.1 is included in the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem)
153
+ - jQuery-UI 1.12: [https://code.jquery.com/](https://jqueryui.com/) (jQuery-UI 1.12.1 is included in the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem)
154
+ - jQuery-UI Timepicker 0.3: [https://code.jquery.com/](https://fgelinas.com/code/timepicker/) (jQuery-UI Timepicker 0.3.3 is included in the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem)
99
155
 
100
156
  ## Setup
101
157
 
102
- (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)
159
+
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.
103
163
 
104
- Please install a Rails 5 gem:
164
+ Install a Rails 5 gem:
105
165
 
106
166
  ```
107
167
  gem install rails -v5.2.4.4
@@ -119,7 +179,7 @@ Add the following to `Gemfile`:
119
179
  gem 'opal-rails', '~> 1.1.2'
120
180
  gem 'opal-async', '~> 1.2.0'
121
181
  gem 'opal-jquery', '~> 0.4.4'
122
- gem 'glimmer-dsl-opal', '~> 0.5.1', require: false
182
+ gem 'glimmer-dsl-opal', '~> 0.7.2'
123
183
  gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
124
184
  gem 'glimmer-dsl-css', '~> 1.1.0', require: false
125
185
 
@@ -150,7 +210,15 @@ Add the following line to the top of an empty `app/assets/javascripts/applicatio
150
210
  require 'glimmer-dsl-opal' # brings opal and other dependencies automatically
151
211
  ```
152
212
 
153
- Open a `Document.ready?` block and add inside it Glimmer GUI DSL code or a require statement for one of the samples below.
213
+ Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
214
+
215
+ ```erb
216
+ <%= stylesheet_link_tag 'glimmer/glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
217
+ ```
218
+
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.
154
222
 
155
223
  ```ruby
156
224
  Document.ready? do
@@ -1397,6 +1465,357 @@ You should see "Hello, Checkbox Group!"
1397
1465
 
1398
1466
  ![Glimmer DSL for Opal Hello Checkbox Group](images/glimmer-dsl-opal-hello-checkbox-group.png)
1399
1467
 
1468
+ #### Hello, Date Time!
1469
+
1470
+ Add the following require statement to `app/assets/javascripts/application.rb`
1471
+
1472
+ ```ruby
1473
+ require 'glimmer-dsl-opal/samples/hello/hello_date_time'
1474
+ ```
1475
+
1476
+ Or add the Glimmer code directly if you prefer to play around with it:
1477
+
1478
+ ```ruby
1479
+ class HelloDateTime
1480
+ class Person
1481
+ attr_accessor :date_of_birth
1482
+ end
1483
+
1484
+ include Glimmer
1485
+
1486
+ def launch
1487
+ person = Person.new
1488
+ person.date_of_birth = DateTime.new(2013, 7, 12, 18, 37, 23)
1489
+
1490
+ shell {
1491
+ row_layout :vertical
1492
+
1493
+ text 'Hello, Date Time!'
1494
+ minimum_size 180, 180
1495
+
1496
+ label {
1497
+ text 'Date of Birth'
1498
+ font height: 16, style: :bold
1499
+ }
1500
+
1501
+ date { # alias for date_time(:date)
1502
+ date_time bind(person, :date_of_birth)
1503
+ }
1504
+
1505
+ date_drop_down { # alias for date_time(:date, :drop_down)
1506
+ date_time bind(person, :date_of_birth)
1507
+ }
1508
+
1509
+ time { # alias for date_time(:time)
1510
+ date_time bind(person, :date_of_birth)
1511
+ }
1512
+
1513
+ calendar { # alias for date_time(:calendar)
1514
+ date_time bind(person, :date_of_birth)
1515
+ }
1516
+ }.open
1517
+ end
1518
+ end
1519
+
1520
+ HelloDateTime.new.launch
1521
+ ```
1522
+
1523
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1524
+
1525
+ ![Glimmer DSL for SWT Hello Checkbox Group](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-date-time.png)
1526
+
1527
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1528
+
1529
+ Start the Rails server:
1530
+ ```
1531
+ rails s
1532
+ ```
1533
+
1534
+ Visit `http://localhost:3000`
1535
+
1536
+ You should see "Hello, Date Time!"
1537
+
1538
+ ![Glimmer DSL for Opal Hello Date Time](images/glimmer-dsl-opal-hello-date-time.png)
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 and table editing 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
+ }
1742
+ table_column {
1743
+ text 'Game Time'
1744
+ width 150
1745
+ sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
1746
+ }
1747
+ table_column {
1748
+ text 'Ballpark'
1749
+ width 180
1750
+ }
1751
+ table_column {
1752
+ text 'Home Team'
1753
+ width 150
1754
+ }
1755
+ table_column {
1756
+ text 'Away Team'
1757
+ width 150
1758
+ }
1759
+ table_column {
1760
+ text 'Promotion'
1761
+ width 150
1762
+ # default text editor is used here
1763
+ }
1764
+
1765
+ # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
1766
+ items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
1767
+
1768
+ # Data-bind table selection
1769
+ selection bind(BaseballGame, :selected_game)
1770
+
1771
+ # Default initial sort property
1772
+ sort_property :date
1773
+
1774
+ # Sort by these additional properties after handling sort by the column the user clicked
1775
+ additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
1776
+ }
1777
+
1778
+ button {
1779
+ text 'Book Selected Game'
1780
+ layout_data :center, :center, true, false
1781
+ font height: 16
1782
+ enabled bind(BaseballGame, :selected_game)
1783
+
1784
+ on_widget_selected {
1785
+ book_selected_game
1786
+ }
1787
+ }
1788
+ }.open
1789
+ end
1790
+
1791
+ def book_selected_game
1792
+ message_box {
1793
+ text 'Baseball Game Booked!'
1794
+ message BaseballGame.selected_game.book!
1795
+ }.open
1796
+ end
1797
+ end
1798
+
1799
+ HelloTable.new.launch
1800
+ ```
1801
+
1802
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1803
+
1804
+ ![Glimmer DSL for SWT Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table.png)
1805
+
1806
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1807
+
1808
+ Start the Rails server:
1809
+ ```
1810
+ rails s
1811
+ ```
1812
+
1813
+ Visit `http://localhost:3000`
1814
+
1815
+ You should see "Hello, Date Time!"
1816
+
1817
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table.png)
1818
+
1400
1819
  ### Elaborate Samples
1401
1820
 
1402
1821
  #### Login
@@ -1688,6 +2107,7 @@ class TicTacToe
1688
2107
  @tic_tac_toe_board = Board.new
1689
2108
  @shell = shell {
1690
2109
  text "Tic-Tac-Toe"
2110
+ minimum_size 150, 178
1691
2111
  composite {
1692
2112
  grid_layout 3, true
1693
2113
  (1..3).each { |row|
@@ -1696,6 +2116,7 @@ class TicTacToe
1696
2116
  layout_data :fill, :fill, true, true
1697
2117
  text bind(@tic_tac_toe_board[row, column], :sign)
1698
2118
  enabled bind(@tic_tac_toe_board[row, column], :empty)
2119
+ font style: :bold, height: 20
1699
2120
  on_widget_selected {
1700
2121
  @tic_tac_toe_board.mark(row, column)
1701
2122
  }
@@ -2136,7 +2557,7 @@ Visit `http://localhost:3000`
2136
2557
 
2137
2558
  You should see "Glimmer Calculator"
2138
2559
 
2139
- ![Glimmer Calculator Opal](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot-opal.png)
2560
+ [![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)
2140
2561
 
2141
2562
  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):
2142
2563
 
@@ -2144,7 +2565,7 @@ Visit http://glimmer-cs-calculator-server.herokuapp.com/welcomes/apple
2144
2565
 
2145
2566
  You should see "Apple Calculator Theme"
2146
2567
 
2147
- ![Glimmer Calculator Opal Apple Calculator Theme](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot-opal-apple.png)
2568
+ [![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)
2148
2569
 
2149
2570
  ## Help
2150
2571