Class: Glimmer::SWT::CommandHandlers::ComboSelectionDataBindingCommandHandler

Inherits:
Object
  • Object
show all
Includes:
Glimmer, CommandHandler
Defined in:
lib/glimmer/swt/command_handlers/combo_selection_data_binding_command_handler.rb

Instance Method Summary collapse

Methods included from Glimmer

#add_contents, add_contents, dsl, #dsl, extended, included, logger, #method_missing, method_missing

Methods included from Glimmer::SwtPackages

included

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

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'lib/glimmer/swt/command_handlers/combo_selection_data_binding_command_handler.rb', line 13

def can_handle?(parent, command_symbol, *args, &block)
  parent.is_a?(GWidget) and
  parent.widget.is_a?(Combo) and
  command_symbol.to_s == "selection" and
  args.size == 1 and
  args[0].is_a?(ModelBinding) and
  args[0].evaluate_options_property.is_a?(Array) and
  block == nil
end

#do_handle(parent, command_symbol, *args, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/glimmer/swt/command_handlers/combo_selection_data_binding_command_handler.rb', line 23

def do_handle(parent, command_symbol, *args, &block)
  model_binding = args[0]
  widget_binding = WidgetBinding.new(parent, "items")
  widget_binding.call(model_binding.evaluate_options_property)
  model = model_binding.base_model
  widget_binding.observe(model, model_binding.options_property_name)

  widget_binding = WidgetBinding.new(parent, "text")
  widget_binding.call(model_binding.evaluate_property)
  widget_binding.observe(model, model_binding.property_name_expression)

  add_contents(parent) {
    on_widget_selected {
      model_binding.call(widget_binding.evaluate_property)
    }
  }
end