glimmer-dsl-opal 0.0.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/README.md +995 -74
  4. data/VERSION +1 -1
  5. data/lib/glimmer-dsl-opal.rb +42 -7
  6. data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
  7. data/lib/glimmer-dsl-opal/missing/net/http.rb +17 -0
  8. data/lib/glimmer-dsl-opal/missing/uri.rb +26 -0
  9. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +2 -3
  10. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
  11. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
  12. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
  13. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -1
  14. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +5 -5
  15. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
  16. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
  17. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
  19. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
  20. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
  23. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
  24. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
  25. data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
  26. data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
  27. data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
  28. data/lib/glimmer/data_binding/element_binding.rb +1 -1
  29. data/lib/glimmer/data_binding/ext/observable_model.rb +40 -0
  30. data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
  31. data/lib/glimmer/data_binding/table_items_binding.rb +70 -0
  32. data/lib/glimmer/dsl/opal/async_exec_expression.rb +17 -0
  33. data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
  34. data/lib/glimmer/dsl/opal/column_properties_expression.rb +22 -0
  35. data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
  36. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +57 -0
  37. data/lib/glimmer/dsl/opal/dsl.rb +17 -14
  38. data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
  39. data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
  40. data/lib/glimmer/dsl/opal/{text_expression.rb → layout_expression.rb} +5 -5
  41. data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
  42. data/lib/glimmer/dsl/opal/message_box_expression.rb +20 -0
  43. data/lib/glimmer/dsl/opal/observe_expression.rb +32 -0
  44. data/lib/glimmer/dsl/opal/property_expression.rb +5 -2
  45. data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
  46. data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
  47. data/lib/glimmer/dsl/opal/shell_expression.rb +2 -2
  48. data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
  49. data/lib/glimmer/dsl/opal/{composite_expression.rb → table_column_expression.rb} +3 -3
  50. data/lib/glimmer/dsl/opal/{list_expression.rb → table_expression.rb} +3 -3
  51. data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +29 -0
  52. data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
  53. data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
  54. data/lib/glimmer/swt.rb +499 -0
  55. data/lib/glimmer/swt/browser_proxy.rb +27 -0
  56. data/lib/glimmer/swt/button_proxy.rb +40 -0
  57. data/lib/glimmer/swt/color_proxy.rb +119 -0
  58. data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +24 -19
  59. data/lib/glimmer/swt/composite_proxy.rb +31 -0
  60. data/lib/glimmer/swt/display_proxy.rb +25 -0
  61. data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
  62. data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
  63. data/lib/glimmer/swt/font_proxy.rb +79 -0
  64. data/lib/glimmer/swt/grid_layout_proxy.rb +71 -0
  65. data/lib/glimmer/swt/label_proxy.rb +34 -0
  66. data/lib/glimmer/swt/layout_data_proxy.rb +52 -0
  67. data/lib/glimmer/swt/layout_proxy.rb +62 -0
  68. data/lib/glimmer/{opal → swt}/list_proxy.rb +31 -23
  69. data/lib/glimmer/swt/message_box_proxy.rb +143 -0
  70. data/lib/glimmer/{opal → swt}/point.rb +1 -1
  71. data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
  72. data/lib/glimmer/swt/row_layout_proxy.rb +105 -0
  73. data/lib/glimmer/swt/shell_proxy.rb +245 -0
  74. data/lib/glimmer/swt/style_constantizable.rb +154 -0
  75. data/lib/glimmer/swt/swt_proxy.rb +53 -0
  76. data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +21 -15
  77. data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
  78. data/lib/glimmer/swt/table_column_proxy.rb +56 -0
  79. data/lib/glimmer/swt/table_item_proxy.rb +147 -0
  80. data/lib/glimmer/swt/table_proxy.rb +159 -0
  81. data/lib/glimmer/swt/text_proxy.rb +46 -0
  82. data/lib/glimmer/swt/widget_proxy.rb +490 -0
  83. data/lib/glimmer/ui/custom_shell.rb +73 -0
  84. data/lib/glimmer/ui/custom_widget.rb +290 -0
  85. data/lib/glimmer/util/proc_tracker.rb +39 -0
  86. metadata +134 -74
  87. data/lib/glimmer/config.rb +0 -22
  88. data/lib/glimmer/dsl/engine.rb +0 -193
  89. data/lib/glimmer/dsl/expression.rb +0 -42
  90. data/lib/glimmer/dsl/expression_handler.rb +0 -48
  91. data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
  92. data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
  93. data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
  94. data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
  95. data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
  96. data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
  97. data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
  98. data/lib/glimmer/dsl/parent_expression.rb +0 -12
  99. data/lib/glimmer/dsl/static_expression.rb +0 -36
  100. data/lib/glimmer/dsl/top_level_expression.rb +0 -7
  101. data/lib/glimmer/error.rb +0 -6
  102. data/lib/glimmer/invalid_keyword_error.rb +0 -6
  103. data/lib/glimmer/opal/div_proxy.rb +0 -22
  104. data/lib/glimmer/opal/document_proxy.rb +0 -128
  105. data/lib/glimmer/opal/element_proxy.rb +0 -281
  106. data/lib/glimmer/opal/grid_layout_proxy.rb +0 -53
  107. data/lib/glimmer/opal/iframe_proxy.rb +0 -23
  108. data/lib/glimmer/opal/input_proxy.rb +0 -41
  109. data/lib/glimmer/opal/label_proxy.rb +0 -25
  110. data/lib/glimmer/opal/layout_data_proxy.rb +0 -31
  111. data/lib/glimmer/opal/tab_item.rb +0 -98
  112. data/lib/samples/elaborate/launch +0 -6
  113. data/lib/samples/hello/hello_combo.rb +0 -34
  114. data/lib/samples/hello/hello_tab.rb +0 -24
  115. data/lib/samples/hello/hello_world.rb +0 -8
  116. data/lib/samples/hello/launch +0 -10
  117. data/lib/samples/launch +0 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.2.0
