Class: ATT::FilePopup

Inherits:
Popup
  • Object
show all
Includes:
FileExt
Defined in:
lib/popup/file_popup.rb

Direct Known Subclasses

SavePopup

Constant Summary collapse

CONFIRM_TEXT =
[ "OPEN", "打开", "Open","保存","Save","SAVE" ]

Constants inherited from Popup

Popup::VERSION

Instance Attribute Summary

Attributes inherited from Popup

#window

Instance Method Summary collapse

Methods inherited from Popup

#assert_exist?, #close, collect_windows, find, find_all, find_when, #initialize, record

Constructor Details

This class inherits a constructor from ATT::Popup

Instance Method Details

#click_confirmObject



27
28
29
30
31
# File 'lib/popup/file_popup.rb', line 27

def click_confirm
  #@window.button( config("open_button") ).click
  #WindowFactory.make_other( @window,config["confirm"] ).click
  confirm_button.click
end

#confirm_buttonObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/popup/file_popup.rb', line 33

def confirm_button
  most_like = @window.button(:index=>1)
  CONFIRM_TEXT.each do |text| 
    most_like.value.include?(text)  && ( return most_like )
  end
  # Warning:at the most time it should be the button index is 1, if not,
  # Now we try find one matched button with CONFIRM_TEXT.
  @window.buttons.find do |button| 
    CONFIRM_TEXT.each do |text|
      button.value.include?(text) && ( break true ) || false
    end
  end
end

#set(file_path) ⇒ Object

Raise RootNotSetError when ATT::Config.root not set and path is not an absolute path



12
13
14
15
16
# File 'lib/popup/file_popup.rb', line 12

def set(file_path)
  check_file_exist?(file_path)
  set_text(file_path)
  click_confirm
end

#set_text(file_path) ⇒ Object



18
19
20
21
# File 'lib/popup/file_popup.rb', line 18

def set_text(file_path)
  #@text_field = WindowFactory.make_other(@window, config["edit"] )
  text_field.set(window_full_path(file_path))
end

#text_fieldObject



23
24
25
# File 'lib/popup/file_popup.rb', line 23

def text_field
  @window.text_field(:instance=>1)
end