glimmer-dsl-swt 4.17.10.4 → 4.18.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.10.4
1
+ 4.18.0.0
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.17.10.4 ruby lib
5
+ # stub: glimmer-dsl-swt 4.18.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.10.4"
9
+ s.version = "4.18.0.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-12-02"
15
- s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
14
+ s.date = "2020-12-19"
15
+ s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
18
18
  s.extra_rdoc_files = [
@@ -131,6 +131,7 @@ Gem::Specification.new do |s|
131
131
  "samples/elaborate/tic_tac_toe/cell.rb",
132
132
  "samples/elaborate/user_profile.rb",
133
133
  "samples/hello/hello_browser.rb",
134
+ "samples/hello/hello_button.rb",
134
135
  "samples/hello/hello_checkbox.rb",
135
136
  "samples/hello/hello_checkbox_group.rb",
136
137
  "samples/hello/hello_combo.rb",
@@ -144,6 +145,7 @@ Gem::Specification.new do |s|
144
145
  "samples/hello/hello_expand_bar.rb",
145
146
  "samples/hello/hello_file_dialog.rb",
146
147
  "samples/hello/hello_group.rb",
148
+ "samples/hello/hello_link.rb",
147
149
  "samples/hello/hello_list_multi_selection.rb",
148
150
  "samples/hello/hello_list_single_selection.rb",
149
151
  "samples/hello/hello_menu_bar.rb",
@@ -164,44 +166,63 @@ Gem::Specification.new do |s|
164
166
  s.homepage = "http://github.com/AndyObtiva/glimmer-dsl-swt".freeze
165
167
  s.licenses = ["MIT".freeze]
166
168
  s.required_ruby_version = Gem::Requirement.new(">= 2.5.3".freeze)
167
- s.rubygems_version = "3.1.4".freeze
169
+ s.rubygems_version = "3.0.6".freeze
168
170
  s.summary = "Glimmer DSL for SWT".freeze
169
171
 
170
172
  if s.respond_to? :specification_version then
171
173
  s.specification_version = 4
172
- end
173
174
 
174
- if s.respond_to? :add_runtime_dependency then
175
- s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.5"])
176
- s.add_runtime_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
177
- s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
178
- s.add_runtime_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
179
- s.add_runtime_dependency(%q<rake-tui>.freeze, [">= 0.2.3", "< 2.0.0"])
180
- s.add_runtime_dependency(%q<git-glimmer>.freeze, ["= 1.7.0"])
181
- s.add_runtime_dependency(%q<logging>.freeze, [">= 2.3.0", "< 3.0.0"])
182
- s.add_runtime_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
183
- s.add_runtime_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
184
- s.add_runtime_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
185
- s.add_runtime_dependency(%q<rouge>.freeze, [">= 3.25.0", "< 4.0.0"])
186
- s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
187
- s.add_development_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
188
- s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
189
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
190
- s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
191
- s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
192
- s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
175
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
176
+ s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.6"])
177
+ s.add_runtime_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
178
+ s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
179
+ s.add_runtime_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
180
+ s.add_runtime_dependency(%q<rake-tui>.freeze, [">= 0.2.3", "< 2.0.0"])
181
+ s.add_runtime_dependency(%q<git-glimmer>.freeze, ["= 1.7.0"])
182
+ s.add_runtime_dependency(%q<logging>.freeze, [">= 2.3.0", "< 3.0.0"])
183
+ s.add_runtime_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
184
+ s.add_runtime_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
185
+ s.add_runtime_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
186
+ s.add_runtime_dependency(%q<rouge>.freeze, [">= 3.26.0", "< 4.0.0"])
187
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
188
+ s.add_development_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
189
+ s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
190
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
191
+ s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
192
+ s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
193
+ s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
194
+ else
195
+ s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.6"])
196
+ s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
197
+ s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
198
+ s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
199
+ s.add_dependency(%q<rake-tui>.freeze, [">= 0.2.3", "< 2.0.0"])
200
+ s.add_dependency(%q<git-glimmer>.freeze, ["= 1.7.0"])
201
+ s.add_dependency(%q<logging>.freeze, [">= 2.3.0", "< 3.0.0"])
202
+ s.add_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
203
+ s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
204
+ s.add_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
205
+ s.add_dependency(%q<rouge>.freeze, [">= 3.26.0", "< 4.0.0"])
206
+ s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
207
+ s.add_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
208
+ s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
209
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
210
+ s.add_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
211
+ s.add_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
212
+ s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
213
+ end
193
214
  else
194
- s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.5"])
195
- s.add_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
196
- s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
197
- s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
215
+ s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.6"])
216
+ s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
217
+ s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
218
+ s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
198
219
  s.add_dependency(%q<rake-tui>.freeze, [">= 0.2.3", "< 2.0.0"])
199
220
  s.add_dependency(%q<git-glimmer>.freeze, ["= 1.7.0"])
200
221
  s.add_dependency(%q<logging>.freeze, [">= 2.3.0", "< 3.0.0"])
201
222
  s.add_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
202
223
  s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
203
224
  s.add_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
204
- s.add_dependency(%q<rouge>.freeze, [">= 3.25.0", "< 4.0.0"])
225
+ s.add_dependency(%q<rouge>.freeze, [">= 3.26.0", "< 4.0.0"])
205
226
  s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
206
227
  s.add_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
207
228
  s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
@@ -36,6 +36,7 @@ require 'nested_inherited_jruby_include_package'
36
36
  require 'super_module'
37
37
  require 'rouge'
38
38
  require 'date'
39
+ require 'facets/string/capitalized'
39
40
 
40
41
  # Internal requires
41
42
  require 'ext/glimmer/config'
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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
@@ -54,9 +54,9 @@ module Glimmer
54
54
  @args = @args.first if @args.size == 1 && @args.first.is_a?(Array)
55
55
  if options&.keys&.include?(:swt_image)
56
56
  @swt_image = options[:swt_image]
57
- @image_data = @swt_image.image_data
57
+ @original_image_data = @image_data = @swt_image.image_data
58
58
  elsif @file_path
59
- @image_data = ImageData.new(input_stream || @file_path)
59
+ @original_image_data = @image_data = ImageData.new(input_stream || @file_path)
60
60
  @swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
61
61
  width = options[:width]
62
62
  height = options[:height]
@@ -65,8 +65,8 @@ module Glimmer
65
65
  scale_to(width, height) unless width.nil? || height.nil?
66
66
  else
67
67
  @swt_image = Image.new(*@args)
68
- @image_data = @swt_image.image_data
69
- end
68
+ @original_image_data = @image_data = @swt_image.image_data
69
+ end
70
70
  end
71
71
 
72
72
  def input_stream
@@ -77,12 +77,13 @@ module Glimmer
77
77
  file_input_stream = object.java_class.resource_as_stream(file_path)
78
78
  else
79
79
  file_input_stream = java.io.FileInputStream.new(@file_path)
80
- end
80
+ end
81
81
  java.io.BufferedInputStream.new(file_input_stream) if file_input_stream
82
82
  end
83
83
 
84
84
  def scale_to(width, height)
85
- scaled_image_data = image_data.scaledTo(width, height)
85
+ return if @image_data.width == width && @image_data.height == height
86
+ scaled_image_data = @original_image_data.scaledTo(width, height)
86
87
  device = swt_image.device
87
88
  swt_image.dispose
88
89
  @swt_image = Image.new(device, scaled_image_data)
@@ -99,7 +100,7 @@ module Glimmer
99
100
 
100
101
  def respond_to?(method, *args, &block)
101
102
  super || swt_image.respond_to?(method, *args, &block)
102
- end
103
+ end
103
104
  end
104
105
  end
105
106
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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
@@ -68,6 +68,10 @@ module Glimmer
68
68
  @swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
69
69
  @swt_layout.marginWidth = 15 if @swt_layout.respond_to?(:marginWidth)
70
70
  @swt_layout.marginHeight = 15 if @swt_layout.respond_to?(:marginHeight)
71
+ @swt_layout.marginTop = 0 if @swt_layout.respond_to?(:marginTop)
72
+ @swt_layout.marginRight = 0 if @swt_layout.respond_to?(:marginRight)
73
+ @swt_layout.marginBottom = 0 if @swt_layout.respond_to?(:marginBottom)
74
+ @swt_layout.marginLeft = 0 if @swt_layout.respond_to?(:marginLeft)
71
75
  @widget_proxy.swt_widget.setLayout(@swt_layout)
72
76
  end
73
77
 
@@ -66,7 +66,6 @@ module Glimmer
66
66
  else
67
67
  @swt_widget = swt_widget_class.new(parent.swt_widget)
68
68
  end
69
- DEFAULT_INITIALIZERS['menu']&.call(swt_widget)
70
69
 
71
70
  if styles.include?(:bar)
72
71
  parent.swt_widget.setMenuBar(swt_widget)
@@ -76,7 +75,7 @@ module Glimmer
76
75
  end
77
76
 
78
77
  def has_attribute?(attribute_name, *args)
79
- if attribute_name.to_s == "text"
78
+ if ['text', 'enabled'].include?(attribute_name.to_s)
80
79
  true
81
80
  else
82
81
  super(attribute_name, *args)
@@ -84,24 +83,29 @@ module Glimmer
84
83
  end
85
84
 
86
85
  def set_attribute(attribute_name, *args)
87
- attribute_name
88
- if attribute_name.to_s == "text"
86
+ if normalized_attribute(attribute_name) == 'text'
89
87
  text_value = args[0]
90
88
  @swt_menu_item.setText text_value
89
+ elsif normalized_attribute(attribute_name) == 'enabled'
90
+ value = args[0]
91
+ @swt_menu_item.setEnabled value
91
92
  else
92
93
  super(attribute_name, *args)
93
94
  end
94
95
  end
95
96
 
96
97
  def get_attribute(attribute_name)
97
- if attribute_name.to_s == "text"
98
+ if normalized_attribute(attribute_name) == 'text'
98
99
  @swt_menu_item.getText
100
+ elsif normalized_attribute(attribute_name) == 'enabled'
101
+ @swt_menu_item.getEnabled
99
102
  else
100
103
  super(attribute_name)
101
104
  end
102
105
  end
103
106
 
104
107
  def can_handle_observation_request?(observation_request, super_only: false)
108
+ observation_request = observation_request.to_s
105
109
  super_result = super(observation_request)
106
110
  if observation_request.start_with?('on_') && !super_result && !super_only
107
111
  return menu_item_proxy.can_handle_observation_request?(observation_request)
@@ -28,7 +28,7 @@ module Glimmer
28
28
  # Follows the Proxy Design Pattern
29
29
  class SashFormProxy < WidgetProxy
30
30
  def post_add_content
31
- swt_widget.setWeights(@weights) unless @weights.nil?
31
+ self.weights = @weights unless @weights.nil?
32
32
  end
33
33
 
34
34
  def set_attribute(attribute_name, *args)
@@ -89,11 +89,15 @@ module Glimmer
89
89
  negative ? ~bit_value : bit_value
90
90
  rescue => e
91
91
  # Glimmer::Config.logger.debug {e.full_message}
92
- bit_value = extra_styles[swt_constant_symbol]
93
- if bit_value
94
- negative ? ~bit_value : bit_value
92
+ if symbol.to_s.size == 1 # accelerator key
93
+ symbol.to_s.bytes.first
95
94
  else
96
- symbol
95
+ bit_value = extra_styles[swt_constant_symbol]
96
+ if bit_value
97
+ negative ? ~bit_value : bit_value
98
+ else
99
+ symbol
100
+ end
97
101
  end
98
102
  end
99
103
  end
@@ -69,7 +69,7 @@ module Glimmer
69
69
  }
