glimmer-dsl-swt 4.18.4.11 → 4.18.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/README.md +7 -5
  4. data/VERSION +1 -1
  5. data/bin/glimmer +3 -3
  6. data/docs/reference/GLIMMER_CONFIGURATION.md +7 -3
  7. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +121 -5
  8. data/docs/reference/GLIMMER_SAMPLES.md +17 -4
  9. data/glimmer-dsl-swt.gemspec +19 -9
  10. data/lib/ext/glimmer/config.rb +3 -7
  11. data/lib/glimmer/data_binding/list_selection_binding.rb +13 -7
  12. data/lib/glimmer/data_binding/table_items_binding.rb +22 -17
  13. data/lib/glimmer/data_binding/tree_items_binding.rb +19 -15
  14. data/lib/glimmer/data_binding/widget_binding.rb +9 -27
  15. data/lib/glimmer/dsl/swt/auto_exec_expression.rb +36 -0
  16. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +9 -6
  17. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +16 -14
  18. data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -2
  19. data/lib/glimmer/dsl/swt/exec_expression.rb +1 -1
  20. data/lib/glimmer/dsl/swt/image_expression.rb +8 -1
  21. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +11 -8
  22. data/lib/glimmer/dsl/swt/pixel_expression.rb +1 -1
  23. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +8 -5
  24. data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
  25. data/lib/glimmer/dsl/swt/widget_expression.rb +4 -3
  26. data/lib/glimmer/launcher.rb +3 -0
  27. data/lib/glimmer/rake_task/scaffold.rb +3 -0
  28. data/lib/glimmer/swt/custom/code_text.rb +11 -11
  29. data/lib/glimmer/swt/custom/drawable.rb +4 -0
  30. data/lib/glimmer/swt/custom/shape.rb +129 -20
  31. data/lib/glimmer/swt/custom/shape/arc.rb +43 -0
  32. data/lib/glimmer/swt/custom/shape/focus.rb +43 -0
  33. data/lib/glimmer/swt/custom/shape/image.rb +86 -0
  34. data/lib/glimmer/swt/custom/shape/line.rb +58 -0
  35. data/lib/glimmer/swt/custom/shape/oval.rb +43 -0
  36. data/lib/glimmer/swt/custom/shape/point.rb +52 -0
  37. data/lib/glimmer/swt/custom/shape/polygon.rb +73 -0
  38. data/lib/glimmer/swt/custom/shape/polyline.rb +73 -0
  39. data/lib/glimmer/swt/custom/shape/rectangle.rb +87 -0
  40. data/lib/glimmer/swt/custom/shape/text.rb +73 -0
  41. data/lib/glimmer/swt/date_time_proxy.rb +9 -3
  42. data/lib/glimmer/swt/directory_dialog_proxy.rb +20 -18
  43. data/lib/glimmer/swt/display_proxy.rb +62 -2
  44. data/lib/glimmer/swt/expand_item_proxy.rb +18 -12
  45. data/lib/glimmer/swt/file_dialog_proxy.rb +20 -18
  46. data/lib/glimmer/swt/font_proxy.rb +1 -1
  47. data/lib/glimmer/swt/image_proxy.rb +1 -1
  48. data/lib/glimmer/swt/layout_data_proxy.rb +21 -15
  49. data/lib/glimmer/swt/layout_proxy.rb +19 -15
  50. data/lib/glimmer/swt/menu_proxy.rb +2 -2
  51. data/lib/glimmer/swt/message_box_proxy.rb +20 -7
  52. data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -2
  53. data/lib/glimmer/swt/shell_proxy.rb +94 -80
  54. data/lib/glimmer/swt/swt_proxy.rb +16 -0
  55. data/lib/glimmer/swt/tab_item_proxy.rb +5 -3
  56. data/lib/glimmer/swt/table_proxy.rb +32 -11
  57. data/lib/glimmer/swt/tree_proxy.rb +11 -16
  58. data/lib/glimmer/swt/widget_listener_proxy.rb +6 -2
  59. data/lib/glimmer/swt/widget_proxy.rb +200 -117
  60. data/lib/glimmer/ui.rb +5 -0
  61. data/lib/glimmer/ui/custom_shell.rb +11 -5
  62. data/lib/glimmer/ui/custom_widget.rb +4 -5
  63. data/samples/elaborate/contact_manager.rb +7 -7
  64. data/samples/elaborate/login.rb +25 -21
  65. data/samples/elaborate/mandelbrot_fractal.rb +3 -5
  66. data/samples/elaborate/tetris.rb +1 -0
  67. data/samples/elaborate/tic_tac_toe.rb +16 -14
  68. data/samples/elaborate/tic_tac_toe/board.rb +5 -5
  69. data/samples/elaborate/tic_tac_toe/cell.rb +5 -5
  70. data/samples/hello/hello_button.rb +7 -7
  71. data/samples/hello/hello_canvas.rb +43 -2
  72. data/samples/hello/hello_checkbox.rb +16 -14
  73. data/samples/hello/hello_checkbox_group.rb +11 -9
  74. data/samples/hello/hello_combo.rb +14 -12
  75. data/samples/hello/hello_computed.rb +7 -7
  76. data/samples/hello/hello_cursor.rb +2 -1
  77. data/samples/hello/hello_custom_shell.rb +17 -21
  78. data/samples/hello/hello_custom_widget.rb +4 -6
  79. data/samples/hello/hello_date_time.rb +14 -12
  80. data/samples/hello/hello_directory_dialog.rb +7 -7
  81. data/samples/hello/hello_expand_bar.rb +8 -8
  82. data/samples/hello/hello_file_dialog.rb +7 -7
  83. data/samples/hello/hello_group.rb +18 -16
  84. data/samples/hello/hello_list_multi_selection.rb +13 -11
  85. data/samples/hello/hello_list_single_selection.rb +13 -11
  86. data/samples/hello/hello_progress_bar.rb +3 -7
  87. data/samples/hello/hello_radio.rb +18 -16
  88. data/samples/hello/hello_radio_group.rb +14 -12
  89. data/samples/hello/hello_spinner.rb +7 -7
  90. data/samples/hello/hello_tab.rb +5 -5
  91. data/samples/hello/hello_table.rb +10 -5
  92. data/samples/hello/hello_tree.rb +485 -0
  93. metadata +17 -18
