private void search(int direction) { String searchText = searchField.getText(); if (searchText == null || searchText.length() == 0 || rTextArea.getText() == null) { return; } boolean forward = direction >= 0; boolean matchCase = matchCaseCB.isSelected(); boolean regex = regexCB.isSelected(); boolean wholeWord = wholeWordCB.isSelected(); if (markAllCB.isSelected()) { rTextArea.markAll(searchText, matchCase, wholeWord, regex); } else { rTextArea.clearMarkAllHighlights(); } SearchContext context = new SearchContext(); context.setSearchFor(searchText); context.setMatchCase(matchCase); context.setRegularExpression(regex); context.setSearchForward(forward); context.setWholeWord(wholeWord); // TODO hack: move cursor before previous search for not jump to next occurrence if (direction == 0 && !COLOR_BG_ERROR.equals(searchField.getBackground())) { try { int caretPos = rTextArea.getCaretPosition(); int lineNum = rTextArea.getLineOfOffset(caretPos) - 1; if (lineNum > 1) { rTextArea.setCaretPosition(rTextArea.getLineStartOffset(lineNum)); } } catch (BadLocationException e) { LOG.error("Caret move error", e); } } boolean found = SearchEngine.find(rTextArea, context); if (!found) { int pos = SearchEngine.getNextMatchPos( searchText, rTextArea.getText(), forward, matchCase, wholeWord); if (pos != -1) { rTextArea.setCaretPosition(forward ? 0 : rTextArea.getDocument().getLength() - 1); search(direction); searchField.setBackground(COLOR_BG_WARN); return; } searchField.setBackground(COLOR_BG_ERROR); } else { searchField.setBackground(COLOR_BG_NORMAL); } }
public String getText(int start, int end) { try { return textArea.getText(start, end - start); } catch (BadLocationException e) { /* ignore */ } return ""; }
/** * Modifies a given TestElement to mirror the data in the gui components. * * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) */ public void modifyTestElement(TestElement te) { te.clear(); this.configureTestElement(te); te.setProperty(BeanShellAssertion.SCRIPT, scriptField.getText()); te.setProperty(BeanShellAssertion.FILENAME, filename.getText()); te.setProperty(BeanShellAssertion.PARAMETERS, parameters.getText()); te.setProperty( new BooleanProperty(BeanShellAssertion.RESET_INTERPRETER, resetInterpreter.isSelected())); }
private ScriptableDataFactory produceFactory() { final ScriptableDataFactory returnDataFactory = new ScriptableDataFactory(); returnDataFactory.setLanguage((String) languageField.getSelectedValue()); if (StringUtils.isEmpty(initScriptTextArea.getText())) { returnDataFactory.setScript(null); } else { returnDataFactory.setScript(initScriptTextArea.getText()); } if (StringUtils.isEmpty(shutdownScriptTextArea.getText())) { returnDataFactory.setShutdownScript(null); } else { returnDataFactory.setShutdownScript(shutdownScriptTextArea.getText()); } final DataSetQuery[] queries = this.queries.values().toArray(new DataSetQuery[this.queries.size()]); for (int i = 0; i < queries.length; i++) { final DataSetQuery query = queries[i]; returnDataFactory.setQuery(query.getQueryName(), query.getQuery()); } return returnDataFactory; }
/** Renvoie le texte actuellement édité. */ public String getText() { return textArea.getText(); }