glimmer 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{glimmer}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andy Maleh"]
12
- s.date = %q{2011-02-22}
12
+ s.date = %q{2011-03-17}
13
13
  s.default_executable = %q{glimmer}
14
14
  s.description = %q{JRuby DSL that enables easy and efficient authoring of user-interfaces using the robust platform-independent Eclipse SWT library}
15
15
  s.email = %q{andy@obtiva.com}
@@ -49,7 +49,6 @@ Gem::Specification.new do |s|
49
49
  "lib/command_handlers/models/table_items_updater.rb",
50
50
  "lib/command_handlers/models/widget_observer.rb",
51
51
  "lib/command_handlers/shell_command_handler.rb",
52
- "lib/command_handlers/swt_constant_command_handler.rb",
53
52
  "lib/command_handlers/tab_item_command_handler.rb",
54
53
  "lib/command_handlers/table_column_properties_data_binding_command_handler.rb",
55
54
  "lib/command_handlers/table_items_data_binding_command_handler.rb",
@@ -59,6 +58,8 @@ Gem::Specification.new do |s|
59
58
  "lib/glimmer.rb",
60
59
  "lib/parent.rb",
61
60
  "lib/shine.rb",
61
+ "lib/string.rb",
62
+ "lib/symbol.rb",
62
63
  "lib/xml_command_handlers.rb",
63
64
  "lib/xml_command_handlers/html_command_handler.rb",
64
65
  "lib/xml_command_handlers/models/depth_first_search_iterator.rb",
@@ -10,7 +10,6 @@ require File.dirname(__FILE__) + "/command_handlers/table_column_properties_data
10
10
  require File.dirname(__FILE__) + "/command_handlers/data_binding_command_handler"
11
11
  require File.dirname(__FILE__) + "/command_handlers/widget_method_command_handler"
12
12
  require File.dirname(__FILE__) + "/command_handlers/widget_command_handler"
13
- require File.dirname(__FILE__) + "/command_handlers/swt_constant_command_handler"
14
13
 
15
14
  # edit to add more command handlers and extend Glimmer
16
15
  CommandHandlerChainFactory.def_dsl(:swt,
@@ -24,6 +23,5 @@ CommandHandlerChainFactory.def_dsl(:swt,
24
23
  TableColumnPropertiesDataBindingCommandHandler.new,
25
24
  DataBindingCommandHandler.new,
26
25
  WidgetMethodCommandHandler.new,
27
- WidgetCommandHandler.new,
28
- SwtConstantCommandHandler.new #at the bottom to avoid stealing commands from other command handlers
26
+ WidgetCommandHandler.new
29
27
  )
@@ -27,7 +27,7 @@ class ListSelectionDataBindingCommandHandler
27
27
  model.add_observer(model_observer.options_property_name, widget_observer)
28
28
 
29
29
  property_type = :string
30
- property_type = :array if parent.has_style?(multi)
30
+ property_type = :array if parent.has_style?(:multi)
31
31
  list_observer = ListObserver.new(parent, property_type)
32
32
  list_observer.update(model_observer.evaluate_property)
33
33
  model.add_observer(model_observer.property_name, list_observer)
@@ -11,15 +11,21 @@ class RTabItemComposite < RWidget
11
11
  @tab_item.widget.control = self.widget
12
12
  end
13
13
 
14
- def respond_to?(method_symbol, *args)
15
- if method_symbol.to_s == "text"
14
+ def has_attribute?(attribute_name, *args)
15
+ if attribute_name.to_s == "text"
16
16
  true
17
17
  else
18
- super(method_symbol, *args)
18
+ super(attribute_name, *args)
19
19
  end
20
20
  end
21
21
 
22
- def text(text_value)
23
- @tab_item.widget.text=text_value
22
+ def set_attribute(attribute_name, *args)
23
+ if attribute_name.to_s == "text"
24
+ text_value = args[0]
25
+ @tab_item.widget.text = text_value
26
+ else
27
+ super(attribute_name, *args)
28
+ end
24
29
  end
30
+
25
31
  end
@@ -27,40 +27,21 @@ class RWidget
27
27
  "table_column" => Proc.new { |table_column| table_column.setWidth(80) },
28
28
  "group" => Proc.new {|group| group.setLayout(GridLayout.new) },
29
29
  }