@@ -32,8 +32,7 @@ module Glimmer
32
32
  'org.eclipse.swt.custom',
33
33
  'org.eclipse.swt.dnd',
34
34
  ]
35
- DEFAULT_AUTO_SYNC_EXEC = false
36
- GUI_THREAD = Thread.current
35
+ DEFAULT_AUTO_SYNC_EXEC = true
37
36
 
38
37
  class << self
39
38
  # Tells Glimmer to import SWT packages into including class (default: true)
@@ -59,10 +58,6 @@ module Glimmer
59
58
  end
60
59
  alias auto_sync_exec? auto_sync_exec
61
60
 
62
- def require_sync_exec?
63
- Thread.current != GUI_THREAD
64
- end
65
-
66
61
  # Returns Logging Devices. Default is [:stdout, :syslog]
67
62
  def logging_devices
68
63
  unless defined? @@logging_devices
@@ -147,9 +142,10 @@ end
147
142
  Glimmer::Config.reset_logger! unless ENV['GLIMMER_LOGGER_ENABLED'].to_s.downcase == 'false'
148
143
  if ENV['GLIMMER_LOGGER_LEVEL']
149
144
  # if glimmer log level is being overridden for debugging purposes, then disable async logging making logging immediate
150
- Glimmer::Config.logging_appender_options = Glimmer::Config.logging_appender_options.merge(async: false, auto_flushing: 1)
145
+ Glimmer::Config.logging_appender_options = Glimmer::Config.logging_appender_options.merge(async: false, auto_flushing: 1, immediate_at: [:unknown, :debug, :info, :error, :fatal])
151
146
  Glimmer::Config.logging_devices = [:stdout]
