Sha256: 9f5fb796bed99392769e6040e5a3750077e942f9887fba8e417a1acb25d34926

Contents?: true

Size: 1018 Bytes

Versions: 8

Compression:

Stored size: 1018 Bytes

Contents

require 'glimmer'
require 'glimmer/dsl/expression'
require 'glimmer/dsl/parent_expression'

module Glimmer
  module DSL
    module SWT
      class WidgetExpression < Expression
        include ParentExpression
  
        EXCLUDED_KEYWORDS = %w[shell display tab_item]
  
        def can_interpret?(parent, keyword, *args, &block)
          !EXCLUDED_KEYWORDS.include?(keyword) and
            parent.respond_to?(:swt_widget) and #TODO change to composite?(parent)
            Glimmer::SWT::WidgetProxy.widget_exists?(keyword)
        end
  
        def interpret(parent, keyword, *args, &block)
          begin
            class_name = "#{keyword.camelcase(:upper)}Proxy".to_sym
            widget_class = Glimmer::SWT.const_get(class_name)
          rescue
            widget_class = Glimmer::SWT::WidgetProxy
          end
          widget_class.new(keyword, parent, args)
        end
      end
    end
  end
end

require 'glimmer/swt/widget_proxy'
require 'glimmer/swt/tree_proxy'
require 'glimmer/swt/table_proxy'

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
glimmer-dsl-swt-0.2.3 lib/glimmer/dsl/swt/widget_expression.rb
glimmer-dsl-swt-0.2.2 lib/glimmer/dsl/swt/widget_expression.rb
glimmer-dsl-swt-0.2.1 lib/glimmer/dsl/swt/widget_expression.rb
glimmer-dsl-swt-0.2.0 lib/glimmer/dsl/swt/widget_expression.rb
glimmer-dsl-swt-0.1.3 lib/glimmer/dsl/swt/widget_expression.rb
glimmer-dsl-swt-0.1.2 lib/glimmer/dsl/swt/widget_expression.rb
glimmer-dsl-swt-0.1.1 lib/glimmer/dsl/swt/widget_expression.rb
glimmer-dsl-swt-0.1.0 lib/glimmer/dsl/swt/widget_expression.rb