glimmer-dsl-opal 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/README.md +453 -48
  4. data/VERSION +1 -1
  5. data/lib/display.rb +31 -0
  6. data/lib/glimmer-dsl-opal.rb +15 -36
  7. data/lib/glimmer-dsl-opal/ext/class.rb +10 -0
  8. data/lib/glimmer-dsl-opal/ext/file.rb +29 -0
  9. data/lib/glimmer-dsl-opal/ext/struct.rb +37 -0
  10. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
  11. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +24 -1
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +46 -0
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -0
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +7 -7
  16. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +62 -32
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +47 -22
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +37 -0
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +84 -0
  20. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +2 -2
  21. data/lib/glimmer/data_binding/observable_element.rb +1 -1
  22. data/lib/glimmer/data_binding/table_items_binding.rb +3 -3
  23. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -0
  24. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  25. data/lib/glimmer/dsl/opal/menu_bar_expression.rb +54 -0
  26. data/lib/glimmer/dsl/opal/menu_expression.rb +61 -0
  27. data/lib/glimmer/dsl/opal/widget_expression.rb +3 -2
  28. data/lib/glimmer/dsl/opal/widget_listener_expression.rb +2 -2
  29. data/lib/glimmer/swt/combo_proxy.rb +40 -1
  30. data/lib/glimmer/swt/control_editor.rb +2 -1
  31. data/lib/glimmer/swt/custom/checkbox_group.rb +2 -2
  32. data/lib/glimmer/swt/custom/radio_group.rb +2 -2
  33. data/lib/glimmer/swt/date_time_proxy.rb +66 -1
  34. data/lib/glimmer/swt/event_listener_proxy.rb +14 -4
  35. data/lib/glimmer/swt/font_proxy.rb +4 -4
  36. data/lib/glimmer/swt/grid_layout_proxy.rb +21 -12
  37. data/lib/glimmer/swt/label_proxy.rb +17 -6
  38. data/lib/glimmer/swt/layout_data_proxy.rb +10 -7
  39. data/lib/glimmer/swt/list_proxy.rb +33 -0
  40. data/lib/glimmer/swt/menu_item_proxy.rb +87 -0
  41. data/lib/glimmer/swt/menu_proxy.rb +162 -0
  42. data/lib/glimmer/swt/message_box_proxy.rb +53 -67
  43. data/lib/glimmer/swt/property_owner.rb +2 -0
  44. data/lib/glimmer/swt/radio_proxy.rb +1 -1
  45. data/lib/glimmer/swt/shell_proxy.rb +32 -187
  46. data/lib/glimmer/swt/tab_folder_proxy.rb +43 -0
  47. data/lib/glimmer/swt/table_column_proxy.rb +4 -3
  48. data/lib/glimmer/swt/table_editor.rb +2 -2
  49. data/lib/glimmer/swt/table_item_proxy.rb +15 -5
  50. data/lib/glimmer/swt/table_proxy.rb +34 -12
  51. data/lib/glimmer/swt/text_proxy.rb +1 -1
  52. data/lib/glimmer/swt/widget_proxy.rb +335 -38
  53. data/lib/glimmer/ui/custom_shell.rb +9 -7
  54. data/lib/glimmer/ui/custom_widget.rb +3 -3
  55. data/lib/os.rb +36 -0
  56. metadata +36 -3
@@ -1,3 +1,24 @@
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
+
1
22
  require_relative 'hello_computed/contact'
2
23
 
3
24
  class HelloComputed
@@ -14,6 +35,7 @@ class HelloComputed
14
35
  def launch
15
36
  shell {
16
37
  text 'Hello, Computed!'
38
+
17
39
  composite {
18
40
  grid_layout {
19
41
  num_columns 2
@@ -21,6 +43,7 @@ class HelloComputed
21
43
  horizontal_spacing 20
22
44
  vertical_spacing 10
23
45
  }
46
+
24
47
  label {text 'First &Name: '}
25
48
  text {
26
49
  text bind(@contact, :first_name)
@@ -29,6 +52,7 @@ class HelloComputed
29
52
  grab_excess_horizontal_space true
30
53
  }
31
54
  }
55
+
32
56
  label {text '&Last Name: '}
33
57
  text {
34
58
  text bind(@contact, :last_name)
@@ -37,6 +61,7 @@ class HelloComputed
37
61
  grab_excess_horizontal_space true
38
62
  }
39
63
  }
