Class: TableItemsBinding
- Inherits:
-
Object
- Object
- TableItemsBinding
- Includes:
- Glimmer, Observable, Observer
- Defined in:
- lib/command_handlers/models/table_items_binding.rb
Instance Method Summary collapse
-
#initialize(parent, model_binding, column_properties) ⇒ TableItemsBinding
constructor
A new instance of TableItemsBinding.
- #populate_table(model_collection, parent, column_properties) ⇒ Object
- #update(model_collection = nil) ⇒ 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(parent, model_binding, column_properties) ⇒ TableItemsBinding
Returns a new instance of TableItemsBinding.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/command_handlers/models/table_items_binding.rb', line 13 def initialize(parent, model_binding, column_properties) @table = parent @model_binding = model_binding @column_properties = column_properties update(@model_binding.evaluate_property) model = model_binding.base_model observe(model, model_binding.property_name_expression) add_contents(@table) { { |dispose_event| unregister_all_observables } } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer
Instance Method Details
#populate_table(model_collection, parent, column_properties) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/command_handlers/models/table_items_binding.rb', line 33 def populate_table(model_collection, parent, column_properties) parent..removeAll model_collection.each do |model| table_item = TableItem.new(parent., SWT::NONE) for index in 0..(column_properties.size-1) table_item.setText(index, model.send(column_properties[index]).to_s) end end end |
#update(model_collection = nil) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/command_handlers/models/table_items_binding.rb', line 26 def update(model_collection=nil) if model_collection and model_collection.is_a?(Array) observe(model_collection, @column_properties) @model_collection = model_collection end populate_table(@model_collection, @table, @column_properties) end |