152
147
  begin
148
+ puts "Adjusting Glimmer logging level to #{ENV['GLIMMER_LOGGER_LEVEL']}"
153
149
  Glimmer::Config.logger.level = ENV['GLIMMER_LOGGER_LEVEL'].strip
154
150
  rescue => e
155
151
  puts e.message
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 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
@@ -50,17 +50,23 @@ module Glimmer
50
50
  # Initialize with list widget and property_type
51
51
  # property_type :string represents default list single selection
52
52
  # property_type :array represents list multi selection
53
- def initialize(widget_proxy, property_type)
53
+ def initialize(widget_proxy, property_type, sync_exec: false, async_exec: false)
54
54
  property_type = :string if property_type.nil? or property_type == :undefined
55
55
  @widget_proxy = widget_proxy
56
56
  @property_type = property_type
57
- @widget_proxy.on_widget_disposed do |dispose_event|
58
- unregister_all_observables
57
+ @sync_exec = sync_exec
58
+ @async_exec = async_exec
59
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do
60
+ @widget_proxy.on_widget_disposed do |dispose_event|
61
+ unregister_all_observables
62
+ end
59
63
  end
60
64
  end
61
65
 
62
66
  def call(value)
63
- PROPERTY_TYPE_UPDATERS[@property_type].call(@widget_proxy, value) unless evaluate_property == value
67
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do
68
+ PROPERTY_TYPE_UPDATERS[@property_type].call(@widget_proxy, value) unless evaluate_property == value
69
+ end
64
70
  end
65
71
 
66
72
  def evaluate_property
@@ -24,6 +24,7 @@ require 'glimmer/data_binding/observable_model'
24
24
  require 'glimmer/data_binding/observable'
25
25
  require 'glimmer/data_binding/observer'
26
26
  require 'glimmer/swt/swt_proxy'
27
+ require 'glimmer/swt/display_proxy'
27
28
 
28
29
  module Glimmer
29
30
  module DataBinding
@@ -37,33 +38,37 @@ module Glimmer
37
38
  @table = parent
38
39
  @model_binding = model_binding
39
40
  @read_only_sort = @model_binding.binding_options[:read_only_sort]
40
- @table.swt_widget.data = @model_binding
41
- @table.swt_widget.set_data('table_items_binding', self)
42
41
  @column_properties = column_properties
43
- @table.on_widget_disposed do |dispose_event|
44
- unregister_all_observables
45
- end
46
42
  if @table.respond_to?(:column_properties=)
47
43
  @table.column_properties = @column_properties
48
44
  else # assume custom widget
49
45
  @table.body_root.column_properties = @column_properties
50
46
  end
51
- @table_observer_registration = observe(model_binding)
52
- call
47
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @model_binding.binding_options[:sync_exec], override_async_exec: @model_binding.binding_options[:async_exec]) do
48
+ @table.swt_widget.data = @model_binding
49
+ @table.swt_widget.set_data('table_items_binding', self)
50
+ @table.on_widget_disposed do |dispose_event|
51
+ unregister_all_observables
52
+ end
53
+ @table_observer_registration = observe(model_binding)
54
+ call
55
+ end
53
56
  end
54
57
 
55
58
  def call(new_model_collection=nil, internal_sort: false)
