Class: HelloTable

Inherits:
Object
  • Object
show all
Includes:
Glimmer
Defined in:
lib/glimmer-dsl-opal/samples/hello/hello_table.rb

Overview

Copyright © 2020 Andy Maleh

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Classes: BaseballGame

Instance Method Summary collapse

Instance Method Details

#book_selected_gameObject



275
276
277
278
279
280
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 275

def book_selected_game
  message_box {
    text 'Baseball Game Booked!'
    message BaseballGame.selected_game.book!
  }.open
end

#launchObject



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 184

def launch
  shell {
    grid_layout
    
    text 'Hello, Table!'
    
    label {
      layout_data :center, :center, true, false
      
      text 'Baseball Playoff Schedule'
      font height: 30, style: :bold
    }
    
    combo(:read_only) {
      layout_data :center, :center, true, false
      selection bind(BaseballGame, :playoff_type)
      font height: 16
    }
    
    table(:editable) { |table_proxy|
      layout_data :fill, :fill, true, true
    
      table_column {
        text 'Game Date'
        width 150
        sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
        editor :date_drop_down, property: :date_time
      }
      table_column {
        text 'Game Time'
        width 150
        sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
        editor :time, property: :date_time
      }
      table_column {
        text 'Ballpark'
        width 180
        editor :none
      }
      table_column {
        text 'Home Team'
        width 150
        editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
      }
      table_column {
        text 'Away Team'
        width 150
        editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
      }
      table_column {
        text 'Promotion'
        width 150
        # default text editor is used here
      }
      
      # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
      items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
      
      # Data-bind table selection
      selection bind(BaseballGame, :selected_game)
      
      # Default initial sort property
      sort_property :date
      
      # Sort by these additional properties after handling sort by the column the user clicked
      additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
      
#         menu {
#           menu_item {
#             text 'Book'
#
#             on_widget_selected {
#               book_selected_game
#             }
#           }
#         }
    }
    
    button {
      text 'Book Selected Game'
      layout_data :center, :center, true, false
      font height: 16
      enabled bind(BaseballGame, :selected_game)
      
      on_widget_selected {
        book_selected_game
      }
    }
  }.open
end