glimmer 0.1.0.0 → 0.1.2

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.
Files changed (83) hide show
  1. data/.rvmrc +1 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.markdown +54 -0
  5. data/Rakefile +54 -0
  6. data/VERSION +1 -0
  7. data/bin/glimmer +132 -0
  8. data/glimmer.gemspec +145 -0
  9. data/images/Bitter-sweet.jpg +0 -0
  10. data/{src → lib}/command_handler.rb +7 -10
  11. data/{src → lib}/command_handler_chain_factory.rb +29 -22
  12. data/{src → lib}/command_handler_chain_link.rb +19 -22
  13. data/{src → lib}/command_handlers.rb +29 -26
  14. data/{src → lib}/command_handlers/bind_command_handler.rb +25 -28
  15. data/lib/command_handlers/combo_selection_data_binding_command_handler.rb +39 -0
  16. data/{src → lib}/command_handlers/data_binding_command_handler.rb +61 -64
  17. data/lib/command_handlers/list_selection_data_binding_command_handler.rb +42 -0
  18. data/lib/command_handlers/models/list_observer.rb +31 -0
  19. data/{src → lib}/command_handlers/models/model_observer.rb +28 -25
  20. data/{src → lib}/command_handlers/models/observable_array.rb +53 -46
  21. data/lib/command_handlers/models/observable_model.rb +61 -0
  22. data/{src → lib}/command_handlers/models/r_runnable.rb +11 -14
  23. data/{src → lib}/command_handlers/models/r_shell.rb +23 -26
  24. data/lib/command_handlers/models/r_tab_item_composite.rb +25 -0
  25. data/{src → lib}/command_handlers/models/r_widget.rb +16 -14
  26. data/lib/command_handlers/models/r_widget_listener.rb +9 -0
  27. data/{src → lib}/command_handlers/models/r_widget_packages.rb +5 -8
  28. data/{src → lib}/command_handlers/models/table_items_updater.rb +38 -39
  29. data/{src → lib}/command_handlers/models/widget_observer.rb +4 -6
  30. data/{src → lib}/command_handlers/shell_command_handler.rb +14 -17
  31. data/{src → lib}/command_handlers/swt_constant_command_handler.rb +18 -21
  32. data/lib/command_handlers/tab_item_command_handler.rb +22 -0
  33. data/{src → lib}/command_handlers/table_column_properties_data_binding_command_handler.rb +20 -23
  34. data/{src → lib}/command_handlers/table_items_data_binding_command_handler.rb +26 -29
  35. data/{src → lib}/command_handlers/widget_command_handler.rb +22 -25
  36. data/{src → lib}/command_handlers/widget_listener_command_handler.rb +36 -34
  37. data/{src → lib}/command_handlers/widget_method_command_handler.rb +18 -21
  38. data/{src → lib}/glimmer.rb +52 -45
  39. data/lib/parent.rb +5 -0
  40. data/{src → lib}/shine.rb +21 -24
  41. data/{src → lib}/xml_command_handlers.rb +15 -18
  42. data/{src → lib}/xml_command_handlers/html_command_handler.rb +45 -49
  43. data/{src → lib}/xml_command_handlers/models/depth_first_search_iterator.rb +17 -20
  44. data/{src → lib}/xml_command_handlers/models/name_space_visitor.rb +17 -20
  45. data/{src → lib}/xml_command_handlers/models/node.rb +80 -83
  46. data/{src → lib}/xml_command_handlers/models/node_visitor.rb +8 -11
  47. data/{src → lib}/xml_command_handlers/models/xml_visitor.rb +58 -61
  48. data/{src → lib}/xml_command_handlers/xml_command_handler.rb +18 -22
  49. data/{src → lib}/xml_command_handlers/xml_name_space_command_handler.rb +31 -34
  50. data/{src → lib}/xml_command_handlers/xml_tag_command_handler.rb +23 -26
  51. data/{src → lib}/xml_command_handlers/xml_text_command_handler.rb +19 -22
  52. data/samples/contactmanager/contact.rb +0 -3
  53. data/samples/contactmanager/contact_manager.rb +1 -4
  54. data/samples/contactmanager/contact_manager_presenter.rb +0 -3
  55. data/samples/contactmanager/contact_repository.rb +0 -3
  56. data/samples/hello_combo.rb +32 -0
  57. data/samples/hello_world.rb +1 -4
  58. data/samples/login.rb +1 -4
  59. data/samples/tictactoe/tic_tac_toe.rb +2 -5
  60. data/samples/tictactoe/tic_tac_toe_board.rb +0 -3
  61. data/test/glimmer_combo_data_binding_test.rb +131 -0
  62. data/test/glimmer_constant_test.rb +6 -11
  63. data/test/glimmer_data_binding_test.rb +16 -16
  64. data/test/glimmer_list_data_binding_test.rb +223 -0
  65. data/test/glimmer_listeners_test.rb +6 -6
  66. data/test/glimmer_shine_data_binding_test.rb +7 -6
  67. data/test/glimmer_tab_item_test.rb +61 -0
  68. data/test/glimmer_table_data_binding_test.rb +7 -20
  69. data/test/glimmer_test.rb +18 -13
  70. data/test/helper.rb +21 -0
  71. data/test/observable_model_test.rb +2 -4
  72. data/test/r_widget_test.rb +5 -5
  73. data/test/samples/contactmanager/contact_manager_presenter_test.rb +1 -4
  74. data/test/samples/tictactoe/tic_tac_toe_test.rb +1 -4
  75. data/test/xml/glimmer_xml_test.rb +43 -43
  76. metadata +210 -105
  77. data/COPYING.LGPL +0 -504
  78. data/README +0 -27
  79. data/src/command_handlers/models/observable_model.rb +0 -35
  80. data/src/command_handlers/models/r_widget_listener.rb +0 -12
  81. data/src/parent.rb +0 -8
  82. data/src/swt.rb +0 -10
  83. data/src/xml.rb +0 -10
