glimmer-dsl-opal 0.4.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +56 -0
  3. data/README.md +892 -16
  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/glimmer-dsl-opal.rb +16 -9
  19. data/lib/glimmer-dsl-opal/ext/date.rb +49 -3
  20. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +23 -0
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +85 -0
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +68 -0
  23. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +5 -5
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +3 -3
  25. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +63 -0
  26. data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +104 -0
  27. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
  28. data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +108 -0
  29. data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +84 -0
  30. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +283 -0
  31. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt +278 -0
  32. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt +20 -0
  33. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css +57 -0
  34. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.js +1496 -0
  35. data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +333 -0
  36. data/lib/glimmer-dsl-opal/vendor/jquery-ui/LICENSE.txt +43 -0
  37. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
  38. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
  39. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
  40. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
  41. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
  42. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
  43. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +7 -0
  44. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +13 -0
  45. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +5 -0
  46. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +5 -0
  47. data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +74 -0
  48. data/lib/glimmer-dsl-swt.rb +1 -0
  49. data/lib/glimmer/data_binding/element_binding.rb +2 -1
  50. data/lib/glimmer/data_binding/table_items_binding.rb +29 -18
  51. data/lib/glimmer/dsl/opal/block_property_expression.rb +41 -0
  52. data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +61 -0
  53. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +8 -6
  54. data/lib/glimmer/dsl/opal/dsl.rb +6 -0
  55. data/lib/glimmer/dsl/opal/property_expression.rb +4 -3
  56. data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
  57. data/lib/glimmer/dsl/opal/shell_expression.rb +7 -2
  58. data/lib/glimmer/dsl/opal/widget_expression.rb +6 -1
  59. data/lib/glimmer/engine.rb +9 -0
  60. data/lib/glimmer/swt.rb +3 -3
  61. data/lib/glimmer/swt/button_proxy.rb +16 -2
  62. data/lib/glimmer/swt/checkbox_proxy.rb +81 -0
  63. data/lib/glimmer/swt/color_proxy.rb +45 -45
  64. data/lib/glimmer/swt/combo_proxy.rb +6 -6
  65. data/lib/glimmer/swt/composite_proxy.rb +2 -2
  66. data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
  67. data/lib/glimmer/swt/custom/radio_group.rb +143 -0
  68. data/lib/glimmer/swt/date_time_proxy.rb +145 -0
  69. data/lib/glimmer/swt/display_proxy.rb +6 -2
  70. data/lib/glimmer/swt/fill_layout_proxy.rb +1 -1
  71. data/lib/glimmer/swt/grid_layout_proxy.rb +19 -8
  72. data/lib/glimmer/swt/group_proxy.rb +38 -0
  73. data/lib/glimmer/swt/label_proxy.rb +27 -7
  74. data/lib/glimmer/swt/layout_data_proxy.rb +39 -21
  75. data/lib/glimmer/swt/layout_proxy.rb +4 -4
  76. data/lib/glimmer/swt/list_proxy.rb +3 -3
  77. data/lib/glimmer/swt/make_shift_shell_proxy.rb +4 -4
  78. data/lib/glimmer/swt/message_box_proxy.rb +10 -8
  79. data/lib/glimmer/swt/property_owner.rb +2 -2
  80. data/lib/glimmer/swt/radio_proxy.rb +82 -0
  81. data/lib/glimmer/swt/row_layout_proxy.rb +33 -10
  82. data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
  83. data/lib/glimmer/swt/shell_proxy.rb +29 -9
  84. data/lib/glimmer/swt/tab_folder_proxy.rb +5 -5
  85. data/lib/glimmer/swt/tab_item_proxy.rb +7 -7
  86. data/lib/glimmer/swt/table_column_proxy.rb +62 -12
  87. data/lib/glimmer/swt/table_item_proxy.rb +14 -7
  88. data/lib/glimmer/swt/table_proxy.rb +225 -16
  89. data/lib/glimmer/swt/text_proxy.rb +50 -2
  90. data/lib/glimmer/swt/widget_proxy.rb +88 -39
  91. data/lib/glimmer/ui/custom_widget.rb +8 -8
  92. data/lib/net/http.rb +1 -5
  93. data/lib/uri.rb +3 -3
  94. metadata +56 -9
  95. data/lib/glimmer/data_binding/ext/observable_model.rb +0 -40
@@ -1,4 +1,4 @@
1
- class Person
1
+ class Person
2
2
  attr_accessor :country, :country_options
3
3
 
4
4
  def initialize
