glimmer-dsl-swt 4.17.8.1 → 4.17.10.1

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +249 -7
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +12 -7
  6. data/lib/glimmer-dsl-swt.rb +4 -3
  7. data/lib/glimmer/data_binding/table_items_binding.rb +5 -5
  8. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +3 -3
  9. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +3 -3
  10. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +3 -3
  11. data/lib/glimmer/dsl/swt/widget_expression.rb +1 -0
  12. data/lib/glimmer/launcher.rb +9 -9
  13. data/lib/glimmer/swt/custom/checkbox_group.rb +29 -8
  14. data/lib/glimmer/swt/custom/code_text.rb +36 -34
  15. data/lib/glimmer/swt/custom/radio_group.rb +27 -6
  16. data/lib/glimmer/swt/date_time_proxy.rb +87 -0
  17. data/lib/glimmer/swt/display_proxy.rb +6 -6
  18. data/lib/glimmer/swt/dnd_proxy.rb +6 -10
  19. data/lib/glimmer/swt/message_box_proxy.rb +7 -7
  20. data/lib/glimmer/swt/sash_form_proxy.rb +3 -3
  21. data/lib/glimmer/swt/shell_proxy.rb +18 -3
  22. data/lib/glimmer/swt/style_constantizable.rb +5 -5
  23. data/lib/glimmer/swt/swt_proxy.rb +7 -8
  24. data/lib/glimmer/swt/tab_item_proxy.rb +9 -4
  25. data/lib/glimmer/swt/table_column_proxy.rb +13 -5
  26. data/lib/glimmer/swt/table_proxy.rb +187 -66
  27. data/lib/glimmer/swt/widget_listener_proxy.rb +4 -4
  28. data/lib/glimmer/swt/widget_proxy.rb +47 -3
  29. data/samples/elaborate/contact_manager.rb +3 -3
  30. data/samples/elaborate/meta_sample.rb +9 -9
  31. data/samples/hello/hello_browser.rb +3 -3
  32. data/samples/hello/hello_checkbox.rb +4 -4
  33. data/samples/hello/hello_checkbox_group.rb +6 -3
  34. data/samples/hello/hello_combo.rb +5 -5
  35. data/samples/hello/hello_date_time.rb +63 -0
  36. data/samples/hello/hello_group.rb +104 -0
  37. data/samples/hello/hello_menu_bar.rb +3 -3
  38. data/samples/hello/hello_pop_up_context_menu.rb +3 -3
  39. data/samples/hello/hello_radio.rb +6 -6
  40. data/samples/hello/hello_radio_group.rb +9 -6
  41. data/samples/hello/hello_sash_form.rb +3 -3
  42. data/samples/hello/hello_spinner.rb +69 -0
  43. data/samples/hello/hello_tab.rb +3 -3
  44. data/samples/hello/hello_table.rb +287 -0
  45. metadata +11 -6
@@ -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
@@ -35,6 +35,7 @@ require 'logging'
35
35
  require 'nested_inherited_jruby_include_package'
36
36
  require 'super_module'
37
37
  require 'rouge'
38
+ require 'date'
38
39
 
39
40
  # Internal requires
40
41
  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
@@ -61,7 +61,7 @@ module Glimmer
61
61
  add_dependent(@table_observer_registration => @table_items_observer_registration)
62
62
  @model_collection = new_model_collection
63
63
  end
64
- populate_table(@model_collection, @table, @column_properties)
64
+ populate_table(@model_collection, @table, @column_properties)
65
65
  end
66
66
 
67
67
  def populate_table(model_collection, parent, column_properties)
@@ -79,7 +79,7 @@ module Glimmer
79
79
  selected_table_items = parent.search {|item| selected_table_item_models.include?(item.getData) }
80
80
  selected_table_items = [parent.swt_widget.getItems.first].to_java(TableItem) if selected_table_items.empty? && !parent.swt_widget.getItems.empty?
81
81
  parent.swt_widget.setSelection(selected_table_items) unless selected_table_items.empty?
82
- parent.sort
82
+ parent.sort!
83
83
  parent.swt_widget.redraw if parent&.swt_widget&.respond_to?(:redraw)
84
84
  end
85
85
  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
@@ -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
@@ -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
@@ -58,3 +58,4 @@ require 'glimmer/swt/table_proxy'
58
58
  require 'glimmer/swt/table_column_proxy'
