本文整理汇总了Java中org.fife.ui.rtextarea.SearchContext类的典型用法代码示例。如果您正苦于以下问题:Java SearchContext类的具体用法?Java SearchContext怎么用?Java SearchContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SearchContext类属于org.fife.ui.rtextarea包,在下文中一共展示了SearchContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replace
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@Override
public final boolean replace(String toFind, String toReplace,
boolean matchCase, boolean wholeWorld, boolean isRegex,
boolean searchBack) {
if (toFind.length() == 0) {
return false;
}
SearchContext context = new SearchContext();
context.setSearchFor(toFind);
context.setReplaceWith(toReplace);
context.setMatchCase(matchCase);
context.setRegularExpression(isRegex);
context.setWholeWord(wholeWorld);
context.setSearchForward(!searchBack);
return SearchEngine.replace(textarea, context);
}
示例2: replaceAll
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@Override
public final int replaceAll(String toFind, String toReplace,
boolean matchCase, boolean wholeWorld, boolean isRegex,
boolean searchBack) {
if (toFind.length() == 0) {
return -1;
}
SearchContext context = new SearchContext();
context.setSearchFor(toFind);
context.setReplaceWith(toReplace);
context.setMatchCase(matchCase);
context.setRegularExpression(isRegex);
context.setWholeWord(wholeWorld);
context.setSearchForward(!searchBack);
return SearchEngine.replaceAll(textarea, context);
}
示例3: actionPerformed
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@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()) {
pane.setSelectionStart(0);
pane.setSelectionEnd(0);
}
}
示例4: actionPerformed
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@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");
}
}
}
示例5: actionPerformed
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@Override
public void actionPerformed(final ActionEvent event) {
if (event.getSource() == prevButton || event.getSource() == nextButton) {
final String command = event.getActionCommand();
final boolean forward = "FindNext".equals(command);
// Create an object defining our search parameters.
final SearchContext context = new SearchContext();
final 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);
final boolean found = SearchEngine.find(btext, context).wasFound();
if (!found) {
JOptionPane.showMessageDialog(null, "Text not found");
}
}
}
示例6: actionPerformed
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@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);
if (!found) {
JOptionPane.showMessageDialog(this, "Text not found");
}
}
示例7: find
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
/**
* Finds the specified string in the code editor.
* @param str The string to find.
* @param matchCase If the search is case-sensitive.
* @param forward Whether to search forwards or backwards.
*/
protected void find(String str, boolean matchCase, boolean forward) {
if(!str.isEmpty()) {
clearFind();
SearchContext context = new SearchContext();
context.setSearchFor(str);
context.setMatchCase(matchCase);
context.setRegularExpression(false);
context.setSearchForward(forward);
context.setWholeWord(false);
SearchEngine.find(txtCode, context);
txtCode.markAll(str, matchCase, false, false);
}
}
示例8: replace
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
/**
* Replaces the next occurrence of the given string by another string.
* @param str The string to find.
* @param by The string to replace with.
* @param matchCase If the search is case-sensitive.
* @param forward Whether to search forwards or backwards.
*/
protected void replace(String str, String by, boolean matchCase, boolean forward) {
if(!str.isEmpty()) {
clearFind();
SearchContext context = new SearchContext();
context.setSearchFor(str);
context.setReplaceWith(by);
context.setMatchCase(matchCase);
context.setRegularExpression(false);
context.setSearchForward(forward);
context.setWholeWord(false);
SearchEngine.replace(txtCode, context);
txtCode.markAll(str, matchCase, false, false);
}
}
示例9: replaceAll
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
/**
* Replaces all occurrence of the given string by another string.
* @param str The string to find.
* @param by The string to replace with.
* @param matchCase If the search is case-sensitive.
* @param forward Whether to search forwards or backwards.
*/
protected void replaceAll(String str, String by, boolean matchCase, boolean forward) {
if(!str.isEmpty()) {
clearFind();
SearchContext context = new SearchContext();
context.setSearchFor(str);
context.setReplaceWith(by);
context.setMatchCase(matchCase);
context.setRegularExpression(false);
context.setSearchForward(forward);
context.setWholeWord(false);
SearchEngine.replaceAll(txtCode, context);
}
}
示例10: performSearch
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
private void performSearch(boolean forward) {
//SearchContext context = new SearchContext();
String text = searchField.getText();
if (text.length() == 0)
return;
boolean caseSensitive = matchCaseCB.isSelected();
boolean regExpr = regexCB.isSelected();
boolean forwardSearch = forward;
boolean wholeWord = false;
SearchContext context = new SearchContext();
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(jep, context);
if (!found)
JOptionPane.showMessageDialog(this.currentFrame, "Text not found");
}
示例11: actionPerformed
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == bSearch)
{
if (fSearch.getText().length() == 0) return;
SearchContext context = new SearchContext();
context.setSearchFor(fSearch.getText());
context.setMatchCase(cbCaseSensitive.isSelected());
context.setRegularExpression(cbRegEx.isSelected());
context.setSearchForward(!cbSearchBackward.isSelected());
context.setWholeWord(cbWholeWord.isSelected());
if (!SearchEngine.find(textArea, context).wasFound())
JOptionPane.showMessageDialog(frame, "Texto no encontrado");
}
if(e.getSource() == bCancel)
this.dispose();
}
示例12: initDialogs
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
private void initDialogs()
{
findDialog = new FindDialog(this, this);
replaceDialog = new ReplaceDialog(this, this);
SearchContext context = findDialog.getSearchContext();
replaceDialog.setSearchContext(context);
findToolBar = new FindToolBar(this);
findToolBar.setSearchContext(context);
replaceToolBar = new ReplaceToolBar(this);
replaceToolBar.setSearchContext(context);
KeyStroke keyStroke =
KeyStroke.getKeyStroke(KeyEvent.VK_F, getToolkit().getMenuShortcutKeyMask()
| InputEvent.SHIFT_MASK);
editor.getInputMap().put(keyStroke, "SHOW_FINDTOOLBAR");
editor.getActionMap().put("SHOW_FINDTOOLBAR",
sectionPanel.addBottomComponent(keyStroke, findToolBar));
}
示例13: actionPerformed
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@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);
if (!found) {
JOptionPane.showMessageDialog(this, "Text not found");
}
}
示例14: makeCell
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
private Component makeCell(JNode node, int column) {
if (column == 0) {
JLabel label = new JLabel(node.makeLongString() + " ", node.getIcon(), SwingConstants.LEFT);
label.setOpaque(true);
label.setToolTipText(label.getText());
return label;
}
if (!node.hasDescString()) {
return emptyLabel;
}
RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setFont(codeFont);
textArea.setEditable(false);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setText(" " + node.makeDescString());
textArea.setRows(1);
textArea.setColumns(textArea.getText().length());
if (highlightText != null) {
SearchContext searchContext = new SearchContext(highlightText);
searchContext.setMatchCase(true);
searchContext.setMarkAll(true);
SearchEngine.markAll(textArea, searchContext);
}
return textArea;
}
示例15: find
import org.fife.ui.rtextarea.SearchContext; //导入依赖的package包/类
@Override
public final boolean find(String toFind, boolean matchCase,
boolean wholeWorld, boolean isRegex, boolean searchBack) {
if (toFind.length() == 0) {
return false;
}
SearchContext context = new SearchContext();
context.setSearchFor(toFind);
context.setMatchCase(matchCase);
context.setRegularExpression(isRegex);
context.setWholeWord(wholeWorld);
context.setSearchForward(!searchBack);
return SearchEngine.find(textarea, context);
}