@@ -1,10 +1,45 @@
1
1
  require 'opal'
2
- require 'opal-parser'
3
- require 'glimmer'
4
2
 
5
- GLIMMER_DSL_OPAL_ROOT = File.expand_path('../..', __FILE__)
6
- GLIMMER_DSL_OPAL_LIB = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib')
3
+ if RUBY_PLATFORM == 'opal'
4
+ GLIMMER_DSL_OPAL_ROOT = File.expand_path('../..', __FILE__)
5
+ GLIMMER_DSL_OPAL_LIB = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib')
6
+ GLIMMER_DSL_OPAL_MISSING = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib', 'glimmer-dsl-opal', 'missing')
7
+
8
+ $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_LIB)
9
+ $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_MISSING) # missing Ruby classes/methods
10
+
11
+ require 'native' # move this to opal-async
12
+ require 'opal-async'
13
+ require 'async/ext'
14
+ require 'glimmer-dsl-opal/vendor/jquery'
15
+ require 'opal-jquery'
16
+ require 'glimmer'
17
+ require 'facets/hash/symbolize_keys'
18
+ require 'glimmer-dsl-opal/ext/exception'
7
19
 
8
- $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_LIB)
9
-
10
- require 'glimmer/dsl/opal/dsl'
20
+ # Spiking async logging
21
+ # logger = Glimmer::Config.logger
22
+ # original_add_method = logger.class.instance_method(:add)
23
+ # logger.define_singleton_method("__original_add", original_add_method)
24
+ # logger.singleton_class.send(:define_method, :add) do |*args|
25
+ # Async::Timeout.new 10000 do
26
+ # __original_add(*args)
27
+ # end
28
+ # end
29
+
30
+ require 'glimmer/dsl/opal/dsl'
31
+ require 'glimmer/data_binding/ext/observable_model'
32
+
33
+ require 'glimmer-dsl-xml'
34
+ require 'glimmer-dsl-css'
35
+ Element.alias_native :replace_with, :replaceWith
36
+
37
+ # Glimmer::Config.loop_max_count = 20
38
+
39
+ Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
40
+ method = method_symbol.to_s
41
+ result = false
42
+ result ||= method == '<<'
43
+ end
44
+
45
+ end
@@ -0,0 +1,5 @@
1
+ class Exception
2
+ def full_message
3
+ backtrace.join("\n")
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ # Missing Net module class methods TODO implement
2
+
3
+ require_relative '../uri'
4
+
5
+ module Net
6
+ # TODO Implement HTTP with jQuery for use in Glimmer DSL for Opal
7
+ # Note: ignore Protocol superclass for now
8
+ class HTTP
9
+ def post_form(uri, params)
10
+ # pd uri.scheme
11
+ # pd uri.host
12
+ # pd uri.path
13
+ # pd uri.query
14
+ # pd params
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # Missing URI module class features
2
+
3
+ module URI
4
+ class HTTP
5
+ REGEX = /([^:]+):\/\/([^\/])\/([^?]*)\??(.*)/
6
+
7
+ def initialize(url)
8
+ @url = url
9
+ uri_match = url.match(REGEX)
10
+ @scheme = uri_match[1]
11
+ @host = uri_match[2]
12
+ @path = uri_match[3]
13
+ @query = uri_match[4]
14
+ # TODO fragment
15
+ end
16
+
17
+ def to_s
18
+ url
19
+ end
20
+ end
21
+ end
22
+ module Kernel
23
+ def URI(url)
24
+ URI::HTTP.new(url)
25
+ end
26
+ end
@@ -81,9 +81,8 @@ class ContactManager
81
81
  @contact_manager_presenter.toggle_sort(:email)