@@ -0,0 +1,108 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ class HelloRadio
23
+ class Person
24
+ attr_accessor :male, :female, :child, :teen, :adult, :senior
25
+
26
+ def initialize
27
+ reset
28
+ end
29
+
30
+ def reset
31
+ self.male = nil
32
+ self.female = nil
33
+ self.child = nil
34
+ self.teen = nil
35
+ self.adult = true
36
+ self.senior = nil
37
+ end
38
+ end
39
+
40
+ include Glimmer
41
+
42
+ def launch
43
+ person = Person.new
44
+
45
+ shell {
46
+ text 'Hello, Radio!'
47
+ row_layout :vertical
48
+
49
+ label {
50
+ text 'Gender:'
51
+ font style: :bold
52
+ }
53
+
54
+ composite {
55
+ row_layout
56
+
57
+ radio {
58
+ text 'Male'
59
+ selection bind(person, :male)
60
+ }
61
+
62
+ radio {
63
+ text 'Female'
64
+ selection bind(person, :female)
65
+ }
66
+ }
67
+
68
+ label {
69
+ text 'Age Group:'
70
+ font style: :bold
71
+ }
72
+
73
+ composite {
74
+ row_layout
75
+
76
+ radio {
77
+ text 'Child'
78
+ selection bind(person, :child)
79
+ }
80
+
81
+ radio {
82
+ text 'Teen'
83
+ selection bind(person, :teen)
84
+ }
85
+
86
+ radio {
87
+ text 'Adult'
88
+ selection bind(person, :adult)
89
+ }
90
+
91
+ radio {
92
+ text 'Senior'
93
+ selection bind(person, :senior)
94
+ }
95
+ }
96
+
97
+ button {
98
+ text 'Reset'
99
+
100
+ on_widget_selected do
101
+ person.reset
102
+ end
103
+ }
104
+ }.open
105
+ end
106
+ end
107
+
108
+ HelloRadio.new.launch
@@ -0,0 +1,84 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ class HelloRadioGroup
23
+ class Person
24
+ attr_accessor :gender, :age_group
25
+
26
+ def initialize
27
+ reset
28
+ end
29
+
30
+ def gender_options
31
+ ['Male', 'Female']
32
+ end
33
+
34
+ def age_group_options
35
+ ['Child', 'Teen', 'Adult', 'Senior']
36
+ end
37
+
38
+ def reset
39
+ self.gender = nil
40
+ self.age_group = 'Adult'
41
+ end
42
+ end
43
+
44
+ include Glimmer
45
+
46
+ def launch
47
+ person = Person.new
48
+
49
+ shell {
50
+ text 'Hello, Radio Group!'
51
+ row_layout :vertical
52
+
53
+ label {
54
+ text 'Gender:'
55
+ font style: :bold
56
+ }
57
+
58
+ radio_group {
59
+ row_layout :horizontal
60
+ selection bind(person, :gender)
61
+ }
62
+
63
+ label {
64
+ text 'Age Group:'
65
+ font style: :bold
66
+ }
67
+
68
+ radio_group {
69
+ row_layout :horizontal
70
+ selection bind(person, :age_group)
71
+ }
72
+
73
+ button {
74
+ text 'Reset'
75
+
76
+ on_widget_selected do
77
+ person.reset
78
+ end
79
+ }
80
+ }.open
81
+ end
82
+ end
83
+
84
+ HelloRadioGroup.new.launch
@@ -0,0 +1,283 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ class HelloTable
23
+ class BaseballGame
24
+ class << self
25
+ attr_accessor :selected_game
26
+
27
+ def all_playoff_games
28
+ @all_playoff_games ||= {
29
+ 'NLDS' => [
30
+ new(Time.new(2037, 10, 6, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers', 'Free Bobblehead'),
31
+ new(Time.new(2037, 10, 7, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers'),
32
+ new(Time.new(2037, 10, 8, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs'),
33
+ new(Time.new(2037, 10, 9, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs'),
34
+ new(Time.new(2037, 10, 10, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 'Free Umbrella'),
35
+ new(Time.new(2037, 10, 6, 18, 0), 'Cincinnati Reds', 'St Louis Cardinals', 'Free Bobblehead'),
36
+ new(Time.new(2037, 10, 7, 18, 0), 'Cincinnati Reds', 'St Louis Cardinals'),
37
+ new(Time.new(2037, 10, 8, 18, 0), 'St Louis Cardinals', 'Cincinnati Reds'),
38
+ new(Time.new(2037, 10, 9, 18, 0), 'St Louis Cardinals', 'Cincinnati Reds'),
39
+ new(Time.new(2037, 10, 10, 18, 0), 'St Louis Cardinals', 'Cincinnati Reds', 'Free Umbrella'),
40
+ ],
41
+ 'ALDS' => [
42
+ new(Time.new(2037, 10, 6, 12, 0), 'New York Yankees', 'Boston Red Sox', 'Free Bobblehead'),
43
+ new(Time.new(2037, 10, 7, 12, 0), 'New York Yankees', 'Boston Red Sox'),
44
+ new(Time.new(2037, 10, 8, 12, 0), 'Boston Red Sox', 'New York Yankees'),
45
+ new(Time.new(2037, 10, 9, 12, 0), 'Boston Red Sox', 'New York Yankees'),
46
+ new(Time.new(2037, 10, 10, 12, 0), 'Boston Red Sox', 'New York Yankees', 'Free Umbrella'),
47
+ new(Time.new(2037, 10, 6, 18, 0), 'Houston Astros', 'Cleveland Indians', 'Free Bobblehead'),
48
+ new(Time.new(2037, 10, 7, 18, 0), 'Houston Astros', 'Cleveland Indians'),
49
+ new(Time.new(2037, 10, 8, 18, 0), 'Cleveland Indians', 'Houston Astros'),
50
+ new(Time.new(2037, 10, 9, 18, 0), 'Cleveland Indians', 'Houston Astros'),
51
+ new(Time.new(2037, 10, 10, 18, 0), 'Cleveland Indians', 'Houston Astros', 'Free Umbrella'),
52
+ ],
53
+ 'NLCS' => [
54
+ new(Time.new(2037, 10, 12, 12, 0), 'Chicago Cubs', 'Cincinnati Reds', 'Free Towel'),
55
+ new(Time.new(2037, 10, 13, 12, 0), 'Chicago Cubs', 'Cincinnati Reds'),
56
+ new(Time.new(2037, 10, 14, 12, 0), 'Cincinnati Reds', 'Chicago Cubs'),
57
+ new(Time.new(2037, 10, 15, 18, 0), 'Cincinnati Reds', 'Chicago Cubs'),
58
+ new(Time.new(2037, 10, 16, 18, 0), 'Cincinnati Reds', 'Chicago Cubs'),
59
+ new(Time.new(2037, 10, 17, 18, 0), 'Chicago Cubs', 'Cincinnati Reds'),
60
+ new(Time.new(2037, 10, 18, 12, 0), 'Chicago Cubs', 'Cincinnati Reds', 'Free Poncho'),
61
+ ],
62
+ 'ALCS' => [
63
+ new(Time.new(2037, 10, 12, 12, 0), 'Houston Astros', 'Boston Red Sox', 'Free Towel'),
64
+ new(Time.new(2037, 10, 13, 12, 0), 'Houston Astros', 'Boston Red Sox'),
65
+ new(Time.new(2037, 10, 14, 12, 0), 'Boston Red Sox', 'Houston Astros'),
66
+ new(Time.new(2037, 10, 15, 18, 0), 'Boston Red Sox', 'Houston Astros'),
67
+ new(Time.new(2037, 10, 16, 18, 0), 'Boston Red Sox', 'Houston Astros'),
68
+ new(Time.new(2037, 10, 17, 18, 0), 'Houston Astros', 'Boston Red Sox'),
69
+ new(Time.new(2037, 10, 18, 12, 0), 'Houston Astros', 'Boston Red Sox', 'Free Poncho'),
70
+ ],
71
+ 'World Series' => [
72
+ new(Time.new(2037, 10, 20, 18, 0), 'Chicago Cubs', 'Boston Red Sox', 'Free Baseball Cap'),
73
+ new(Time.new(2037, 10, 21, 18, 0), 'Chicago Cubs', 'Boston Red Sox'),
74
+ new(Time.new(2037, 10, 22, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
75
+ new(Time.new(2037, 10, 23, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
76
+ new(Time.new(2037, 10, 24, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
77
+ new(Time.new(2037, 10, 25, 18, 0), 'Chicago Cubs', 'Boston Red Sox'),
78
+ new(Time.new(2037, 10, 26, 18, 0), 'Chicago Cubs', 'Boston Red Sox', 'Free World Series Polo'),
79
+ ]
80
+ }
81
+ end
82
+
83
+ def playoff_type
84
+ @playoff_type ||= 'World Series'
85
+ end
86
+
87
+ def playoff_type=(new_playoff_type)
88
+ @playoff_type = new_playoff_type
89
+ self.schedule=(all_playoff_games[@playoff_type])
90
+ end
91
+
92
+ def playoff_type_options
93
+ all_playoff_games.keys
94
+ end
95
+
96
+ def schedule
97
+ @schedule ||= all_playoff_games[playoff_type]
98
+ end
99
+
100
+ def schedule=(new_schedule)
101
+ @schedule = new_schedule
102
+ end
103
+ end
104
+
105
+ include Glimmer
106
+ include Glimmer::DataBinding::ObservableModel
107
+
108
+ TEAM_BALLPARKS = {
109
+ 'Boston Red Sox' => 'Fenway Park',
110
+ 'Chicago Cubs' => 'Wrigley Field',
111
+ 'Cincinnati Reds' => 'Great American Ball Park',
112
+ 'Cleveland Indians' => 'Progressive Field',
113
+ 'Houston Astros' => 'Minute Maid Park',
114
+ 'Milwaukee Brewers' => 'Miller Park',
115
+ 'New York Yankees' => 'Yankee Stadium',
116
+ 'St Louis Cardinals' => 'Busch Stadium',
117
+ }
118
+
119
+ attr_accessor :date_time, :home_team, :away_team, :ballpark, :promotion
120
+
121
+ def initialize(date_time, home_team, away_team, promotion = 'N/A')
122
+ self.date_time = date_time
123
+ self.home_team = home_team
124
+ self.away_team = away_team
125
+ self.promotion = promotion
126
+ observe(self, :date_time) do |new_value|
127
+ notify_observers(:game_date)
128
+ notify_observers(:game_time)
129
+ end
130
+ end
131
+
132
+ def home_team=(home_team_value)
133
+ if home_team_value != away_team
134
+ @home_team = home_team_value
135
+ self.ballpark = TEAM_BALLPARKS[@home_team]
136
+ end
137
+ end
138
+
139
+ def away_team=(away_team_value)
140
+ if away_team_value != home_team
141
+ @away_team = away_team_value
142
+ end
143
+ end
144
+
145
+ def date
146
+ Date.new(date_time.year, date_time.month, date_time.day)
147
+ end
148
+
149
+ def time
150
+ Time.new(0, 1, 1, date_time.hour, date_time.min, date_time.sec, '+00:00')
151
+ end
152
+
153
+ def game_date
154
+ date_time.strftime("%m/%d/%Y")
155
+ end
156
+
157
+ def game_time
158
+ date_time.strftime("%I:%M %p")
159
+ end
160
+
161
+ def home_team_options
162
+ TEAM_BALLPARKS.keys
163
+ end
164
+
165
+ def away_team_options
166
+ TEAM_BALLPARKS.keys
167
+ end
168
+
169
+ def ballpark_options
170
+ [TEAM_BALLPARKS[@home_team], TEAM_BALLPARKS[@away_team]]
171
+ end
172
+
173
+ def to_s
174
+ "#{home_team} vs #{away_team} at #{ballpark} on #{game_date} #{game_time}"
175
+ end
176
+
177
+ def book!
178
+ "Thank you for booking #{to_s}"
179
+ end
180
+ end
181
+
182
+ include Glimmer
183
+
184
+ def launch
185
+ shell {
186
+ grid_layout
187
+
188
+ text 'Hello, Table!'
189
+
190
+ label {
191
+ layout_data :center, :center, true, false
192
+
193
+ text 'Baseball Playoff Schedule'
194
+ font height: 30, style: :bold
195
+ }
196
+
197
+ combo(:read_only) {
198
+ layout_data :center, :center, true, false
199
+ selection bind(BaseballGame, :playoff_type)
200
+ font height: 16
201
+ }
202
+
203
+ table(:editable) { |table_proxy|
204
+ layout_data :fill, :fill, true, true
205
+
206
+ table_column {
207
+ text 'Game Date'
208
+ width 150
209
+ sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
210
+ # editor :date_drop_down, property: :date_time
211
+ }
212
+ table_column {
213
+ text 'Game Time'
214
+ width 150
215
+ sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
216
+ # editor :time, property: :date_time
217
+ }
218
+ table_column {
219
+ text 'Ballpark'
220
+ width 180
221
+ # editor :none
222
+ }
223
+ table_column {
224
+ text 'Home Team'
225
+ width 150
226
+ # editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
227
+ }
228
+ table_column {
229
+ text 'Away Team'
230
+ width 150
231
+ # editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
232
+ }
233
+ table_column {
234
+ text 'Promotion'
235
+ width 150
236
+ # default text editor is used here
237
+ }
238
+
239
+ # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
240
+ items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
241
+
242
+ # Data-bind table selection
243
+ selection bind(BaseballGame, :selected_game)
244
+
245
+ # Default initial sort property
246
+ sort_property :date
247
+
248
+ # Sort by these additional properties after handling sort by the column the user clicked
249
+ additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
250
+
251
+ # menu {
252
+ # menu_item {
253
+ # text 'Book'
254
+ #
255
+ # on_widget_selected {
256
+ # book_selected_game
257
+ # }
258
+ # }
259
+ # }
260
+ }
261
+
262
+ button {
263
+ text 'Book Selected Game'
264
+ layout_data :center, :center, true, false
265
+ font height: 16
266
+ enabled bind(BaseballGame, :selected_game)
267
+
268
+ on_widget_selected {
269
+ book_selected_game
270
+ }
271
+ }
272
+ }.open
273
+ end
274
+
275
+ def book_selected_game
276
+ message_box {
277
+ text 'Baseball Game Booked!'
278
+ message BaseballGame.selected_game.book!
279
+ }.open
280
+ end
281
+ end
282
+
283
+ HelloTable.new.launch