59
59
  require 'glimmer/swt/sash_form_proxy'
60
60
  require 'glimmer/swt/styled_text_proxy'
61
+ require 'glimmer/swt/date_time_proxy'
@@ -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
@@ -31,12 +31,12 @@ module Glimmer
31
31
  OPERATING_SYSTEMS_SUPPORTED = ["mac", "windows", "linux"]
32
32
 
33
33
  TEXT_USAGE = <<~MULTI_LINE_STRING
34
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
34
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
35
35
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
36
36
 
37
- Runs Glimmer applications and tasks.
37
+ Runs Glimmer applications and tasks.
38
38
 
39
- When applications are specified, they are run using JRuby,
39
+ When applications are specified, they are run using JRuby,
40
40
  automatically preloading the glimmer Ruby gem and SWT jar dependency.
41
41
 
42
42
  Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
@@ -112,7 +112,7 @@ module Glimmer
112
112
  def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
113
113
  jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
114
114
  env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
115
- env_vars_string = env_vars.map do |k,v|
115
+ env_vars_string = env_vars.map do |k,v|
116
116
  if OS.windows? && ENV['PROMPT'] # detect command prompt (or powershell)
117
117
  "set #{k}=#{v} && "
118
118
  else
@@ -224,8 +224,8 @@ module Glimmer
224
224
  task_name = task.name_with_args.sub('glimmer:', '')
225
225
  line = "glimmer #{task_name.ljust(max_task_size)} # #{task.comment}"
226
226
  bound = TTY::Screen.width - 6
227
- line.size <= bound ? line : "#{line[0..(bound - 3)]}..."
228
- end
227
+ line.size <= bound ? line : "#{line[0..(bound - 3)]}..."
228
+ end
229
229
  end
230
230
  end
231
231
 
@@ -1,9 +1,30 @@
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 'glimmer/ui/custom_widget'
2
23
 
3
24
  module Glimmer
4
25
  module SWT
5
26
  module Custom
6
- # CodeText is a customization of StyledText with support for Ruby Syntax Highlighting
27
+ # A custom widget rendering a group of checkboxes generated via data-binding
7
28
  class CheckboxGroup
8
29
  include Glimmer::UI::CustomWidget
9
30
 
@@ -71,7 +92,7 @@ module Glimmer
71
92
  if observation_request != 'on_widget_disposed'
72
93
  checkboxes.count.times do |index|
73
94
  checkbox = checkboxes[index]
74
- label = labels[index]
95
+ label = labels[index]
75
96
  listener_block = lambda do |event|
76
97
  event.widget = self.swt_widget
77
98
  block.call(event)
@@ -81,7 +102,7 @@ module Glimmer
81
102
  label.handle_observation_request('on_mouse_up', &listener_block)
82
103
  else
83
104
  checkbox.handle_observation_request(observation_request, &listener_block) if checkbox.can_handle_observation_request?(observation_request)
84
- label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
105
+ label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
85
106
  end
86
107
  end
87
108
  end
@@ -93,7 +114,7 @@ module Glimmer
93
114
 
94
115
  def has_attribute?(attribute_name, *args)
95
116
  (@composites.to_a + @checkboxes.to_a + @labels.to_a).map do |widget_proxy|
96
- return true if widget_proxy.has_attribute?(attribute_name, *args)
117
+ return true if widget_proxy.has_attribute?(attribute_name, *args)
97
118
  end
98
119
  super
99
120
  end
@@ -124,16 +145,16 @@ module Glimmer
124
145
  margin_height 0
125
146
  horizontal_spacing 0
126
147
  vertical_spacing 0