82
82
  }
83
83
  }
84
- items bind(@contact_manager_presenter, :results),
85
- column_properties(:first_name, :last_name, :email)
86
- on_mouse_down { |event|
84
+ items bind(@contact_manager_presenter, :results), column_properties(:first_name, :last_name, :email)
85
+ on_mouse_up { |event|
87
86
  table_proxy.edit_table_item(event.table_item, event.column_index)
88
87
  }
89
88
  }
@@ -1,3 +1,24 @@
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
+
1
22
  require_relative "contact"
2
23
 
3
24
  class ContactManager
@@ -103,105 +124,8 @@ class ContactManager
103
124
  Jason
104
125
  Emma
105
126
  Olivia
106
- Ava
107
- Isabella
108
- Sophia
109
- Charlotte
110
- Mia
111
- Amelia
112
- Harper
113
- Evelyn
114
- Abigail
115
- Emily
116
- Elizabeth
117
- Mila
118
- Ella
119
- Avery
120
- Sofia
121
- Camila
122
- Aria
123
- Scarlett
124
- Victoria
125
- Madison
126
- Luna
127
- Grace
128
- Chloe
129
- Penelope
130
- Layla
131
- Riley
132
- Zoey
133
- Nora
134
- Lily
135
- Eleanor
136
- Hannah
137
- Lillian
138
- Addison
139
- Aubrey
140
- Ellie
141
- Stella
142
- Natalie
143
- Zoe
144
- Leah
145
- Hazel
146
- Violet
147
- Aurora
148
- Savannah
149
- Audrey
150
- Brooklyn
151
- Bella
152
- Claire
153
- Skylar
154
- Lucy
155
- Paisley
156
- Everly
157
- Anna
158
- Caroline
159
- Nova
160
- Genesis
161
- Emilia
162
- Kennedy
163
- Samantha
164
- Maya
165
- Willow
166
- Kinsley
167
- Naomi
168
- Aaliyah
169
- Elena
170
- Sarah
171
- Ariana
172
- Allison
173
- Gabriella
174
- Alice
175
- Madelyn
176
- Cora
177
- Ruby
178
- Eva
179
- Serenity
180
- Autumn
181
- Adeline
182
- Hailey
183
- Gianna
184
- Valentina
185
- Isla
186
- Eliana
187
- Quinn
188
- Nevaeh
189
- Ivy
190
- Sadie
191
- Piper
192
- Lydia
193
- Alexa
194
- Josephine
195
- Emery
196
- Julia
197
- Delilah
198
- Arianna
199
- Vivian
200
- Kaylee
201
- Sophie
202
- Brielle
203
- Madeline
204
127
  ]
128
+
205
129
  NAMES_LAST = %w[
206
130
  Smith
207
131
  Johnson
@@ -214,8 +138,9 @@ class ContactManager
214
138
  Anderson
215
139
  Taylor
216
140
  ]
141
+
217
142
  def initialize(contacts = nil)
218
- @contacts = contacts || 1000.times.map do |n|
143
+ @contacts = contacts || 100.times.map do |n|
219
144
  random_first_name_index = (rand*NAMES_FIRST.size).to_i
220
145
  random_last_name_index = (rand*NAMES_LAST.size).to_i
221
146
  first_name = NAMES_FIRST[random_first_name_index]
@@ -1,4 +1,3 @@
1
- require "java"
2
1
  require "observer"
3
2
 
4
3
  #Presents login screen data