@@ -1,16 +1,16 @@
1
- # Copyright (C) 2007-2008 Annas Al Maleh
2
- # Licensed under the LGPL. See /COPYING.LGPL for more details.
3
-
4
- require "test/unit"
5
- require File.dirname(__FILE__) + "/../src/swt"
1
+ require File.dirname(__FILE__) + "/helper"
6
2
 
7
3
  class GlimmerTest < Test::Unit::TestCase
8
- include Glimmer
4
+ include Glimmer
9
5
 
10
6
  include_package 'org.eclipse.swt'
11
7
  include_package 'org.eclipse.swt.widgets'
12
8
  include_package 'org.eclipse.swt.layout'
13
9
 
10
+ def setup
11
+ dsl :swt
12
+ end
13
+
14
14
  def teardown
15
15
  @target.display.dispose if @target.display
16
16
  end
@@ -27,10 +27,5 @@ class GlimmerTest < Test::Unit::TestCase
27
27
  assert_has_style SWT::NO_FOCUS, composite_widget
28
28
  assert_has_style SWT::BORDER, composite_widget
29
29
  end
30
-
31
- def assert_has_style(style, widget)
32
- assert_equal style, widget.getStyle & style
33
- end
34
-
35
30
  end
36
31
 
@@ -1,16 +1,16 @@
1
- # Copyright (C) 2007-2008 Annas Al Maleh
2
- # Licensed under the LGPL. See /COPYING.LGPL for more details.
3
-
4
- require "test/unit"
5
- require File.dirname(__FILE__) + "/../src/swt"
1
+ require File.dirname(__FILE__) + "/helper"
6
2
 
7
3
  class GlimmerDataBindingTest < Test::Unit::TestCase
8
- include Glimmer
4
+ include Glimmer
9
5
 
10
6
  include_package 'org.eclipse.swt'
11
7
  include_package 'org.eclipse.swt.widgets'
12
8
  include_package 'org.eclipse.swt.layout'
13
9
 
10
+ def setup
11
+ dsl :swt
12
+ end
13
+
14
14
  def teardown
15
15
  @target.display.dispose if @target.display
16
16
  end
@@ -34,10 +34,10 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
34
34
  assert_equal "Bruce Ting", @text.widget.getText
35
35
 
36
36
  person.name = "Lady Butterfly"
37
- assert_equal "Lady Butterfly", @text.widget.getText
37
+ assert_equal "Lady Butterfly", @text.widget.getText
38
38
 
39
39
  @text.widget.setText("Allen Cork")
40
- assert_equal "Allen Cork", person.name
40
+ assert_equal "Allen Cork", person.name
41
41
  end
42
42
 
43
43
  def test_text_widget_data_binding_fixnum_property
@@ -55,10 +55,10 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
55
55
  assert_equal "15", @text.widget.getText
56
56
 
57
57
  person.age = 27
58
- assert_equal "27", @text.widget.getText
58
+ assert_equal "27", @text.widget.getText
59
59
 
60
60
  @text.widget.setText("30")
61
- assert_equal 30, person.age
61
+ assert_equal 30, person.age
62
62
  end
63
63
 
