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) ⇒ 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 Observer
#add_dependent, #dependents, #dependents_for, proc, #register, #registration_for, #registrations, #remove_dependent, #unregister, #unregister_all_observables, #unregister_dependents_with_observable
Methods included from Observable
#add_observer, #inspect, #remove_observer
Methods included from Glimmer
Constructor Details
#initialize(widget_proxy, property_type) ⇒ ListSelectionBinding
Initialize with list widget and property_type property_type :string represents default list single selection property_type :array represents list multi selection
33 34 35 36 37 38 39 40 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 33 def initialize(, property_type) property_type = :string if property_type.nil? or property_type == :undefined @widget_proxy = @property_type = property_type @widget_proxy. do |dispose_event| unregister_all_observables end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer
Instance Attribute Details
#widget_proxy ⇒ Object (readonly)
Returns the value of attribute widget_proxy.
13 14 15 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 13 def @widget_proxy end |
Instance Method Details
#call(value) ⇒ Object
42 43 44 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 42 def call(value) PROPERTY_TYPE_UPDATERS[@property_type].call(@widget_proxy, value) unless evaluate_property == value end |
#evaluate_property ⇒ Object
46 47 48 49 |
# File 'lib/glimmer/data_binding/list_selection_binding.rb', line 46 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 |