org.netbeans.jemmy.Waiter Java Examples

The following examples show how to use org.netbeans.jemmy.Waiter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProgressSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process started.
 */
public static void waitStarted(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? Boolean.TRUE : null;
            }
            public String getDescription() {
                return("Wait process "+name+" is started.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    
}
 
Example #2
Source File: GeneralKnockout.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected Object[] getAnnotations(EditorOperator eOp, int limit) {
    eOp.makeComponentVisible();
    evt.waitNoEvent(1000);
    try {
        final EditorOperator eo = new EditorOperator(eOp.getName());
        final int _limit = limit;
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object oper) {
                return eo.getAnnotations().length > _limit ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return ("Wait parser annotations."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    Object[] anns = eOp.getAnnotations();
    return anns;
}
 
Example #3
Source File: GeneralRequire.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected Object[] getAnnotations(EditorOperator eOp, int limit) {
    eOp.makeComponentVisible();
    evt.waitNoEvent(1000);
    try {
        final EditorOperator eo = new EditorOperator(eOp.getName());
        final int _limit = limit;
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object oper) {
                return eo.getAnnotations().length > _limit ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return ("Wait parser annotations."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    Object[] anns = eOp.getAnnotations();
    return anns;
}
 
Example #4
Source File: GeneralAngular.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected Object[] getAnnotations(EditorOperator eOp, int limit) {
    eOp.makeComponentVisible();
    evt.waitNoEvent(1000);
    try {
        final EditorOperator eo = new EditorOperator(eOp.getName());
        final int _limit = limit;
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object oper) {
                return eo.getAnnotations().length > _limit ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return ("Wait parser annotations."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    Object[] anns = eOp.getAnnotations();
    return anns;
}
 
Example #5
Source File: GeneralNodeJs.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected Object[] getAnnotations(EditorOperator eOp, int limit) {
    eOp.makeComponentVisible();
    evt.waitNoEvent(1000);
    try {
        final EditorOperator eo = new EditorOperator(eOp.getName());
        final int _limit = limit;
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object oper) {
                return eo.getAnnotations().length > _limit ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return ("Wait parser annotations."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    Object[] anns = eOp.getAnnotations();
    return anns;
}
 
Example #6
Source File: SaveAllAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Waits until SaveAllAction is finished.
 */
private void waitFinished() {
    try {
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object systemAction) {
                return DataObject.getRegistry().getModifiedSet().isEmpty() ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return "SaveAllAction is finished";
            }
        }).waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Waiting interrupted.", e);
    }
}
 
Example #7
Source File: Property.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Waits for property with given name in specified property sheet.
 * @param propSheetOper PropertySheetOperator where to find property.
 * @param name property display name
 */
private Node.Property waitProperty(final PropertySheetOperator propSheetOper, final String name) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object param) {
                Node.Property property = null;
                JTableOperator table = propSheetOper.tblSheet();
                for(int row=0;row<table.getRowCount();row++) {
                    if(table.getValueAt(row, 1) instanceof Node.Property) {
                        property = (Node.Property)table.getValueAt(row, 1);
                        if(propSheetOper.getComparator().equals(property.getDisplayName(), name)) {
                            return property;
                        }
                    }
                }
                return null;
            }
            public String getDescription() {
                return("Wait property "+name);
            }
        });
        return (Node.Property)waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
}
 
Example #8
Source File: ComponentOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits for this Component has the keyboard focus.
 *
 * @throws TimeoutExpiredException
 */
public void waitHasFocus() {
    Waiter<String, Void> focusWaiter = new Waiter<>(new Waitable<String, Void>() {
        @Override
        public String actionProduced(Void obj) {
            return hasFocus() ? "" : null;
        }

        @Override
        public String getDescription() {
            return "Wait component has focus";
        }

        @Override
        public String toString() {
            return "ComponentOperator.waitHasFocus.Waitable{description = " + getDescription() + '}';
        }
    });
    focusWaiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitFocusTimeout");
    focusWaiter.setOutput(output.createErrorOutput());
    try {
        focusWaiter.waitAction(null);
    } catch (InterruptedException e) {
        output.printStackTrace(e);
    }
}
 
Example #9
Source File: PropertySheetOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Waits for property sheet anywhere in IDE. First it tries to find TopComponent
 * representing global properties and if not found, it tries to find 
 * property sheet in all dialogs owned by Main Window or other frames.
 * @param sheetName name of property sheet
 * @param index index of property sheet 
 */
private static JComponent waitPropertySheet(final String sheetName, final int index) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object obj) {
                return findPropertySheet(sheetName, index);
            }
            public String getDescription() {
                return("Wait PropertySheet with name="+sheetName+
                       " index="+index+" loaded");
            }
        });
        Timeouts times = JemmyProperties.getCurrentTimeouts().cloneThis();
        times.setTimeout("Waiter.WaitingTime", times.getTimeout("ComponentOperator.WaitComponentTimeout"));
        waiter.setTimeouts(times);
        waiter.setOutput(JemmyProperties.getCurrentOutput());
        return (JComponent)waiter.waitAction(null);
    } catch(InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
}
 
