Class: Glimmer::SWT::ListSelectionBinding
- Inherits:
-
Object
- Object
- Glimmer::SWT::ListSelectionBinding
- Includes:
- Glimmer, Observable, Observer
- Defined in:
- lib/glimmer/swt/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
- #call(value) ⇒ Object
- #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.
Methods included from Observer
#add_dependent, #dependents, #dependents_for, proc, #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 Glimmer::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
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/glimmer/swt/list_selection_binding.rb', line 29 def initialize(, property_type) property_type = :string if property_type.nil? or property_type == :undefined @widget = @property_type = property_type add_contents(@widget) { { |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.
12 13 14 |
# File 'lib/glimmer/swt/list_selection_binding.rb', line 12 def @widget end |
Instance Method Details
#call(value) ⇒ Object
39 40 41 |
# File 'lib/glimmer/swt/list_selection_binding.rb', line 39 def call(value) @@property_type_updaters[@property_type].call(@widget, value) unless evaluate_property == value end |
#evaluate_property ⇒ Object
42 43 44 45 46 |
# File 'lib/glimmer/swt/list_selection_binding.rb', line 42 def evaluate_property selection_array = @widget..send("selection").to_a property_value = @@property_evaluators[@property_type].call(selection_array) return property_value end |