Class: ListSelectionBinding
- Inherits:
-
Object
- Object
- ListSelectionBinding
- Includes:
- Glimmer, Observable, Observer
- Defined in:
- lib/command_handlers/models/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 or []).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 }
Instance Attribute Summary collapse
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
Instance Method Summary collapse
- #evaluate_property ⇒ Object
-
#initialize(widget, 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.
- #update(value) ⇒ Object
Methods included from Observer
#add_dependent, #dependents, #dependents_for, #register, #registrations, #registrations_for, #remove_dependent, #unregister, #unregister_all_observables, #unregister_dependents_with_observable
Methods included from Observable
#add_observer, #remove_observer
Methods included from Glimmer
#add_contents, add_contents, dsl, #dsl, extended, included, logger, #method_missing, method_missing
Methods included from SwtPackages
Constructor Details
#initialize(widget, 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
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/command_handlers/models/list_selection_binding.rb', line 27 def initialize(, property_type) property_type = :string if property_type.nil? or property_type == :undefined = @property_type = property_type add_contents() { { |dispose_event| unregister_all_observables } } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer
Instance Attribute Details
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
10 11 12 |
# File 'lib/command_handlers/models/list_selection_binding.rb', line 10 def end |
Instance Method Details
#evaluate_property ⇒ Object
40 41 42 43 44 |
# File 'lib/command_handlers/models/list_selection_binding.rb', line 40 def evaluate_property selection_array = ..send("selection").to_a property_value = @@property_evaluators[@property_type].call(selection_array) return property_value end |
#update(value) ⇒ Object
37 38 39 |
# File 'lib/command_handlers/models/list_selection_binding.rb', line 37 def update(value) @@property_type_updaters[@property_type].call(, value) unless evaluate_property == value end |