Example #10
Source File: WidgetOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Waits for index-th widget specified by WidgetChooser under given parent
 * widget.
 *
 * @param parentWidget parent Widget
 * @param widgetChooser WidgetChooser implementation
 * @param index index to be found
 * @return Widget instance if found or throws JemmyException if not found.
 */
private static Widget waitWidget(final Widget parentWidget, final WidgetChooser widgetChooser, final int index) {
    try {
        Waiter waiter = new Waiter(new Waitable() {

            @Override
            public Object actionProduced(Object obj) {
                return findWidget(parentWidget, widgetChooser, index);
            }

            @Override
            public String getDescription() {
                return (index > 0 ? index + "-th " : "")
                        + (widgetChooser == null ? "Widget " : widgetChooser.getDescription())
                        + " displayed";
            }
        });
        Timeouts timeouts = JemmyProperties.getCurrentTimeouts().cloneThis();
        timeouts.setTimeout("Waiter.WaitingTime", timeouts.getTimeout("WidgetOperator.WaitWidgetTimeout"));
        waiter.setTimeouts(timeouts);
        waiter.setOutput(JemmyProperties.getCurrentOutput());
        return (Widget) waiter.waitAction(null);
    } catch (InterruptedException ex) {
        throw new JemmyException("Interrupted.", ex);
    }
}
 
Example #11
Source File: OutputOperatorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait until clipboard contains string data and returns the text. */
private String getClipboardText() throws Exception {
    Waiter waiter = new Waiter(new Waitable() {

        @Override
        public Object actionProduced(Object obj) {
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            if (contents == null) {
                return null;
            } else {
                return contents.isDataFlavorSupported(DataFlavor.stringFlavor) ? Boolean.TRUE : null;
            }
        }

        @Override
        public String getDescription() {
            return ("Wait clipboard contains string data");
        }
    });
    waiter.waitAction(null);
    return Toolkit.getDefaultToolkit().getSystemClipboard().
            getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
}
 
Example #12
Source File: OutputTabOperatorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait until clipboard contains string data and returns the text. */
private String getClipboardText() throws Exception {
    Waiter waiter = new Waiter(new Waitable() {

        @Override
        public Object actionProduced(Object obj) {
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            if (contents == null) {
                return null;
            } else {
                return contents.isDataFlavorSupported(DataFlavor.stringFlavor) ? Boolean.TRUE : null;
            }
        }

        @Override
        public String getDescription() {
            return ("Wait clipboard contains string data");
        }
    });
    waiter.waitAction(null);
    return Toolkit.getDefaultToolkit().getSystemClipboard().
            getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
}
 
