Search in sources :

Example 1 with IFindReplaceTarget

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);
    }
}
Also used : IFindReplaceTarget(org.eclipse.jface.text.IFindReplaceTarget) TextViewer(org.eclipse.jface.text.TextViewer)

Example 2 with IFindReplaceTarget

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;
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Color(org.eclipse.swt.graphics.Color) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IFindReplaceTarget(org.eclipse.jface.text.IFindReplaceTarget) IFindReplaceTargetExtension(org.eclipse.jface.text.IFindReplaceTargetExtension)

Example 3 with IFindReplaceTarget

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);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) Event(org.eclipse.swt.widgets.Event) Combo(org.eclipse.swt.widgets.Combo) IFindReplaceTarget(org.eclipse.jface.text.IFindReplaceTarget) Test(org.junit.Test)

Example 4 with IFindReplaceTarget

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"));
}
Also used : FindReplaceAction(org.eclipse.ui.texteditor.FindReplaceAction) IFindReplaceTarget(org.eclipse.jface.text.IFindReplaceTarget)

Example 5 with IFindReplaceTarget

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;
}
Also used : IFindReplaceTarget(org.eclipse.jface.text.IFindReplaceTarget) IFindReplaceTargetExtension(org.eclipse.jface.text.IFindReplaceTargetExtension) ITextViewer(org.eclipse.jface.text.ITextViewer)

Aggregations

IFindReplaceTarget (org.eclipse.jface.text.IFindReplaceTarget)10 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 GroupMarker (org.eclipse.jface.action.GroupMarker)2 IFindReplaceTargetExtension (org.eclipse.jface.text.IFindReplaceTargetExtension)2 Point (org.eclipse.swt.graphics.Point)2 VerticalButton (org.jkiss.dbeaver.ui.controls.VerticalButton)2 AutoRefreshControl (org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl)2 ResultSetPanelDescriptor (org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)2 StatisticsPresentation (org.jkiss.dbeaver.ui.controls.resultset.view.StatisticsPresentation)2 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IMarkRegionTarget (org.eclipse.jface.text.IMarkRegionTarget)1 ITextViewer (org.eclipse.jface.text.ITextViewer)1 ITextViewerExtension (org.eclipse.jface.text.ITextViewerExtension)1 TextViewer (org.eclipse.jface.text.TextViewer)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 SWT (org.eclipse.swt.SWT)1 ST (org.eclipse.swt.custom.ST)1 StyledText (org.eclipse.swt.custom.StyledText)1 Color (org.eclipse.swt.graphics.Color)1