Sha256: 9748671c70fa0b4fff77f0bbfa71c690ede7ce4a56adaa4a08be461d2227952c

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require File.dirname(__FILE__) + "/../../command_handler"
require File.dirname(__FILE__) + "/../g_widget"
require File.dirname(__FILE__) + "/../custom_widget"

module Glimmer
  module SWT
    module CommandHandlers
      # TODO rename to observation command handler (or keyword handler)

      class WidgetListenerCommandHandler
        include CommandHandler

        include_package 'org.eclipse.swt.widgets'

        def can_handle?(parent, command_symbol, *args, &block)
          widget_parentage = (parent.is_a?(GWidget) || parent.is_a?(CustomWidget))
          Glimmer.logger.debug "parent is a widget: #{widget_parentage}"
          return unless widget_parentage
          Glimmer.logger.debug "keyword starts with on_: #{command_symbol.to_s.start_with?('on_')}"
          return unless command_symbol.to_s.start_with?('on_')
          Glimmer.logger.debug "args are empty?: #{args.empty?}"
          return unless args.empty?
          Glimmer.logger.debug "block exists?: #{!block.nil?}"
          return unless !block.nil?
          result = parent.can_handle_observation_request?(command_symbol.to_s)
          Glimmer.logger.debug "can add listener? #{result}"
          result
        end

        def do_handle(parent, command_symbol, *args, &block)
          parent.handle_observation_request(command_symbol.to_s, &block)
          ListenerParent.new #TODO refactor and move to models
        end

        #TODO refactor and move to separate file
        class ListenerParent
          include Parent

          def process_block(block)
            #NOOP
          end

        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glimmer-0.4.9 lib/glimmer/swt/command_handlers/widget_listener_command_handler.rb