30
-
31
- def initialize(underscored_widget_name, parent, style, &contents)
32
- style = default_style(underscored_widget_name) unless style
33
- @widget = eval underscored_widget_name.to_s.camelcase + '.new(parent, style)'
30
+
31
+ #styles is a comma separate list of symbols representing SWT styles in lower case
32
+ def initialize(underscored_widget_name, parent, styles, &contents)
33
+ @widget = underscored_widget_name.swt_widget.new(parent, style(underscored_widget_name, styles))
34
34
  @@default_initializers[underscored_widget_name].call(@widget) if @@default_initializers[underscored_widget_name]
35
35
  end
36
36
 
37
- def default_style(underscored_widget_name)
38
- style = @@default_styles[underscored_widget_name] if @@default_styles[underscored_widget_name]
39
- style = SWT::NONE unless style
40
- style
41
- end
42
-
43
- def respond_to?(method_symbol, *args)
44
- @widget.respond_to?("set#{method_symbol.to_s.camelcase(:upper)}", args)
37
+ def has_attribute?(attribute_name, *args)
38
+ @widget.respond_to?(attribute_setter(attribute_name), args)
45
39
  end
46
-
47
- def method_missing(method_symbol, *args)
48
- statement_to_eval = "@widget.send('set' + method_symbol.to_s.camelcase(:upper)"
49
- statement_to_eval << expand_arguments(args)
50
- statement_to_eval << ")"
51
- eval statement_to_eval
52
- end
53
-
54
- def expand_arguments(args)
55
- expanded_args = ""
56
- index = 0
57
- args.each do
58
- expanded_args << ", args[#{index}]"
59
- index += 1
60
- end
61
- expanded_args
40
+
41
+ def set_attribute(attribute_name, *args)
42
+ @widget.send(attribute_setter(attribute_name), *args)
62
43
  end
63
-
44
+
64
45
  def self.widget_exists?(underscored_widget_name)
65
46
  begin
66
47
  eval underscored_widget_name.camelcase
@@ -142,7 +123,31 @@ class RWidget
142
123
  end
143
124
 
144
125
  def has_style?(style)
145
- (widget.style & style) == style
126
+ (widget.style & style.swt_constant) == style.swt_constant
146
127
  end
128
+
129
+ private
130
+
131
+ def style(underscored_widget_name, styles)
132
+ styles.empty? ? default_style(underscored_widget_name) : swt_style(styles)
133
+ end
134
+
135
+ def default_style(underscored_widget_name)
136
+ style = @@default_styles[underscored_widget_name] if @@default_styles[underscored_widget_name]
137
+ style = SWT::NONE unless style
138
+ style
139
+ end
140
+
141
+ def swt_style(styles)
142
+ swt_styles(styles).inject(0) { |combined_style, style| combined_style | style }
143
+ end
144
+
145
+ def swt_styles(styles)
146
+ styles.map(&:swt_constant)
147
+ end
147
148
 
149
+ def attribute_setter(attribute_name)
150
+ "set#{attribute_name.to_s.camelcase(:upper)}"
151
+ end
152
+
148
153
  end
@@ -15,10 +15,8 @@ class TableItemsUpdater
15
15
  model.add_observer(model_observer.property_name, self)
16
16
  end
17
17
  def update(model_collection=nil)
18
- if (model_collection and
19
- model_collection.is_a?(Array) and
20
- !model_collection.is_a?(ObservableArray))
21
- model_collection.extend(ObservableArray)
18
+ if model_collection and model_collection.is_a?(Array)
19
+ model_collection.extend(ObservableArray) unless model_collection.is_a?(ObservableArray)
22
20
  model_collection.add_observer(@column_properties, self)
