glimmer-dsl-swt 4.17.9.0 → 4.17.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2020 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -22,43 +22,115 @@
22
22
  class HelloTable
23
23
  class BaseballGame
24
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
+
25
96
  def schedule
26
- @schedule ||= [
27
- new(Time.new(2037, 10, 6, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers', 5, 7),
28
- new(Time.new(2037, 10, 7, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers', 11, 7),
29
- new(Time.new(2037, 10, 8, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 2, 3),
30
- new(Time.new(2037, 10, 9, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 1, 0),
31
- new(Time.new(2037, 10, 10, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 9, 10),
32
- new(Time.new(2037, 10, 6, 18, 0), 'Chicago White Sox', 'St Louis Cardinals', 2, 4),
33
- new(Time.new(2037, 10, 7, 18, 0), 'Chicago White Sox', 'St Louis Cardinals', 5, 6),
34
- new(Time.new(2037, 10, 8, 18, 0), 'St Louis Cardinals', 'Chicago White Sox', 0, 7),
35
- new(Time.new(2037, 10, 9, 18, 0), 'St Louis Cardinals', 'Chicago White Sox', 3, 4),
36
- new(Time.new(2037, 10, 10, 18, 0), 'St Louis Cardinals', 'Chicago White Sox', 11, 13),
37
- ]
97
+ @schedule ||= all_playoff_games[playoff_type]
38
98
  end
39
99
 
40
100
  def schedule=(new_schedule)
41
101
  @schedule = new_schedule
42
102
  end
103
+
104
+ def selected_game=(new_game)
105
+ @selected_game = new_game
106
+ end
43
107
  end
44
108
 
109
+ include Glimmer
45
110
  include Glimmer::DataBinding::ObservableModel
46
111
 
47
112
  TEAM_BALLPARKS = {
113
+ 'Boston Red Sox' => 'Fenway Park',
48
114
  'Chicago Cubs' => 'Wrigley Field',
49
- 'Chicago White Sox' => 'Guaranteed Rate Field',
115
+ 'Cincinnati Reds' => 'Great American Ball Park',
116
+ 'Cleveland Indians' => 'Progressive Field',
117
+ 'Houston Astros' => 'Minute Maid Park',
50
118
  'Milwaukee Brewers' => 'Miller Park',
51
- 'St Louis Cardinals' => 'Busch Stadium'
119
+ 'New York Yankees' => 'Yankee Stadium',
120
+ 'St Louis Cardinals' => 'Busch Stadium',
52
121
  }
53
122
 
54
- attr_accessor :home_team, :away_team, :date_time, :ballpark, :home_team_runs, :away_team_runs
123
+ attr_accessor :date_time, :home_team, :away_team, :ballpark, :promotion
55
124
 
56
- def initialize(date_time, home_team, away_team, home_team_runs, away_team_runs)
125
+ def initialize(date_time, home_team, away_team, promotion = 'N/A')
57
126
  self.date_time = date_time
58
127
  self.home_team = home_team
59
128
  self.away_team = away_team
60
- self.home_team_runs = home_team_runs
61
- self.away_team_runs = away_team_runs
129
+ self.promotion = promotion
130
+ observe(self, :date_time) do |new_value|
131
+ notify_observers(:game_date)
132
+ notify_observers(:game_time)
133
+ end
62
134
  end
63
135
 
64
136
  def home_team=(home_team_value)
@@ -74,8 +146,20 @@ class HelloTable
74
146
  end
75
147
  end
76
148
 
77
- def game_date_time
78
- date_time.strftime("%Y-%m-%d %I:%M %p")
149
+ def date
150
+ Date.new(date_time.year, date_time.month, date_time.day)
151
+ end
152
+
153
+ def time
154
+ Time.new(0, 1, 1, date_time.hour, date_time.min, date_time.sec, '+00:00')
155
+ end
156
+
157
+ def game_date
158
+ date_time.strftime("%m/%d/%Y")
159
+ end
160
+
161
+ def game_time
162
+ date_time.strftime("%I:%M %p")
79
163
  end
80
164
 
81
165
  def home_team_options
@@ -85,52 +169,117 @@ class HelloTable
85
169
  def away_team_options
86
170
  TEAM_BALLPARKS.keys
87
171
  end
172
+
173
+ def ballpark_options
174
+ [TEAM_BALLPARKS[@home_team], TEAM_BALLPARKS[@away_team]]
175
+ end
176
+
177
+ def to_s
178
+ "#{home_team} vs #{away_team} at #{ballpark} on #{game_date} #{game_time}"
179
+ end
180
+
181
+ def book!
182
+ "Thank you for booking #{to_s}"
183
+ end
88
184
  end
89
185
 
90
186
  include Glimmer
91
187
 
92
188
  def launch
93
189
  shell {
190
+ grid_layout
191
+
94
192
  text 'Hello, Table!'
193
+
194
+ label {
195
+ layout_data :center, :center, true, false
196
+
197
+ text 'Baseball Playoff Schedule'
198
+ font height: 30, style: :bold
199
+ }
200
+
201
+ combo(:read_only) {
202
+ layout_data :center, :center, true, false
203
+ selection bind(BaseballGame, :playoff_type)
204
+ font height: 16
205
+ }
206
+
95
207
  table(:editable) { |table_proxy|
208
+ layout_data :fill, :fill, true, true
209
+
96
210
  table_column {
97
- text 'Game Date/Time'
211
+ text 'Game Date'
98
212
  width 150
99
- sort_property :date_time # ensure sorting by real date value (not `game_date_time` string specified in items below)
100
- editor :none
213
+ sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
214
+ editor :date_drop_down, property: :date_time
101
215
  }
102
216
  table_column {
103
- text 'Home Team'
217
+ text 'Game Time'
104
218
  width 150
105
- editor :combo, :read_only
219
+ sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
220
+ editor :time, property: :date_time
106
221
  }
107
222
  table_column {
108
- text 'Home Team Runs'
109
- width 100
110
- editor :spinner
223
+ text 'Ballpark'
224
+ width 180
225
+ editor :none
111
226
  }
112
227
  table_column {
113
- text 'Away Team'
228
+ text 'Home Team'
114
229
  width 150
115
- editor :combo, :read_only
230
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
116
231
  }
117
232
  table_column {
118
- text 'Away Team Runs'
119
- width 100
120
- editor :spinner
233
+ text 'Away Team'
234
+ width 150
235
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
121
236
  }
122
237
  table_column {
123
- text 'Ballpark'
238
+ text 'Promotion'
124
239
  width 150
125
- editor :none
240
+ # default text editor is used here
126
241
  }
127
242
 
128
243
  # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
129
- items bind(BaseballGame, :schedule), column_properties(:game_date_time, :home_team, :home_team_runs, :away_team, :away_team_runs, :ballpark)
244
+ items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
245
+
246
+ # Data-bind table selection
247
+ selection bind(BaseballGame, :selected_game)
248
+
249
+ # Default initial sort property
250
+ sort_property :date
130
251
 
131
- # Sort by these additional properties after handling the main column sort the user selected
132
- additional_sort_properties :date_time, :home_team, :away_team, :ballpark, :home_team_runs, :away_team_runs
252
+ # Sort by these additional properties after handling sort by the column the user clicked
253
+ additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
254
+
255
+ menu {
256
+ menu_item {
257
+ text 'Book'
258
+
259
+ on_widget_selected {
260
+ book_selected_game
261
+ }
262
+ }
263
+ }
133
264
  }
265
+
266
+ button {
267
+ text 'Book Selected Game'
268
+ layout_data :center, :center, true, false
269
+ font height: 16
270
+ enabled bind(BaseballGame, :selected_game)
271
+
272
+ on_widget_selected {
273
+ book_selected_game
274
+ }
275
+ }
276
+ }.open
277
+ end
278
+
279
+ def book_selected_game
280
+ message_box {
281
+ text 'Baseball Game Booked!'
282
+ message BaseballGame.selected_game.book!
134
283
  }.open
135
284
  end
136
285
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.9.0
4
+ version: 4.17.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-07 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -452,6 +452,7 @@ files:
452
452
  - samples/hello/hello_radio.rb
453
453
  - samples/hello/hello_radio_group.rb
454
454
  - samples/hello/hello_sash_form.rb
455
+ - samples/hello/hello_spinner.rb
455
456
  - samples/hello/hello_styled_text.rb
456
457
  - samples/hello/hello_tab.rb
457
458
  - samples/hello/hello_table.rb