64
+
40
65
  label {text '&Year of Birth: '}
41
66
  text {
42
67
  text bind(@contact, :year_of_birth)
@@ -45,6 +70,7 @@ class HelloComputed
45
70
  grab_excess_horizontal_space true
46
71
  }
47
72
  }
73
+
48
74
  label {text 'Name: '}
49
75
  label {
50
76
  text bind(@contact, :name, computed_by: [:first_name, :last_name])
@@ -53,6 +79,7 @@ class HelloComputed
53
79
  grab_excess_horizontal_space true
54
80
  }
55
81
  }
82
+
56
83
  label {text 'Age: '}
57
84
  label {
58
85
  text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 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
@@ -26,7 +26,7 @@ require 'date'
26
26
  class EmailShell
27
27
  include Glimmer::UI::CustomShell
28
28
 
29
- # multiple options without default values
29
+ # multiple options without default values
30
30
  options :date, :subject, :from, :message
31
31
 
32
32
  # single option with default value
@@ -41,7 +41,7 @@ class EmailShell
41
41
  shell(swt_style) {
42
42
  grid_layout(2, false)
43
43
 
44
- text subject
44
+ text subject
45
45
 
46
46
  label {
47
47
  text 'Date:'
@@ -78,7 +78,7 @@ class EmailShell
78
78
  }
79
79
 
80
80
  background :white
81
- text message
81
+ text message
82
82
  }
83
83
  }
84
84
  }
@@ -149,7 +149,7 @@ class HelloCustomShell
149
149
  }
150
150
  }
151
151
  }.open
152
- end
152
+ end
153
153
  end
154
154
 
155
155
  HelloCustomShell.new.launch
@@ -1,41 +1,71 @@
1
- class Person
2
- attr_accessor :provinces, :provinces_options
3
-
4
- def initialize
5
- self.provinces_options=[
6
- "",
7
- "Quebec",
8
- "Ontario",
9
- "Manitoba",
10
- "Saskatchewan",
11
- "Alberta",
12
- "British Columbia",
13
- "Nova Skotia",
14
- "Newfoundland"
15
- ]
16
- self.provinces = ["Quebec", "Manitoba", "Alberta"]
17
- end
18
-
19
- def reset_provinces
20
- self.provinces = ["Quebec", "Manitoba", "Alberta"]
21
- end
22
- end
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.
23
21
 
24
22
  class HelloListMultiSelection
23
+ class Person
24
+ attr_accessor :provinces, :provinces_options
25
+
26
+ def initialize
27
+ self.provinces_options = [
28
+ '',
29
+ 'Alberta',
30
+ 'British Columbia',
31
+ 'Manitoba',
32
+ 'New Brunswick',
33
+ 'Newfoundland and Labrador',
34
+ 'Northwest Territories',
35
+ 'Nova Scotia',
36
+ 'Nunavut',
37
+ 'Ontario',
38
+ 'Prince Edward Island',
39
+ 'Quebec',
40
+ 'Saskatchewan',
41
+ 'Yukon'
42
+ ]
43
+ reset_provinces
44
+ end
45
+
46
+ def reset_provinces
47
+ self.provinces = ['Quebec', 'Manitoba', 'Alberta']
48
+ end
49
+ end
50
+
25
51
  include Glimmer
52
+
26
53
  def launch
27
54
  person = Person.new
