use of org.eclipse.jface.text.IFindReplaceTarget in project cubrid-manager by CUBRID.
the class FindReplaceDialog method replaceSelected.
/**
* Replace current selected text with input.
*/
protected void replaceSelected() {
TextViewer st = TextEditorFindReplaceMediator.getCurrentTextEditor();
if (st == null) {
return;
}
IFindReplaceTarget target = TextEditorFindReplaceMediator.getFindAndReplaceInterface();
if (target == null) {
return;
}
if (isTextSelected()) {
try {
target.replaceSelection(replaceText.getText());
} catch (Exception ignored) {
}
updateTextCombo(replaceText);
}
}
use of org.eclipse.jface.text.IFindReplaceTarget in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method initializeFindScopeColor.
/**
* Initializes the background color used for highlighting the document ranges
* defining search scopes.
*
* @param viewer the viewer to initialize
* @since 2.0
*/
private void initializeFindScopeColor(ISourceViewer viewer) {
IPreferenceStore store = getPreferenceStore();
if (store != null) {
StyledText styledText = viewer.getTextWidget();
Color color = createColor(store, PREFERENCE_COLOR_FIND_SCOPE, styledText.getDisplay());
IFindReplaceTarget target = viewer.getFindReplaceTarget();
if (target != null && target instanceof IFindReplaceTargetExtension)
((IFindReplaceTargetExtension) target).setScopeHighlightColor(color);
if (fFindScopeHighlightColor != null)
fFindScopeHighlightColor.dispose();
fFindScopeHighlightColor = color;
}
}
use of org.eclipse.jface.text.IFindReplaceTarget in project eclipse.platform.text by eclipse.
the class FindReplaceDialogTest method testShiftEnterReversesSearchDirection.
@Test
public void testShiftEnterReversesSearchDirection() {
openTextViewerAndFindReplaceDialog();
Combo findField = (Combo) fFindReplaceDialog.get("fFindField");
findField.setText("line");
IFindReplaceTarget target = (IFindReplaceTarget) fFindReplaceDialog.get("fTarget");
runEventQueue();
Shell shell = ((Shell) fFindReplaceDialog.get("fActiveShell"));
if (shell == null && Util.isGtk()) {
if (ScreenshotTest.isRunByGerritHudsonJob()) {
takeScreenshot();
return;
} else
fail("this test does not work on GTK unless the runtime workbench has focus. Screenshot: " + takeScreenshot());
}
final Event event = new Event();
event.detail = SWT.TRAVERSE_RETURN;
event.character = SWT.CR;
findField.traverse(SWT.TRAVERSE_RETURN, event);
runEventQueue();
assertEquals(0, (target.getSelection()).x);
assertEquals(4, (target.getSelection()).y);
event.doit = true;
findField.traverse(SWT.TRAVERSE_RETURN, event);
runEventQueue();
assertEquals(5, (target.getSelection()).x);
assertEquals(4, (target.getSelection()).y);
event.stateMask = SWT.SHIFT;
event.doit = true;
findField.traverse(SWT.TRAVERSE_RETURN, event);
assertEquals(0, (target.getSelection()).x);
assertEquals(4, (target.getSelection()).y);
Button forwardRadioButton = (Button) fFindReplaceDialog.get("fForwardRadioButton");
forwardRadioButton.setSelection(false);
event.doit = true;
forwardRadioButton.traverse(SWT.TRAVERSE_RETURN, event);
assertEquals(5, (target.getSelection()).x);
}
use of org.eclipse.jface.text.IFindReplaceTarget in project dbeaver by dbeaver.
the class UIUtils method fillDefaultStyledTextContextMenu.
public static void fillDefaultStyledTextContextMenu(IMenuManager menu, final StyledText text) {
final Point selectionRange = text.getSelectionRange();
menu.add(new StyledTextAction(IWorkbenchCommandConstants.EDIT_COPY, selectionRange.y > 0, text, ST.COPY));
menu.add(new StyledTextAction(IWorkbenchCommandConstants.EDIT_PASTE, text.getEditable(), text, ST.PASTE));
menu.add(new StyledTextAction(IWorkbenchCommandConstants.EDIT_CUT, selectionRange.y > 0, text, ST.CUT));
menu.add(new StyledTextAction(IWorkbenchCommandConstants.EDIT_SELECT_ALL, true, text, ST.SELECT_ALL));
IFindReplaceTarget stFindReplaceTarget = new StyledTextFindReplaceTarget(text);
menu.add(new FindReplaceAction(ResourceBundle.getBundle("org.eclipse.ui.texteditor.ConstructedEditorMessages"), "Editor.FindReplace.", text.getShell(), stFindReplaceTarget));
menu.add(new GroupMarker("styled_text_additions"));
}
use of org.eclipse.jface.text.IFindReplaceTarget in project mylyn.docs by eclipse.
the class IncrementalFindHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ITextViewer viewer = getTextViewer(event);
if (viewer != null) {
IFindReplaceTarget findReplaceTarget = viewer.getFindReplaceTarget();
if (findReplaceTarget.canPerformFind()) {
if (findReplaceTarget instanceof IFindReplaceTargetExtension) {
IFindReplaceTargetExtension extension = (IFindReplaceTargetExtension) findReplaceTarget;
extension.beginSession();
}
}
}
return null;
}
Aggregations