70
70
 
71
71
  DEFAULT_INITIALIZERS = {
72
- 'composite' => lambda do |composite|
72
+ composite: lambda do |composite|
73
73
  if composite.get_layout.nil?
74
74
  layout = GridLayout.new
75
75
  layout.marginWidth = 15
@@ -77,18 +77,18 @@ module Glimmer
77
77
  composite.layout = layout
78
78
  end
79
79
  end,
80
- 'scrolled_composite' => lambda do |scrolled_composite|
80
+ scrolled_composite: lambda do |scrolled_composite|
81
81
  scrolled_composite.expand_horizontal = true
82
82
  scrolled_composite.expand_vertical = true
83
83
  end,
84
- 'table' => lambda do |table|
84
+ table: lambda do |table|
85
85
  table.setHeaderVisible(true)
86
86
  table.setLinesVisible(true)
87
87
  end,
88
- 'table_column' => lambda do |table_column|
88
+ table_column: lambda do |table_column|
89
89
  table_column.setWidth(80)
90
90
  end,
91
- 'group' => lambda do |group|
91
+ group: lambda do |group|
92
92
  group.layout = GridLayout.new if group.get_layout.nil?
93
93
  end,
94
94
  }
@@ -160,7 +160,7 @@ module Glimmer
160
160
  end
