Class: Lebowski::Foundation::Views::Support::CollectionItemViewArray

Inherits:
CollectionItemArray show all
Includes:
Lebowski::Foundation, Lebowski::Foundation::Views
Defined in:
lib/lebowski/foundation/views/collection.rb

Overview

Represents a generic array of item views for a collection view

Constant Summary collapse

SELECT_ALL_KEY =
'a'

Constants included from Lebowski::Foundation

SC_BRANCH_CLOSED, SC_BRANCH_OPEN, SC_BUTTON1_STATUS, SC_BUTTON2_STATUS, SC_BUTTON3_STATUS, SC_LEAF_NODE, SC_MIXED_STATE, SC_PICKER_FIXED, SC_PICKER_MENU, SC_PICKER_POINTER, SC_T_ARRAY, SC_T_BOOL, SC_T_CLASS, SC_T_ERROR, SC_T_FUNCTION, SC_T_HASH, SC_T_NULL, SC_T_NUMBER, SC_T_OBJECT, SC_T_STRING, SC_T_UNDEFINED

Instance Method Summary collapse

Methods inherited from CollectionItemArray

#initialize, #selected

Methods inherited from ObjectArray

#[], #all?, #any?, #count, #each, #empty?, #filter, #find_all, #find_first, #find_indexes, #find_last, #first, #initialize, #last, #member?, #none?, #one?, #prefilter

Constructor Details

This class inherits a constructor from Lebowski::Foundation::Views::Support::CollectionItemArray

Instance Method Details

#deselect(filter) ⇒ Object



236
237
238
239
240
241
242
243
244
# 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_allObject



255
256
257
# File 'lib/lebowski/foundation/views/collection.rb', line 255

def deselect_all()
  @parent.click
end

#find_with_content(content) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# 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) ⇒ Object



184
185
186
187
# 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) ⇒ Object



209
210
211
212
213
# 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) ⇒ Object



215
216
217
218
# 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_allObject



246
247
248
249
250
251
252
253
# 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) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# 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