56
- new_model_collection = model_binding_evaluated_property = @model_binding.evaluate_property unless internal_sort # this ensures applying converters (e.g. :on_read)
57
- table_cells = @table.swt_widget.items.map {|item| @table.column_properties.size.times.map {|i| item.get_text(i)} }
58
- model_cells = new_model_collection.to_a.map {|m| @table.cells_for(m)}
59
- return if table_cells == model_cells
60
- if new_model_collection and new_model_collection.is_a?(Array)
61
- @table_items_observer_registration&.unobserve
62
- @table_items_observer_registration = observe(new_model_collection, @column_properties)
63
- add_dependent(@table_observer_registration => @table_items_observer_registration)
64
- @model_collection = new_model_collection
59
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @model_binding.binding_options[:sync_exec], override_async_exec: @model_binding.binding_options[:async_exec]) do
60
+ new_model_collection = model_binding_evaluated_property = @model_binding.evaluate_property unless internal_sort # this ensures applying converters (e.g. :on_read)
61
+ table_cells = @table.swt_widget.items.map {|item| @table.column_properties.size.times.map {|i| item.get_text(i)} }
62
+ model_cells = new_model_collection.to_a.map {|m| @table.cells_for(m)}
63
+ return if table_cells == model_cells
64
+ if new_model_collection and new_model_collection.is_a?(Array)
65
+ @table_items_observer_registration&.unobserve
66
+ @table_items_observer_registration = observe(new_model_collection, @column_properties)
67
+ add_dependent(@table_observer_registration => @table_items_observer_registration)
68
+ @model_collection = new_model_collection
69
+ end
70
+ populate_table(@model_collection, @table, @column_properties, internal_sort: internal_sort)
65
71
  end
66
- populate_table(@model_collection, @table, @column_properties, internal_sort: internal_sort)
67
72
  end
68
73
 
69
74
  def populate_table(model_collection, parent, column_properties, internal_sort: false)
@@ -43,29 +43,33 @@ module Glimmer
43
43
  else # assume custom widget
44
44
  @tree.body_root.tree_properties = @tree_properties
45
45
  end
46
- call
47
- model = model_binding.base_model
48
- observe(model, model_binding.property_name_expression)
49
- @tree.on_widget_disposed do |dispose_event|
50
- unregister_all_observables
46
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @model_binding.binding_options[:sync_exec], override_async_exec: @model_binding.binding_options[:async_exec]) do
47
+ call
48
+ model = model_binding.base_model
49
+ observe(model, model_binding.property_name_expression)
50
+ @tree.on_widget_disposed do |dispose_event|
51
+ unregister_all_observables
52
+ end
51
53
  end
52
54
  end
53
55
 
54
56
  def call(new_value=nil)
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])}
61
- populate_tree(@model_tree_root_node, @tree, @tree_properties)
57
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @model_binding.binding_options[:sync_exec], override_async_exec: @model_binding.binding_options[:async_exec]) do
58
+ @model_tree_root_node = @model_binding.evaluate_property
59
+ old_tree_items = @tree.all_tree_items
60
+ old_model_tree_nodes = old_tree_items.map(&:get_data)
61
+ new_model_tree_nodes = []
62
+ recursive_depth_first_search(@model_tree_root_node, @tree_properties, new_model_tree_nodes)
63
+ 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])}
64
+ populate_tree(@model_tree_root_node, @tree, @tree_properties)
65
+ end
62
66
  end
63
67
 
64
68
  def populate_tree(model_tree_root_node, parent, tree_properties)
65
69
  # TODO get rid of model_tree_root_node, parent, tree_properties as an argument given it is stored as an instance variable
66
70
  # TODO make it change things by delta instead of removing all
67
71
  old_tree_items = parent.all_tree_items
68
- selected_tree_item_model = parent.swt_widget.getSelection.map(&:get_data).first
72
+ selected_tree_item_models = parent.swt_widget.getSelection.map(&:get_data)
69
73
  old_tree_item_expansion_by_data = old_tree_items.reduce({}) {|hash, ti| hash.merge(ti.getData => ti.getExpanded)}
70
74
  old_tree_items.each do |tree_item|
71
75
  tree_item.getData('observer_registrations').each(&:unregister)
@@ -74,8 +78,8 @@ module Glimmer
74
78
  parent.swt_widget.removeAll
75
79
  populate_tree_node(model_tree_root_node, parent.swt_widget, tree_properties)