@@ -37,11 +37,11 @@ class TicTacToe
37
37
  display_game_over_message("Draw!")
38
38
  end
39
39
 
40
- def display_game_over_message(message)
41
- message_box = MessageBox.new(@shell.swt_widget)
42
- message_box.setText("Game Over")
43
- message_box.setMessage(message)
44
- message_box.open
40
+ def display_game_over_message(message_text)
41
+ message_box(@shell) {
42
+ text 'Game Over'
43
+ message message_text
44
+ }.open
45
45
  @tic_tac_toe_board.reset
46
46
  end
47
47
 
@@ -0,0 +1,63 @@
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 Person
23
+ attr_accessor :country, :country_options
24
+
25
+ def initialize
26
+ self.country_options = ['', 'Canada', 'US', 'Mexico']
27
+ reset_country
28
+ end
29
+
30
+ def reset_country
31
+ self.country = 'Canada'
32
+ end
33
+ end
34
+
35
+ class HelloCombo
36
+ include Glimmer
37
+
38
+ def launch
39
+ person = Person.new
40
+
41
+ shell {
42
+ row_layout(:vertical) {
43
+ pack false
44
+ }
45
+
46
+ text 'Hello, Combo!'
47
+
48
+ combo(:read_only) {
49
+ selection bind(person, :country)
50
+ }
51
+
52
+ button {
53
+ text 'Reset Selection'
54
+
55
+ on_widget_selected do
56
+ person.reset_country
57
+ end
58
+ }
59
+ }.open
60
+ end
61
+ end
62
+
63
+ HelloCombo.new.launch
@@ -1,19 +1,19 @@
1
- require_relative "hello_computed/contact"
1
+ require_relative 'hello_computed/contact'
2
2
 
3
3
  class HelloComputed
4
4
  include Glimmer
5
5
 
6
6
  def initialize
7
7
  @contact = Contact.new(
8
- first_name: "Barry",
9
- last_name: "McKibbin",
8
+ first_name: 'Barry',
9
+ last_name: 'McKibbin',
10
10
  year_of_birth: 1985
11
11
  )
12
12
  end
13
13
 
14
14
  def launch
15
15
  shell {
16
- text "Hello Computed"
16
+ text 'Hello, Computed!'
17
17
  composite {
18
18
  grid_layout {
19
19
  num_columns 2
@@ -21,44 +21,44 @@ class HelloComputed
21
21
  horizontal_spacing 20
22
22
  vertical_spacing 10
23
23
  }
24
- label {text "First &Name: "}
24
+ label {text 'First &Name: '}
25
25
  text {
26
26
  text bind(@contact, :first_name)
27
27
  layout_data {
28
- horizontalAlignment :fill
29
- grabExcessHorizontalSpace true
28
+ horizontal_alignment :fill
29
+ grab_excess_horizontal_space true
30
30
  }
31
31
  }
32
- label {text "&Last Name: "}
32
+ label {text '&Last Name: '}
33
33
  text {
34
34
  text bind(@contact, :last_name)
35
35
  layout_data {
36
- horizontalAlignment :fill
37
- grabExcessHorizontalSpace true
36
+ horizontal_alignment :fill
37
+ grab_excess_horizontal_space true
38
38
  }
39
39
  }
40
- label {text "&Year of Birth: "}
40
+ label {text '&Year of Birth: '}
41
41
  text {
42
42
  text bind(@contact, :year_of_birth)
43
43
  layout_data {
44
- horizontalAlignment :fill
45
- grabExcessHorizontalSpace true
44
+ horizontal_alignment :fill
45
+ grab_excess_horizontal_space true
46
46
  }
47
47
  }
48
- label {text "Name: "}
48
+ label {text 'Name: '}
49
49
  label {
50
50
  text bind(@contact, :name, computed_by: [:first_name, :last_name])
51
51
  layout_data {
52
- horizontalAlignment :fill
53
- grabExcessHorizontalSpace true
52
+ horizontal_alignment :fill
53
+ grab_excess_horizontal_space true
54
54
  }
55
55
  }
56
- label {text "Age: "}
56
+ label {text 'Age: '}
57
57
  label {
58
58
  text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
59
59
  layout_data {
60
- horizontalAlignment :fill
61
- grabExcessHorizontalSpace true
60
+ horizontal_alignment :fill
61
+ grab_excess_horizontal_space true
62
62
  }
63
63
  }
64
64
  }