Class: Lebowski::Foundation::Views::SelectFieldView
- Inherits:
-
View
- Object
- ProxyObject
- SCObject
- View
- Lebowski::Foundation::Views::SelectFieldView
- Defined in:
- lib/lebowski/foundation/views/select_field.rb
Overview
Represents a proxy to a SproutCore select field view (SC.SelectFieldView)
Constant Summary collapse
- EMPTY_VALUE =
'***'
Constants included from Mixins::StallSupport
Mixins::StallSupport::DEFAULT_KEY_STALLS, Mixins::StallSupport::DEFAULT_STALL
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
Constants included from Mixins::WaitActions
Mixins::WaitActions::DEFAULT_TIMEOUT
Instance Attribute Summary
Attributes inherited from ProxyObject
#driver, #name, #parent, #rel_path
Instance Method Summary collapse
-
#has_empty_option? ⇒ Boolean
Use to check if this view has an empty item.
- #select(val) ⇒ Object
-
#select_empty ⇒ Object
Used to select the empty item, if there is one.
-
#select_with_index(val) ⇒ Object
Used to select an item via its index.
-
#select_with_name(val) ⇒ Object
Used to select an item via its label.
-
#select_with_value(val) ⇒ Object
Used to select an item via its value.
- #selected? ⇒ Boolean
- #selected_with_index?(index) ⇒ Boolean
- #selected_with_name?(value) ⇒ Boolean
- #selected_with_value?(value) ⇒ Boolean
Methods inherited from View
#abs_path, #action_locator_args, #action_target, #assigned_layer_id?, #child_views, #core_query, #frame, #height, #layer, #layer_id, #position, #scroll_to_visible, #scrollable_parent_view, #width
Methods included from Mixins::DelegateSupport
Methods included from Mixins::UserActions
#basic_click, #click, #click_at, #double_click, #drag, #drag_after, #drag_before, #drag_on_to, #drag_to, #drag_to_end_of, #drag_to_start_of, #focus, #key_down, #key_up, #mouse_down, #mouse_down_at, #mouse_move, #mouse_move_at, #mouse_up, #mouse_up_at, #mouse_wheel_delta_x, #mouse_wheel_delta_y, #right_click, #right_click_at, #right_mouse_down, #right_mouse_down_at, #right_mouse_up, #right_mouse_up_at, #type, #type_key
Methods included from Mixins::StallSupport
adjust_all_stalls, adjust_default_key_stall, adjust_default_stall, reset, #stall
Methods included from Mixins::KeyCheck
Methods included from Mixins::PositionedElement
#height, #position, #position_relative_to, #scroll_to_visible, #width
Methods inherited from SCObject
#has_represented_sc_class?, #kind_of_represented_sc_class?, represented_sc_class, #represented_sc_class, representing_sc_class
Methods inherited from ProxyObject
#==, #[], #abs_path, #abs_path_with, #define, #define_proxy, #init_ext, #initialize, #method_missing, #none?, #object?, #proxy, #represent_as, #sc_all_classes, #sc_class, #sc_guid, #sc_kind_of?, #sc_path_defined?, #sc_type_of, #unravel_relative_path
Methods included from Mixins::DefinePathsSupport
#define_path, #define_paths_for, #defined_path, #defined_paths, #path_defined?, #root_defined_path_part, #root_defined_path_part=
Methods included from Mixins::WaitActions
Constructor Details
This class inherits a constructor from Lebowski::Foundation::ProxyObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Lebowski::Foundation::ProxyObject
Instance Method Details
#has_empty_option? ⇒ Boolean
Use to check if this view has an empty item
30 31 32 33 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 30 def has_empty_option?() empty = self['emptyName'] return (not (empty.nil? or empty.empty?)) end |
#select(val) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 62 def select(val) return if val.nil? if val.kind_of? Integer select_with_index(val) elsif val == :empty select_empty else select_with_name(val.to_s) end end |
#select_empty ⇒ Object
Used to select the empty item, if there is one
112 113 114 115 116 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 112 def select_empty() option_locator = "value=#{EMPTY_VALUE}" @driver.sc_select(:view, option_locator, self.abs_path) stall :select end |
#select_with_index(val) ⇒ Object
Used to select an item via its index
79 80 81 82 83 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 79 def select_with_index(val) option_locator = "index=#{val}" @driver.sc_select(:view, option_locator, self.abs_path) stall :select end |
#select_with_name(val) ⇒ Object
Used to select an item via its label
90 91 92 93 94 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 90 def select_with_name(val) option_locator = "label=regexi:^#{val}$" @driver.sc_select(:view, option_locator, self.abs_path) stall :select end |
#select_with_value(val) ⇒ Object
Used to select an item via its value
101 102 103 104 105 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 101 def select_with_value(val) option_locator = "value=regexi:^(nu|st|sc)#{val}$" @driver.sc_select(:view, option_locator, self.abs_path) stall :select end |
#selected? ⇒ Boolean
20 21 22 23 24 25 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 20 def selected?() val = self['value'] return false if val.nil? return false if (val.kind_of?(String) and (val.empty? or val == EMPTY_VALUE)) return true end |
#selected_with_index?(index) ⇒ Boolean
58 59 60 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 58 def selected_with_index?(index) # TODO end |
#selected_with_name?(value) ⇒ Boolean
35 36 37 38 39 40 41 42 43 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 35 def selected_with_name?(value) objs = self['objects'] val = self['value'] objs.each do |obj| name = get_object_name(obj) return (val == get_object_value(obj)) if (not (name =~ /^#{value}$/i).nil?) end return false end |
#selected_with_value?(value) ⇒ Boolean
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lebowski/foundation/views/select_field.rb', line 45 def selected_with_value?(value) objs = self['objects'] val = self['value'] objs.each do |obj| if value.kind_of? String return true if (not (val =~ /^#{get_object_value(obj)}$/i).nil?) else return true if (value == val) end end return false end |