glimmer-dsl-swt 4.17.5.0 → 4.17.8.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -2
  3. data/README.md +250 -83
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +20 -5
  6. data/lib/glimmer/data_binding/tree_items_binding.rb +20 -2
  7. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +61 -0
  8. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +2 -0
  9. data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -0
  10. data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +48 -0
  11. data/lib/glimmer/dsl/swt/dsl.rb +2 -0
  12. data/lib/glimmer/dsl/swt/file_dialog_expression.rb +48 -0
  13. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +61 -0
  14. data/lib/glimmer/dsl/swt/shell_expression.rb +3 -3
  15. data/lib/glimmer/dsl/swt/widget_expression.rb +8 -8
  16. data/lib/glimmer/swt/custom/checkbox_group.rb +181 -0
  17. data/lib/glimmer/swt/custom/code_text.rb +39 -31
  18. data/lib/glimmer/swt/custom/radio_group.rb +176 -0
  19. data/lib/glimmer/swt/directory_dialog_proxy.rb +65 -0
  20. data/lib/glimmer/swt/expand_item_proxy.rb +0 -1
  21. data/lib/glimmer/swt/file_dialog_proxy.rb +66 -0
  22. data/lib/glimmer/swt/menu_proxy.rb +4 -4
  23. data/lib/glimmer/swt/shell_proxy.rb +5 -5
  24. data/lib/glimmer/swt/tab_item_proxy.rb +3 -3
  25. data/lib/glimmer/swt/widget_proxy.rb +27 -27
  26. data/lib/glimmer/ui/custom_shell.rb +3 -3
  27. data/lib/glimmer/ui/custom_widget.rb +3 -0
  28. data/samples/elaborate/meta_sample.rb +24 -19
  29. data/samples/hello/hello_checkbox.rb +85 -0
  30. data/samples/hello/hello_checkbox_group.rb +68 -0
  31. data/samples/hello/hello_combo.rb +12 -12
  32. data/samples/hello/hello_directory_dialog.rb +60 -0
  33. data/samples/hello/hello_expand_bar.rb +3 -1
  34. data/samples/hello/hello_file_dialog.rb +60 -0
  35. data/samples/hello/hello_group.rb +104 -0
  36. data/samples/hello/hello_list_multi_selection.rb +23 -23
  37. data/samples/hello/hello_list_single_selection.rb +18 -17
  38. data/samples/hello/hello_radio.rb +108 -0
  39. data/samples/hello/hello_radio_group.rb +84 -0
  40. data/samples/hello/hello_world.rb +3 -3
  41. metadata +19 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.5.0
1
+ 4.17.8.2
@@ -2,16 +2,16 @@
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.5.0 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.8.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.5.0"
9
+ s.version = "4.17.8.2"
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-10-24"
14
+ s.date = "2020-11-03"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
45
45
  "lib/glimmer/dsl/swt/async_exec_expression.rb",
46
46
  "lib/glimmer/dsl/swt/bind_expression.rb",
47
47
  "lib/glimmer/dsl/swt/block_property_expression.rb",
48
+ "lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb",
48
49
  "lib/glimmer/dsl/swt/color_expression.rb",
49
50
  "lib/glimmer/dsl/swt/column_properties_expression.rb",
50
51
  "lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb",
@@ -52,11 +53,13 @@ Gem::Specification.new do |s|
52
53
  "lib/glimmer/dsl/swt/custom_widget_expression.rb",
53
54
  "lib/glimmer/dsl/swt/data_binding_expression.rb",
54
55
  "lib/glimmer/dsl/swt/dialog_expression.rb",
56
+ "lib/glimmer/dsl/swt/directory_dialog_expression.rb",
55
57
  "lib/glimmer/dsl/swt/display_expression.rb",
56
58
  "lib/glimmer/dsl/swt/dnd_expression.rb",
57
59
  "lib/glimmer/dsl/swt/dsl.rb",
58
60
  "lib/glimmer/dsl/swt/exec_expression.rb",
59
61
  "lib/glimmer/dsl/swt/expand_item_expression.rb",
62
+ "lib/glimmer/dsl/swt/file_dialog_expression.rb",
60
63
  "lib/glimmer/dsl/swt/font_expression.rb",
61
64
  "lib/glimmer/dsl/swt/image_expression.rb",
62
65
  "lib/glimmer/dsl/swt/layout_data_expression.rb",
@@ -67,6 +70,7 @@ Gem::Specification.new do |s|
67
70
  "lib/glimmer/dsl/swt/message_box_expression.rb",
68
71
  "lib/glimmer/dsl/swt/observe_expression.rb",
69
72
  "lib/glimmer/dsl/swt/property_expression.rb",
