Class: Glimmer::DSL::SWT::TreeItemsDataBindingExpression

Inherits:
Expression
  • Object
show all
Defined in:
lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb

Instance Method Summary collapse

Instance Method Details

#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (Glimmer::Error)


32
33
34
35
36
37
38
39
40
41
42
# File 'lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb', line 32

def can_interpret?(parent, keyword, *args, &block)
  initial_condition = ((keyword == "items") and block.nil? and parent.respond_to?(:swt_widget) and parent.swt_widget.is_a?(Tree))
  return false unless initial_condition
  raise Glimmer::Error, 'Tree items args must be 2' unless args.size == 2
  raise Glimmer::Error, 'Tree items first arg must be a bind expression' unless args[0].is_a?(DataBinding::ModelBinding)
  raise Glimmer::Error, 'Tree items data-binding initial value must not be an array yet a single item representing tree root' unless !args[0].evaluate_property.is_a?(Array)
  raise Glimmer::Error, 'Tree items second arg must be an array' unless args[1].is_a?(Array)
  raise Glimmer::Error, 'Tree items second arg must not be empty' unless !args[1].empty?
  raise Glimmer::Error, 'Tree items second arg array elements must be of type hash' unless args[1].first.is_a?(Hash)
  true
end

#interpret(parent, keyword, *args, &block) ⇒ Object



44
45
46
47
48
# File 'lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb', line 44

def interpret(parent, keyword, *args, &block)
  model_binding = args[0]
  tree_properties = args[1]
  DataBinding::TreeItemsBinding.new(parent, model_binding, tree_properties)
end