glimmer-dsl-swt 4.17.4.1 → 4.17.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -3
  3. data/README.md +267 -107
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +24 -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/expand_item_expression.rb +60 -0
  13. data/lib/glimmer/dsl/swt/file_dialog_expression.rb +48 -0
  14. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +61 -0
  15. data/lib/glimmer/dsl/swt/shell_expression.rb +4 -4
  16. data/lib/glimmer/dsl/swt/widget_expression.rb +9 -8
  17. data/lib/glimmer/swt/custom/checkbox_group.rb +160 -0
  18. data/lib/glimmer/swt/custom/code_text.rb +25 -18
  19. data/lib/glimmer/swt/custom/radio_group.rb +155 -0
  20. data/lib/glimmer/swt/directory_dialog_proxy.rb +65 -0
  21. data/lib/glimmer/swt/expand_item_proxy.rb +97 -0
  22. data/lib/glimmer/swt/file_dialog_proxy.rb +66 -0
  23. data/lib/glimmer/swt/image_proxy.rb +5 -0
  24. data/lib/glimmer/swt/menu_proxy.rb +5 -5
  25. data/lib/glimmer/swt/sash_form_proxy.rb +1 -1
  26. data/lib/glimmer/swt/shell_proxy.rb +6 -6
  27. data/lib/glimmer/swt/styled_text_proxy.rb +43 -0
  28. data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
  29. data/lib/glimmer/swt/widget_proxy.rb +86 -82
  30. data/lib/glimmer/ui/custom_shell.rb +4 -4
  31. data/lib/glimmer/ui/custom_widget.rb +3 -0
  32. data/samples/elaborate/meta_sample.rb +36 -31
  33. data/samples/hello/hello_checkbox.rb +85 -0
  34. data/samples/hello/hello_checkbox_group.rb +68 -0
  35. data/samples/hello/hello_combo.rb +12 -12
  36. data/samples/hello/hello_directory_dialog.rb +60 -0
  37. data/samples/hello/hello_expand_bar.rb +110 -0
  38. data/samples/hello/hello_file_dialog.rb +60 -0
  39. data/samples/hello/hello_list_multi_selection.rb +23 -23
  40. data/samples/hello/hello_list_single_selection.rb +18 -17
  41. data/samples/hello/hello_radio.rb +108 -0
  42. data/samples/hello/hello_radio_group.rb +84 -0
  43. data/samples/hello/hello_styled_text.rb +138 -0
  44. data/samples/hello/hello_world.rb +4 -4
  45. metadata +23 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.4.1
1
+ 4.17.8.0
@@ -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.4.1 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.8.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.4.1"
9
+ s.version = "4.17.8.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-10-22"
14
+ s.date = "2020-11-01"
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,10 +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",
61
+ "lib/glimmer/dsl/swt/expand_item_expression.rb",
62
+ "lib/glimmer/dsl/swt/file_dialog_expression.rb",
59
63
  "lib/glimmer/dsl/swt/font_expression.rb",
60
64
  "lib/glimmer/dsl/swt/image_expression.rb",
61
65
  "lib/glimmer/dsl/swt/layout_data_expression.rb",
@@ -66,6 +70,7 @@ Gem::Specification.new do |s|
66
70
  "lib/glimmer/dsl/swt/message_box_expression.rb",
67
71
  "lib/glimmer/dsl/swt/observe_expression.rb",
68
72
  "lib/glimmer/dsl/swt/property_expression.rb",
73
+ "lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb",
69
74
  "lib/glimmer/dsl/swt/rgb_expression.rb",
70
75
  "lib/glimmer/dsl/swt/rgba_expression.rb",
71
76
  "lib/glimmer/dsl/swt/shell_expression.rb",
@@ -84,9 +89,14 @@ Gem::Specification.new do |s|
84
89
  "lib/glimmer/rake_task/scaffold.rb",
85
90
  "lib/glimmer/swt/color_proxy.rb",
86
91
  "lib/glimmer/swt/cursor_proxy.rb",
92
+ "lib/glimmer/swt/custom/checkbox_group.rb",
87
93
  "lib/glimmer/swt/custom/code_text.rb",
94
+ "lib/glimmer/swt/custom/radio_group.rb",
95
+ "lib/glimmer/swt/directory_dialog_proxy.rb",
88
96
  "lib/glimmer/swt/display_proxy.rb",
89
97
  "lib/glimmer/swt/dnd_proxy.rb",
