Class: Glimmer::DataBinding::ListSelectionBinding
- Inherits:
-
Object
- Object
- Glimmer::DataBinding::ListSelectionBinding
- Includes:
- Glimmer, Observable, Observer
- Defined in:
- lib/glimmer/data_binding/list_selection_binding.rb
Overview
SWT List widget selection binding
Constant Summary collapse
- PROPERTY_TYPE_UPDATERS =
{ :string => lambda { |, value| ..select(..index_of(value.to_s)) }, :array => lambda { |, value| ..selection=(value || []).to_java(:string) } }
- PROPERTY_EVALUATORS =
{ :string => lambda do |selection_array| return nil if selection_array.empty? selection_array[0] end, :array => lambda do |selection_array| selection_array end }
Constants included from Glimmer
Instance Attribute Summary collapse
-
#widget_proxy ⇒ Object
readonly
Returns the value of attribute widget_proxy.
Instance Method Summary collapse
- #call(value) ⇒ Object
- #evaluate_property ⇒ Object
-
#initialize(widget_proxy, property_type, sync_exec: false, async_exec: false) ⇒ ListSelectionBinding
constructor
Initialize with list widget and property_type property_type :string represents default list single selection property_type :array represents list multi selection.
Methods included from Glimmer
Constructor Details
#initialize(widget_proxy, property_type, sync_exec: false, async_exec: false) ⇒ ListSelectionBinding
Initialize with list widget and property_type property_type :string represents default list single selection property_type :array represents list multi selection
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 53 def initialize(, property_type, sync_exec: false, async_exec: false) property_type = :string if property_type.nil? or property_type == :undefined @widget_proxy = @property_type = property_type @sync_exec = sync_exec @async_exec = async_exec Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do @widget_proxy. do |dispose_event| unregister_all_observables end end end |
Instance Attribute Details
#widget_proxy ⇒ Object (readonly)
Returns the value of attribute widget_proxy.
33 34 35 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 33 def @widget_proxy end |
Instance Method Details
#call(value) ⇒ Object
66 67 68 69 70 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 66 def call(value) Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do PROPERTY_TYPE_UPDATERS[@property_type].call(@widget_proxy, value) unless evaluate_property == value end end |
#evaluate_property ⇒ Object
72 73 74 75 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 72 def evaluate_property selection_array = @widget_proxy..send('selection').to_a #TODO refactor send('selection') into proper method invocation PROPERTY_EVALUATORS[@property_type].call(selection_array) end |