161
161
  if @swt_widget&.get_data('proxy').nil?
162
162
  @swt_widget.set_data('proxy', self)
163
- DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
163
+ DEFAULT_INITIALIZERS[underscored_widget_name.to_s.to_sym]&.call(@swt_widget)
164
164
  @parent_proxy.post_initialize_child(self)
165
165
  end
166
166
  end
@@ -202,7 +202,22 @@ module Glimmer
202
202
  end
203
203
  end
204
204
 
205
+ def has_attribute_getter?(attribute_getter_name, *args)
206
+ attribute_getter_name = attribute_getter_name.to_s.underscore
207
+ return false unless !attribute_getter_name.end_with?('=') && !attribute_getter_name.start_with?('set_')
208
+ args.empty? && swt_widget.respond_to?(attribute_getter_name)
209
+ end
210
+
211
+ def has_attribute_setter?(attribute_setter_name, *args)
212
+ attribute_setter_name = attribute_setter_name.to_s
213
+ underscored_attribute_setter_name = attribute_setter_name.underscore
214
+ return false unless attribute_setter_name.end_with?('=') || (attribute_setter_name.start_with?('set_') && !args.empty?)
215
+ attribute_name = underscored_attribute_setter_name.sub(/^set_/, '').sub(/=$/, '')
216
+ has_attribute?(attribute_name, *args)
217
+ end
218
+
205
219
  def has_attribute?(attribute_name, *args)
