当前位置: 首页>>代码示例>>Java>>正文


Java SearchContext.setReplaceWith方法代码示例

本文整理汇总了Java中org.fife.ui.rtextarea.SearchContext.setReplaceWith方法的典型用法代码示例。如果您正苦于以下问题:Java SearchContext.setReplaceWith方法的具体用法?Java SearchContext.setReplaceWith怎么用?Java SearchContext.setReplaceWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fife.ui.rtextarea.SearchContext的用法示例。


在下文中一共展示了SearchContext.setReplaceWith方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:18,代码来源:SourceCodeEditor.java

示例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);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:18,代码来源:SourceCodeEditor.java

示例3: 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);
	}
}
 
开发者ID:brunonova,项目名称:drmips,代码行数:24,代码来源:FrmSimulator.java

示例4: 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);
	}
}
 
开发者ID:brunonova,项目名称:drmips,代码行数:23,代码来源:FrmSimulator.java

示例5: searchText

import org.fife.ui.rtextarea.SearchContext; //导入方法依赖的package包/类
public void searchText(String operation, boolean regex, boolean matchCase,
		boolean wholeWord, boolean markAll, boolean forSearch) {
	int chosenIndex = tabPane.getSelectedIndex();
	if (chosenIndex < 0) {
		JOptionPane.showMessageDialog(null, "No files opened to search on");
		return;
	}
	RTextScrollPane htmlScroll = (RTextScrollPane) tabPane
			.getComponentAt(chosenIndex);
	RSyntaxTextArea searchtextArea = (RSyntaxTextArea) htmlScroll
			.getViewport().getView();
	SearchContext context = new SearchContext();
	String text = searchField.getText();
	if (text.length() == 0) {
		return;
	}
	context.setSearchFor(text);
	context.setMatchCase(matchCase);
	context.setRegularExpression(regex);
	context.setSearchForward(forSearch);
	context.setWholeWord(wholeWord);
	context.setMarkAll(markAll);
	boolean found = false;
	if (operation.equals("replace")) {
		context.setReplaceWith(repWithField.getText());
		found = SearchEngine.replace(searchtextArea, context).wasFound();
	} else if (operation.equals("replaceAll")) {
		context.setReplaceWith(repWithField.getText());
		found = SearchEngine.replaceAll(searchtextArea, context).wasFound();
	} else {
		found = SearchEngine.find(searchtextArea, context).wasFound();
	}
	if (!found) {
		JOptionPane.showMessageDialog(null, "Text not found");
	}
}
 
开发者ID:csanuragjain,项目名称:APKRepatcher,代码行数:37,代码来源:APKRepatcher.java

示例6: actionPerformed

import org.fife.ui.rtextarea.SearchContext; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e)
{
	if(e.getSource() == bCancel)
		this.dispose();

	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(e.getSource() == bSearch)
	{
		if (!SearchEngine.find(textArea, context).wasFound())
			JOptionPane.showMessageDialog(frame, "Texto no encontrado");
		return;
	}
	
	if(fReplace.getText().length() == 0) return;

	context.setReplaceWith(fReplace.getText());

	if(e.getSource() == bReplace)
	{
		SearchEngine.replace(textArea, context);
		return;
	}
	if(e.getSource() == bReplaceAll)
	{
		SearchEngine.replaceAll(textArea, context).wasFound();
		return;
	}
}
 
开发者ID:pedromateo,项目名称:tug_qt_unit_testing_fw,代码行数:37,代码来源:DialogReplace.java

示例7: searchReplace

import org.fife.ui.rtextarea.SearchContext; //导入方法依赖的package包/类
private void searchReplace(Mode mode, Direction direction) {
    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(direction == Direction.FORWARD);
    context.setWholeWord(false);

    SearchResult searchResult;

    if (mode == Mode.FIND) {
        searchResult = SearchEngine.find(textArea, context);
    } else {
        context.setReplaceWith(replaceField.getText());
        searchResult = SearchEngine.replace(textArea, context);
    }

    if (!searchResult.wasFound()) {
        if (direction == Direction.FORWARD) {
            textArea.setCaretPosition(0);
        } else {
            textArea.setCaretPosition(
                    textArea.getText().length());

        }

        if (mode == Mode.FIND) {
            searchResult = SearchEngine.find(textArea, context);
        } else {
            searchResult = SearchEngine.replace(textArea, context);
        }

        if (!searchResult.wasFound()) {
            JOptionPane.showMessageDialog(this,
                    String.format("Text \"%s\" not found in file", text));
        }
    }
}
 
开发者ID:loadtestgo,项目名称:pizzascript,代码行数:44,代码来源:FindReplaceDialog.java


注:本文中的org.fife.ui.rtextarea.SearchContext.setReplaceWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。