glimmer 0.1.11.470 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +104 -66
  3. data/bin/girb +1 -3
  4. data/bin/glimmer +1 -1
  5. data/lib/glimmer_application.rb +35 -76
  6. data/vendor/swt/linux/swt.jar +0 -0
  7. data/vendor/swt/mac/swt.jar +0 -0
  8. data/vendor/swt/windows/swt.jar +0 -0
  9. metadata +15 -55
  10. data/.coveralls.yml +0 -1
  11. data/.rspec +0 -2
  12. data/.ruby-gemset +0 -1
  13. data/.ruby-version +0 -1
  14. data/Gemfile +0 -14
  15. data/RELEASE.md +0 -15
  16. data/Rakefile +0 -43
  17. data/TODO.md +0 -12
  18. data/VERSION +0 -1
  19. data/bin/girb_runner.rb +0 -1
  20. data/glimmer.gemspec +0 -160
  21. data/images/Bitter-sweet.jpg +0 -0
  22. data/samples/contactmanager/contact.rb +0 -9
  23. data/samples/contactmanager/contact_manager.rb +0 -71
  24. data/samples/contactmanager/contact_manager_presenter.rb +0 -24
  25. data/samples/contactmanager/contact_repository.rb +0 -24
  26. data/samples/hello_combo.rb +0 -36
  27. data/samples/hello_list_multi_selection.rb +0 -46
  28. data/samples/hello_list_single_selection.rb +0 -36
  29. data/samples/hello_tab.rb +0 -26
  30. data/samples/hello_world.rb +0 -10
  31. data/samples/hellocomputed/contact.rb +0 -19
  32. data/samples/hellocomputed/hello_computed.rb +0 -68
  33. data/samples/login.rb +0 -92
  34. data/samples/tictactoe/tic_tac_toe.rb +0 -64
  35. data/samples/tictactoe/tic_tac_toe_board.rb +0 -146
  36. data/spec/lib/command_handlers/models/observable_model_spec.rb +0 -22
  37. data/spec/lib/command_handlers/models/r_widget_spec.rb +0 -52
  38. data/spec/lib/glimmer__combo_data_binding__spec.rb +0 -130
  39. data/spec/lib/glimmer__constant__spec.rb +0 -30
  40. data/spec/lib/glimmer__data_binding__spec.rb +0 -404
  41. data/spec/lib/glimmer__list_data_binding__spec.rb +0 -224
  42. data/spec/lib/glimmer__listeners__spec.rb +0 -60
  43. data/spec/lib/glimmer__shine_data_binding__spec.rb +0 -89
  44. data/spec/lib/glimmer__tab_item__spec.rb +0 -55
  45. data/spec/lib/glimmer__table_data_binding__spec.rb +0 -121
  46. data/spec/lib/glimmer__tree_data_binding__spec.rb +0 -113
  47. data/spec/lib/glimmer_spec.rb +0 -251
  48. data/spec/lib/xml/glimmer_xml_spec.rb +0 -154
  49. data/spec/samples/contactmanager/contact_manager_presenter_spec.rb +0 -81
  50. data/spec/samples/tictactoe/tic_tac_toe_spec.rb +0 -263
  51. data/spec/spec_helper.rb +0 -124
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ObservableModel do
4
- class Person
5
- attr_accessor :name
6
- end
7
-
8
- it "observes model" do
9
- person = Person.new
10
- person.name = "Marty"
11
- expect(person.name).to eq("Marty")
12
- person.extend ObservableModel
13
- person.add_observer(:name, self)
14
- person.name = "Julia"
15
- expect(@observed_name).to eq("Julia")
16
- expect(person.name).to eq("Julia")
17
- end
18
-
19
- def update(name)
20
- @observed_name = name
21
- end
22
- end
@@ -1,52 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe RWidget do
4
- include Glimmer
5
-
6
- before do
7
- dsl :swt
8
- end
9
-
10
- it 'asyncronously executes' do
11
- @target = shell {
12
- @text = text {
13
- text "text1"
14
- }
15
- }
16
-
17
- @target.async_exec do
18
- @text.widget.setText("text2")
19
- end
20
-
21
- @target.async_exec do
22
- expect(@text.widget.getText).to eq("text2")
23
- @target.widget.close
24
- end
25
-
26
- @target.open
27
- end
28
-
29
- it "syncronously executes" do
30
- @target = shell {
31
- @text = text {
32
- text "text1"
33
- }
34
- }
35
-
36
- @target.async_exec do
37
- expect(@text.widget.getText).to eq("text2")
38
- @text.widget.setText("text3")
39
- end
40
-
41
- @target.sync_exec do
42
- @text.widget.setText("text2")
43
- end
44
-
45
- @target.async_exec do
46
- @target.widget.close
47
- end
48
-
49
- @target.open
50
- end
51
-
52
- end
@@ -1,130 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Glimmer Combo Data Binding" do
4
- include Glimmer
5
-
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
-
10
- before do
11
- dsl :swt
12
- end
13
-
14
- after do
15
- @target.display.dispose if @target.display
16
- end
17
-
18
- class Person
19
- attr_accessor :country, :country_options
20
-
21
- def initialize
22
- self.country_options=["", "Canada", "US", "Mexico"]
23
- end
24
- end
25
-
26
- it "tests data binding selection property" do
27
- person = Person.new
28
-
29
- @target = shell {
30
- @combo = combo {
31
- selection bind(person, :country)
32
- }
33
- }
34
-
35
- expect(@combo.widget.item_count).to eq(4)
36
- expect(@combo.widget.selection_index).to eq(-1)
37
- expect(@combo.widget.text).to eq("")
38
-
39
- person.country = "Canada"
40
-
41
- expect(@combo.widget.text).to eq("Canada")
42
-
43
- person.country_options << "France"
44
-
45
- expect(@combo.widget.item_count).to eq(5)
46
-
47
- person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
48
-
49
- expect(@combo.widget.item_count).to eq(6)
50
-
51
- person.country_options << "Italy"
52
- person.country_options << "Germany"
53
- person.country_options << "Australia"
54
-
55
- expect(@combo.widget.item_count).to eq(9)
56
-
57
- expect(@combo.widget.text).to eq("")
58
-
59
- @combo.widget.select(2)
60
- @combo.widget.notifyListeners(SWT::Selection, nil)
61
- expect(person.country).to eq("US")
62
-
63
- person.country = "Canada"
64
-
65
- expect(@combo.widget.text).to eq("Canada")
66
-
67
- person.country = "Russia"
68
-
69
- expect(@combo.widget.text).to eq("Russia")
70
-
71
- person.country = ""
72
-
73
- expect(@combo.widget.text).to eq("")
74
-
75
- person.country = "Japan"
76
-
77
- expect(@combo.widget.text).to eq("Japan")
78
- end
79
-
80
- it "tests read only widget data binding selection property" do
81
- person = Person.new
82
- person.country = "Canada"
83
-
84
- @target = shell {
85
- @combo = combo(:read_only) {
86
- selection bind(person, :country)
87
- }
88
- }
89
-
90
- expect(@combo.widget.item_count).to eq(4)
91
- expect(@combo.widget.text).to eq("Canada")
92
-
93
- person.country_options << "France"
94
-
95
- expect(@combo.widget.item_count).to eq(5)
96
-
97
- person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
98
-
99
- expect(@combo.widget.item_count).to eq(6)
100
-
101
- person.country_options << "Italy"
102
- person.country_options << "Germany"
103
- person.country_options << "Australia"
104
-
105
- expect(@combo.widget.item_count).to eq(9)
106
-
107
- expect(@combo.widget.text).to eq("")
108
-
109
- @combo.widget.select(8)
110
- @combo.widget.notifyListeners(SWT::Selection, nil)
111
- expect(person.country).to eq("Australia")
112
-
113
- person.country = "Canada"
114
-
115
- expect(@combo.widget.text).to eq("Canada")
116
-
117
- person.country = "Russia"
118
-
119
- expect(@combo.widget.text).to eq("Russia")
120
-
121
- person.country = ""
122
-
123
- expect(@combo.widget.text).to eq("")
124
-
125
- person.country = "Japan"
126
-
127
- expect(@combo.widget.text).to eq("")
128
- end
129
-
130
- end
@@ -1,30 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Glimmer Constant" do
4
- include Glimmer
5
-
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
-
10
- before do
11
- dsl :swt
12
- end
13
-
14
- after do
15
- @target.display.dispose if @target.display
16
- end
17
-
18
- it "test shell with default layout and composite" do
19
- @target = shell {
20
- composite(:border, :no_focus) {
21
- }
22
- }
23
-
24
- expect(@target.widget.children.size).to eq(1)
25
- expect(@target.widget.children[0]).to be_instance_of(org.eclipse.swt.widgets.Composite)
26
- composite_widget = @target.widget.children[0]
27
- expect(composite_widget).to have_style(:no_focus)
28
- expect(composite_widget).to have_style(:border)
29
- end
30
- end
@@ -1,404 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Glimmer Data Binding" do
4
- include Glimmer
5
-
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
-
10
- SWT = org.eclipse.swt.SWT unless Object.const_defined?(:SWT)
11
-
12
- before do
13
- dsl :swt
14
- end
15
-
16
- after do
17
- @target.display.dispose if @target.display
18
- end
19
-
20
- class Person
21
- attr_accessor :name, :age, :adult
22
- end
23
-
24
- class PersonWithComputedValues
25
- attr_accessor :first_name, :last_name, :year_of_birth
26
- def name
27
- "#{last_name}, #{first_name}"
28
- end
29
- def age
30
- Time.now.year - year_of_birth
31
- end
32
- end
33
-
34
- class Address
35
- attr_accessor :street, :city, :state, :zip
36
- end
37
-
38
- class PersonWithNestedProperties
39
- attr_accessor :address1, :address2
40
- end
41
-
42
- it "tests text widget data binding string property" do
43
- person = Person.new
44
- person.name = "Bruce Ting"
45
-
46
- @target = shell {
47
- composite {
48
- @text = text {
49
- text bind(person, :name)
50
- }
51
- }
52
- }
53
-
54
- expect(@text.widget.getText).to eq("Bruce Ting")
55
-
56
- person.name = "Lady Butterfly"
57
- expect(@text.widget.getText).to eq("Lady Butterfly")
58
-
59
- @text.widget.setText("Allen Cork")
60
- expect(person.name).to eq("Allen Cork")
61
- end
62
-
63
- it "tests text widget data binding fixnum property" do
64
- person = Person.new
65
- person.age = 15
66
-
67
- @target = shell {
68
- composite {
69
- @text = text {
70
- text bind(person, :age, :fixnum)
71
- }
72
- }
73
- }
74
-
75
- expect(@text.widget.getText).to eq("15")
76
-
77
- person.age = 27
78
- expect(@text.widget.getText).to eq("27")
79
-
80
- @text.widget.setText("30")
81
- expect(person.age).to eq(30)
82
- end
83
-
84
- it "tests label widget data binding string property" do
85
- person = Person.new
86
- person.name = "Bruce Ting"
87
-
88
- @target = shell {
89
- composite {
90
- @label = label {
91
- text bind(person, :name)
92
- }
93
- }
94
- }
95
-
96
- expect(@label.widget.getText).to eq("Bruce Ting")
97
-
98
- person.name = "Lady Butterfly"
99
- expect(@label.widget.getText).to eq("Lady Butterfly")
100
- end
101
-
102
- it "tests label widget computed value data binding string property" do
103
- person = PersonWithComputedValues.new
104
- person.first_name = "Marty"
105
- person.last_name = "McFly"
106
-
107
- @target = shell {
108
- composite {
109
- @label = label {
110
- text bind(person, :name, computed_by: [:first_name, :last_name])
111
- }
112
- }
113
- }
114
-
115
- expect(@label.widget.getText).to eq("McFly, Marty")
116
-
117
- person.first_name = "Martin"
118
- expect(@label.widget.getText).to eq("McFly, Martin")
119
-
120
- person.last_name = "MacFly"
121
- expect(@label.widget.getText).to eq("MacFly, Martin")
122
- end
123
-
124
- it "tests label widget computed value data binding fixnum property" do
125
- person = PersonWithComputedValues.new
126
- person.year_of_birth = Time.now.year - 40 #TODO TimeCop gem ?
127
-
128
- @target = shell {
129
- composite {
130
- @label = label {
131
- text bind(person, :age, :fixnum, computed_by: [:year_of_birth])
132
- }
133
- }
134
- }
135
-
136
- expect(@label.widget.getText).to eq("40")
137
-
138
- person.year_of_birth = Time.now.year - 41
139
- expect(@label.widget.getText).to eq("41")
140
- end
141
-
142
- it "tests checkbox widget data binding boolean property" do
143
- person = Person.new
144
- person.adult = true
145
-
146
- @target = shell {
147
- composite {
148
- @check_box = button(:check) {
149
- selection bind(person, :adult)
150
- }
151
- }
152
- }
153
-
154
- expect(@check_box.widget.getSelection).to eq(true)
155
-
156
- person.adult = false
157
- expect(@check_box.widget.getSelection).to eq(false)
158
-
159
- @check_box.widget.setSelection(true)
160
- @check_box.widget.notifyListeners(SWT::Selection, nil)
161
- expect(person.adult).to eq(true)
162
- end
163
-
164
- it "tests radio widget data binding boolean property" do
165
- person = Person.new
166
- person.adult = true
167
-
168
- @target = shell {
169
- composite {
170
- @radio = button(:radio) {
171
- selection bind(person, :adult)
172
- }
173
- }
174
- }
175
-
176
- expect(@radio.widget.getSelection).to eq(true)
177
-
178
- person.adult = false
179
- expect(@radio.widget.getSelection).to eq(false)
180
-
181
- @radio.widget.setSelection(true)
182
- @radio.widget.notifyListeners(SWT::Selection, nil)
183
- expect(person.adult).to eq(true)
184
- end
185
-
186
- it "tests spinner widget data binding fixnum property" do
187
- person = Person.new
188
- person.age = 17
189
-
190
- @target = shell {
191
- composite {
192
- @spinner = spinner {
193
- selection bind(person, :age)
194
- }
195
- }
196
- }
197
-
198
- expect(@spinner.widget.getSelection).to eq(17)
199
-
200
- person.age = 20
201
- expect(@spinner.widget.getSelection).to eq(20)
202
-
203
- @spinner.widget.setSelection(34)
204
- @spinner.widget.notifyListeners(SWT::Selection, nil)
205
- expect(person.age).to eq(34)
206
- end
207
-
208
- it "tests widget data binding enablement" do
209
- person = Person.new
210
- person.adult = true
211
-
212
- @target = shell {
213
- composite {
214
- @text = text {
215
- enabled bind(person, :adult)
216
- }
217
- }
218
- }
219
-
220
- expect(@text.widget.isEnabled).to eq(true)
221
-
222
- person.adult = false
223
- expect(@text.widget.isEnabled).to eq(false)
224
- end
225
-
226
- it "tests multiple widget data binding enablement to same model property" do
227
- person = Person.new
228
- person.adult = true
229
-
230
- @target = shell {
231
- composite {
232
- @text = text {
233
- enabled bind(person, :adult)
234
- }
235
- @text2 = text {
236
- enabled bind(person, :adult)
237
- }
238
- @text3 = text {
239
- enabled bind(person, :adult)
240
- }
241
- }
242
- }
243
-
244
- expect(@text.widget.isEnabled).to eq(true)
245
- expect(@text2.widget.isEnabled).to eq(true)
246
- expect(@text3.widget.isEnabled).to eq(true)
247
-
248
- person.adult = false
249
- expect(@text.widget.isEnabled).to eq(false)
250
- expect(@text2.widget.isEnabled).to eq(false)
251
- expect(@text3.widget.isEnabled).to eq(false)
252
- end
253
-
254
- it "tests multiple widget data bindings to different model properties" do
255
- person = Person.new
256
- person.name = "Nancy"
257
- person.age = 15
258
- person.adult = true
259
-
260
- @target = shell {
261
- composite {
262
- @label = label {
263
- text bind(person, :name)
264
- }
265
- @text = text {
266
- text bind(person, :age, :fixnum)
267
- }
268
- @check_box = button(:check) {
269
- selection bind(person, :adult)
270
- }
271
- }
272
- }
273
-
274
- expect(@label.widget.getText).to eq("Nancy")
275
- expect(@text.widget.getText).to eq("15")
276
- expect(@check_box.widget.getSelection).to eq(true)
277
-
278
- person.name = "Drew"
279
- expect(@label.widget.getText).to eq("Drew")
280
-
281
- person.age = 27
282
- expect(@text.widget.getText).to eq("27")
283
-
284
- person.adult = false
285
- expect(@check_box.widget.getSelection).to eq(false)
286
-
287
- @text.widget.setText("30")
288
- expect(person.age).to eq(30)
289
-
290
- @check_box.widget.setSelection(true)
291
- @check_box.widget.notifyListeners(SWT::Selection, nil)
292
- expect(person.adult).to eq(true)
293
- end
294
-
295
- context "nested data binding" do
296
-
297
- it "tests text widget data binding to nested string property" do
298
- person = PersonWithNestedProperties.new
299
- person.address1 = Address.new
300
- person.address2 = Address.new
301
-
302
- person.address1.street = "20 Naper Ave"
303
- person.address1.city = "Indianapolis"
304
- person.address1.state = "IN"
305
- person.address1.zip = "46183"
306
-
307
- person.address2.street = "101 Confession St"
308
- person.address2.city = "Denver"
309
- person.address2.state = "CO"
310
- person.address2.zip = "80014"
311
-
312
- @target = shell {
313
- composite {
314
- @address1_street_text_widget = text {
315
- text bind(person, "address1.street")
316
- }
317
- @address1_city_text_widget = text {
318
- text bind(person, "address1.city")
319
- }
320
- @address1_state_text_widget = text {
321
- text bind(person, "address1.state")
322
- }
323
- @address1_zip_text_widget = text {
324
- text bind(person, "address1.zip")
325
- }
326
- }
327
- composite {
328
- @address2_street_text_widget = text {
329
- text bind(person, "address2.street")
330
- }
331
- @address2_city_text_widget = text {
332
- text bind(person, "address2.city")
333
- }
334
- @address2_state_text_widget = text {
335
- text bind(person, "address2.state")
336
- }
337
- @address2_zip_text_widget = text {
338
- text bind(person, "address2.zip")
339
- }
340
- }
341
- }
342
-
343
- expect(@address1_street_text_widget.widget.getText).to eq("20 Naper Ave")
344
- expect(@address1_city_text_widget.widget.getText).to eq("Indianapolis")
345
- expect(@address1_state_text_widget.widget.getText).to eq("IN")
346
- expect(@address1_zip_text_widget.widget.getText).to eq("46183")
347
-
348
- expect(@address2_street_text_widget.widget.getText).to eq("101 Confession St")
349
- expect(@address2_city_text_widget.widget.getText).to eq("Denver")
350
- expect(@address2_state_text_widget.widget.getText).to eq("CO")
351
- expect(@address2_zip_text_widget.widget.getText).to eq("80014")
352
-
353
- person.address1.street = "123 Main St"
354
- person.address1.city = "Chicago"
355
- person.address1.state = "IL"
356
- person.address1.zip = "60654"
357
-
358
- person.address2.street = "100 Park Ave"
359
- person.address2.city = "San Diego"
360
- person.address2.state = "CA"
361
- person.address2.zip = "92014"
362
-
363
- expect(@address1_street_text_widget.widget.getText).to eq("123 Main St")
364
- expect(@address1_city_text_widget.widget.getText).to eq("Chicago")
365
- expect(@address1_state_text_widget.widget.getText).to eq("IL")
366
- expect(@address1_zip_text_widget.widget.getText).to eq("60654")
367
-
368
- expect(@address2_street_text_widget.widget.getText).to eq("100 Park Ave")
369
- expect(@address2_city_text_widget.widget.getText).to eq("San Diego")
370
- expect(@address2_state_text_widget.widget.getText).to eq("CA")
371
- expect(@address2_zip_text_widget.widget.getText).to eq("92014")
372
-
373
- person.address2 = person.address1
374
-
375
- expect(@address2_street_text_widget.widget.getText).to eq("123 Main St")
376
- expect(@address2_city_text_widget.widget.getText).to eq("Chicago")
377
- expect(@address2_state_text_widget.widget.getText).to eq("IL")
378
- expect(@address2_zip_text_widget.widget.getText).to eq("60654")
379
-
380
- person.address2 = Address.new
381
-
382
- person.address2.street = "101 Confession St"
383
- person.address2.city = "Denver"
384
- person.address2.state = "CO"
385
- person.address2.zip = "80014"
386
-
387
- expect(@address2_street_text_widget.widget.getText).to eq("101 Confession St")
388
- expect(@address2_city_text_widget.widget.getText).to eq("Denver")
389
- expect(@address2_state_text_widget.widget.getText).to eq("CO")
390
- expect(@address2_zip_text_widget.widget.getText).to eq("80014")
391
-
392
- person.address2.street = "123 Main St"
393
- person.address2.city = "Chicago"
394
- person.address2.state = "IL"
395
- person.address2.zip = "60654"
396
-
397
- expect(@address2_street_text_widget.widget.getText).to eq("123 Main St")
398
- expect(@address2_city_text_widget.widget.getText).to eq("Chicago")
399
- expect(@address2_state_text_widget.widget.getText).to eq("IL")
400
- expect(@address2_zip_text_widget.widget.getText).to eq("60654")
401
- end
402
-
403
- end
404
- end