Sha256: 3883153e4e2bcfa0647ac7e9b834c4ff2c52448a34d5cc6454119b39c2056d2f

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

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

class WidgetListenerCommandHandler
  include CommandHandler
  
  include_package 'org.eclipse.swt.widgets'

  def can_handle?(parent, command_symbol, *args, &block)
    Glimmer.logger.debug "parent is a widget: " + (parent.is_a?(RWidget)).to_s
    return unless parent.is_a?(RWidget)
    Glimmer.logger.debug "on listener?: " + (command_symbol.to_s[0,3] == "on_").to_s
    return unless command_symbol.to_s[0,3] == "on_"
    Glimmer.logger.debug "command symbol is longer than 3: " + (command_symbol.to_s.length > 3).to_s
    return unless command_symbol.to_s.length > 3
    Glimmer.logger.debug "args are 0?: " + (args.size == 0).to_s
    return unless args.size == 0
    Glimmer.logger.debug "can add listener? " + (parent.can_add_listener?(command_symbol.to_s[3, command_symbol.to_s.length])).to_s
    parent.can_add_listener?(command_symbol.to_s[3, command_symbol.to_s.length])
  end
  
  def do_handle(parent, command_symbol, *args, &block)
    parent.add_listener(command_symbol.to_s[3, command_symbol.to_s.length], &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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
glimmer-0.3.5 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.3.4 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.3.3 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.3.2 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.3.1 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.2.5 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.2.4 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.2.3 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.2.2 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.2.1 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.2.0 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.11.SWT4.14 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.11.470 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.10.470 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.9.470 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.8.470 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.5.470 lib/command_handlers/widget_listener_command_handler.rb