64
64
  def test_label_widget_data_binding_string_property
@@ -94,11 +94,11 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
94
94
  assert_equal true, @check_box.widget.getSelection
95
95
 
96
96
  person.adult = false
97
- assert_equal false, @check_box.widget.getSelection
97
+ assert_equal false, @check_box.widget.getSelection
98
98
 
99
99
  @check_box.widget.setSelection(true)
100
100
  @check_box.widget.notifyListeners(SWT::Selection, nil)
101
- assert_equal true, person.adult
101
+ assert_equal true, person.adult
102
102
  end
103
103
 
104
104
  def test_radio_widget_data_binding_boolean_property
@@ -116,11 +116,11 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
116
116
  assert_equal true, @radio.widget.getSelection
117
117
 
118
118
  person.adult = false
119
- assert_equal false, @radio.widget.getSelection
119
+ assert_equal false, @radio.widget.getSelection
120
120
 
121
121
  @radio.widget.setSelection(true)
122
122
  @radio.widget.notifyListeners(SWT::Selection, nil)
123
- assert_equal true, person.adult
123
+ assert_equal true, person.adult
124
124
  end
125
125
 
126
126
  def test_spinner_widget_data_binding_fixnum_property
@@ -138,11 +138,11 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
138
138
  assert_equal 17, @spinner.widget.getSelection
139
139
 
140
140
  person.age = 20
141
- assert_equal 20, @spinner.widget.getSelection
141
+ assert_equal 20, @spinner.widget.getSelection
142
142
 
143
143
  @spinner.widget.setSelection(34)
144
144
  @spinner.widget.notifyListeners(SWT::Selection, nil)
145
- assert_equal 34, person.age
145
+ assert_equal 34, person.age
146
146
  end
147
147
 
148
148
  def test_widget_data_binding_enablement
