Java Code Examples for org.netbeans.jemmy.operators.JListOperator#getModel()
The following examples show how to use
org.netbeans.jemmy.operators.JListOperator#getModel() .
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: BeansTestCase.java From netbeans with Apache License 2.0 | 6 votes |
public boolean openDialog(EditorOperator operator) { operator.pressKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK); JDialogOperator jdo = new JDialogOperator(); JListOperator list = new JListOperator(jdo); ListModel lm = list.getModel(); for (int i = 0; i < lm.getSize(); i++) { CodeGenerator cg = (CodeGenerator) lm.getElementAt(i); if(cg.getDisplayName().equals("Add Property...")) { list.setSelectedIndex(i); jdo.pushKey(KeyEvent.VK_ENTER); new EventTool().waitNoEvent(250); return true; } } fail("Dialog not found"); return false; }
Example 2
Source File: GenerateCodeOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** * Opens requested code generation dialog * @param type Displayname of menu item * @param editor Operator of editor window where should be menu opened * @return true is item is found, false elsewhere */ public static boolean openDialog(String type, EditorOperator editor) { new EventTool().waitNoEvent(1000); editor.pushKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK); JDialogOperator jdo = new JDialogOperator(); new EventTool().waitNoEvent(1000); JListOperator list = new JListOperator(jdo); ListModel lm = list.getModel(); for (int i = 0; i < lm.getSize(); i++) { CodeGenerator cg = (CodeGenerator) lm.getElementAt(i); if(cg.getDisplayName().equals(type)) { list.setSelectedIndex(i); jdo.pushKey(KeyEvent.VK_ENTER); new EventTool().waitNoEvent(1000); return true; } } return false; }
Example 3
Source File: GenerateCodeOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** * Compares list of items provided in the Insert Code dialog with the list of expected items * @param editor Operator of editor window where should Insert Code should be caled * @param items Expected items * @return true if both list are the same, false otherwise */ public static boolean containsItems(EditorOperator editor, String ... items) { Set<String> actItems = new HashSet<String>(); List<String> expItems = Arrays.asList(items); editor.pushKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK); JDialogOperator jdo = new JDialogOperator(); JListOperator list = new JListOperator(jdo); ListModel lm = list.getModel(); for (int i = 0; i < lm.getSize(); i++) { CodeGenerator cg = (CodeGenerator) lm.getElementAt(i); actItems.add(cg.getDisplayName()); if(!expItems.contains(cg.getDisplayName())) return false; } for (String string : expItems) { if(!actItems.contains(string)) return false; } return true; }
Example 4
Source File: GenerateCodeOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** * Check if Insertcode popup contains requested item * @param editor Operator of editor window where should Insert Code should be caled * @param items Expected items * @return true if all requested item are pressent, to exact match use {@link #containsItems(org.netbeans.jellytools.EditorOperator, java.lang.String[]) containsItems} */ public static boolean checkItems(EditorOperator editor, String ... items) { Set<String> expItems = new HashSet<String>(Arrays.asList(items)); editor.pushKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK); JDialogOperator jdo = new JDialogOperator(); JListOperator list = new JListOperator(jdo); ListModel lm = list.getModel(); for (int i = 0; i < lm.getSize(); i++) { CodeGenerator cg = (CodeGenerator) lm.getElementAt(i); expItems.remove(cg.getDisplayName()); } if(!expItems.isEmpty()) return false; return true; }
Example 5
Source File: CodeTemplatesTest.java From netbeans with Apache License 2.0 | 5 votes |
private void invokeTemplateAsHint(EditorOperator editor, final String description) { final String blockTemplatePrefix = "<html>Surround with "; new EventTool().waitNoEvent(500); editor.pressKey(KeyEvent.VK_ENTER, KeyEvent.ALT_DOWN_MASK); new EventTool().waitNoEvent(500); JListOperator jlo = new JListOperator(MainWindowOperator.getDefault()); ListModel model = jlo.getModel(); int i; for (i = 0; i < model.getSize(); i++) { Object item = model.getElementAt(i); String hint = "n/a"; if (item instanceof SurroundWithFix) { hint = ((SurroundWithFix) item).getText(); } if (hint.startsWith(blockTemplatePrefix + description)) { System.out.println("Found at "+i+" position: "+hint); break; } } if (i == model.getSize()) { fail("Template not found in the hint popup"); } new EventTool().waitNoEvent(2000); jlo.selectItem(i); new EventTool().waitNoEvent(500); }
Example 6
Source File: RemoveSurroundingTest.java From netbeans with Apache License 2.0 | 5 votes |
private void dumpAndSelect(int row, int col, int select) { oper.setCaretPosition(row, col); oper.pressKey(KeyEvent.VK_BACK_SPACE, KeyEvent.ALT_DOWN_MASK); JDialogOperator jdo = new JDialogOperator(MainWindowOperator.getDefault()); JListOperator jlo = new JListOperator(jdo); ListModel model = jlo.getModel(); int i; for (i = 0; i < model.getSize(); i++) { Object item = model.getElementAt(i); if(item instanceof CodeDeleter) { CodeDeleter codeDeleter = (CodeDeleter) item; ref(codeDeleter.getDisplayName()); HighlightsSequence highlights = codeDeleter.getHighlight().getHighlights(0, oper.getText().length()); while(highlights.moveNext()) { ref(highlights.getStartOffset()+" "+highlights.getEndOffset()); AttributeSet attributes = highlights.getAttributes(); Enumeration<?> attributeNames = attributes.getAttributeNames(); while(attributeNames.hasMoreElements()) { Object nextElement = attributeNames.nextElement(); ref(nextElement+" "+attributes.getAttribute(nextElement)); } } } } if(select>-1) { jlo.selectItem(select); ref(oper.getText()); } }
Example 7
Source File: AbbreviationsAddRemovePerformer.java From netbeans with Apache License 2.0 | 5 votes |
public static void useHint(final EditorOperator editor, final int lineNumber, String hintPrefix) throws InterruptedException { Object annots = new Waiter(new Waitable() { public Object actionProduced(Object arg0) { Object[] annotations = editor.getAnnotations(lineNumber); if (annotations.length == 0) { return null; } else { return annotations; } } public String getDescription() { return "Waiting for annotations for current line"; } }).waitAction(null); editor.pressKey(KeyEvent.VK_ENTER, KeyEvent.ALT_DOWN_MASK); JListOperator jlo = new JListOperator(MainWindowOperator.getDefault()); int index = -1; ListModel model = jlo.getModel(); for (int i = 0; i < model.getSize(); i++) { Object element = model.getElementAt(i); String desc = getText(element); if (desc.startsWith(hintPrefix)) { index = i; } } assertTrue("Requested hint not found", index != -1); jlo.selectItem(index); jlo.pushKey(KeyEvent.VK_ENTER); }
Example 8
Source File: testPalette.java From netbeans with Apache License 2.0 | 4 votes |
private void DragSomething( String sFile, String sLocation, String sComponent ) { // Locate coords of HTML code EditorOperator eoPHP = new EditorOperator( sFile ); eoPHP.setCaretPosition( sLocation, false ); int iX = 0, iY = 0; JEditorPaneOperator txt = eoPHP.txtEditorPane( ); JEditorPane epane = ( JEditorPane )txt.getSource( ); try { Rectangle rct = epane.modelToView( epane.getCaretPosition( ) ); iX = rct.x; iY = rct.y; } catch( BadLocationException ex ) { fail( "Unable to detect destination location." ); } //TopComponentOperator top = new TopComponentOperator( "EmptyPHPWebPage.php" ); TopComponentOperator pal = new TopComponentOperator( "Palette" ); JListOperator list = new JListOperator( pal, 0 ); ListModel lmd = list.getModel( ); int iIndex = list.findItemIndex( sComponent ); list.selectItem( iIndex ); Point pt = list.getClickPoint( iIndex ); MouseRobotDriver m_mouseDriver = new MouseRobotDriver(new Timeout("", 500)); m_mouseDriver.moveMouse( list, pt.x, pt.y ); m_mouseDriver.pressMouse( InputEvent.BUTTON1_MASK, 0 ); m_mouseDriver.enterMouse( txt ); m_mouseDriver.dragMouse( txt, iX, iY, InputEvent.BUTTON1_MASK, 0 ); m_mouseDriver.releaseMouse( InputEvent.BUTTON1_MASK, 0 ); return; }