Sha256: febb907d7714ea409c814cf0a2d7d7f1b7de5229adaa252131e6cc2975d28bef

Contents?: true

Size: 1.79 KB

Versions: 30

Compression:

Stored size: 1.79 KB

Contents

require 'glimmer/dsl/expression'
require 'glimmer/data_binding/model_binding'
require 'glimmer/data_binding/widget_binding'
require 'glimmer/data_binding/list_selection_binding'

module Glimmer
  module DSL
    module SWT
      class ListSelectionDataBindingExpression < Expression
        include_package 'org.eclipse.swt.widgets'
  
        def can_interpret?(parent, keyword, *args, &block)
          keyword == 'selection' and
            block.nil? and
            parent.respond_to?(:swt_widget) and
            parent.swt_widget.is_a?(List) and
            args.size == 1 and
            args[0].is_a?(DataBinding::ModelBinding) and
            args[0].evaluate_options_property.is_a?(Array)
        end
  
        def interpret(parent, keyword, *args, &block)
          model_binding = args[0]
          widget_binding = DataBinding::WidgetBinding.new(parent, 'items')
          widget_binding.call(model_binding.evaluate_options_property)
          model = model_binding.base_model
          #TODO make this options observer dependent and all similar observers in widget specific data binding interpretrs
          widget_binding.observe(model, model_binding.options_property_name)
  
          property_type = :string
          property_type = :array if parent.has_style?(:multi)
          list_selection_binding = DataBinding::ListSelectionBinding.new(parent, property_type)
          list_selection_binding.call(model_binding.evaluate_property)
          #TODO check if nested data binding works for list widget and other widgets that need custom data binding
          list_selection_binding.observe(model, model_binding.property_name_expression)
  
          parent.on_widget_selected do
            model_binding.call(list_selection_binding.evaluate_property)
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
glimmer-dsl-swt-0.6.9 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.8 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.7 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.6 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.5 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.4 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.3 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.2 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.1 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.6.0 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.5.6 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.5.5 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.5.4 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.5.3 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.5.2 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.5.1 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.5.0 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.4.1 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.4.0 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
glimmer-dsl-swt-0.3.1 lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb