/** * get a JDialogOperator object if it is open * * @param title * the Dialog title * @param secondsToWait * how many seconds to wait for the dialog to appear * @return */ public JDialogOperator getDialogIfExists(String title, int secondsToWait) { DialogWaiter waiter = new DialogWaiter(); waiter.getTimeouts().setTimeout("DialogWaiter.WaitDialogTimeout", secondsToWait * 1000); JDialogOperator dialog; try { waiter.waitDialog(new ComponentChooserHelper(title)); dialog = new JDialogOperator(new ComponentChooserHelper(title)); } catch (Exception e) { return null; } return dialog; }
/** * Closes all opened dialogs. */ public static void closeAllDialogs() { javax.swing.JDialog dialog; org.netbeans.jemmy.ComponentChooser chooser = new org.netbeans.jemmy.ComponentChooser() { @Override public boolean checkComponent(Component comp) { return (comp instanceof javax.swing.JDialog && comp.isShowing()); } @Override public String getDescription() { return ("Dialog"); } }; while ((dialog = (javax.swing.JDialog) org.netbeans.jemmy.DialogWaiter.getDialog(chooser)) != null) { closeDialogs(findBottomDialog(dialog, chooser), chooser); } }
private static Dialog waitJFileChooserDialog(final WindowOperator parent) { try { final DialogWaiter waiter = new DialogWaiter(); waiter.setTimeouts(parent.getTimeouts()); waiter.setOutput(parent.getOutput()); return waiter.waitDialog( (Window) parent.getSource(), new JFileChooserJDialogFinder(parent.getOutput())); } catch (InterruptedException ex) { parent.getOutput().printStackTrace(ex); return(null); } } }
/** * Closes all opened dialogs. */ public static void closeAllDialogs() { javax.swing.JDialog dialog; org.netbeans.jemmy.ComponentChooser chooser = new org.netbeans.jemmy.ComponentChooser() { @Override public boolean checkComponent(Component comp) { return (comp instanceof javax.swing.JDialog && comp.isShowing()); } @Override public String getDescription() { return ("Dialog"); } }; while ((dialog = (javax.swing.JDialog) org.netbeans.jemmy.DialogWaiter.getDialog(chooser)) != null) { closeDialogs(findBottomDialog(dialog, chooser), chooser); } }