glimmer-dsl-swt 4.17.8.1 → 4.17.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/README.md +249 -7
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +12 -7
- data/lib/glimmer-dsl-swt.rb +4 -3
- data/lib/glimmer/data_binding/table_items_binding.rb +5 -5
- data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/widget_expression.rb +1 -0
- data/lib/glimmer/launcher.rb +9 -9
- data/lib/glimmer/swt/custom/checkbox_group.rb +29 -8
- data/lib/glimmer/swt/custom/code_text.rb +36 -34
- data/lib/glimmer/swt/custom/radio_group.rb +27 -6
- data/lib/glimmer/swt/date_time_proxy.rb +87 -0
- data/lib/glimmer/swt/display_proxy.rb +6 -6
- data/lib/glimmer/swt/dnd_proxy.rb +6 -10
- data/lib/glimmer/swt/message_box_proxy.rb +7 -7
- data/lib/glimmer/swt/sash_form_proxy.rb +3 -3
- data/lib/glimmer/swt/shell_proxy.rb +18 -3
- data/lib/glimmer/swt/style_constantizable.rb +5 -5
- data/lib/glimmer/swt/swt_proxy.rb +7 -8
- data/lib/glimmer/swt/tab_item_proxy.rb +9 -4
- data/lib/glimmer/swt/table_column_proxy.rb +13 -5
- data/lib/glimmer/swt/table_proxy.rb +187 -66
- data/lib/glimmer/swt/widget_listener_proxy.rb +4 -4
- data/lib/glimmer/swt/widget_proxy.rb +47 -3
- data/samples/elaborate/contact_manager.rb +3 -3
- data/samples/elaborate/meta_sample.rb +9 -9
- data/samples/hello/hello_browser.rb +3 -3
- data/samples/hello/hello_checkbox.rb +4 -4
- data/samples/hello/hello_checkbox_group.rb +6 -3
- data/samples/hello/hello_combo.rb +5 -5
- data/samples/hello/hello_date_time.rb +63 -0
- data/samples/hello/hello_group.rb +104 -0
- data/samples/hello/hello_menu_bar.rb +3 -3
- data/samples/hello/hello_pop_up_context_menu.rb +3 -3
- data/samples/hello/hello_radio.rb +6 -6
- data/samples/hello/hello_radio_group.rb +9 -6
- data/samples/hello/hello_sash_form.rb +3 -3
- data/samples/hello/hello_spinner.rb +69 -0
- data/samples/hello/hello_tab.rb +3 -3
- data/samples/hello/hello_table.rb +287 -0
- metadata +11 -6
@@ -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
|
@@ -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
|
@@ -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
|
@@ -19,7 +19,7 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
class HelloRadio
|
22
|
+
class HelloRadio
|
23
23
|
class Person
|
24
24
|
attr_accessor :male, :female, :child, :teen, :adult, :senior
|
25
25
|
|
@@ -37,13 +37,13 @@ class HelloRadio
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
include Glimmer
|
40
|
+
include Glimmer
|
41
41
|
|
42
42
|
def launch
|
43
43
|
person = Person.new
|
44
44
|
|
45
45
|
shell {
|
46
|
-
text 'Hello, Radio!'
|
46
|
+
text 'Hello, Radio!'
|
47
47
|
row_layout :vertical
|
48
48
|
|
49
49
|
label {
|
@@ -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
|
@@ -19,6 +19,9 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
# This sample demonstrates the use of a `radio_group` in Glimmer, which provides terser syntax
|
23
|
+
# than HelloRadio for representing multiple radio buttons by relying on data-binding to
|
24
|
+
# automatically spawn the `radio` widgets based on available options on the model.
|
22
25
|
class HelloRadioGroup
|
23
26
|
class Person
|
24
27
|
attr_accessor :gender, :age_group
|
@@ -32,7 +35,7 @@ class HelloRadioGroup
|
|
32
35
|
end
|
33
36
|
|
34
37
|
def age_group_options
|
35
|
-
['Child', 'Teen', 'Adult', 'Senior']
|
38
|
+
['Child', 'Teen', 'Adult', 'Senior']
|
36
39
|
end
|
37
40
|
|
38
41
|
def reset
|
@@ -47,8 +50,8 @@ class HelloRadioGroup
|
|
47
50
|
person = Person.new
|
48
51
|
|
49
52
|
shell {
|
50
|
-
text 'Hello, Radio Group!'
|
51
|
-
row_layout :vertical
|
53
|
+
text 'Hello, Radio Group!'
|
54
|
+
row_layout :vertical
|
52
55
|
|
53
56
|
label {
|
54
57
|
text 'Gender:'
|
@@ -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
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Copyright (c) 2007-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 HelloSpinner
|
23
|
+
class Person
|
24
|
+
attr_accessor :donation
|
25
|
+
end
|
26
|
+
|
27
|
+
include Glimmer
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@person = Person.new
|
31
|
+
@person.donation = 500
|
32
|
+
end
|
33
|
+
|
34
|
+
def launch
|
35
|
+
shell {
|
36
|
+
grid_layout
|
37
|
+
|
38
|
+
text 'Hello, Spinner!'
|
39
|
+
|
40
|
+
label {
|
41
|
+
text 'Please select the amount you would like to donate to the poor:'
|
42
|
+
}
|
43
|
+
|
44
|
+
composite {
|
45
|
+
grid_layout 3, false
|
46
|
+
|
47
|
+
label {
|
48
|
+
text 'Amount:'
|
49
|
+
font style: :bold
|
50
|
+
}
|
51
|
+
|
52
|
+
label {
|
53
|
+
text '$'
|
54
|
+
}
|
55
|
+
|
56
|
+
spinner {
|
57
|
+
digits 2 # digits after the decimal point
|
58
|
+
minimum 500 # minimum value (including digits after the decimal point)
|
59
|
+
maximum 15000 # maximum value (including digits after the decimal point)
|
60
|
+
increment 500 # increment on up and down (including digits after the decimal point)
|
61
|
+
page_increment 5000 # page increment on page up and page down (including digits after the decimal point)
|
62
|
+
selection bind(@person, :donation) # selection must be set last if other properties are configured to ensure value is within bounds
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}.open
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
HelloSpinner.new.launch
|
data/samples/hello/hello_tab.rb
CHANGED
@@ -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
|
@@ -0,0 +1,287 @@
|
|
1
|
+
# Copyright (c) 2007-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
|
+
|
104
|
+
def selected_game=(new_game)
|
105
|
+
@selected_game = new_game
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
include Glimmer
|
110
|
+
include Glimmer::DataBinding::ObservableModel
|
111
|
+
|
112
|
+
TEAM_BALLPARKS = {
|
113
|
+
'Boston Red Sox' => 'Fenway Park',
|
114
|
+
'Chicago Cubs' => 'Wrigley Field',
|
115
|
+
'Cincinnati Reds' => 'Great American Ball Park',
|
116
|
+
'Cleveland Indians' => 'Progressive Field',
|
117
|
+
'Houston Astros' => 'Minute Maid Park',
|
118
|
+
'Milwaukee Brewers' => 'Miller Park',
|
119
|
+
'New York Yankees' => 'Yankee Stadium',
|
120
|
+
'St Louis Cardinals' => 'Busch Stadium',
|
121
|
+
}
|
122
|
+
|
123
|
+
attr_accessor :date_time, :home_team, :away_team, :ballpark, :promotion
|
124
|
+
|
125
|
+
def initialize(date_time, home_team, away_team, promotion = 'N/A')
|
126
|
+
self.date_time = date_time
|
127
|
+
self.home_team = home_team
|
128
|
+
self.away_team = away_team
|
129
|
+
self.promotion = promotion
|
130
|
+
observe(self, :date_time) do |new_value|
|
131
|
+
notify_observers(:game_date)
|
132
|
+
notify_observers(:game_time)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def home_team=(home_team_value)
|
137
|
+
if home_team_value != away_team
|
138
|
+
@home_team = home_team_value
|
139
|
+
self.ballpark = TEAM_BALLPARKS[@home_team]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def away_team=(away_team_value)
|
144
|
+
if away_team_value != home_team
|
145
|
+
@away_team = away_team_value
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
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")
|
163
|
+
end
|
164
|
+
|
165
|
+
def home_team_options
|
166
|
+
TEAM_BALLPARKS.keys
|
167
|
+
end
|
168
|
+
|
169
|
+
def away_team_options
|
170
|
+
TEAM_BALLPARKS.keys
|
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
|
184
|
+
end
|
185
|
+
|
186
|
+
include Glimmer
|
187
|
+
|
188
|
+
def launch
|
189
|
+
shell {
|
190
|
+
grid_layout
|
191
|
+
|
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
|
+
|
207
|
+
table(:editable) { |table_proxy|
|
208
|
+
layout_data :fill, :fill, true, true
|
209
|
+
|
210
|
+
table_column {
|
211
|
+
text 'Game Date'
|
212
|
+
width 150
|
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
|
215
|
+
}
|
216
|
+
table_column {
|
217
|
+
text 'Game Time'
|
218
|
+
width 150
|
219
|
+
sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
|
220
|
+
editor :time, property: :date_time
|
221
|
+
}
|
222
|
+
table_column {
|
223
|
+
text 'Ballpark'
|
224
|
+
width 180
|
225
|
+
editor :none
|
226
|
+
}
|
227
|
+
table_column {
|
228
|
+
text 'Home Team'
|
229
|
+
width 150
|
230
|
+
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
|
231
|
+
}
|
232
|
+
table_column {
|
233
|
+
text 'Away Team'
|
234
|
+
width 150
|
235
|
+
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
|
236
|
+
}
|
237
|
+
table_column {
|
238
|
+
text 'Promotion'
|
239
|
+
width 150
|
240
|
+
# default text editor is used here
|
241
|
+
}
|
242
|
+
|
243
|
+
# Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
|
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
|
251
|
+
|
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
|
+
}
|
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!
|
283
|
+
}.open
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
HelloTable.new.launch
|