76
80
  parent.all_tree_items.each { |ti| ti.setExpanded(!!old_tree_item_expansion_by_data[ti.getData]) }
77
- tree_item_to_select = parent.depth_first_search {|ti| ti.getData == selected_tree_item_model}
78
- parent.swt_widget.setSelection(tree_item_to_select)
81
+ selected_tree_items = parent.depth_first_search {|item| selected_tree_item_models.include?(item.get_data) }
82
+ parent.swt_widget.setSelection(selected_tree_items)
79
83
  end
80
84
 
81
85
  def populate_tree_node(model_tree_node, parent, tree_properties)
@@ -32,36 +32,27 @@ module Glimmer
32
32
  include Observer
33
33
 
34
34
  attr_reader :widget, :property
35
- def initialize(widget, property, translator = nil, sync_exec: false, async_exec: false)
35
+ def initialize(widget, property, sync_exec: nil, async_exec: nil)
36
36
  @widget = widget
37
37
  @property = property
38
- @translator = translator || proc {|value| value} #TODO check on this it doesn't seem used
39
38
  @sync_exec = sync_exec
40
39
  @async_exec = async_exec
41
-
42
- if @widget.respond_to?(:on_widget_disposed)
43
- @widget.on_widget_disposed do |dispose_event|
44
- unregister_all_observables
40
+ SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do
41
+ if @widget.respond_to?(:on_widget_disposed)
42
+ @widget.on_widget_disposed do |dispose_event|
43
+ unregister_all_observables
44
+ end
45
45
  end
46
46
  end
47
47
  end
48
48
 
49
49
  def call(value)
50
- converted_value = translated_value = @translator.call(value)
51
-
52
- update_operation = lambda do
50
+ SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do
53
51
  if @widget.respond_to?(:disposed?) && @widget.disposed?
54
52
  unregister_all_observables
55
53
  return
56
54
  end
57
- @widget.set_attribute(@property, converted_value) unless evaluate_property == converted_value
58
- end
59
- if @sync_exec || Config.auto_sync_exec? && Config.require_sync_exec?
60
- SWT::DisplayProxy.instance.sync_exec(&update_operation)
61
- elsif @async_exec
62
- SWT::DisplayProxy.instance.async_exec(&update_operation)
63
- else
64
- update_operation.call
55
+ @widget.set_attribute(@property, value) unless evaluate_property == value
65
56
  end
66
57
  end
67
58
 
@@ -70,16 +61,7 @@ module Glimmer
70
61
  unregister_all_observables
71
62
  return
72
63
  end
73
- read_operation = lambda do
74
- @widget.get_attribute(@property)
75
- end
76
- if @sync_exec || Config.auto_sync_exec? && Config.require_sync_exec?
77
- SWT::DisplayProxy.instance.sync_exec(&read_operation)
78
- elsif @async_exec
79
- SWT::DisplayProxy.instance.async_exec(&read_operation)
80
- else
81
- read_operation.call
82
- end
64
+ @widget.get_attribute(@property)
83
65
  end
84
66
  end
85
67
  end
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2007-2021 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/swt/exec_expression'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module SWT
28
+ # Automatically executes code block against the SWT Event Loop
29
+ # with sync_exec if needed (inside a thread other than GUI thread)
30
+ # to manipulate SWT UI objects on the UI thread safely
31
+ class AutoExecExpression < StaticExpression
32
+ include ExecExpression
33
+ end
34
+ end
35
+ end
36
+ end
@@ -22,6 +22,7 @@
22
22
  require 'glimmer/dsl/expression'
23
23
  require 'glimmer/data_binding/model_binding'
24
24
  require 'glimmer/data_binding/widget_binding'
25
+ require 'glimmer/swt/display_proxy'
25
26
 
26
27
  module Glimmer
27
28
  module DSL
@@ -36,23 +37,25 @@ module Glimmer
36
37
  args[0].is_a?(DataBinding::ModelBinding) and
