< prev index next >

core/JemmyCore/src/org/jemmy/input/StringMenuOwner.java

Print this page




  29 import org.jemmy.interfaces.MenuOwner;
  30 import org.jemmy.lookup.LookupCriteria;
  31 
  32 /**
  33  * In most cases menu has a text associated with every menu item. This interface
  34  * makes it easy to push the menu based on that text information.
  35  * @author shura
  36  */
  37 public abstract class StringMenuOwner<T> extends StringCriteriaList<T>
  38         implements MenuOwner<T> {
  39 
  40     private static final String MENU_PATH_LENGTH_ERROR = "Menu path length should be greater than 0";
  41 
  42     public StringMenuOwner(Wrap<?> menuOwner) {
  43         super(menuOwner.getEnvironment());
  44     }
  45 
  46     /**
  47      * Pushes the menu using one string for one level of the menu. Comparison
  48      * is done according to the policy.
  49      * @param texts
  50      * @see #getPolicy()
  51      */
  52     public void push(String... texts) {
  53         if(texts.length == 0) {
  54             throw new IllegalArgumentException(MENU_PATH_LENGTH_ERROR);
  55         }
  56         menu().push(createCriteriaList(texts));
  57     }
  58 
  59     /**
  60      * A shortcut to <code>menu().push(LookupCriteria<T> ...)</code>
  61      * @see #menu()
  62      * @see Menu#push(org.jemmy.lookup.LookupCriteria<T>[])
  63      * @param criteria
  64      */
  65     public void push(LookupCriteria<T>... criteria) {
  66         menu().push(criteria);
  67     }
  68 
  69     /**
  70      * Select a menu item using one string for one level of the menu. Comparison
  71      * is done according to the policy.
  72      * @param texts
  73      * @return wrap for the last selected item
  74      * @see #getPolicy()
  75      */
  76     public Wrap<? extends T> select(String... texts) {
  77         if(texts.length == 0) {
  78             throw new IllegalArgumentException(MENU_PATH_LENGTH_ERROR);
  79         }
  80         return menu().select(createCriteriaList(texts));
  81     }
  82 
  83     /**
  84      * A shortcut to <code>menu().select(LookupCriteria<T> ...)</code>
  85      * @see #menu()
  86      * @see Menu#select(org.jemmy.lookup.LookupCriteria<T>[])
  87      * @param criteria

  88      */
  89     public Wrap<? extends T> select(LookupCriteria<T>... criteria) {
  90         return menu().select(criteria);
  91     }
  92 
  93 }


  29 import org.jemmy.interfaces.MenuOwner;
  30 import org.jemmy.lookup.LookupCriteria;
  31 
  32 /**
  33  * In most cases menu has a text associated with every menu item. This interface
  34  * makes it easy to push the menu based on that text information.
  35  * @author shura
  36  */
  37 public abstract class StringMenuOwner<T> extends StringCriteriaList<T>
  38         implements MenuOwner<T> {
  39 
  40     private static final String MENU_PATH_LENGTH_ERROR = "Menu path length should be greater than 0";
  41 
  42     public StringMenuOwner(Wrap<?> menuOwner) {
  43         super(menuOwner.getEnvironment());
  44     }
  45 
  46     /**
  47      * Pushes the menu using one string for one level of the menu. Comparison
  48      * is done according to the policy.
  49      * @param texts todo document
  50      * @see #getPolicy()
  51      */
  52     public void push(String... texts) {
  53         if(texts.length == 0) {
  54             throw new IllegalArgumentException(MENU_PATH_LENGTH_ERROR);
  55         }
  56         menu().push(createCriteriaList(texts));
  57     }
  58 
  59     /**
  60      * A shortcut to <code>menu().push(LookupCriteria ...)</code>
  61      * @see #menu()
  62      * @see Menu#push(LookupCriteria[])
  63      * @param criteria the lookup criteria
  64      */
  65     public void push(LookupCriteria<T>... criteria) {
  66         menu().push(criteria);
  67     }
  68 
  69     /**
  70      * Select a menu item using one string for one level of the menu. Comparison
  71      * is done according to the policy.
  72      * @param texts todo document
  73      * @return wrap for the last selected item
  74      * @see #getPolicy()
  75      */
  76     public Wrap<? extends T> select(String... texts) {
  77         if(texts.length == 0) {
  78             throw new IllegalArgumentException(MENU_PATH_LENGTH_ERROR);
  79         }
  80         return menu().select(createCriteriaList(texts));
  81     }
  82 
  83     /**
  84      * A shortcut to <code>menu().select(LookupCriteria ...)</code>
  85      * @see #menu()
  86      * @see Menu#select(LookupCriteria[])
  87      * @param criteria the lookup criteria
  88      * @return todo document
  89      */
  90     public Wrap<? extends T> select(LookupCriteria<T>... criteria) {
  91         return menu().select(criteria);
  92     }
  93 
  94 }
< prev index next >