98
+ "lib/glimmer/swt/expand_item_proxy.rb",
99
+ "lib/glimmer/swt/file_dialog_proxy.rb",
90
100
  "lib/glimmer/swt/font_proxy.rb",
91
101
  "lib/glimmer/swt/image_proxy.rb",
92
102
  "lib/glimmer/swt/layout_data_proxy.rb",
@@ -98,6 +108,7 @@ Gem::Specification.new do |s|
98
108
  "lib/glimmer/swt/scrolled_composite_proxy.rb",
99
109
  "lib/glimmer/swt/shell_proxy.rb",
100
110
  "lib/glimmer/swt/style_constantizable.rb",
111
+ "lib/glimmer/swt/styled_text_proxy.rb",
101
112
  "lib/glimmer/swt/swt_proxy.rb",
102
113
  "lib/glimmer/swt/tab_item_proxy.rb",
103
114
  "lib/glimmer/swt/table_column_proxy.rb",
@@ -119,18 +130,26 @@ Gem::Specification.new do |s|
119
130
  "samples/elaborate/tic_tac_toe/cell.rb",
120
131
  "samples/elaborate/user_profile.rb",
121
132
  "samples/hello/hello_browser.rb",
133
+ "samples/hello/hello_checkbox.rb",
134
+ "samples/hello/hello_checkbox_group.rb",
122
135
  "samples/hello/hello_combo.rb",
123
136
  "samples/hello/hello_computed.rb",
124
137
  "samples/hello/hello_computed/contact.rb",
125
138
  "samples/hello/hello_custom_shell.rb",
126
139
  "samples/hello/hello_custom_widget.rb",
140
+ "samples/hello/hello_directory_dialog.rb",
127
141
  "samples/hello/hello_drag_and_drop.rb",
142
+ "samples/hello/hello_expand_bar.rb",
143
+ "samples/hello/hello_file_dialog.rb",
128
144
  "samples/hello/hello_list_multi_selection.rb",
129
145
  "samples/hello/hello_list_single_selection.rb",
130
146
  "samples/hello/hello_menu_bar.rb",
131
147
  "samples/hello/hello_message_box.rb",
132
148
  "samples/hello/hello_pop_up_context_menu.rb",
149
+ "samples/hello/hello_radio.rb",
150
+ "samples/hello/hello_radio_group.rb",
133
151
  "samples/hello/hello_sash_form.rb",
152
+ "samples/hello/hello_styled_text.rb",
134
153
  "samples/hello/hello_tab.rb",
135
154
  "samples/hello/hello_world.rb",
136
155
  "vendor/swt/linux/swt.jar",
@@ -148,7 +167,7 @@ Gem::Specification.new do |s|
148
167
  end
149
168
 
150
169
  if s.respond_to? :add_runtime_dependency then
151
- s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.1"])
170
+ s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.2"])
152
171
  s.add_runtime_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
153
172
  s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
154
173
  s.add_runtime_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
@@ -167,7 +186,7 @@ Gem::Specification.new do |s|
167
186
  s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
168
187
  s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
169
188
  else
170
- s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.1"])
189
+ s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.2"])
171
190
  s.add_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
172
191
  s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
173
192
  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,60 @@
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'
23
+ require 'glimmer/dsl/static_expression'
24
+ require 'glimmer/dsl/parent_expression'
25
+ require 'glimmer/swt/widget_proxy'
26
+ require 'glimmer/swt/expand_item_proxy'
27
+
28
+ module Glimmer
29
+ module DSL
30
+ module SWT
31
+ class ExpandItemExpression < StaticExpression
32
+ include ParentExpression
33
+
34
+ include_package 'org.eclipse.swt.widgets'
35
+
36
+ def can_interpret?(parent, keyword, *args, &block)
37
+ initial_condition = (keyword == 'expand_item') and parent.respond_to?(:swt_widget)
38
+ if initial_condition
39
+ if parent.swt_widget.is_a?(ExpandBar)
40
+ return true
41
+ else
42
+ Glimmer::Config.logger.error {"expand_item widget may only be used directly under a expand_bar widget!"}
43
+ end
44
+ end
45
+ false
46
+ end
47
+
48
+ def interpret(parent, keyword, *args, &block)
49
+ Glimmer::SWT::ExpandItemProxy.new(parent, args)
50
+ end
51
+
52
+ def add_content(parent, &block)
53
+ super
54
+ parent.post_add_content
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
@@ -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