@@ -0,0 +1,223 @@
1
+ require File.dirname(__FILE__) + "/helper"
2
+
3
+ class GlimmerListDataBindingTest < Test::Unit::TestCase
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
+ def setup
11
+ dsl :swt
12
+ end
13
+
14
+ def teardown
15
+ @target.display.dispose if @target.display
16
+ end
17
+
18
+ class Person
19
+ attr_accessor :country, :country_options
20
+ attr_accessor :provinces, :provinces_options
21
+
22
+ def initialize
23
+ self.country_options=[
24
+ "",
25
+ "Canada",
26
+ "US",
27
+ "Mexico"
28
+ ]
29
+ self.provinces_options=[
30
+ "",
31
+ "Quebec",
32
+ "Ontario",
33
+ "Manitoba",
34
+ "Saskatchewan",
35
+ "Alberta",
36
+ "British Columbia",
37
+ "Nova Skotia",
38
+ "Newfoundland"
39
+ ]
40
+ end
41
+ end
42
+
43
+ def test_single_selection_property
44
+ person = Person.new
45
+
46
+ @target = shell {
47
+ @list = list {
48
+ selection bind(person, :country)
49
+ }
50
+ }
51
+
52
+ assert_equal 4, @list.widget.item_count
53
+ assert_equal -1, @list.widget.selection_index
54
+ assert_equal [], @list.widget.selection.to_a
55
+
56
+ @list.widget.select(1)
57
+ @list.widget.notifyListeners(SWT::Selection, nil)
58
+ assert_equal "Canada", person.country
59
+
60
+ person.country_options << "France"
61
+
62
+ assert_equal 5, @list.widget.item_count
63
+
64
+ person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
65
+
66
+ assert_equal 6, @list.widget.item_count
67
+
68
+ person.country_options << "Italy"
69
+ person.country_options << "Germany"
70
+ person.country_options << "Australia"
71
+
72
+ assert_equal 9, @list.widget.item_count
73
+
74
+ person.country = "Canada"
75
+
76
+ assert_equal 1, @list.widget.selection_index
77
+ assert_equal ["Canada"], @list.widget.selection.to_a
78
+
79
+ person.country = "Russia"
80
+
81
+ assert_equal 4, @list.widget.selection_index
82
+ assert_equal ["Russia"], @list.widget.selection.to_a
83
+
84
+ person.country = ""
85
+
86
+ assert_equal 0, @list.widget.selection_index
87
+ assert_equal [""], @list.widget.selection.to_a
88
+
89
+ person.country = "Japan"
90
+
91
+ assert_equal 0, @list.widget.selection_index
92
+ assert_equal [""], @list.widget.selection.to_a
93
+
94
+ @list.widget.select(2)
95
+ @list.widget.notifyListeners(SWT::Selection, nil)
96
+ assert_equal "US", person.country
97
+ end
98
+
99
+ def test_single_selection_property_with_model_preinitialized
100
+ person = Person.new
101
+ person.country = "Canada"
102
+
103
+ @target = shell {
104
+ @list = list {
105
+ selection bind(person, :country)
106
+ }
107
+ }
108
+
109
+ assert_equal 4, @list.widget.item_count
110
+ assert_equal 1, @list.widget.selection_index
111
+ assert_equal ["Canada"], @list.widget.selection.to_a
112
+
113
+ @list.widget.select(2)
114
+ @list.widget.notifyListeners(SWT::Selection, nil)
115
+ assert_equal "US", person.country
116
+
117
+ person.country_options << "France"
118
+
119
+ assert_equal 5, @list.widget.item_count
120
+
121
+ person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
122
+
123
+ assert_equal 6, @list.widget.item_count
124
+
125
+ person.country_options << "Italy"
126
+ person.country_options << "Germany"
127
+ person.country_options << "Australia"
128
+
129
+ assert_equal 9, @list.widget.item_count
130
+
131
+ person.country = "Canada"
132
+
133
+ assert_equal 1, @list.widget.selection_index
134
+ assert_equal ["Canada"], @list.widget.selection.to_a
135
+
136
+ person.country = "Russia"
137
+
138
+ assert_equal 4, @list.widget.selection_index
139
+ assert_equal ["Russia"], @list.widget.selection.to_a
140
+
141
+ person.country = ""
142
+
143
+ assert_equal 0, @list.widget.selection_index
144
+ assert_equal [""], @list.widget.selection.to_a
145
+
146
+ person.country = "Japan"
147
+
148
+ assert_equal 0, @list.widget.selection_index
149
+ assert_equal [""], @list.widget.selection.to_a
150
+ end
151
+
152
+ def test_multi_selection_property
153
+ person = Person.new
154
+
155
+ @target = shell {
156
+ @list = list(multi) {
157
+ selection bind(person, :provinces)
158
+ }
159
+ }
160
+
161
+ assert_equal 0, @list.widget.selection_count.to_i
162
+ assert_equal [], @list.widget.selection.to_a
163
+
164
+ @list.widget.select(1)
165
+ @list.widget.notifyListeners(SWT::Selection, nil)
166
+ assert_equal ["Quebec"], person.provinces
167
+
168
+ @list.widget.select(2)
169
+ @list.widget.notifyListeners(SWT::Selection, nil)
170
+ assert_equal ["Quebec", "Ontario"], person.provinces
171
+
172
+ person.provinces=["Ontario", "Manitoba", "Alberta"]
173
+
174
+ assert_equal 3, @list.widget.selection_count.to_i
175
+ assert_equal [2, 3, 5], @list.widget.selection_indices.to_a
176
+ assert_equal ["Ontario", "Manitoba", "Alberta"], @list.widget.selection.to_a
177
+
178
+ person.provinces << "Quebec"
179
+ person.provinces << "Saskatchewan"
180
+ person.provinces << "British Columbia"
181
+
182
+ assert_equal 6, @list.widget.selection_count.to_i
183
+ assert_equal [1, 2, 3, 4, 5, 6], @list.widget.selection_indices.to_a
184
+ assert_equal ["Quebec", "Ontario", "Manitoba", "Saskatchewan", "Alberta", "British Columbia"], @list.widget.selection.to_a
185
+ end
186
+
187
+ def test_multi_selection_property_with_model_preinitialized
188
+ person = Person.new
189
+ person.provinces = []
190
+
191
+ @target = shell {
192
+ @list = list(multi) {
193
+ selection bind(person, :provinces)
194
+ }
195
+ }
196
+
197
+ assert_equal 0, @list.widget.selection_count.to_i
198
+ assert_equal [], @list.widget.selection.to_a
199
+
200
+ @list.widget.select(1)
201
+ @list.widget.notifyListeners(SWT::Selection, nil)
202
+ assert_equal ["Quebec"], person.provinces
203
+
204
+ @list.widget.select(2)
205
+ @list.widget.notifyListeners(SWT::Selection, nil)
206
+ assert_equal ["Quebec", "Ontario"], person.provinces
207
+
208
+ person.provinces=["Ontario", "Manitoba", "Alberta"]
209
+
210
+ assert_equal 3, @list.widget.selection_count.to_i
211
+ assert_equal [2, 3, 5], @list.widget.selection_indices.to_a
212
+ assert_equal ["Ontario", "Manitoba", "Alberta"], @list.widget.selection.to_a
213
+
214
+ person.provinces << "Quebec"
215
+ person.provinces << "Saskatchewan"
216
+ person.provinces << "British Columbia"
217
+
218
+ assert_equal 6, @list.widget.selection_count.to_i
219
+ assert_equal [1, 2, 3, 4, 5, 6], @list.widget.selection_indices.to_a
220
+ assert_equal ["Quebec", "Ontario", "Manitoba", "Saskatchewan", "Alberta", "British Columbia"], @list.widget.selection.to_a
221
+ end
222
+ end
223
+
@@ -1,16 +1,16 @@
1
- # Copyright (C) 2007-2008 Annas Al Maleh
2
- # Licensed under the LGPL. See /COPYING.LGPL for more details.
3
-
4
- require "test/unit"
5
- require File.dirname(__FILE__) + "/../src/swt"
1
+ require File.dirname(__FILE__) + "/helper"
6
2
 
