Package org.netbeans.jemmy

Examples of org.netbeans.jemmy.Waiter


    public Component waitSubComponent(final ComponentChooser chooser, final int index) {
        getOutput().printLine("Waiting for \"" + chooser.getDescription() +
                              "\" subcomponent");
        final ComponentSearcher searcher = new ComponentSearcher((Container)getSource());
        searcher.setOutput(getOutput().createErrorOutput());
  Waiter waiter = new Waiter(new Waitable() {
    public Object actionProduced(Object obj) {
                    return(searcher.findComponent(chooser, index));
    }
    public String getDescription() {
        return("Wait for \"" + chooser.getDescription() +
         "\" subcomponent to be displayed");
    }
      });
        waiter.setTimeouts(getTimeouts().cloneThis());
  waiter.getTimeouts().setTimeout("Waiter.WaitingTime",
          getTimeouts().
          getTimeout("ComponentOperator.WaitComponentTimeout"));
        waiter.setOutput(getOutput());
  try {
      return((Component)waiter.waitAction(null));
  } catch (InterruptedException e) {
      throw(new JemmyException("Waiting for \"" + chooser.getDescription() +
             "\" component has been interrupted", e));
  }
    }
View Full Code Here


    //End of mapping                                      //
    ////////////////////////////////////////////////////////

    private void waitPainted(int index) {
  Waiter drawingWaiter = new Waiter(new Waitable() {
    public Object actionProduced(Object param) {
        JList list = getFileList();
        int last_one = list.getModel().getSize() - 1;
        if(last_one == -1) {
      return("");
        }
        int current = (param != null) ? ((Integer)param).intValue() : 0;
                    try {
                        if(list.getCellBounds(current, current) != null) {
                            return(list.getCellBounds(last_one, last_one));
                        } else {
                            return(null);
                        }
                    } catch(NullPointerException e) {
                        //sometimes thrown from list.getCellBounds when item exists but not painted
                        return(null);
                    }
    }
    public String getDescription() {
        return("List drawed");
    }
      });
  drawingWaiter.setTimeouts(getTimeouts().cloneThis());
  drawingWaiter.
      getTimeouts().
      setTimeout("Waiter.WaitingTime",
           getTimeouts().
           getTimeout("JFileChooserOperator.WaitListPaintedTimeout"));
  drawingWaiter.setOutput(getOutput().createErrorOutput());
  try {
      drawingWaiter.waitAction((index != -1) ? new Integer(index) : null);
  } catch(InterruptedException e) {
      output.printStackTrace(e);
  }
    }
View Full Code Here

           }
       }, index));
    }

    private int findFileIndex(final String file, final StringComparator comparator) {
        Waiter fileWaiter = new Waiter(new Waitable() {
                public Object actionProduced(Object obj) {
                    File[] files = getFiles();
                    for(int i = 0; i < files.length; i++) {
                        if(comparator.equals(files[i].getName(),
                                             file)) {
                            return(new Integer(i));
                        }
                    }
                    return(null);
                }
                public String getDescription() {
                    return("\"" + file + "\" file to be displayed");
                }
            });
        fileWaiter.setOutput(getOutput().createErrorOutput());
        fileWaiter.setTimeouts(getTimeouts().cloneThis());
        fileWaiter.getTimeouts().setTimeout("Waiter.WaitingTime",
                                            getTimeouts().
                                            getTimeout("JFileChooserOperator.WaitListPaintedTimeout"));
        try {
            return(((Integer)fileWaiter.waitAction(null)).intValue());
        } catch(InterruptedException e) {
            throw(new JemmyException("Waiting has been interrupted!"));
        }
    }
View Full Code Here

        }
        return(result);
    }

    private JMenuItem runAction(final OneReleaseAction action, ComponentOperator env, long waitingTime, final String description) {
        Waiter waiter = new Waiter(new Waitable() {
                public Object actionProduced(Object param) {
                    return(queueTool.invokeSmoothly(action));
                }
                public String getDescription() {
                    return(description);
                }
            });
        waiter.setOutput(env.getOutput().createErrorOutput());
        waiter.setTimeouts(env.getTimeouts().cloneThis());
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime",
                                        waitingTime);
        waiter.getTimeouts().setTimeout("Waiter.TimeDelta", 100);
        //1.5 workaround
        if(System.getProperty("java.specification.version").compareTo("1.4") > 0) {
            queueTool.setOutput(env.getOutput().createErrorOutput());
            queueTool.waitEmpty(10);
            queueTool.waitEmpty(10);
            queueTool.waitEmpty(10);
        }
        //end of 1.5 workaround
        try {
            return((JMenuItem)waiter.waitAction(null));
        } catch(InterruptedException e) {
            action.stop();
            throw(new JemmyException("Waiting has been interrupted", e));
        }
    }
View Full Code Here

                }
            }).getSource());
    }

    protected JMenuItem waitItem(ComponentOperator oper, MenuElement element, PathChooser chooser, int depth) {
  Waiter waiter = new Waiter(new JMenuItemWaiter(element, chooser, depth));
  waiter.setOutput(oper.getOutput().createErrorOutput());
  waiter.setTimeouts(oper.getTimeouts());
  try {
      return((JMenuItem)waiter.waitAction(null));
  } catch(InterruptedException e) {
      throw(new JemmyException("Waiting has been interrupted", e));
  }
    }
View Full Code Here

  output.printLine("Wait \"" + chooser.getDescription() +
       "\" value in progressbar\n    : " +
       toStringSource());
  output.printGolden("Wait \"" + chooser.getDescription() +
       "\" value in progressbar");
  Waiter wt = new Waiter(new Waitable() {
    public Object actionProduced(Object obj) {
        return(chooser.checkValue(((JProgressBar)getSource()).getValue()) ?
         "" : null);
    }
    public String getDescription() {
        return("\"" + chooser.getDescription() + "\" value");
    }
      });
  wt.setTimeoutsToCloneOf(timeouts, "JProgressBarOperator.WaitValueTimeout");
  wt.setOutput(output.createErrorOutput());
  try {
      wt.waitAction(null);
  } catch (InterruptedException e) {
      throw(new JemmyException("Exception during progressbar value waiting", e));
  }
    }
View Full Code Here

    public Component waitSubComponent(final ComponentChooser chooser, final int index) {
        getOutput().printLine("Waiting for \"" + chooser.getDescription() +
                              "\" subcomponent");
        final ComponentSearcher searcher = new ComponentSearcher((Container)getSource());
        searcher.setOutput(getOutput().createErrorOutput());
  Waiter waiter = new Waiter(new Waitable() {
    public Object actionProduced(Object obj) {
                    return(searcher.findComponent(chooser, index));
    }
    public String getDescription() {
        return("Wait for \"" + chooser.getDescription() +
         "\" subcomponent to be displayed");
    }
      });
  waiter.setTimeoutsToCloneOf(getTimeouts(), "ComponentOperator.WaitComponentTimeout");
        waiter.setOutput(getOutput());
  try {
      return((Component)waiter.waitAction(null));
  } catch (InterruptedException e) {
      throw(new JemmyException("Waiting for \"" + chooser.getDescription() +
             "\" component has been interrupted", e));
  }
    }
View Full Code Here

TOP

Related Classes of org.netbeans.jemmy.Waiter

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.