Sha256: 04bfecb317d87f131338e31bb0807cfaaa95a39197f9b81b4f1d4a55d8491d9e

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 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)
    puts "parent is a widget: " + (parent.is_a?(RWidget)).to_s
    return unless parent.is_a?(RWidget)
    puts "on listener?: " + (command_symbol.to_s[0,3] == "on_").to_s
    return unless command_symbol.to_s[0,3] == "on_"
    puts "command symbol is longer than 3: " + (command_symbol.to_s.length > 3).to_s
    return unless command_symbol.to_s.length > 3
    puts "args are 0?: " + (args.size == 0).to_s
    return unless args.size == 0
    puts "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

4 entries across 4 versions & 1 rubygems

Version Path
glimmer-0.1.4.470 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.4.swt.pre.4.7.0 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.3 lib/command_handlers/widget_listener_command_handler.rb
glimmer-0.1.2 lib/command_handlers/widget_listener_command_handler.rb