7
3
  class GlimmerDataBindingTest < Test::Unit::TestCase
8
- include Glimmer
4
+ include Glimmer
9
5
 
10
6
  include_package 'org.eclipse.swt'
11
7
  include_package 'org.eclipse.swt.widgets'
12
8
  include_package 'org.eclipse.swt.layout'
13
9
 
10
+ def setup
11
+ dsl :swt
12
+ end
13
+
14
14
  def teardown
15
15
  @target.display.dispose if @target.display
16
16
  end
@@ -1,17 +1,18 @@
1
- # Copyright (C) 2007-2008 Annas Al Maleh
2
- # Licensed under the LGPL. See /COPYING.LGPL for more details.
1
+ require File.dirname(__FILE__) + "/helper"
3
2
 
4
- require "test/unit"
5
- require File.dirname(__FILE__) + "/../src/swt"
6
- require File.dirname(__FILE__) + "/../src/shine"
3
+ require File.dirname(__FILE__) + "/../lib/shine"
7
4
 
8
5
  class GlimmerDataBindingTest < Test::Unit::TestCase
9
- include Glimmer
6
+ include Glimmer
10
7
 
11
8
  include_package 'org.eclipse.swt'
12
9
  include_package 'org.eclipse.swt.widgets'
13
10
  include_package 'org.eclipse.swt.layout'
14
11
 
12
+ def setup
13
+ dsl :swt
14
+ end
15
+
15
16
  def teardown
16
17
  @target.display.dispose if @target.display
17
18
  end
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + "/helper"
2
+
3
+ class GlimmerTest < Test::Unit::TestCase
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
+ include_package 'org.eclipse.swt.graphics'
10
+
11
+ def setup
12
+ dsl :swt
13
+ end
14
+
15
+ def teardown
16
+ @target.display.dispose if @target.display
17
+ end
18
+
19
+ def test_tab_item_composite_with_default_layout
20
+ @target = shell {
21
+ @tab_folder = tab_folder {
22
+ @tab_item_composite = tab_item {
23
+ text "Tab 1"
24
+ label {text "Hello"}
25
+ }
26
+ }
27
+ }
28
+
29
+ assert_not_nil @target
30
+ assert_not_nil @target.widget
31
+ assert_equal 1, @tab_folder.widget.items.size
32
+ assert_instance_of Composite, @tab_item_composite.widget
33
+ assert_equal @tab_item_composite.widget, @tab_folder.widget.items[0].control
34
+ assert_equal "Tab 1", @tab_item_composite.tab_item.widget.text
35
+ assert_not_nil @tab_item_composite.widget.getLayout
36
+ assert_instance_of GridLayout, @tab_item_composite.widget.getLayout
37
+ end
38
+
39
+ def test_tab_item_composite_with_fill_layout
40
+ @target = shell {
41
+ @tab_folder = tab_folder {
42
+ @tab_item_composite = tab_item {
43
+ text "Tab 2"
44
+ layout FillLayout.new
45
+ label {text "Hello"}
46
+ }
47
+ }
48
+ }
49
+
50
+ assert_not_nil @target
51
+ assert_not_nil @target.widget
52
+ assert_equal 1, @tab_folder.widget.items.size
53
+ assert_instance_of Composite, @tab_item_composite.widget
54
+ assert_equal @tab_item_composite.widget, @tab_folder.widget.items[0].control
55
+ assert_equal "Tab 2", @tab_item_composite.tab_item.widget.text
56
+ assert_not_nil @tab_item_composite.widget.getLayout
57
+ assert_instance_of FillLayout, @tab_item_composite.widget.getLayout
58
+ end
59
+
60
+ end
61
+