73
+ "lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb",
70
74
  "lib/glimmer/dsl/swt/rgb_expression.rb",
71
75
  "lib/glimmer/dsl/swt/rgba_expression.rb",
72
76
  "lib/glimmer/dsl/swt/shell_expression.rb",
@@ -85,10 +89,14 @@ Gem::Specification.new do |s|
85
89
  "lib/glimmer/rake_task/scaffold.rb",
86
90
  "lib/glimmer/swt/color_proxy.rb",
87
91
  "lib/glimmer/swt/cursor_proxy.rb",
92
+ "lib/glimmer/swt/custom/checkbox_group.rb",
88
93
  "lib/glimmer/swt/custom/code_text.rb",
94
+ "lib/glimmer/swt/custom/radio_group.rb",
95
+ "lib/glimmer/swt/directory_dialog_proxy.rb",
89
96
  "lib/glimmer/swt/display_proxy.rb",
90
97
  "lib/glimmer/swt/dnd_proxy.rb",
91
98
  "lib/glimmer/swt/expand_item_proxy.rb",
99
+ "lib/glimmer/swt/file_dialog_proxy.rb",
92
100
  "lib/glimmer/swt/font_proxy.rb",
93
101
  "lib/glimmer/swt/image_proxy.rb",
94
102
  "lib/glimmer/swt/layout_data_proxy.rb",
@@ -122,18 +130,25 @@ Gem::Specification.new do |s|
122
130
  "samples/elaborate/tic_tac_toe/cell.rb",
123
131
  "samples/elaborate/user_profile.rb",
124
132
  "samples/hello/hello_browser.rb",
133
+ "samples/hello/hello_checkbox.rb",
134
+ "samples/hello/hello_checkbox_group.rb",
125
135
  "samples/hello/hello_combo.rb",
126
136
  "samples/hello/hello_computed.rb",
127
137
  "samples/hello/hello_computed/contact.rb",
128
138
  "samples/hello/hello_custom_shell.rb",
129
139
  "samples/hello/hello_custom_widget.rb",
140
+ "samples/hello/hello_directory_dialog.rb",
130
141
  "samples/hello/hello_drag_and_drop.rb",
131
142
  "samples/hello/hello_expand_bar.rb",
143
+ "samples/hello/hello_file_dialog.rb",
144
+ "samples/hello/hello_group.rb",
132
145
  "samples/hello/hello_list_multi_selection.rb",
133
146
  "samples/hello/hello_list_single_selection.rb",
134
147
  "samples/hello/hello_menu_bar.rb",
135
148
  "samples/hello/hello_message_box.rb",
136
149
  "samples/hello/hello_pop_up_context_menu.rb",
150
+ "samples/hello/hello_radio.rb",
151
+ "samples/hello/hello_radio_group.rb",
137
152
  "samples/hello/hello_sash_form.rb",
138
153
  "samples/hello/hello_styled_text.rb",
139
154
  "samples/hello/hello_tab.rb",
@@ -153,7 +168,7 @@ Gem::Specification.new do |s|
153
168
  end
154
169
 
155
170
  if s.respond_to? :add_runtime_dependency then
156
- s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.1"])
171
+ s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.2"])
157
172
  s.add_runtime_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
158
173
  s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
159
174
  s.add_runtime_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
@@ -172,7 +187,7 @@ Gem::Specification.new do |s|
172
187
  s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
173
188
  s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
174
189
  else
175
- s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.1"])
190
+ s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.2"])
176
191
  s.add_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
177
192
  s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
178
193
  s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
@@ -33,7 +33,7 @@ module Glimmer
33
33
 
34
34
  include_package 'org.eclipse.swt'
35
35
  include_package 'org.eclipse.swt.widgets'
36
-
36
+
37
37
  def initialize(parent, model_binding, tree_properties)
38
38
  @tree = parent
39
39
  @model_binding = model_binding
@@ -53,13 +53,19 @@ module Glimmer
53
53
 
54
54
  def call(new_value=nil)
55
55
  @model_tree_root_node = @model_binding.evaluate_property
56
+ old_tree_items = @tree.all_tree_items
57
+ old_model_tree_nodes = old_tree_items.map(&:get_data)
58
+ new_model_tree_nodes = []
59
+ recursive_depth_first_search(@model_tree_root_node, @tree_properties, new_model_tree_nodes)
60
+ return if old_model_tree_nodes == new_model_tree_nodes && old_tree_items.map(&:text) == new_model_tree_nodes.map {|model_tree_node| model_tree_node.send(@tree_properties[:text])}
56
61
  populate_tree(@model_tree_root_node, @tree, @tree_properties)
57
62
  end
58
63
 