55
+
28
56
  shell {
29
- composite {
30
- list(:multi) {
31
- selection bind(person, :provinces)
32
- }
33
- button {
34
- text "Reset"
35
- on_widget_selected do
36
- person.reset_provinces
37
- end
38
- }
57
+ grid_layout
58
+
59
+ text 'Hello, List Multi Selection!'
60
+
61
+ list(:multi) {
62
+ selection bind(person, :provinces)
63
+ }
64
+
65
+ button {
66
+ text 'Reset Selections To Default Values'
67
+
68
+ on_widget_selected { person.reset_provinces }
39
69
  }
40
70
  }.open
41
71
  end
@@ -1,31 +1,56 @@
1
- class Person
2
- attr_accessor :country, :country_options
3
-
4
- def initialize
5
- self.country_options=["", "Canada", "US", "Mexico"]
6
- self.country = "Canada"
7
- end
8
-
9
- def reset_country
10
- self.country = "Canada"
11
- end
12
- end
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.
13
21
 
14
22
  class HelloListSingleSelection
23
+ class Person
24
+ attr_accessor :country, :country_options
25
+
26
+ def initialize
27
+ self.country_options = ['', 'Canada', 'US', 'Mexico']
28
+ reset_country
29
+ end
30
+
31
+ def reset_country
32
+ self.country = 'Canada'
33
+ end
34
+ end
35
+
15
36
  include Glimmer
37
+
16
38
  def launch
17
39
  person = Person.new
40
+
18
41
  shell {
19
- composite {
20
- list {
21
- selection bind(person, :country)
22
- }
23
- button {
24
- text "Reset"
25
- on_widget_selected do
26
- person.reset_country
27
- end
28
- }
42
+ grid_layout
43
+
44
+ text 'Hello, List Single Selection!'
45
+
46
+ list {
47
+ selection bind(person, :country)
48
+ }
49
+
50
+ button {
51
+ text 'Reset Selection To Default Value'
52
+
53
+ on_widget_selected { person.reset_country }
29
54
  }
30
55
  }.open
31
56
  end
@@ -0,0 +1,37 @@
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
+ include Glimmer
23
+
24
+ shell {
25
+ text 'Hello, Message Box!'
26
+
27
+ button {
28
+ text 'Please Click To Win a Surprise'
29
+
30
+ on_widget_selected {
31
+ message_box {
32
+ text 'Surprise'
33
+ message "Congratulations!\n\nYou won $1,000,000!"
34
+ }.open
35
+ }
36
+ }
37
+ }.open
@@ -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
+ include Glimmer
23
+
24
+ shell {
25
+ grid_layout {
26
+ margin_width 0
27
+ margin_height 0
28
+ }
29
+
30
+ text 'Hello, Pop Up Context Menu!'
31
+
32
+ label {
33
+ text "Right-Click on the Text to\nPop Up a Context Menu"
34
+ font height: 50
35
+
36
+ menu {
37
+ menu {
38
+ text '&History'
39
+ menu {
40
+ text '&Recent'
41
+ menu_item {
42
+ text 'File 1'
43
+ on_widget_selected {
44
+ message_box {
45
+ text 'File 1'
46
+ message 'File 1 Contents'
47
+ }.open
48
+ }
49
+ }
50
+ menu_item {
51
+ text 'File 2'
52
+ on_widget_selected {
53
+ message_box {
54
+ text 'File 2'
55
+ message 'File 2 Contents'
56
+ }.open
57
+ }
58
+ }
59
+ }
60
+ menu {
61
+ text '&Archived'
62
+ menu_item {
63
+ text 'File 3'
64
+ on_widget_selected {
65
+ message_box {
66
+ text 'File 3'
67
+ message 'File 3 Contents'
68
+ }.open
69
+ }
70
+ }
71
+ menu_item {
72
+ text 'File 4'
73
+ on_widget_selected {
74
+ message_box {
75
+ text 'File 4'
76
+ message 'File 4 Contents'
77
+ }.open
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }.open
@@ -207,13 +207,13 @@ class HelloTable
207
207
  text 'Game Date'
208
208
  width 150
209
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
210
+ editor :date_drop_down, property: :date_time
211
211
  }
212
212
  table_column {
213
213
  text 'Game Time'
214
214
  width 150
215
215
  sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
216
- # editor :time, property: :date_time
216
+ editor :time, property: :date_time
217
217
  }
218
218
  table_column {
219
219
  text 'Ballpark'
@@ -4,7 +4,7 @@ module Glimmer
4
4
  def method_missing(method, *args, &block)
5
5
  method_name = method.to_s
6
6
  if method_name.start_with?('on_')
7
- handle_observation_request(method_name, &block)
7
+ handle_observation_request(method_name, block)
8
8
  else
9
9
  super
10
10
  end