220
+ # TODO test that attribute getter responds too
206
221
  widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
207
222
  if widget_custom_attribute
208
223
  @swt_widget.respond_to?(widget_custom_attribute[:setter][:name])
@@ -212,12 +227,15 @@ module Glimmer
212
227
  end
213
228
 
214
229
  def set_attribute(attribute_name, *args)
230
+ # TODO Think about widget subclasses overriding set_attribute to add more attributes vs adding as Ruby attributes directly
215
231
  widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
232
+ apply_property_type_converters(normalized_attribute(attribute_name), args)
216
233
  if widget_custom_attribute
217
234
  widget_custom_attribute[:setter][:invoker].call(@swt_widget, args)
218
235
  elsif @swt_widget.respond_to?(attribute_setter(attribute_name))
219
- apply_property_type_converters(attribute_name, args)
220
236
  @swt_widget.send(attribute_setter(attribute_name), *args) unless @swt_widget.send(attribute_getter(attribute_name)) == args.first
237
+ elsif @swt_widget.respond_to?(ruby_attribute_setter(attribute_name))
238
+ @swt_widget.send(ruby_attribute_setter(attribute_name), args)
221
239
  else
222
240
  send(ruby_attribute_setter(attribute_name), args)
223
241
  end
@@ -233,6 +251,12 @@ module Glimmer
233
251
  end
234
252
  elsif @swt_widget.respond_to?(attribute_getter(attribute_name))
235
253
  @swt_widget.send(attribute_getter(attribute_name))
254
+ elsif @swt_widget.respond_to?(ruby_attribute_getter(attribute_name))
255
+ @swt_widget.send(ruby_attribute_getter(attribute_name))
256
+ elsif @swt_widget.respond_to?(attribute_name)
257
+ @swt_widget.send(attribute_name)
258
+ elsif respond_to?(ruby_attribute_getter(attribute_name))
259
+ send(ruby_attribute_getter(attribute_name))
236
260
  else
237
261
  send(attribute_name)
238
262
  end
@@ -607,11 +631,16 @@ module Glimmer
607
631
  def method_missing(method, *args, &block)
608
632
  if can_handle_observation_request?(method)
609
633
  handle_observation_request(method, &block)
634
+ elsif has_attribute_setter?(method, *args)
635
+ set_attribute(method, *args)
636
+ elsif has_attribute_getter?(method, *args)
637
+ get_attribute(method, *args)
610
638
  else
611
639
  swt_widget.send(method, *args, &block)
612
640
  end
613
641
  rescue => e
614
- Glimmer::Config.logger.debug {"Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}"}
642
+ Glimmer::Config.logger.debug { "Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}" }
643
+ Glimmer::Config.logger.debug { e.full_message }
615
644
  super
616
645
  # TODO consider get_attribute too
617
646
  end
@@ -639,16 +668,26 @@ module Glimmer
639
668
  end
640
669
 
641
670
  def ruby_attribute_setter(attribute_name)
642
- "#{attribute_name}="
671
+ "#{normalized_attribute(attribute_name)}="
643
672
  end