59
64
  def populate_tree(model_tree_root_node, parent, tree_properties)
65
+ # TODO get rid of model_tree_root_node, parent, tree_properties as an argument given it is stored as an instance variable
60
66
  # TODO make it change things by delta instead of removing all
61
- selected_tree_item_model = parent.swt_widget.getSelection.map(&:getData).first
62
67
  old_tree_items = parent.all_tree_items
68
+ selected_tree_item_model = parent.swt_widget.getSelection.map(&:get_data).first
63
69
  old_tree_item_expansion_by_data = old_tree_items.reduce({}) {|hash, ti| hash.merge(ti.getData => ti.getExpanded)}
64
70
  old_tree_items.each do |tree_item|
65
71
  tree_item.getData('observer_registrations').each(&:unregister)
@@ -78,6 +84,7 @@ module Glimmer
78
84
  observer_registrations = @tree_properties.reduce([]) do |array, key_value_pair|
79
85
  array + [observe(model_tree_node, key_value_pair.last)]
80
86
  end
87
+
81
88
  tree_item.setData('observer_registrations', observer_registrations)
82
89
  tree_item.setData(model_tree_node)
83
90
  tree_item.setText((model_tree_node && model_tree_node.send(tree_properties[:text])).to_s)
@@ -85,6 +92,17 @@ module Glimmer
85
92
  populate_tree_node(child, tree_item, tree_properties)
86
93
  end
87
94
  end
95
+
96
+ def recursive_depth_first_search(model_tree_node, tree_properties, collection)
97
+ return if model_tree_node.nil?
98
+ collection << model_tree_node
99
+ model_tree_node.send(tree_properties[:children]).to_a.each do |child_model_tree_node|
100
+ recursive_depth_first_search(child_model_tree_node, tree_properties, collection)
101
+ end
102
+ end
103
+
88
104
  end
105
+
89
106
  end
107
+
90
108
  end
@@ -0,0 +1,61 @@
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 'glimmer/dsl/expression'
23
+ require 'glimmer/data_binding/model_binding'
24
+ require 'glimmer/data_binding/widget_binding'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module SWT
29
+ class CheckboxGroupSelectionDataBindingExpression < Expression
30
+
31
+ def can_interpret?(parent, keyword, *args, &block)
32
+ keyword == 'selection' and
33
+ block.nil? and
34
+ (parent.is_a?(Glimmer::SWT::Custom::CheckboxGroup) or (parent.is_a?(Glimmer::UI::CustomWidget) and parent.body_root.is_a?(Glimmer::SWT::Custom::CheckboxGroup)) ) and
35
+ args.size == 1 and
36
+ args[0].is_a?(DataBinding::ModelBinding) and
37
+ args[0].evaluate_options_property.is_a?(Array)
38
+ end
39
+
40
+ def interpret(parent, keyword, *args, &block)
41
+ model_binding = args[0]
42
+
43
+ #TODO make this options observer dependent and all similar observers in widget specific data binding handlers
44
+ # TODO consider delegating some of this work
45
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'items')
46
+ widget_binding.call(model_binding.evaluate_options_property)
47
+ model = model_binding.base_model
48
+ widget_binding.observe(model, model_binding.options_property_name)
49
+
50
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'selection')
51
+ widget_binding.call(model_binding.evaluate_property)
52
+ widget_binding.observe(model, model_binding.property_name_expression)
53
+
54
+ parent.on_widget_selected do
55
+ model_binding.call(widget_binding.evaluate_property)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -26,6 +26,8 @@ require 'glimmer/dsl/top_level_expression'
26
26
  require 'glimmer/ui/custom_widget'
27
27
  require 'glimmer/ui/custom_shell'
28
28
  require 'glimmer/swt/custom/code_text'
29
+ require 'glimmer/swt/custom/radio_group'
30
+ require 'glimmer/swt/custom/checkbox_group'
29
31
 
30
32
  module Glimmer
31
33
  module DSL
@@ -37,6 +37,7 @@ module Glimmer
37
37
  end
38
38
 
39
39
  def interpret(parent, keyword, *args, &block)
40
+ # TODO reconcile this with the actual org.eclipse.swt.widgets.Dialog widget (maybe rename this as dialog_shell)
40
41
  args = [parent] + args unless parent.nil?
41
42
  args += [:dialog_trim, :application_modal]
42
43
  Glimmer::SWT::ShellProxy.send(:new, *args)
