/** * @param str - if null -> reset current highlights */ private void highlightAllMatches(@Nullable String str) { SearchContext context = new SearchContext(str); context.setMarkAll(true); context.setMatchCase(true); context.setWholeWord(true); SearchEngine.markAll(this, context); }
private Component makeCell(JNode node, int column) { if (column == 0) { JLabel label = new JLabel(node.makeLongString() + " ", node.getIcon(), SwingConstants.LEFT); label.setFont(font); label.setOpaque(true); label.setToolTipText(label.getText()); return label; } if (!node.hasDescString()) { return emptyLabel; } RSyntaxTextArea textArea = CodeArea.getDefaultArea(mainWindow); textArea.setLayout(new GridLayout(1, 1)); textArea.setEditable(false); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setText(" " + node.makeDescString()); textArea.setRows(1); textArea.setColumns(textArea.getText().length() + 1); if (highlightText != null) { SearchContext searchContext = new SearchContext(highlightText); searchContext.setMatchCase(!highlightTextCaseInsensitive); searchContext.setMarkAll(true); SearchEngine.markAll(textArea, searchContext); } return textArea; }
@Override public void actionPerformed(ActionEvent event) { if (textField.getText().length() == 0) return; RSyntaxTextArea pane = mainWindow.getModel().getCurrentTextArea(); if (pane == null) return; SearchContext context = new SearchContext(); context.setSearchFor(textField.getText()); context.setMatchCase(mcase.isSelected()); context.setRegularExpression(regex.isSelected()); context.setSearchForward(!reverse.isSelected()); context.setWholeWord(wholew.isSelected()); if (!SearchEngine.find(pane, context).wasFound()) { if (wrap.isSelected()) { pane.setSelectionStart(0); pane.setSelectionEnd(0); } else { mainWindow.getLabel().setText("Search Complete"); } } }
@Override public void actionPerformed(ActionEvent e) { if (textField.getText().length() == 0) return; RSyntaxTextArea pane = mainWindow.getModel().getCurrentTextArea(); if (pane == null) return; SearchContext context = new SearchContext(); context.setSearchFor(textField.getText()); context.setMatchCase(mcase.isSelected()); context.setRegularExpression(regex.isSelected()); context.setSearchForward(direction); context.setWholeWord(wholew.isSelected()); if (!SearchEngine.find(pane, context).wasFound()) { if (wrap.isSelected()) { pane.setSelectionStart(0); pane.setSelectionEnd(0); } else { mainWindow.getLabel().setText("Search Complete"); } } }
context.setMatchCase(matchCase); context.setRegularExpression(regex); context.setSearchForward(forward);
@Override public void actionPerformed(ActionEvent e) { // "FindNext" => search forward, "FindPrev" => search backward String command = e.getActionCommand(); boolean forward = "FindNext".equals(command); // Create an object defining our search parameters. SearchContext context = new SearchContext(); String text = searchField.getText(); if (text.length() == 0) { return; } context.setSearchFor(text); context.setMatchCase(matchCaseCB.isSelected()); context.setRegularExpression(regexCB.isSelected()); context.setSearchForward(forward); context.setWholeWord(false); boolean found = SearchEngine.find(textArea, context).wasFound(); if (!found) { JOptionPane.showMessageDialog(this, "Text not found"); } }
context.setMatchCase(true); context.setSearchFor(toMark.toLowerCase()); findIn = findIn.toLowerCase();
textArea.setText("root roOt root"); String expected = "oo oO oo"; context.setMatchCase(false); context.setWholeWord(false); context.setReplaceWith("$1"); textArea.setCaretPosition(textArea.getText().length()-4); expected = "oo oO oo"; context.setMatchCase(false); context.setWholeWord(false); context.setReplaceWith("$1"); textArea.setText("152k 5271143M 3985k"); expected = "1.52 5.271143 3.985"; context.setMatchCase(false); context.setWholeWord(false); context.setReplaceWith("$1.$2"); textArea.setText(expected); textArea.setCaretPosition(8); context.setMatchCase(false); context.setWholeWord(false); context.setReplaceWith("$1.$2");
textArea.setText(text); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false); context.setRegularExpression(false); textArea.setText(text); expected = "How much FOOBAR wOuld a woodChuck chUck, if a woodchuck could chuck FOOBAR?"; context.setMatchCase(false); context.setWholeWord(true); context.setRegularExpression(false); textArea.setText(text); expected = "How much wood wOuld a woodChuck FOOBAR, if a woodchuck could chuck wOod?"; context.setMatchCase(true); context.setWholeWord(true); context.setRegularExpression(false); textArea.setText(text); expected = textArea.getText().replaceAll("(?i:" + context.getSearchFor() + ")", context.getReplaceWith()); context.setMatchCase(false); context.setWholeWord(false); context.setRegularExpression(true); textArea.setText(text); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false); context.setRegularExpression(true);
/** * Click on the replace all button */ public void onReplaceAll() { String text = findTF.getText(); if (text.length() == 0) { return; } String textReplace = replaceTF.getText(); if (!textReplace.equals(text)) { boolean matchCase = matchCaseCB.isSelected(); boolean wholeWord = wholeWrdsCB.isSelected(); boolean regex = regexCB.isSelected(); SearchContext c = new SearchContext(); c.setMatchCase(matchCase); c.setSearchFor(text); c.setWholeWord(wholeWord); c.setRegularExpression(regex); c.setReplaceWith(textReplace); SearchEngine.replaceAll(rSyntaxTextArea, c); } }
/** * Click on the replace all button */ public void onReplaceAll() { String text = findTF.getText(); if (text.length() == 0) { return; } String textReplace = replaceTF.getText(); if (!textReplace.equals(text)) { boolean matchCase = matchCaseCB.isSelected(); boolean wholeWord = wholeWrdsCB.isSelected(); boolean regex = regexCB.isSelected(); SearchContext c = new SearchContext(); c.setMatchCase(matchCase); c.setSearchFor(text); c.setWholeWord(wholeWord); c.setRegularExpression(regex); c.setReplaceWith(textReplace); SearchEngine.replaceAll(rSyntaxTextArea, c); } }
/** * Click on the replace button */ public void onReplace() { String text = findTF.getText(); if (text.length() == 0) { return; } String textReplace = replaceTF.getText(); if (!textReplace.equals(text)) { boolean forward = downCB.isSelected(); boolean matchCase = matchCaseCB.isSelected(); boolean wholeWord = wholeWrdsCB.isSelected(); boolean regex = regexCB.isSelected(); SearchContext c = new SearchContext(); c.setMatchCase(matchCase); c.setSearchFor(text); c.setReplaceWith(textReplace); c.setWholeWord(wholeWord); c.setRegularExpression(regex); c.setSearchForward(forward); boolean found = SearchEngine.replace(rSyntaxTextArea, c); if (!found) { LOGGER.info(I18N.tr("Text not found !")); } } }
/** * Click on the find next button */ public void onFindNext() { String text = findTF.getText(); if (text.length() == 0) { return; } boolean markAll = markAllCB.isSelected(); boolean forward = downCB.isSelected(); boolean matchCase = matchCaseCB.isSelected(); boolean wholeWord = wholeWrdsCB.isSelected(); boolean regex = regexCB.isSelected(); SearchContext c = new SearchContext(); c.setMarkAll(markAll); c.setMatchCase(matchCase); c.setSearchFor(text); c.setWholeWord(wholeWord); c.setRegularExpression(regex); c.setSearchForward(forward); boolean found = SearchEngine.find(rSyntaxTextArea, c).wasFound(); if (!found) { LOGGER.info(I18N.tr("Text not found !")); } }
/** * Click on the find next button */ public void onFindNext() { String text = findTF.getText(); if (text.length() == 0) { return; } boolean markAll = markAllCB.isSelected(); boolean forward = downCB.isSelected(); boolean matchCase = matchCaseCB.isSelected(); boolean wholeWord = wholeWrdsCB.isSelected(); boolean regex = regexCB.isSelected(); if (markAll) { rSyntaxTextArea.clearMarkAllHighlights(); rSyntaxTextArea.markAll(text, matchCase, wholeWord, regex); } SearchContext c = new SearchContext(); c.setMatchCase(matchCase); c.setSearchFor(text); c.setWholeWord(wholeWord); c.setRegularExpression(regex); c.setSearchForward(forward); boolean found = SearchEngine.find(rSyntaxTextArea, c); if (!found) { LOGGER.info(I18N.tr("Text not found !")); } }
textArea.setText(text); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false); context.setRegularExpression(false); textArea.setText(text); expected = "How much wood wOuld a woodChuck FOOBAR, if a woodchuck could FOOBAR wOod?"; context.setMatchCase(false); context.setWholeWord(true); context.setRegularExpression(false); textArea.setText(text); expected = "How much wood wOuld a woodChuck chUck, if a woodchuck could FOOBAR wOod?"; context.setMatchCase(true); context.setWholeWord(true); context.setRegularExpression(false); textArea.setText(text); expected = textArea.getText().replaceAll("(?i:" + context.getSearchFor() + ")", context.getReplaceWith()); context.setMatchCase(false); context.setWholeWord(false); context.setRegularExpression(true); textArea.setText(text); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false); context.setRegularExpression(true);
context.setMatchCase(false); textArea.setCaretPosition(end); SearchResult res = SearchEngine.markAll(textArea, context); context.setMatchCase(true); textArea.setCaretPosition(end); res = SearchEngine.markAll(textArea, context); context.setMatchCase(false); context.setWholeWord(true); textArea.setCaretPosition(end); context.setMatchCase(true); context.setWholeWord(true); textArea.setCaretPosition(end); context.setMatchCase(false); context.setWholeWord(false); context.setRegularExpression(true); context.setMatchCase(true); context.setWholeWord(false); context.setRegularExpression(true); context.setMatchCase(false); context.setWholeWord(true); context.setRegularExpression(true); context.setMatchCase(true);
private SearchContext createSearchContext(String text, boolean forward, boolean matchCase, boolean isRegex) { SearchContext context = new SearchContext(); context.setSearchFor(text); context.setMatchCase(matchCase); context.setRegularExpression(isRegex); context.setSearchForward(forward); context.setMarkAll(false); context.setSearchSelectionOnly(false); context.setWholeWord(false); return context; } }
context.setMatchCase(false); textArea.setCaretPosition(end); boolean found = findImpl(context); context.setMatchCase(true); textArea.setCaretPosition(end); found = findImpl(context); context.setMatchCase(false); context.setWholeWord(true); textArea.setCaretPosition(end); context.setMatchCase(true); context.setWholeWord(true); textArea.setCaretPosition(end); context.setMatchCase(false); context.setWholeWord(false); context.setRegularExpression(true); context.setMatchCase(true); context.setWholeWord(false); context.setRegularExpression(true); context.setMatchCase(false); context.setWholeWord(true); context.setRegularExpression(true); context.setMatchCase(true);
context.setMatchCase(true); textArea.setCaretPosition(0); found = findImpl(context); context.setMatchCase(false); context.setWholeWord(true); textArea.setCaretPosition(0); context.setMatchCase(true); context.setWholeWord(true); textArea.setCaretPosition(0); context.setMatchCase(false); context.setWholeWord(false); context.setRegularExpression(true); context.setMatchCase(true); context.setWholeWord(false); context.setRegularExpression(true); context.setMatchCase(false); context.setWholeWord(true); context.setRegularExpression(true); context.setMatchCase(true); context.setWholeWord(true); context.setRegularExpression(true);
public void searchInTextarea() { String text = samlGUI.getActionPanel().getSearchText(); SearchContext context = new SearchContext(); context.setMatchCase(false); context.setMarkAll(true); context.setSearchFor(text); context.setWholeWord(false); SearchResult result = SearchEngine.find(textArea, context); if (!result.wasFound()) { textArea.setCaretPosition(0); SearchEngine.find(textArea, context); } }