Package org.fest.swing.util

Examples of org.fest.swing.util.TimeoutWatch


   */
  @RunsInEDT
  JList findDropDownList() {
    JPopupMenu popup = robot.findActivePopupMenu();
    if (popup == null) {
      TimeoutWatch watch = startWatchWithTimeoutOf(robot.settings().timeoutToFindPopup());
      popup = robot.findActivePopupMenu();
      while (popup == null) {
        if (watch.isTimeOut()) return null;
        pause();
        popup = robot.findActivePopupMenu();
      }
    }
    return findListIn(popup);
View Full Code Here


    toWaitFor.addComponentListener(this);
  }

  private void startWaiting(long timeout) {
    if (alreadyVisible()) return;
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!shown) {
      pause(DEFAULT_SLEEP_TIME);
      if (watch.isTimeOut()) {
        done();
        throw new WaitTimedOutError("Timed out waiting for component to be visible");
      }
    }
  }
View Full Code Here

    // Make sure the correct window is in front
    activateWindowOfFocusTarget(target, currentOwner);
    giveFocusTo(target);
    try {
      if (wait) {
        TimeoutWatch watch = startWatchWithTimeoutOf(settings().timeoutToBeVisible());
        while (!focusMonitor.hasFocus()) {
          if (watch.isTimeOut()) throw actionFailure(concat("Focus change to ", format(target), " failed"));
          pause();
        }
      }
    } finally {
      target.removeFocusListener(focusMonitor);
View Full Code Here

  // Wait the given number of milliseconds for the component to be showing and ready.
  @RunsInEDT
  private boolean waitForComponentToBeReady(Component c, long timeout) {
    if (isReadyForInput(c)) return true;
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!isReadyForInput(c)) {
      if (c instanceof JPopupMenu) {
        // wiggle the mouse over the parent menu item to ensure the sub-menu shows
        Pair<Component, Point> invokerAndCenterOfInvoker = invokerAndCenterOfInvoker((JPopupMenu)c);
        Component invoker = invokerAndCenterOfInvoker.i;
        if (invoker instanceof JMenu) jitter(invoker, invokerAndCenterOfInvoker.ii);
      }
      if (watch.isTimeOut()) return false;
      pause();
    }
    return true;
  }
View Full Code Here

  /** {@inheritDoc} */
  @RunsInEDT
  public JPopupMenu findActivePopupMenu() {
    JPopupMenu popup = activePopupMenu();
    if (popup != null || isEventDispatchThread()) return popup;
    TimeoutWatch watch = startWatchWithTimeoutOf(POPUP_TIMEOUT);
    while ((popup = activePopupMenu()) == null) {
      if (watch.isTimeOut()) break;
      pause(100);
    }
    return popup;
  }
View Full Code Here

   * @deprecated use <code>{@link ComponentDragAndDrop}</code> instead.
   */
  @RunsInEDT
  @Deprecated public void drop(Component target, Point where) {
    dragOver(target, where);
    TimeoutWatch watch = startWatchWithTimeoutOf(settings().eventPostingDelay() * 4);
    while (!robot.isDragging()) {
      if (watch.isTimeOut()) throw actionFailure("There is no drag in effect");
      pause();
    }
    int dropDelay = settings().dropDelay();
    int delayBetweenEvents = delayBetweenEvents();
    if (dropDelay > delayBetweenEvents) pause(dropDelay - delayBetweenEvents);
View Full Code Here

   * @throws NullPointerException if the given condition is <code>null</code>.
   * @throws WaitTimedOutError if the wait times out.
   */
  public static void pause(Condition condition, long timeout) {
    if (condition == null) throw new NullPointerException("The condition to verify should not be null");
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!condition.test()) {
      if (watch.isTimeOut() && !condition.test()) {
        condition.done();
        throw timeoutExpired(condition);
      }
      pause(SLEEP_INTERVAL);
    }
View Full Code Here

   * @throws NullPointerException if the array of conditions has one or more <code>null</code> values.
   * @throws WaitTimedOutError if the wait times out.
   */
  public static void pause(Condition[] conditions, long timeout) {
    validate(conditions);
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!areSatisfied(conditions)) {
      if (watch.isTimeOut()) {
        done(conditions);
        throw timeoutExpired(conditions);
      }
      pause(SLEEP_INTERVAL);
    }
View Full Code Here

   * @throws ActionFailedException if there is no drag action in effect.
   */
  @RunsInEDT
  public void drop(Component target, Point where) {
    dragOver(target, where);
    TimeoutWatch watch = startWatchWithTimeoutOf(settings().eventPostingDelay() * 4);
    while (!robot.isDragging()) {
      if (watch.isTimeOut()) throw actionFailure("There is no drag in effect");
      pause();
    }
    int dropDelay = settings().dropDelay();
    int delayBetweenEvents = delayBetweenEvents();
    if (dropDelay > delayBetweenEvents) pause(dropDelay - delayBetweenEvents);
View Full Code Here

TOP

Related Classes of org.fest.swing.util.TimeoutWatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.