Class: Glimmer::SWT::CommandHandlers::ListSelectionDataBindingCommandHandler
- Inherits:
-
Object
- Object
- Glimmer::SWT::CommandHandlers::ListSelectionDataBindingCommandHandler
- Includes:
- Glimmer, CommandHandler
- Defined in:
- lib/glimmer/swt/command_handlers/list_selection_data_binding_command_handler.rb
Instance Method Summary collapse
- #can_handle?(parent, command_symbol, *args, &block) ⇒ Boolean
- #do_handle(parent, command_symbol, *args, &block) ⇒ Object
Methods included from Glimmer
#add_contents, add_contents, dsl, #dsl, extended, included, logger, #method_missing, method_missing
Methods included from Glimmer::SwtPackages
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer
Instance Method Details
#can_handle?(parent, command_symbol, *args, &block) ⇒ Boolean
14 15 16 17 18 19 20 21 22 |
# File 'lib/glimmer/swt/command_handlers/list_selection_data_binding_command_handler.rb', line 14 def can_handle?(parent, command_symbol, *args, &block) parent.is_a?(GWidget) and parent..is_a?(List) and command_symbol.to_s == "selection" and args.size == 1 and args[0].is_a?(ModelBinding) and args[0]..is_a?(Array) and block == nil end |
#do_handle(parent, command_symbol, *args, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/glimmer/swt/command_handlers/list_selection_data_binding_command_handler.rb', line 24 def do_handle(parent, command_symbol, *args, &block) model_binding = args[0] = WidgetBinding.new(parent, "items") .call(model_binding.) model = model_binding.base_model #TODO make this options observer dependent and all similar observers in widget specific data binding handlers .observe(model, model_binding.) property_type = :string property_type = :array if parent.has_style?(:multi) list_selection_binding = ListSelectionBinding.new(parent, property_type) list_selection_binding.call(model_binding.evaluate_property) #TODO check if nested data binding works for list widget and other widgets that need custom data binding list_selection_binding.observe(model, model_binding.property_name_expression) add_contents(parent) { { model_binding.call(list_selection_binding.evaluate_property) } } end |