127
- }
148
+ }
128
149
  checkboxes << checkbox { |checkbox_proxy|
129
- on_widget_selected {
150
+ on_widget_selected {
130
151
  self.selection_indices = checkboxes.each_with_index.map {|cb, i| i if cb.selection}.to_a.compact
131
152
  }
132
153
  }
133
154
  labels << label { |label_proxy|
134
155
  layout_data :fill, :center, true, false
135
156
  text item
136
- on_mouse_up { |event|
157
+ on_mouse_up { |event|
137
158
  found_text = labels.each_with_index.detect {|l, i| event.widget == l.swt_widget}[0]&.text
138
159
  selection_values = self.selection
139
160
  if selection_values.include?(found_text)
@@ -148,7 +169,7 @@ module Glimmer
148
169
  }
149
170
  end
150
171
  observation_requests.to_a.each do |observation_request, block|
151
- delegate_observation_request_to_checkboxes(observation_request, &block)
172
+ delegate_observation_request_to_checkboxes(observation_request, &block)
152
173
  end
153
174
  self.selection = current_selection
154
175
  end
@@ -38,32 +38,25 @@ module Glimmer
38
38
  swt_widget&.text
39
39
  end
40
40
 
41
- def syntax_highlighting
41
+ def syntax_highlighting(text)
42
42
  return [] if text.to_s.strip.empty?
43
- return @syntax_highlighting if already_syntax_highlighted?
44
- @last_text = text
45
- @lexer ||= Rouge::Lexer.find_fancy('ruby', text)
46
- lex = @lexer.lex(text).to_a
47
- text_size = 0
48
- lex_hashes = lex.map do |pair|
49
- {token_type: pair.first, token_text: pair.last}
50
- end.each do |hash|
51
- hash[:token_index] = text_size
52
- text_size += hash[:token_text].size
53
- end
54
- text_lines = text.split("\n")
55
- line_index = 0
56
- @syntax_highlighting = text_lines_map = text_lines.reduce({}) do |hash, line|
57
- line_hashes = []
58
- line_hashes << lex_hashes.shift while lex_hashes.any? && lex_hashes.first[:token_index].between?(line_index, line_index + line.size)
59
- hash.merge(line_index => line_hashes).tap do
60
- line_index += line.size + 1
43
+ @syntax_highlighting ||= {}
44
+ unless @syntax_highlighting.keys.include?(text)
45
+ lex = lexer.lex(text).to_a
46
+ text_size = 0
47
+ @syntax_highlighting[text] = lex.map do |pair|
48
+ {token_type: pair.first, token_text: pair.last}
49
+ end.each do |hash|
50
+ hash[:token_index] = text_size
51
+ text_size += hash[:token_text].size
61
52
  end
62
53
  end
54
+ @syntax_highlighting[text]
63
55
  end
64
56
 
65
- def already_syntax_highlighted?
66
- @last_text == text
57
+ def lexer
58
+ # TODO Try to use Rouge::Lexer.find_fancy('guess', code) in the future to guess the language or otherwise detect it from file extension
59
+ @lexer ||= Rouge::Lexer.find_fancy('ruby')
67
60
  end
68
61
 
69
62
  before_body {
@@ -78,22 +71,31 @@ module Glimmer
78
71
  top_margin 5
79
72
  right_margin 5
80
73
  bottom_margin 5
74
+
75
+ on_modify_text { |event|
76
+ # clear unnecessary syntax highlighting cache on text updates, and do it async to avoid affecting performance
77
+ new_text = event.data
78
+ async_exec {
79
+ unless @syntax_highlighting.nil?
80
+ lines = new_text.to_s.split("\n")
81
+ line_diff = @syntax_highlighting.keys - lines
82
+ line_diff.each do |line|
83
+ @syntax_highlighting.delete(line)
84
+ end
85
+ end
86
+ }
87
+ }
81
88
 
82
89
  on_line_get_style { |line_style_event|
83
- @styles ||= {}
84
- @styles = {} unless already_syntax_highlighted?
85
- if @styles[line_style_event.lineOffset].nil?
86
- styles = []
87
- syntax_highlighting[line_style_event.lineOffset].to_a.each do |token_hash|
88
- start_index = token_hash[:token_index]
89
- size = token_hash[:token_text].size
90
- token_color = SYNTAX_COLOR_MAP[token_hash[:token_type].name] || [:black]
91
- token_color = color(*token_color).swt_color
92
- styles << StyleRange.new(start_index, size, token_color, nil)
93
- end
94
- @styles[line_style_event.lineOffset] = styles.to_java(StyleRange)
90
+ styles = []
91
+ syntax_highlighting(line_style_event.lineText).to_a.each do |token_hash|
92
+ start_index = token_hash[:token_index]
93
+ size = token_hash[:token_text].size
94
+ token_color = SYNTAX_COLOR_MAP[token_hash[:token_type].name] || [:black]
95
+ token_color = color(*token_color).swt_color
96
+ styles << StyleRange.new(line_style_event.lineOffset + start_index, size, token_color, nil)
95
97
  end
96
- line_style_event.styles = @styles[line_style_event.lineOffset] unless @styles[line_style_event.lineOffset].empty?
98
+ line_style_event.styles = styles.to_java(StyleRange) unless styles.empty?
97
99
  }
98
100
  }
99
101
  }
@@ -1,9 +1,30 @@
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 'glimmer/ui/custom_widget'
2
23
 
3
24
  module Glimmer
4
25
  module SWT
5
26
  module Custom
6
- # CodeText is a customization of StyledText with support for Ruby Syntax Highlighting
27
+ # A custom widget rendering a group of radios generated via data-binding
7
28
  class RadioGroup
8
29
  include Glimmer::UI::CustomWidget
9
30
 
@@ -65,7 +86,7 @@ module Glimmer
65
86
  if observation_request != 'on_widget_disposed'
66
87
  radios.count.times do |index|
67
88
  radio = radios[index]
68
- label = labels[index]
89
+ label = labels[index]
69
90
  if observation_request == 'on_widget_selected'
70
91
  radio_block = lambda do |event|
71
92
  if event.widget.selection || selection_index == -1
@@ -76,7 +97,7 @@ module Glimmer
76
97
  label_block = lambda do |event|
77
98
  self.selection_index = index
78
99
  block.call(event)
79
- end
100
+ end
80
101
  radio.handle_observation_request(observation_request, &radio_block) if radio.can_handle_observation_request?(observation_request)
81
102
  label.handle_observation_request('on_mouse_up', &label_block)
82
103
  else
@@ -85,7 +106,7 @@ module Glimmer
85
106
  block.call(event)
86
107
  end
87
108
  radio.handle_observation_request(observation_request, &listener_block) if radio.can_handle_observation_request?(observation_request)
88
- label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
109
+ label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
89
110
  end
90
111
  end
91
112
  end
@@ -97,7 +118,7 @@ module Glimmer
97
118
 
98
119
  def has_attribute?(attribute_name, *args)
99
120
  (@composites.to_a + @radios.to_a + @labels.to_a).map do |widget_proxy|
100
- return true if widget_proxy.has_attribute?(attribute_name, *args)
121
+ return true if widget_proxy.has_attribute?(attribute_name, *args)
101
122
  end
102
123
  super
103
124
  end
@@ -145,7 +166,7 @@ module Glimmer
145
166
  }
146
167
  end
147
168
  observation_requests.to_a.each do |observation_request, block|
148
- delegate_observation_request_to_radios(observation_request, &block)
169
+ delegate_observation_request_to_radios(observation_request, &block)
149
170
  end
150
171
  self.selection = current_selection
151
172
  end
@@ -0,0 +1,87 @@
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
+
22
+ require 'date'
23
+ require 'glimmer/swt/widget_proxy'
24
+
25
+ module Glimmer
26
+ module SWT
27
+ # Proxy for org.eclipse.swt.widgets.DateTime
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class DateTimeProxy < WidgetProxy
31
+ CUSTOM_ATTRIBUTES = %w[date_time date time month]
32
+
33
+ def date_time
34
+ DateTime.new(year, month, day, hours, minutes, seconds)
35
+ end
36
+
37
+ def date_time=(date_time_value)
38
+ self.time = date_time_value.to_time
39
+ end
40
+
41
+ def date
42
+ date_time.to_date
43
+ end
44
+
45
+ def date=(date_value)
46
+ self.year = date_value.year
47
+ self.month = date_value.month
48
+ self.day = date_value.day
49
+ end
50
+
51
+ def time
52
+ date_time.to_time
53
+ end
54
+
55
+ def time=(time_value)
56
+ self.date = time_value.to_date
57
+ self.hours = time_value.hour
58
+ self.minutes = time_value.min
59
+ self.seconds = time_value.sec
60
+ end
61
+
62
+ def month
63
+ swt_widget.month + 1
64
+ end
65
+
66
+ def month=(new_value)
67
+ swt_widget.month = new_value - 1
68
+ end
69
+
70
+ def set_attribute(attribute_name, *args)
71
+ if CUSTOM_ATTRIBUTES.include?(attribute_name.to_s)
72
+ send(ruby_attribute_setter(attribute_name), args.first)
73
+ else
74
+ super(attribute_name, *args)
75
+ end
76
+ end
77
+
78
+ def get_attribute(attribute_name)
79
+ if CUSTOM_ATTRIBUTES.include?(attribute_name.to_s)
80
+ send(attribute_name)
81
+ else
82
+ super(attribute_name)
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end