Class: Glimmer::SWT::CommandHandlers::DataBindingCommandHandler
- Inherits:
-
Object
- Object
- Glimmer::SWT::CommandHandlers::DataBindingCommandHandler
- Extended by:
- Glimmer
- Includes:
- CommandHandler
- Defined in:
- lib/glimmer/swt/command_handlers/data_binding_command_handler.rb
Overview
Responsible for wiring two-way data-binding for text and selection properties on Text, Button, and Spinner widgets. Does so by using the output of the bind(model, property) command in the form of a ModelBinding, which is then connected to an anonymous widget observer (aka widget_data_binder as per widget_data_binders array)
Depends on BindCommandHandler
Constant Summary collapse
- @@widget_data_binders =
{ Java::OrgEclipseSwtWidgets::Text => { :text => Proc.new do |, model_binding| add_contents() { on_modify_text { |modify_event| model_binding.call(..getText) } } end, }, Java::OrgEclipseSwtWidgets::Button => { :selection => Proc.new do |, model_binding| add_contents() { { |selection_event| model_binding.call(..getSelection) } } end }, Java::OrgEclipseSwtWidgets::Spinner => { :selection => Proc.new do |, model_binding| add_contents() { { |selection_event| model_binding.call(..getSelection) } } end } }
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
Instance Method Details
#can_handle?(parent, command_symbol, *args, &block) ⇒ Boolean
53 54 55 56 57 |
# File 'lib/glimmer/swt/command_handlers/data_binding_command_handler.rb', line 53 def can_handle?(parent, command_symbol, *args, &block) (parent.is_a?(GWidget) and args.size == 1 and args[0].is_a?(ModelBinding)) end |
#do_handle(parent, command_symbol, *args, &block) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/glimmer/swt/command_handlers/data_binding_command_handler.rb', line 59 def do_handle(parent, command_symbol, *args, &block) model_binding = args[0] = [parent, command_symbol.to_s] = WidgetBinding.new(*) .call(model_binding.evaluate_property) .observe(model_binding) = @@widget_data_binders[parent..class] = [command_symbol.to_s.to_sym] if .call(parent, model_binding) if end |