org.netbeans.jemmy.ComponentChooser Java Examples
The following examples show how to use
org.netbeans.jemmy.ComponentChooser.
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: DefaultJMenuDriver.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
protected JPopupMenu waitPopupMenu(final ComponentOperator oper) { return ((JPopupMenu) JPopupMenuOperator.waitJPopupMenu(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return (comp == ((JMenuOperator) oper).getPopupMenu() && comp.isShowing()); } @Override public String getDescription() { return ((JMenuOperator) oper).getText() + "'s popup"; } @Override public String toString() { return "waitPopupMenu.ComponentChooser{description = " + getDescription() + '}'; } }).getSource()); }
Example #2
Source File: JFileChooserOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns file list. * * @return a list being used to display directory content. */ public JList<?> getFileList() { return ((JList) innerSearcher. findComponent(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return (comp != null && comp instanceof JList); } @Override public String getDescription() { return "JList"; } @Override public String toString() { return "JFileChooserOperator.getFileList.ComponentChooser{description = " + getDescription() + '}'; } })); }
Example #3
Source File: JTreeOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Waits row to be collapsed. * * @param row a row index to wait collapsed. */ public void waitCollapsed(final int row) { getOutput().printLine("Wait " + Integer.toString(row) + "'th row to be collapsed in component \n : " + toStringSource()); getOutput().printGolden("Wait " + Integer.toString(row) + "'th row to be collapsed"); waitState(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return isCollapsed(row); } @Override public String getDescription() { return "Has " + Integer.toString(row) + "'th row collapsed"; } @Override public String toString() { return "JTreeOperator.waitCollapsed.ComponentChooser{description = " + getDescription() + '}'; } }); }
Example #4
Source File: Utilities.java From netbeans with Apache License 2.0 | 6 votes |
public static ArrayList<Component> findComponentsInContainer(Container cont, ComponentChooser chooser, boolean recursive) { Component[] components = cont.getComponents(); ArrayList<Component> results = new ArrayList<Component>(); for (int i = 0; i < components.length; i++) { if (components[i] != null) { if (chooser.checkComponent(components[i])) { results.add(components[i]); //System.out.println("Added :"+components[i].toString()); } if (recursive && components[i] instanceof Container) { ArrayList<Component> aa = findComponentsInContainer((Container) components[i], chooser, recursive); //System.out.println("adding all " + aa); results.addAll(aa); } } } return results; }
Example #5
Source File: JTreeOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Waits path to be expanded. * * @param path a path to wait expanded. */ public void waitExpanded(final TreePath path) { if (path != null) { getOutput().printLine("Wait \"" + path.toString() + "\" path to be expanded in component \n : " + toStringSource()); getOutput().printGolden("Wait \"" + path.toString() + "\" path to be expanded"); waitState(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return isExpanded(path); } @Override public String getDescription() { return "Has \"" + path.toString() + "\" path expanded"; } @Override public String toString() { return "JTreeOperator.waitExpanded.ComponentChooser{description = " + getDescription() + '}'; } }); } else { throw (new NoSuchPathException()); } }
Example #6
Source File: SearchInOptionsTest.java From netbeans with Apache License 2.0 | 6 votes |
private JLabelOperator getJLabelOperator(final String category) { return new JLabelOperator(optionsOperator, new ComponentChooser() { @Override public boolean checkComponent(Component comp) { if (comp.getClass().getName().equals("org.netbeans.modules.options.OptionsPanel$CategoryButton") ||// NOI18N comp.getClass().getName().equals("org.netbeans.modules.options.OptionsPanel$NimbusCategoryButton")) { // NOI18N if (((JLabel) comp).getText() != null) { return stringComparator.equals(((JLabel) comp).getText(), category); } } return false; } @Override public String getDescription() { return "OptionsPanel$CategoryButton with text " + category; // NOI18N } }); }
Example #7
Source File: JTabbedPaneOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Wait for a page to exist. * * @param chooser page searching criteria * @return a page index. */ public int waitPage(final TabPageChooser chooser) { waitState(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return findPage(chooser) > -1; } @Override public String getDescription() { return "Tabbed with " + chooser.getDescription() + " page."; } @Override public String toString() { return "JTabbedPaneOperator.waitPage.Action{description = " + getDescription() + '}'; } }); return findPage(chooser); }
Example #8
Source File: TopComponentOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** If subchooser is null, return TopComponent. * Else if c is instance of MultiViewCloneableTopComponent try to find * and return sub component in MVCTC corresponding to sub chooser. Else * check TC in sub chooser and return it if matches. MVCTC can host * several views, e.g. source and design view in form editor or xml, servlets, * overview views in web.xml editor. Then EditorOperator is able to find * appropriate CloneableEditor in MVCTC. * @param c TopComponent to check * @param subchooser ComponentChooser to check if matches * @return given TopComponent or appropriate sub component */ private static JComponent checkSubchooser(TopComponent c, ComponentChooser subchooser) { if (subchooser == null) { return c; } else { boolean isMultiView = false; try { //isMultiView = c instanceof MultiViewCloneableTopComponent; isMultiView = isMultyView(c); } catch (Throwable t) { // ignore possible NoClassDefFoundError because org.netbeans.core.multiview module is not enabled in IDE } if (isMultiView) { TopComponentOperator tco = new TopComponentOperator((JComponent) c); // suppress output when finding sub component tco.setOutput(TestOut.getNullOutput()); return (JComponent) tco.findSubComponent(subchooser); } else { if (subchooser.checkComponent(c)) { return c; } } } return null; }
Example #9
Source File: OutputTabOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** Waits for text to be displayed in this output tab. * @param text text to wait for */ public void waitText(final String text) { getOutput().printLine("Wait \"" + text + "\" text in component \n : " + toStringSource()); getOutput().printGolden("Wait \"" + text + "\" text"); waitState(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return (findLine(text) > -1); } @Override public String getDescription() { return ("\"" + text + "\" text"); } }); }
Example #10
Source File: FrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Waits for the frame to have a specified state. * * @param state a state for the frame to have. */ public void waitState(final int state) { getOutput().printLine("Wait frame to have " + Integer.toString(state) + " state \n : " + toStringSource()); getOutput().printGolden("Wait frame to have " + Integer.toString(state) + " state"); waitState(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return ((Frame) comp).getExtendedState() == state; } @Override public String getDescription() { return Integer.toString(state) + " state"; } @Override public String toString() { return "FrameOperator.waitState.ComponentChooser{description = " + getDescription() + '}'; } }); }
Example #11
Source File: WidgetOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** * Returns Scene widget which is parent of all other widgets. It throws * JemmyException when Scene is not found. * * @param tco TopComponentOperator where to find Scene * @return Scene instance */ private static Scene waitScene(TopComponentOperator tco) { Component sceneComp = tco.waitSubComponent(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return comp.getClass().getName().endsWith("SceneComponent"); } @Override public String getDescription() { return "SceneComponent"; } }); try { Field[] fields = sceneComp.getClass().getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field field = fields[i]; Class<?> type = field.getType(); if (Scene.class.isAssignableFrom(type)) { field.setAccessible(true); return (Scene) field.get(sceneComp); } } } catch (Exception ex) { throw new JemmyException("Exception while getting Scene field from " + sceneComp, ex); } throw new JemmyException("Scene field not found in " + sceneComp); }
Example #12
Source File: JComponentOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Looks for a first window-like container. * * @return either WindowOperator of JInternalFrameOperator */ public ContainerOperator<?> getWindowContainerOperator() { Component resultComp; if (getSource() instanceof Window) { resultComp = getSource(); } else { resultComp = getContainer(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return (comp instanceof Window || comp instanceof JInternalFrame); } @Override public String getDescription() { return ""; } }); } ContainerOperator<?> result; if (resultComp instanceof Window) { result = new WindowOperator((Window) resultComp); } else { result = new ContainerOperator<>((Container) resultComp); } result.copyEnvironment(this); return result; }
Example #13
Source File: JellyTestCase.java From netbeans with Apache License 2.0 | 5 votes |
private static void closeDialogs(JDialog dialog, ComponentChooser chooser) { Window[] ownees = dialog.getOwnedWindows(); for (int i = 0; i < ownees.length; i++) { if (chooser.checkComponent(ownees[i])) { closeDialogs((JDialog) ownees[i], chooser); } } new JDialogOperator(dialog).requestClose(); }
Example #14
Source File: JFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a JFrameOperator object. * * @param chooser a component chooser specifying searching criteria. * @param index an index between appropriate ones. * @param env an operator to copy environment from. */ public JFrameOperator(ComponentChooser chooser, int index, Operator env) { this((JFrame) waitFrame(new JFrameFinder(chooser), index, env.getTimeouts(), env.getOutput())); copyEnvironment(env); }
Example #15
Source File: TreeTableOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns operator for a tree which is showed as a part of * the table. * @return JTreeOperator instance */ public JTreeOperator tree() { if(_tree == null) { // Need to wait until TreeTable is populated. Otherwise it can throw // NPE from getValueAt(0, 0). waitState(new ComponentChooser() { public boolean checkComponent(Component comp) { return getColumnCount() > 0 && getRowCount() > 0; } public String getDescription() { return "TreeTable contains any rows."; } }); // cell renderer component for first column is JTree Object value = getValueAt(0, 0); JTree jTree = (JTree)getCellRenderer(0, 0).getTableCellRendererComponent((JTable)this.getSource(), value, false, false, 0, 0); // Need to set EmptyVisualizer because found JTree doesn't have any parent Container // and calling makeComponentVisible() throws NPE // _tree = new JTreeOperator(jTree); _tree = new RenderedTreeOperator(this, jTree); _tree.setVisualizer(new EmptyVisualizer()); } // Everytime make parent container visible because tree has EmptyVisualizer // and it is need for example for popup menu operations on JTree makeComponentVisible(); return _tree; }
Example #16
Source File: JPopupMenuOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public JMenuItemOperator[] showMenuItems(ComponentChooser[] choosers) { if (choosers == null || choosers.length == 0) { return JMenuItemOperator.getMenuItems((MenuElement) getSource(), this); } else { return JMenuItemOperator.getMenuItems((JMenu) pushMenu(choosers), this); } }
Example #17
Source File: DialogOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a DialogOperator object. * * @param chooser a component chooser specifying searching criteria. * @param index an index between appropriate ones. * @param env an operator to copy environment from. */ public DialogOperator(ComponentChooser chooser, int index, Operator env) { this(waitDialog(new DialogFinder(chooser), index, env.getTimeouts(), env.getOutput())); copyEnvironment(env); }
Example #18
Source File: PluginsOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Waits until specified tab is enabled. * @param tabName name of tab */ public void waitTabEnabled(final String tabName) { final int installedIndex = tabbedPane().waitPage(tabName); tabbedPane().waitState(new ComponentChooser() { public boolean checkComponent(Component comp) { return tabbedPane().isEnabledAt(installedIndex); } public String getDescription() { return "page " + tabName + " enabled";// NOI18N } }); }
Example #19
Source File: JMenuItemOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static ComponentChooser[] createChoosers(String[] names, StringComparator comparator) { ComponentChooser[] choosers = new ComponentChooser[names.length]; for (int i = 0; i < choosers.length; i++) { choosers[i] = new JMenuItemOperator.JMenuItemByLabelFinder(names[i], comparator); } return choosers; }
Example #20
Source File: ListDemoTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void waitModelSize(JListOperator listOp, int size) { listOp.waitState(new ComponentChooser() { public boolean checkComponent(Component comp) { return getUIValue(listOp, (JList list) -> list.getModel().getSize()) == size; } public String getDescription() { return "Model size to be equal to " + size; } }); }
Example #21
Source File: TreeDemoTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void waitRowCount(JTreeOperator tree, int count) { tree.waitState(new ComponentChooser() { public boolean checkComponent(Component comp) { return tree.getRowCount() == count; } public String getDescription() { return "A tree to have " + count + " rows"; } }); }
Example #22
Source File: JTreeOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public ByRenderedComponentTreeRowChooser(ComponentChooser chooser) { this.chooser = chooser; }
Example #23
Source File: QueueJMenuDriver.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Object pushMenu(final ComponentOperator oper, PathChooser chooser) { queueTool.setOutput(oper.getOutput().createErrorOutput()); checkSupported(oper); JMenuItem result; OneReleaseAction action; if (oper instanceof JMenuBarOperator) { action = new OneReleaseAction(chooser, 0, oper, false) { @Override protected void pushAlone(JMenuItemOperator subMenuOper) { if (subMenuOper.getSource() instanceof JMenu && isMenuBarSelected((JMenuBar) oper.getSource())) { DriverManager.getMouseDriver(subMenuOper).enterMouse(subMenuOper); } else { DriverManager.getButtonDriver(subMenuOper).push(subMenuOper); } } @Override protected boolean inTheMiddle(JMenuOperator subMenuOper, boolean mousePressed) { if (isMenuBarSelected((JMenuBar) oper.getSource())) { DriverManager.getMouseDriver(subMenuOper).enterMouse(subMenuOper); return false; } else { return super.inTheMiddle(subMenuOper, mousePressed); } } @Override protected void process(MenuElement element) { super.process(element); } @Override public MenuElement getMenuElement() { return (MenuElement) oper.getSource(); } }; } else if (oper instanceof JPopupMenuOperator) { action = new OneReleaseAction(chooser, 0, oper, false) { @Override public MenuElement getMenuElement() { return (MenuElement) oper.getSource(); } }; } else { DriverManager.getButtonDriver(oper).press(oper); action = new OneReleaseAction(chooser, 0, oper, false) { @Override public MenuElement launch() { process((MenuElement) oper.getSource()); return (MenuElement) oper.getSource(); } @Override public MenuElement getMenuElement() { return null; } }; } queueTool.waitEmpty(10); queueTool.waitEmpty(10); queueTool.waitEmpty(10); result = runAction(action, oper, oper.getTimeouts().getTimeout("ComponentOperator.WaitComponentTimeout"), (chooser instanceof DescriptablePathChooser) ? ((DescriptablePathChooser) chooser).getDescription() : "Menu pushing"); if (result instanceof JMenu) { for (int i = 1; i < chooser.getDepth(); i++) { final JMenu menu = (JMenu) result; final ComponentChooser popupChooser = new PopupMenuChooser(menu); action = new OneReleaseAction(chooser, i, oper, action.mousePressed) { @Override public MenuElement getMenuElement() { Window win = JPopupMenuOperator.findJPopupWindow(popupChooser); if (win != null && win.isShowing()) { return JPopupMenuOperator.findJPopupMenu(win, popupChooser); } else { return null; } } }; result = runAction(action, oper, oper.getTimeouts().getTimeout("JMenuOperator.WaitPopupTimeout"), (chooser instanceof DescriptablePathChooser) ? ((DescriptablePathChooser) chooser).getDescription() : "Menu pushing"); } } return result; }
Example #24
Source File: JInternalFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Initiaites suboperators. */ protected void initOperators() { iconOperator = new JDesktopIconOperator(((JInternalFrame) getSource()).getDesktopIcon()); iconOperator.copyEnvironment(this); Container titlePane = findTitlePane(); if (!isIcon() && titlePane != null) { if (titleOperator == null) { titleOperator = new ContainerOperator<>(titlePane); int bttCount = 0; if (getContainer(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { return comp instanceof JDesktopPane; } @Override public String getDescription() { return "Desctop pane"; } @Override public String toString() { return "JInternalFrameOperator.initOperators.ComponentChooser{description = " + getDescription() + '}'; } }) != null) { minOper = new JButtonOperator(titleOperator, bttCount); bttCount++; if (((JInternalFrame) getSource()).isMaximizable()) { maxOper = new JButtonOperator(titleOperator, bttCount); bttCount++; } else { maxOper = null; } } else { minOper = null; maxOper = null; } if (isClosable()) { closeOper = new JButtonOperator(titleOperator, bttCount); } else { closeOper = null; } } } else { titleOperator = null; minOper = null; maxOper = null; closeOper = null; } }
Example #25
Source File: JListOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public ByRenderedComponentListItemChooser(ComponentChooser chooser) { this.chooser = chooser; }
Example #26
Source File: ListOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Constructs a ListOperator object. * * @param cont a container * @param chooser a component chooser specifying searching criteria. * @param index an index between appropriate ones. */ public ListOperator(ContainerOperator<?> cont, ComponentChooser chooser, int index) { this((List) cont. waitSubComponent(new ListFinder(chooser), index)); copyEnvironment(cont); }
Example #27
Source File: JSpinnerOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Constructs a JSpinnerOperator object. * * @param cont a container * @param chooser a component chooser specifying searching criteria. * @param index an index between appropriate ones. * @throws TimeoutExpiredException */ public JSpinnerOperator(ContainerOperator<?> cont, ComponentChooser chooser, int index) { this((JSpinner) cont. waitSubComponent(new JSpinnerFinder(chooser), index)); copyEnvironment(cont); }
Example #28
Source File: JDialogOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Constructs a JDialogOperator object. * * @param owner window - owner * @param chooser a component chooser specifying searching criteria. * @param index an index between appropriate ones. */ public JDialogOperator(WindowOperator owner, ComponentChooser chooser, int index) { this((JDialog) owner. waitSubWindow(new JDialogFinder(chooser), index)); copyEnvironment(owner); }
Example #29
Source File: JInternalFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Constructs a JInternalFrameOperator object. * * @param cont a container * @param chooser a component chooser specifying searching criteria. * @param index an index between appropriate ones. */ public JInternalFrameOperator(ContainerOperator<?> cont, ComponentChooser chooser, int index) { this((JInternalFrame) cont. waitSubComponent(new JInternalFrameFinder(chooser), index)); copyEnvironment(cont); }
Example #30
Source File: TextFieldOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Constructs a TextFieldOperator object. * * @param cont a container * @param chooser a component chooser specifying searching criteria. * @param index an index between appropriate ones. */ public TextFieldOperator(ContainerOperator<?> cont, ComponentChooser chooser, int index) { this((TextField) cont. waitSubComponent(new TextFieldFinder(chooser), index)); copyEnvironment(cont); }