@@ -0,0 +1,48 @@
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 'glimmer/dsl/static_expression'
23
+ require 'glimmer/dsl/parent_expression'
24
+ require 'glimmer/dsl/top_level_expression'
25
+ require 'glimmer/swt/directory_dialog_proxy'
26
+
27
+ module Glimmer
28
+ module DSL
29
+ module SWT
30
+ class DirectoryDialogExpression < StaticExpression
31
+ include TopLevelExpression
32
+ include ParentExpression
33
+
34
+ include_package 'org.eclipse.swt.widgets'
35
+
36
+ def can_interpret?(parent, keyword, *args, &block)
37
+ keyword == 'directory_dialog' and
38
+ (parent.nil? or parent.is_a?(Shell) or parent.is_a?(Glimmer::SWT::ShellProxy))
39
+ end
40
+
41
+ def interpret(parent, keyword, *args, &block)
42
+ args = [parent] + args unless parent.nil?
43
+ Glimmer::SWT::DirectoryDialogProxy.send(:new, *args)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -41,6 +41,8 @@ module Glimmer
41
41
  layout
42
42
  widget_listener
43
43
  combo_selection_data_binding
44
+ checkbox_group_selection_data_binding
45
+ radio_group_selection_data_binding
44
46
  list_selection_data_binding
45
47
  tree_items_data_binding
46
48
  table_items_data_binding
@@ -0,0 +1,48 @@
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 'glimmer/dsl/static_expression'
23
+ require 'glimmer/dsl/parent_expression'
24
+ require 'glimmer/dsl/top_level_expression'
25
+ require 'glimmer/swt/file_dialog_proxy'
26
+
27
+ module Glimmer
28
+ module DSL
29
+ module SWT
30
+ class FileDialogExpression < StaticExpression
31
+ include TopLevelExpression
32
+ include ParentExpression
33
+
34
+ include_package 'org.eclipse.swt.widgets'
35
+
36
+ def can_interpret?(parent, keyword, *args, &block)
37
+ keyword == 'file_dialog' and
38
+ (parent.nil? or parent.is_a?(Shell) or parent.is_a?(Glimmer::SWT::ShellProxy))
39
+ end
40
+
41
+ def interpret(parent, keyword, *args, &block)
42
+ args = [parent] + args unless parent.nil?
43
+ Glimmer::SWT::FileDialogProxy.send(:new, *args)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,61 @@
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 'glimmer/dsl/expression'
23
+ require 'glimmer/data_binding/model_binding'
24
+ require 'glimmer/data_binding/widget_binding'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module SWT
29
+ class RadioGroupSelectionDataBindingExpression < Expression
30
+
31
+ def can_interpret?(parent, keyword, *args, &block)
32
+ keyword == 'selection' and
33
+ block.nil? and
34
+ (parent.is_a?(Glimmer::SWT::Custom::RadioGroup) or (parent.is_a?(Glimmer::UI::CustomWidget) and parent.body_root.is_a?(Glimmer::SWT::Custom::RadioGroup)) ) and
35
+ args.size == 1 and
36
+ args[0].is_a?(DataBinding::ModelBinding) and
37
+ args[0].evaluate_options_property.is_a?(Array)
38
+ end
39
+
40
+ def interpret(parent, keyword, *args, &block)
41
+ model_binding = args[0]
42
+
43
+ #TODO make this options observer dependent and all similar observers in widget specific data binding handlers
44
+ # TODO consider delegating some of this work
45
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'items')
46
+ widget_binding.call(model_binding.evaluate_options_property)
47
+ model = model_binding.base_model
48
+ widget_binding.observe(model, model_binding.options_property_name)
49
+
50
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'selection')
51
+ widget_binding.call(model_binding.evaluate_property)
52
+ widget_binding.observe(model, model_binding.property_name_expression)
53
+
54
+ parent.on_widget_selected do
55
+ model_binding.call(widget_binding.evaluate_property)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ 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
@@ -28,24 +28,24 @@ module Glimmer
28
28
  module SWT
29
29
  class WidgetExpression < Expression
30
30
  include ParentExpression
31
-
31
+
32
32
  EXCLUDED_KEYWORDS = %w[shell display tab_item]
33
-
33
+
34
34
  def can_interpret?(parent, keyword, *args, &block)
35
35
  !EXCLUDED_KEYWORDS.include?(keyword) and
36
36
  parent.respond_to?(:swt_widget) and #TODO change to composite?(parent)
37
37
  Glimmer::SWT::WidgetProxy.widget_exists?(keyword)
38
38
  end
39
-
39
+
40
40
  def interpret(parent, keyword, *args, &block)
41
41
  Glimmer::SWT::WidgetProxy.create(keyword, parent, args)
42
42
  end
43
-
43
+
44
44
  def add_content(parent, &block)
45
45
  super
46
46
  parent.post_add_content
47
47
  end
48
-
48
+
49
49
  end
50
50
  end
51
51
  end