Sha256: cfeb26433bd11a185e2254f869149fdf26fd8d66d64902c1786f4adbc5ddb2a5

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 KB

Contents

require File.dirname(__FILE__) + "/../command_handler"
require File.dirname(__FILE__) + "/models/r_widget"
require File.dirname(__FILE__) + "/models/model_binding"

# Responsible for setting up the return value of the bind keyword (command symbol)
# as a ModelBinding. It is then used by another command handler like
# DataBindingCommandHandler for text and selection properties on Text and Spinner
# or TableItemsDataBindingCommandHandler for items in a Table
class BindCommandHandler
  include CommandHandler

  include_package 'org.eclipse.swt.widgets'

  def can_handle?(parent, command_symbol, *args, &block)
    (
      parent.is_a?(RWidget) and
      command_symbol.to_s == "bind" and
      (
        (
          (args.size == 2) and
          (
            args[1].is_a?(Symbol) or
            args[1].is_a?(String)
          )
        ) or
        (
          (args.size == 3) and
          (args[1].is_a?(Symbol) or args[1].is_a?(String)) and
          (args[2].is_a?(Symbol) or args[2].is_a?(String) or args[2].is_a?(Hash))
        ) or
        (
          (args.size == 4) and
          (args[1].is_a?(Symbol) or args[1].is_a?(String)) and
          (args[2].is_a?(Symbol) or args[2].is_a?(String)) and
          (args[3].is_a?(Hash))
        )
      ) and
      block == nil
    )
  end

  def do_handle(parent, command_symbol, *args, &block)
    property_type = args[2] if (args.size == 3) && !args[2].is_a?(Hash)
    binding_options = args[2] if args[2].is_a?(Hash)
    binding_options = args[3] if args[3].is_a?(Hash)
    ModelBinding.new(args[0], args[1].to_s, property_type, binding_options)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
glimmer-0.3.5 lib/command_handlers/bind_command_handler.rb
glimmer-0.3.4 lib/command_handlers/bind_command_handler.rb
glimmer-0.3.3 lib/command_handlers/bind_command_handler.rb
glimmer-0.3.2 lib/command_handlers/bind_command_handler.rb
glimmer-0.3.1 lib/command_handlers/bind_command_handler.rb
glimmer-0.2.5 lib/command_handlers/bind_command_handler.rb
glimmer-0.2.4 lib/command_handlers/bind_command_handler.rb
glimmer-0.2.3 lib/command_handlers/bind_command_handler.rb
glimmer-0.2.2 lib/command_handlers/bind_command_handler.rb