Class: Osaka::TypicalOpenDialog

Inherits:
TypicalFinderDialog show all
Defined in:
lib/osaka/typicalopendialog.rb

Instance Attribute Summary

Attributes inherited from TypicalFinderDialog

#control

Instance Method Summary collapse

Methods inherited from TypicalFinderDialog

#initialize, #set_folder

Constructor Details

This class inherits a constructor from Osaka::TypicalFinderDialog

Instance Method Details

#amount_of_files_in_listObject



46
47
48
49
50
# File 'lib/osaka/typicalopendialog.rb', line 46

def amount_of_files_in_list
  amount_of_rows = control.get!("rows", file_list_location)
  amount_match_data = amount_of_rows.match(/.*row (\d) of/)
  amount_match_data.nil? ? 0 : amount_match_data[1].to_i
end

#click_openObject



29
30
31
# File 'lib/osaka/typicalopendialog.rb', line 29

def click_open
  control.click(at.button("Open"))
end

#field_location_from_row(row) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/osaka/typicalopendialog.rb', line 33

def field_location_from_row(row)
  if (greyed_out?(row))
    static_field_location_from_row(row)
  else
    text_field_location_from_row(row)
  end
end

#file_list_locationObject



9
10
11
12
13
14
15
# File 'lib/osaka/typicalopendialog.rb', line 9

def file_list_location
  if [:snow_leopard, :lion, :mountain_lion, :mavericks].include? control.mac_version
    at.outline(1).scroll_area(2).splitter_group(1).group(1)
  else
    at.outline(1).scroll_area(1).splitter_group(1).splitter_group(1).group(1)
  end
end

#filename_at(row) ⇒ Object



52
53
54
# File 'lib/osaka/typicalopendialog.rb', line 52

def filename_at(row)
  control.get!("value", field_location_from_row(row))
end

#greyed_out?(row) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/osaka/typicalopendialog.rb', line 25

def greyed_out?(row)
  !control.exists?(text_field_location_from_row(row))
end

#select_file(filename) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/osaka/typicalopendialog.rb', line 56

def select_file(filename)
  amount_of_files_in_list.times() { |row|
    if filename_at(row+1) == filename
      select_file_by_row(row+1)
      click_open
      return
    end
  }
end

#select_file_by_row(row) ⇒ Object



41
42
43
44
# File 'lib/osaka/typicalopendialog.rb', line 41

def select_file_by_row(row)
  raise(OpenDialogCantSelectFile, "Tried to select a file, but it either doesn't exist or is greyed out") if (greyed_out?(row))
  control.set!("selected", at.row(row) + file_list_location, true)
end

#static_field_location_from_row(row) ⇒ Object



21
22
23
# File 'lib/osaka/typicalopendialog.rb', line 21

def static_field_location_from_row(row)
  at.static_text(1).ui_element(1).row(row) + file_list_location
end

#text_field_location_from_row(row) ⇒ Object



17
18
19
# File 'lib/osaka/typicalopendialog.rb', line 17

def text_field_location_from_row(row)
  at.text_field(1).ui_element(1).row(row) + file_list_location
end