37
38
  args[0].evaluate_options_property.is_a?(Array)
38
39
  end
39
-
40
+
40
41
  def interpret(parent, keyword, *args, &block)
41
42
  model_binding = args[0]
42
43
 
43
44
  #TODO make this options observer dependent and all similar observers in widget specific data binding handlers
44
45
  # TODO consider delegating some of this work
45
- widget_binding = DataBinding::WidgetBinding.new(parent, 'items')
46
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'items', sync_exec: model_binding.binding_options[:sync_exec], async_exec: model_binding.binding_options[:async_exec])
46
47
  widget_binding.call(model_binding.evaluate_options_property)
47
48
  model = model_binding.base_model
48
49
  widget_binding.observe(model, model_binding.options_property_name)
49
50
 
50
- widget_binding = DataBinding::WidgetBinding.new(parent, 'selection')
51
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'selection', sync_exec: model_binding.binding_options[:sync_exec], async_exec: model_binding.binding_options[:async_exec])
51
52
  widget_binding.call(model_binding.evaluate_property)
52
- widget_binding.observe(model, model_binding.property_name_expression)
53
+ widget_binding.observe(model_binding)
53
54
 
54
- parent.on_widget_selected do
55
- model_binding.call(widget_binding.evaluate_property)
55
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: model_binding.binding_options[:sync_exec], override_async_exec: model_binding.binding_options[:async_exec]) do
56
+ parent.on_widget_selected do
57
+ model_binding.call(widget_binding.evaluate_property)
58
+ end
56
59
  end
57
60
  end
58
61
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 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
@@ -22,6 +22,7 @@
22
22
  require 'glimmer/dsl/expression'
23
23
  require 'glimmer/data_binding/model_binding'
24
24
  require 'glimmer/data_binding/widget_binding'
25
+ require 'glimmer/swt/display_proxy'
25
26
 
26
27
  module Glimmer
27
28
  module DSL
@@ -44,21 +45,22 @@ module Glimmer
44
45
 
45
46
  #TODO make this options observer dependent and all similar observers in widget specific data binding handlers
46
47
  # TODO consider delegating some of this work
47
- widget_binding = DataBinding::WidgetBinding.new(parent, 'items')
48
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'items', sync_exec: model_binding.binding_options[:sync_exec], async_exec: model_binding.binding_options[:async_exec])
48
49
  widget_binding.call(model_binding.evaluate_options_property)
49
- model = model_binding.base_model
50
- widget_binding.observe(model, model_binding.options_property_name)
50
+ widget_binding.observe(model_binding.model, model_binding.options_property_name)
51
51
 
52
- widget_binding = DataBinding::WidgetBinding.new(parent, 'text')
52
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'text', sync_exec: model_binding.binding_options[:sync_exec], async_exec: model_binding.binding_options[:async_exec])
53
53
  widget_binding.call(model_binding.evaluate_property)
54
- widget_binding.observe(model, model_binding.property_name_expression)
54
+ widget_binding.observe(model_binding)
55
55
 
56
- parent.on_widget_selected do
57
- model_binding.call(widget_binding.evaluate_property)
58
- end
59
-
60
- parent.on_modify_text do
61
- model_binding.call(widget_binding.evaluate_property)
56
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: model_binding.binding_options[:sync_exec], override_async_exec: model_binding.binding_options[:async_exec]) do
57
+ parent.on_widget_selected do
58
+ model_binding.call(widget_binding.evaluate_property)
59
+ end
60
+
61
+ parent.on_modify_text do
62
+ model_binding.call(widget_binding.evaluate_property)
63
+ end
62
64
  end
63
65
  end
64
66
  end
@@ -42,8 +42,7 @@ module Glimmer
42
42
 
43
43
  def interpret(parent, keyword, *args, &block)
44
44
  model_binding = args[0]