23
21
  @model_collection = model_collection
24
22
  end
@@ -8,15 +8,12 @@ class TabItemCommandHandler
8
8
 
9
9
  def can_handle?(parent, command_symbol, *args, &block)
10
10
  parent.is_a?(RWidget) and
11
- command_symbol.to_s == "tab_item" and
12
- (args.size == 0 or
13
- (args.size == 1 and args[0].is_a?(Fixnum)))
11
+ command_symbol.to_s == "tab_item"
14
12
  end
15
13
 
16
14
  def do_handle(parent, command_symbol, *args, &block)
17
- style = args[0] if args.size == 1
18
- tab_item = RWidget.new(command_symbol.to_s, parent.widget, style)
19
- RTabItemComposite.new(tab_item, parent.widget, style)
15
+ tab_item = RWidget.new(command_symbol.to_s, parent.widget, args)
16
+ RTabItemComposite.new(tab_item, parent.widget, args)
20
17
  end
21
18
 
22
19
  end
@@ -9,15 +9,12 @@ class WidgetCommandHandler
9
9
  def can_handle?(parent, command_symbol, *args, &block)
10
10
  parent.is_a?(RWidget) and
11
11
  command_symbol.to_s != "shell" and
12
- (args.size == 0 or
13
- (args.size == 1 and args[0].is_a?(Fixnum))) and
14
12
  RWidget.widget_exists?(command_symbol.to_s)
15
13
  end
16
14
 
17
15
  def do_handle(parent, command_symbol, *args, &block)
18
- style = args[0] if args.size == 1
19
- puts "style argument is: " + style.to_s
20
- RWidget.new(command_symbol.to_s, parent.widget, style)
16
+ puts "widget styles are: " + args.inspect
17
+ RWidget.new(command_symbol.to_s, parent.widget, args)
21
18
  end
22
19
 
23
20
  end
@@ -8,11 +8,11 @@ class WidgetMethodCommandHandler
8
8
  parent.is_a?(RWidget) and
9
9
  args.size > 0 and
10
10
  block == nil and
11
- parent.respond_to?(command_symbol, *args)
11
+ parent.has_attribute?(command_symbol, *args)
12
12
  end
13
13
 
14
14
  def do_handle(parent, command_symbol, *args, &block)
15
- parent.send(command_symbol, *args)
15
+ parent.set_attribute(command_symbol, *args)
16
16
  nil
17
17
  end
18
18
 
@@ -6,6 +6,8 @@
6
6
  require "rubygems"
7
7
  require "facets"
8
8
  require "java"
9
+ require File.dirname(__FILE__) + "/string"
10
+ require File.dirname(__FILE__) + "/symbol"
9
11
  require File.dirname(__FILE__) + "/parent"
10
12
 
11
13
  module Glimmer
@@ -48,5 +50,5 @@ module Glimmer
48
50
  end
49
51
 
50
52
  # Command handlers may rely on Glimmer, so this is put here to avoid an infinite loop.
51
- require File.dirname(__FILE__) + "/command_handlers"
52
53
  require File.dirname(__FILE__) + "/xml_command_handlers"
54
+ require File.dirname(__FILE__) + "/command_handlers"
@@ -0,0 +1,8 @@
1
+ class String
2
+ def swt_widget
3
+ org.eclipse.swt.widgets.__send__(camelcase(:upper))
4
+ end
5
+ def swt_constant
6
+ org.eclipse.swt.__send__("SWT").class_eval(upcase)
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + "/string"
2
+
3
+ class Symbol
4
+ def swt_widget
5
+ to_s.swt_widget
6
+ end
7
+ def swt_constant
8
+ to_s.swt_constant
9
+ end
10
+ end
@@ -35,7 +35,7 @@ class ContactManager
35
35
  }
36
36
 