Example #13
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void setCaret(EditorOperator eo, final int line) {
    eo.makeComponentVisible();
    eo.setCaretPositionToLine(line);
    new EventTool().waitNoEvent(100);

    try {
        new Waiter(new Waitable() {

            public Object actionProduced(Object editorOper) {
                EditorOperator op = (EditorOperator) editorOper;
                if (op.getLineNumber() == line) {
                    return Boolean.TRUE;
                }
                return null;
            }

            public String getDescription() {
                return "Wait caret position on line " + line;
            }
        }).waitAction(eo);
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
}
 
Example #14
Source File: GeneralJSF.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected Object[] getAnnotations(EditorOperator eOp, int limit) {
    eOp.makeComponentVisible();
    evt.waitNoEvent(1000);
    try {
        final EditorOperator eo = new EditorOperator(eOp.getName());
        final int _limit = limit;
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object oper) {
                return eo.getAnnotations().length > _limit ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return ("Wait parser annotations."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    Object[] anns = eOp.getAnnotations();
    return anns;
}
 
Example #15
Source File: MeasureEntityBeanActionTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize() {
    // open a java file in the editor
    beanNode = new Node(new ProjectsTabOperator().getProjectRootNode("TestApplication-ejb"), "Enterprise Beans|TestEntityEB");
    final ActionNoBlock action = new ActionNoBlock(null, popup_menu);
    try {
        new Waiter(new Waitable() {

            @Override
            public Object actionProduced(Object param) {
                return action.isEnabled(beanNode) ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return "wait menu is enabled";
            }
        }).waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    new OpenAction().performAPI(beanNode);
    editor = new EditorOperator("TestEntityBean.java");
}
 
Example #16
Source File: ProfilerValidationTest.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until profiler is not stopped.
 */
private void waitProfilerStopped() {
    try {
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object object) {
                final int state = Profiler.getDefault().getProfilingState();
                final int mode = Profiler.getDefault().getProfilingMode();
                if ((state == Profiler.PROFILING_PAUSED) || (state == Profiler.PROFILING_RUNNING)) {
                    if (mode == Profiler.MODE_PROFILE) {
                        return null;
                    }
                }
                return Boolean.TRUE;
            }

            @Override
            public String getDescription() {
                return ("Wait profiler stopped."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        throw new JemmyException("Waiting for profiler stopped failed.", ex);
    }
}
 
Example #17
Source File: ProgressSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process with given name finished.
 */
public static void waitFinished(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? null : Boolean.TRUE;
            }
            public String getDescription() {
                return("Wait process "+name+" is finished.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    
}
 
Example #18
Source File: AbstractJ2eeFile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected boolean srcFileExist(String name) {
    boolean retVal = false;
    File f = new File(FileUtil.toFile(prjRoot), srcRoot);
    try {
        final File ff = new File(f, name);
        //System.err.println(ff.getAbsolutePath());
        //System.err.println("srcEx: " + ff.exists());
        Waiter waiter = new Waiter(new Waitable() {

            @Override
            public Object actionProduced(Object anObject) {
                return ff.exists() ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return "file " + ff + " exists";
            }
        });
        waiter.waitAction(null);
        retVal = ff.exists();
    } catch (Exception e) {
    }
    return retVal;
}
 
Example #19
Source File: ProgressOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process started.
 */
public static void waitStarted(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? Boolean.TRUE : null;
            }
            public String getDescription() {
                return("Wait process "+name+" is started.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }

}
 
Example #20
Source File: ProgressOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process with given name finished.
 */
public static void waitFinished(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? null : Boolean.TRUE;
            }
            public String getDescription() {
                return("Wait process "+name+" is finished.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }

}
 
Example #21
Source File: GeneralJSP.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected Object[] getAnnotations(EditorOperator eOp, int limit) {
    eOp.makeComponentVisible();
    evt.waitNoEvent(1000);
    try {
        final EditorOperator eo = new EditorOperator(eOp.getName());
        final int _limit = limit;
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object oper) {
                return eo.getAnnotations().length > _limit ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return ("Wait parser annotations."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    Object[] anns = eOp.getAnnotations();
    return anns;
}
 
Example #22
Source File: WsValidation.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void waitForTextInEditor(final EditorOperator eo, final String text) {
    try {
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object obj) {
                return eo.contains(text) ? Boolean.TRUE : null; //NOI18N
            }

            @Override
            public String getDescription() {
                return ("Editor contains " + text); //NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ie) {
        throw new JemmyException("Interrupted.", ie); //NOI18N
    }
}
 
Example #23
Source File: PatternsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private File getFileFromProject(String fileName) {
    final FileObject fo = getProjectSourceRoot();
    final String location = getRestPackage().replace('.', '/') + "/" + fileName + ".java"; //NOI18N
    try {
        FileObject file = (FileObject) new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object obj) {
                return fo.getFileObject(location);
            }

            @Override
            public String getDescription() {
                return FileUtil.toFile(fo).getAbsolutePath() + File.separator + location + " exists"; //NOI18N
            }
        }).waitAction(null);
        return FileUtil.toFile(file);
    } catch (InterruptedException ie) {
        throw new JemmyException("Interrupted.", ie); //NOI18N
    }
}
 
Example #24
Source File: RestTestBase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Waits for defined number of children under RESTful Web Services node. It
 * throws TimeoutExpiredException if timeout passes.
 */
protected void waitRestNodeChildren(final int count) {
    final Node restNode = getRestNode();
    try {
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object obj) {
                return restNode.getChildren().length == count ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return count + " children under " + restNode.getText(); //NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ie) {
        throw new JemmyException("Interrupted.", ie); //NOI18N
    }
}
 
Example #25
Source File: EditorOperatorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Test of getAnnotations method. Expects bookmark 
 * created in test testGetToolbarButton() and parser annotations on 
 * inserted lines (testInsert).
 * @throws java.lang.InterruptedException
 */
public void testGetAnnotations() throws InterruptedException {
    // wait parser annotations
    new Waiter(new Waitable() {

        @Override
        public Object actionProduced(Object oper) {
            return eo.getAnnotations().length > 1 ? Boolean.TRUE : null;
        }

        @Override
        public String getDescription() {
            return ("Wait parser annotations."); // NOI18N
        }
    }).waitAction(null);
}
 
Example #26
Source File: ProgressOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process started.
 */
public static void waitStarted(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? Boolean.TRUE : null;
            }
            public String getDescription() {
                return("Wait process "+name+" is started.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    
}
 
Example #27
Source File: ProgressOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process with given name finished.
 */
public static void waitFinished(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? null : Boolean.TRUE;
            }
            public String getDescription() {
                return("Wait process "+name+" is finished.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    
}
 
Example #28
Source File: GeneralCSSPrep.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected Object[] getAnnotations(EditorOperator eOp, int limit) {
    eOp.makeComponentVisible();
    try {
        final EditorOperator eo = new EditorOperator(eOp.getName());
        final int _limit = limit;
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object oper) {
                return eo.getAnnotations().length > _limit ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return ("Wait parser annotations."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    Object[] anns = eOp.getAnnotations();
    return anns;
}
 
Example #29
Source File: NodeUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Test cut */
public static void testClipboard(final Object clipboard1) {        
    Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object obj) {
                Object clipboard2 = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
                return clipboard1 != clipboard2 ? Boolean.TRUE : null;
            }
            public String getDescription() {
                return("Wait clipboard contains data"); // NOI18N
            }
    });
    try {
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Waiting interrupted.", e);
    }
}
 
Example #30
Source File: NewProjectWizardOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Selects given project category
 * @param category name of the category to select
 */
public void selectCategory(String category) {
    // we need to wait until some node is selected because 'please, wait' node
    // is shown before tree is initialized. Then we can change selection.
    try {
        new Waiter(new Waitable() {

            @Override
            public Object actionProduced(Object param) {
                return treeCategories().isSelectionEmpty() ? null : Boolean.TRUE;
            }

            @Override
            public String getDescription() {
                return ("Wait node is selected");
            }
        }).waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    } catch (TimeoutExpiredException tee) {
        // ignore it because sometimes can happen that no category is selected by default
    }
    new Node(treeCategories(), category).select();
}