644
673
 
645
674
  def attribute_setter(attribute_name)
646
- "set#{attribute_name.to_s.camelcase(:upper)}"
675
+ "set#{normalized_attribute(attribute_name).camelcase(:upper)}"
647
676
  end
648
677
 
649
678
  def attribute_getter(attribute_name)
650
- "get#{attribute_name.to_s.camelcase(:upper)}"
679
+ "get#{normalized_attribute(attribute_name).camelcase(:upper)}"
651
680
  end
681
+
682
+ def normalized_attribute(attribute_name)
683
+ attribute_name = attribute_name.to_s if attribute_name.is_a?(Symbol)
684
+ attribute_name = attribute_name.underscore unless attribute_name.downcase?
685
+ attribute_name = attribute_name.sub(/^get_/, '') if attribute_name.start_with?('get_')
686
+ attribute_name = attribute_name.sub(/^set_/, '') if attribute_name.start_with?('set_')
687
+ attribute_name = attribute_name.sub(/=$/, '') if attribute_name.end_with?('=')
688
+ attribute_name
689
+ end
690
+ alias ruby_attribute_getter normalized_attribute
652
691
 
653
692
  # TODO refactor following methods to eliminate duplication
654
693
  # perhaps consider relying on raising an exception to avoid checking first
@@ -799,11 +838,14 @@ module Glimmer
799
838
  end
800
839
  # TODO consider detecting type on widget method and automatically invoking right converter (e.g. :to_s for String, :to_i for Integer)
801
840
  @property_type_converters ||= {
802
- alignment: -> (*value) {
841
+ accelerator: lambda { |*value|
842
+ SWTProxy[*value]
843
+ },
844
+ alignment: lambda { |*value|
803
845
  SWTProxy[*value]
804
846
  },
805
- :background => color_converter,
806
- :background_image => lambda do |*value|
847
+ background: color_converter,
848
+ background_image: lambda do |*value|
807
849
  image_proxy = ImageProxy.create(*value)
808
850
 
809
851
  if image_proxy&.file_path&.end_with?('.gif')
@@ -844,7 +886,7 @@ module Glimmer
844
886
 
845
887
  image_proxy&.swt_image
846
888
  end,
847
- :cursor => lambda do |value|
889
+ cursor: lambda do |value|
848
890
  cursor_proxy = nil
849
891
  if value.is_a?(CursorProxy)
850
892
  cursor_proxy = value
@@ -856,8 +898,9 @@ module Glimmer
856
898
  :enabled => lambda do |value|
857
899
  !!value
858
900
  end,
859
- :foreground => color_converter,
860
- :font => lambda do |value|
901
+ foreground: color_converter,
902
+ link_foreground: color_converter,
903
+ font: lambda do |value|
861
904
  if value.is_a?(Hash)
862
905
  font_properties = value
863
906
  FontProxy.new(self, font_properties).swt_font
@@ -865,21 +908,21 @@ module Glimmer
865
908
  value
866
909
  end
867
910
  end,
868
- :image => lambda do |*value|
911
+ image: lambda do |*value|
869
912
  ImageProxy.create(*value).swt_image
870
913
  end,
871
- :images => lambda do |array|
914
+ images: lambda do |array|
872
915
  array.to_a.map do |value|
873
916
  ImageProxy.create(value).swt_image
874
917
  end.to_java(Image)
875
918
  end,
876
- :items => lambda do |value|
919
+ items: lambda do |value|
877
920
  value.to_java :string
878
921
  end,
879
- :text => lambda do |value|
922
+ text: lambda do |value|
880
923
  value.to_s
881
924
  end,
882
- :transfer => lambda do |value|
925
+ transfer: lambda do |value|
883
926
  value = value.first if value.is_a?(Array) && value.size == 1 && value.first.is_a?(Array)
884
927
  transfer_object_extrapolator = lambda do |transfer_name|
885
928
  transfer_type = "#{transfer_name.to_s.camelcase(:upper)}Transfer".to_sym
@@ -898,9 +941,12 @@ module Glimmer
898
941
  result = result.to_java(Transfer) unless result.is_a?(ArrayJavaProxy)
899
942
  result
900
943
  end,
901
- :visible => lambda do |value|
944
+ visible: lambda do |value|
902
945
  !!value
903
946
  end,
947
+ weights: lambda do |value|
948
+ value.to_java(:int)
949
+ end,
904
950
  }
905
951
  end
906
952
  end