class Lebowski::Foundation::Views::Support::CollectionItemViewArray

Represents a generic array of item views for a collection view

Constants

SELECT_ALL_KEY

Public Instance Methods

deselect(filter) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 236
def deselect(filter)
  raise ArgumentError.new "filter required" if filter.nil?
  
  @parent.key_down :ctrl_key
  each filter do |view, index|
    view.deselect
  end
  @parent.key_up :ctrl_key
end
deselect_all() click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 255
def deselect_all()
  @parent.click
end
find_with_content(content) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 189
def find_with_content(content)
  if content.nil?
    raise ArgumentError.new "content can not be nil"
  end

  content = [content] if (not content.kind_of? Array)

  items = []
  content.each do |obj|
    if not obj.kind_of? Lebowski::Foundation::ProxyObject
      raise ArgumentInvalidTypeError.new "content", obj, Lebowski::Foundation::ProxyObject
    end

    guid = obj.sc_guid
    result = find_all({ :sc_guid => guid })
    items << result[0] if (not result.empty?)
  end
  return items
end
index_of(obj) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 184
def index_of(obj)
  indexes = find_indexes({ :sc_guid => obj.content.sc_guid })
  return indexes.empty? ? -1 : indexes[0]
end
select(filter) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 209
def select(filter)
  raise ArgumentError.new "filter required" if filter.nil?
  deselect_all
  select_with_fiter(filter)
end
select_add(filter) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 215
def select_add(filter)
  raise ArgumentError.new "filter required" if filter.nil?
  select_with_fiter(filter)
end
select_all() click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 246
def select_all()
  num_views = count
  return if (num_views == 0)

  if num_views > 1
    select_range(self[0], self[num_views - 1])
  end            
end
select_range(val1, val2) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 220
def select_range(val1, val2)
  idx1 = get_index(val1, 'val1')
  idx2 = get_index(val2, 'val2')
  items_count = @parent.item_views.count
  if (idx1 < 0 or idx1 >= items_count) or (idx2 < 0 or idx2 >= items_count)
    raise ArgumentError.new "arguments are out of bounds"
  end
  item1 = @parent.item_views[idx1]
  item2 = @parent.item_views[idx2]
  item1.click
  @parent.key_down :shift_key
  item1.select
  item2.select
  @parent.key_up :shift_key
end

Protected Instance Methods

create_object(index, expected_type=nil) click to toggle source

@Override

Will mixin collection view support for returned proxy

# File lib/lebowski/foundation/views/collection.rb, line 264
def create_object(index, expected_type=nil)
  rel_path = "itemViewForContentIndex.#{index}"
  obj =  @parent[rel_path, expected_type]
  # Before we return the item view we have to make sure the
  # proxy has collection item view support mixin
  mix_in_support_for_object obj
  return obj
end
mix_in_support_for_object(obj) click to toggle source

Mixes in the CollectionItemViewSupport mixin for the given proxy object.

This is required since the example view provided to a collection view can be any type of view; therefore, we can't assume the proxy representing the view will already have collection item view suppor

# File lib/lebowski/foundation/views/collection.rb, line 278
def mix_in_support_for_object(obj)
  if not obj.class.ancestors.member? Mixins::CollectionItemViewSupport            
    obj.extend Mixins::CollectionItemViewSupport
  end
end

Private Instance Methods

get_index(val, val_name) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 286
def get_index(val, val_name)
  return val if val.kind_of?(Integer)
  return index_of(val) if val.kind_of?(Lebowski::Foundation::ProxyObject)
  raise ArgumentInvalidTypeError.new val_name, val, Integer, Lebowski::Foundation::ProxyObject
end
select_with_fiter(filter) click to toggle source
# File lib/lebowski/foundation/views/collection.rb, line 292
def select_with_fiter(filter)
  each filter do |view, index|
    view.select_add
  end
end