37
37
  table {
38
- layout_data GridData.new(fill, fill, true, true)
38
+ layout_data GridData.new(:fill.swt_constant, :fill.swt_constant, true, true)
39
39
  table_column {
40
40
  text "First Name"
41
41
  width 80
@@ -15,7 +15,7 @@ class HelloCombo
15
15
  person = Person.new
16
16
  shell {
17
17
  composite {
18
- combo(read_only) {
18
+ combo(:read_only) {
19
19
  selection bind(person, :country)
20
20
  }
21
21
  button {
@@ -10,11 +10,9 @@ class HelloWorld
10
10
  def launch
11
11
  @shell = shell {
12
12
  text "SWT"
13
- composite {
14
- label {
15
- text "Hello World!"
16
- }
17
- }
13
+ label {
14
+ text "Hello World!"
15
+ }
18
16
  }
19
17
  @shell.open
20
18
  end
@@ -66,7 +66,7 @@ class Login
66
66
  }
67
67
 
68
68
  label { text "Password:" }
69
- text(SWT::PASSWORD | SWT::BORDER) {
69
+ text(:password, :border) {
70
70
  text bind(presenter, :password)
71
71
  enabled bind(presenter, :logged_out)
72
72
  }
@@ -20,7 +20,7 @@ class TicTacToe
20
20
  (1..3).each { |row_number|
21
21
  (1..3).each { |column_number|
22
22
  button {
23
- layout_data GridData.new(fill, fill, true, true)
23
+ layout_data GridData.new(:fill.swt_constant, :fill.swt_constant, true, true)
24
24
  text bind(@tic_tac_toe_board.box(row_number, column_number), :sign)
25
25
  enabled bind(@tic_tac_toe_board.box(row_number, column_number), :empty)
26
26
  on_widget_selected {
@@ -82,7 +82,7 @@ class GlimmerComboDataBindingTest < Test::Unit::TestCase
82
82
  person.country = "Canada"
83
83
 
84
84
  @target = shell {
85
- @combo = combo(read_only) {
85
+ @combo = combo(:read_only) {
86
86
  selection bind(person, :country)
87
87
  }
88
88
  }
@@ -17,15 +17,15 @@ class GlimmerTest < Test::Unit::TestCase
17
17
 
18
18
  def test_shell_with_default_layout
19
19
  @target = shell {
20
- composite(border | no_focus) {
20
+ composite(:border, :no_focus) {
21
21
  }
22
22
  }
23
23
 
24
24
  assert_equal 1, @target.widget.children.size
25
25
  assert_instance_of Composite, @target.widget.children[0]
26
26
  composite_widget = @target.widget.children[0]
27
- assert_has_style SWT::NO_FOCUS, composite_widget
28
- assert_has_style SWT::BORDER, composite_widget
27
+ assert_has_style :no_focus, composite_widget
28
+ assert_has_style :border, composite_widget
29
29
  end
30
30
  end
31
31
 
@@ -85,7 +85,7 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
85
85
 
86
86
  @target = shell {
87
87
  composite {
88
- @check_box = button(SWT::CHECK) {
88
+ @check_box = button(:check) {
89
89
  selection bind(person, :adult)
90
90
  }
91
91
  }
@@ -107,7 +107,7 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
107
107
 
108
108
  @target = shell {
109
109
  composite {
110
- @radio = button(SWT::RADIO) {
110
+ @radio = button(:radio) {
111
111
  selection bind(person, :adult)
112
112
  }
113
113
  }
@@ -205,7 +205,7 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
205
205
  @text = text {
206
206
  text bind(person, :age, :fixnum)
207
207
  }
208
- @check_box = button(SWT::CHECK) {
208
+ @check_box = button(:check) {
209
209
  selection bind(person, :adult)
210
210
  }
211
211
  }
@@ -153,7 +153,7 @@ class GlimmerListDataBindingTest < Test::Unit::TestCase
153
153
  person = Person.new
154
154
 
155
155
  @target = shell {
156
- @list = list(multi) {
156
+ @list = list(:multi) {
157
157
  selection bind(person, :provinces)
158
158
  }
159
159
  }
@@ -189,7 +189,7 @@ class GlimmerListDataBindingTest < Test::Unit::TestCase
189
189
  person.provinces = []
190
190
 
191
191
  @target = shell {
192
- @list = list(multi) {
192
+ @list = list(:multi) {
193
193
  selection bind(person, :provinces)
194
194
  }
195
195
  }
@@ -56,7 +56,7 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
56
56
  composite {
57
57
  @label = label {}
58
58
  @text = text {}
59
- @check_box = button(SWT::CHECK) {}
59
+ @check_box = button(:check) {}
60
60
  }
61
61
  }
62
62
 
@@ -25,98 +25,98 @@ class GlimmerTest < Test::Unit::TestCase
25
25
  assert_not_nil @target.widget.getLayout
26
26
  assert_instance_of FillLayout, @target.widget.getLayout
27
27
  end
28
-
28
+
29
29
  def test_shell_with_title_and_layout
30
30
  shell_layout = GridLayout.new
31
31
  @target = shell {
32
32
  text "Title"
33
33
  layout shell_layout
34
34
  }
35
-
35
+
36
36
  assert_equal "Title", @target.widget.getText
37
37
  assert_equal shell_layout, @target.widget.getLayout
38
38
  end
39
-
39
+
40
40
  def test_shell_with_bounds
41
41
  @target = shell {
42
42
  bounds 50, 75, 800, 600
43
43
  }
44
-
44
+
45
45
  assert_equal Rectangle.new(50, 75, 800, 600), @target.widget.getBounds
46
46
  end
47
-
47
+
48
48
  def test_shell_with_size
49
49
  GlimmerTest.class_eval("undef_method :size") #hack to remove existing size method in test class
50
-
50
+
51
51
  @target = shell {
52
52
  size 800, 600
53
53
  }
54
-
54
+
55
55
  assert_equal Point.new(800, 600), @target.widget.getSize
56
56
  end
57
-
57
+
58
58
  def test_shell_and_composite_with_default_style_and_layout
59
59
  @target = shell {
60
60
  composite
61
61
  }
62
-
62
+
63
63
  assert_equal 1, @target.widget.children.size
64
64
  assert_instance_of Composite, @target.widget.children[0]
65
65
  composite_widget = @target.widget.children[0]
66
- assert_has_style SWT::NONE, composite_widget
66
+ assert_has_style :none, composite_widget
67
67
  assert_instance_of GridLayout, composite_widget.getLayout
68
68
  grid_layout = composite_widget.getLayout
69
69
  assert_equal 1, grid_layout.numColumns
70
70
  assert_equal false, grid_layout.makeColumnsEqualWidth
71
71
  end
72
-
72
+
73
73
  def test_shell_and_group_with_default_style_and_layout
74
74
  @target = shell {
75
75
  group {
76
76
  text "Title"
77
77
  }
78
78
  }
79
-
79
+
80
80
  assert_equal 1, @target.widget.children.size
81
81
  assert_instance_of Group, @target.widget.children[0]
82
82
  group_widget = @target.widget.children[0]
83
- assert_has_style SWT::NONE, group_widget
83
+ assert_has_style :none, group_widget
84
84
  assert_instance_of GridLayout, group_widget.getLayout
85
85
  grid_layout = group_widget.getLayout
86
86
  assert_equal 1, grid_layout.numColumns
87
87
  assert_equal false, grid_layout.makeColumnsEqualWidth
88
88
  assert_equal "Title", group_widget.getText
89
89
  end
90
-
90
+
91
91
  def test_shell_and_composite_with_style_and_layout
92
92
  composite_layout = RowLayout.new
93
93
  @target = shell {
94
- composite(SWT::NO_FOCUS) {
94
+ composite(:no_focus) {
95
95
  layout composite_layout
96
96
  }
97
97
  }
98
-
98
+
99
99
  assert_equal 1, @target.widget.children.size
100
100
  assert_instance_of Composite, @target.widget.children[0]
101
101
  composite_widget = @target.widget.children[0]
102
- assert_has_style SWT::NO_FOCUS, composite_widget
102
+ assert_has_style :no_focus, composite_widget
103
103
  assert_equal composite_layout, composite_widget.getLayout
104
104
  end
105
-
105
+
106
106
  def test_shell_and_composite_and_text_with_default_style
107
107
  @target = shell {
108
108
  composite {
109
109
  text
110
110
  }
111
111
  }
112
-
112
+
113
113
  composite_widget = @target.widget.children[0]
114
114
  assert_equal 1, composite_widget.children.size
115
115
  assert_instance_of Text, composite_widget.children[0]
116
116
  text_widget = composite_widget.children[0]
117
- assert_has_style SWT::BORDER, text_widget
117
+ assert_has_style :border, text_widget
118
118
  end
119
-
119
+
120
120
  def test_shell_and_composite_with_custom_layout_and_text_with_default_style
121
121
  composite_layout = RowLayout.new
122
122
  @target = shell {
@@ -125,68 +125,68 @@ class GlimmerTest < Test::Unit::TestCase
125
125
  layout composite_layout
126
126
  }
127
127
  }
128
-
128
+
129
129
  composite_widget = @target.widget.children[0]
130
130
  assert_equal composite_layout, composite_widget.getLayout
131
131
  assert_equal 1, composite_widget.children.size
132
132
  assert_instance_of Text, composite_widget.children[0]
133
133
  text_widget = composite_widget.children[0]
134
- assert_has_style SWT::BORDER, text_widget
134
+ assert_has_style :border, text_widget
135
135
  end
136
-
136
+
137
137
  def test_shell_and_composite_and_text_with_style_and_text
138
138
  @target = shell {
139
139
  composite {
140
- text(SWT::PASSWORD) {
140
+ text(:password) {
141
141
  text "Hello"
142
142
  }
143
143
  }
144
144
  }
145
-
145
+
146
146
  composite_widget = @target.widget.children[0]
147
147
  assert_equal 1, composite_widget.children.size
148
148
  assert_instance_of Text, composite_widget.children[0]
149
149
  text_widget = composite_widget.children[0]
150
- assert_has_style SWT::PASSWORD, text_widget
150
+ assert_has_style :password, text_widget
151
151
  assert_equal "Hello", text_widget.getText
152
152
  end
153
-
153
+
154
154
  def test_shell_and_spinner_default
155
155
  @target = shell {
156
156
  @spinner = spinner {
157
157
  selection 55
158
158
  }
159
159
  }
160
-
160
+
161
161
  assert_instance_of Spinner, @spinner.widget
162
- assert_has_style SWT::BORDER, @spinner.widget
162
+ assert_has_style :border, @spinner.widget
163
163
  assert_equal 55, @spinner.widget.getSelection
164
164
  end
165
-
165
+
166
166
  def test_shell_and_spinner_default
167
167
  @target = shell {
168
168
  @list = list {
169
169
  }
170
170
  }
171
-
171
+
172
172
  assert_instance_of List, @list.widget
173
- assert_has_style SWT::BORDER, @list.widget
174
- assert_has_style SWT::SINGLE, @list.widget
175
- assert_has_style SWT::V_SCROLL, @list.widget
173
+ assert_has_style :border, @list.widget
174
+ assert_has_style :single, @list.widget
175
+ assert_has_style :v_scroll, @list.widget
176
176
  end
177
-
177
+
178
178
  def test_shell_and_button_default
179
179
  @target = shell {
180
180
  @button = button {
181
181
  text "Push Me"
182
182
  }
183
183
  }
184
-
184
+
185
185
  assert_instance_of Button, @button.widget
186
- assert_has_style SWT::PUSH, @button.widget
186
+ assert_has_style :push, @button.widget
187
187
  assert_equal "Push Me", @button.widget.text
188
188
  end
189
-
189
+
190
190
  def test_shell_and_table_and_table_column_defaults
191
191
  @target = shell {
192
192
  @table = table {
@@ -194,43 +194,43 @@ class GlimmerTest < Test::Unit::TestCase
194
194
  }
195
195
  }
196
196
 
197
- assert_has_style SWT::BORDER, @table.widget
197
+ assert_has_style :border, @table.widget
198
198
  assert @table.widget.getHeaderVisible
199
199
  assert @table.widget.getLinesVisible
200
200
  assert_equal 80, @table_column.widget.getWidth
201
201
  end
202
-
202
+
203
203
  def test_shell_containing_undefined_command
204
204
  @target = shell {
205
- undefined_command(:undefined_parameter) {
205
+ undefined_command(:undefined_parameter) {
206
206
  }
207
207
  }
208
-
208
+
209
209
  assert_not_nil @target
210
210
  assert_not_nil @target.widget
211
211
  assert_instance_of Shell, @target.widget
212
212
  assert_not_nil @target.widget.getLayout
213
213
  assert_instance_of FillLayout, @target.widget.getLayout
214
214
  end
215
-
216
-
215
+
216
+
217
217
  def test_add_contents
218
218
  @target = shell {
219
219
  }
220
-
220
+
221
221
  add_contents(@target) {
222
222
  composite {
223
- text(SWT::PASSWORD) {
223
+ text(:password) {
224
224
  text "Hello"
225
225
  }
226
226
  }
227
227
  }
228
-
228
+
229
229
  composite_widget = @target.widget.children[0]
230
230
  assert_equal 1, composite_widget.children.size
231
231
  assert_instance_of Text, composite_widget.children[0]
232
232
  text_widget = composite_widget.children[0]
233
- assert_has_style SWT::PASSWORD, text_widget
233
+ assert_has_style :password, text_widget
234
234
  assert_equal "Hello", text_widget.getText
235
235
  end
236
236
 
@@ -16,6 +16,6 @@ require 'glimmer'
16
16
 
17
17
  class Test::Unit::TestCase
18
18
  def assert_has_style(style, widget)
19
- assert_equal style, widget.getStyle & style
19
+ assert_equal style.swt_constant, widget.getStyle & style.swt_constant
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Maleh
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-22 00:00:00 -06:00
18
+ date: 2011-03-17 00:00:00 -06:00
19
19
  default_executable: glimmer
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -134,7 +134,6 @@ files:
134
134
  - lib/command_handlers/models/table_items_updater.rb
135
135
  - lib/command_handlers/models/widget_observer.rb
136
136
  - lib/command_handlers/shell_command_handler.rb
137
- - lib/command_handlers/swt_constant_command_handler.rb
138
137
  - lib/command_handlers/tab_item_command_handler.rb
139
138
  - lib/command_handlers/table_column_properties_data_binding_command_handler.rb
140
139
  - lib/command_handlers/table_items_data_binding_command_handler.rb
@@ -144,6 +143,8 @@ files:
144
143
  - lib/glimmer.rb
145
144
  - lib/parent.rb
146
145
  - lib/shine.rb
146
+ - lib/string.rb
147
+ - lib/symbol.rb
147
148
  - lib/xml_command_handlers.rb
148
149
  - lib/xml_command_handlers/html_command_handler.rb
149
150
  - lib/xml_command_handlers/models/depth_first_search_iterator.rb
@@ -1,19 +0,0 @@
1
- require File.dirname(__FILE__) + "/../command_handler"
2
- require File.dirname(__FILE__) + "/models/r_widget"
3
-
4
- class SwtConstantCommandHandler
5
- include CommandHandler
6
-
7
- include_package 'org.eclipse.swt'
8
-
9
- def can_handle?(parent, command_symbol, *args, &block)
10
- args.size == 0 and
11
- block == nil
12
- end
13
-
14
- def do_handle(parent, command_symbol, *args, &block)
15
- puts 'org.eclipse.swt.SWT::' + command_symbol.to_s.upcase
16
- eval 'org.eclipse.swt.SWT::' + command_symbol.to_s.upcase
17
- end
18
-
19
- end