45
- widget_binding_parameters = [parent, keyword, {async_exec: model_binding.binding_options[:async_exec], sync_exec: model_binding.binding_options[:sync_exec]}]
46
- widget_binding = DataBinding::WidgetBinding.new(*widget_binding_parameters)
45
+ widget_binding = DataBinding::WidgetBinding.new(parent, keyword, sync_exec: model_binding.binding_options[:sync_exec], async_exec: model_binding.binding_options[:async_exec])
47
46
  widget_binding.call(model_binding.evaluate_property)
48
47
  #TODO make this options observer dependent and all similar observers in widget specific data binding handlers
49
48
  widget_binding.observe(model_binding)
@@ -41,7 +41,7 @@ module Glimmer
41
41
  end
42
42
 
43
43
  def interpret(parent, keyword, *args, &block)
44
- Glimmer::SWT::DisplayProxy.instance.swt_display.send(exec_operation, *args) do |*args|
44
+ Glimmer::SWT::DisplayProxy.instance.send(exec_operation, *args) do |*args|
45
45
  begin
46
46
  block.call(*args)
47
47
  rescue => e
@@ -34,8 +34,15 @@ module Glimmer
34
34
  include ParentExpression
35
35
 
36
36
  def can_interpret?(parent, keyword, *args, &block)
37
+ options = args.last.is_a?(Hash) ? args.last : {}
37
38
  (keyword == 'image') and
38
- (parent.nil? or parent.respond_to?('image=') or args.first.is_a?(Numeric))
39
+ (
40
+ options.keys.include?(:top_level) or
41
+ (
42
+ !parent.is_a?(Glimmer::SWT::Custom::Shape) and
43
+ (parent.nil? or parent.respond_to?('image=') or args.first.is_a?(Numeric))
44
+ )
45
+ )
39
46
  end
40
47
 
41
48
  def interpret(parent, keyword, *args, &block)
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 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
@@ -23,6 +23,7 @@ require 'glimmer/dsl/expression'
23
23
  require 'glimmer/data_binding/model_binding'
24
24
  require 'glimmer/data_binding/widget_binding'
25
25
  require 'glimmer/data_binding/list_selection_binding'
26
+ require 'glimmer/swt/display_proxy'
26
27
 
27
28
  module Glimmer
28
29
  module DSL
@@ -42,7 +43,7 @@ module Glimmer
42
43
 
43
44
  def interpret(parent, keyword, *args, &block)
44
45
  model_binding = args[0]
45
- widget_binding = DataBinding::WidgetBinding.new(parent, 'items')
46
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'items', sync_exec: model_binding.binding_options[:sync_exec], async_exec: model_binding.binding_options[:async_exec])
46
47
  widget_binding.call(model_binding.evaluate_options_property)
47
48
  model = model_binding.base_model
48
49
  #TODO make this options observer dependent and all similar observers in widget specific data binding interpretrs
@@ -50,13 +51,15 @@ module Glimmer
50
51
 
51
52
  property_type = :string
52
53
  property_type = :array if parent.has_style?(:multi)
53
- list_selection_binding = DataBinding::ListSelectionBinding.new(parent, property_type)
54
+ list_selection_binding = DataBinding::ListSelectionBinding.new(parent, property_type, sync_exec: model_binding.binding_options[:sync_exec], async_exec: model_binding.binding_options[:async_exec])
54
55
  list_selection_binding.call(model_binding.evaluate_property)
55
56
  #TODO check if nested data binding works for list widget and other widgets that need custom data binding
56
- list_selection_binding.observe(model, model_binding.property_name_expression)
57
+ list_selection_binding.observe(model_binding)
57
58
 
58
- parent.on_widget_selected do
59
- model_binding.call(list_selection_binding.evaluate_property)
59
+ Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: model_binding.binding_options[:sync_exec], override_async_exec: model_binding.binding_options[:async_exec]) do
60
+ parent.on_widget_selected do
61
+ model_binding.call(list_selection_binding.evaluate_property)
62
+ end
60
63
  end
61
64
  end
62
65
  end