Search in sources :

Example 6 with TextViewer

use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.

the class TextEditorFindReplaceMediator method findNext.

/**
	 *
	 * Find next searched string
	 *
	 * @return boolean
	 */
public static boolean findNext() {
    TextViewer st = getCurrentTextEditor();
    if (st == null) {
        return false;
    }
    String searchedStr = st.getTextWidget().getSelectionText();
    if (searchedStr == null || searchedStr.trim().length() == 0) {
        return false;
    }
    FindReplaceOption findReplaceOption = new FindReplaceOption();
    findReplaceOption.setSearchedStr(searchedStr);
    return findAndSelect(st.getTextWidget().getCaretOffset(), true, findReplaceOption) >= 0;
}
Also used : FindReplaceOption(com.cubrid.tool.editor.dialog.FindReplaceOption) TextViewer(org.eclipse.jface.text.TextViewer)

Example 7 with TextViewer

use of org.eclipse.jface.text.TextViewer 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 8 with TextViewer

use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.

the class FindReplaceDialog method setSelectedText.

/**
	 * 
	 * Set the selected text from focus text editor
	 * 
	 */
public void setSelectedText() {
    TextViewer textViewer = TextEditorFindReplaceMediator.getCurrentTextEditor();
    if (textViewer == null || textViewer.getTextWidget() == null || textViewer.getTextWidget().isDisposed()) {
        return;
    }
    if (findText == null || findText.isDisposed()) {
        return;
    }
    String selectedText = textViewer.getTextWidget().getSelectionText();
    if (selectedText == null || selectedText.trim().length() == 0) {
        return;
    }
    if (findText.getItems() != null && Arrays.asList(findText.getItems()).contains(selectedText)) {
        findText.setText(selectedText);
    } else {
        findText.add(selectedText);
        findText.setText(selectedText);
    }
    writeConfiguration();
}
Also used : TextViewer(org.eclipse.jface.text.TextViewer)

Example 9 with TextViewer

use of org.eclipse.jface.text.TextViewer in project eclipse.platform.text by eclipse.

the class TextViewerTest method testSetRedraw_Bug441827.

@Test
public void testSetRedraw_Bug441827() throws Exception {
    Shell shell = new Shell();
    try {
        TextViewer textViewer = new TextViewer(shell, SWT.NONE);
        Document document = new Document("abc");
        textViewer.setDocument(document);
        int len = document.getLength();
        // Select the whole document with the caret at the beginning.
        textViewer.setSelectedRange(len, -len);
        assertEquals(0, textViewer.getSelectedRange().x);
        assertEquals(len, textViewer.getSelectedRange().y);
        assertEquals(0, textViewer.getTextWidget().getCaretOffset());
        textViewer.setRedraw(false);
        textViewer.setRedraw(true);
        // Check that the selection and the caret position are preserved.
        assertEquals(0, textViewer.getSelectedRange().x);
        assertEquals(len, textViewer.getSelectedRange().y);
        assertEquals(0, textViewer.getTextWidget().getCaretOffset());
    } finally {
        shell.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Document(org.eclipse.jface.text.Document) TextViewer(org.eclipse.jface.text.TextViewer) Test(org.junit.Test)

Example 10 with TextViewer

use of org.eclipse.jface.text.TextViewer in project linuxtools by eclipse.

the class OcountView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    viewer = new TextViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    viewer.setEditable(false);
    viewer.getTextWidget().setFont(JFaceResources.getFont(IDebugUIConstants.PREF_DETAIL_PANE_FONT));
    Control control = viewer.getControl();
    GridData gd = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(gd);
    Document d = new Document(text);
    viewer.setDocument(d);
    viewer.refresh();
    OprofileUiPlugin.getDefault().setOcountView(this);
    this.parent = parent;
}
Also used : Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData) Document(org.eclipse.jface.text.Document) TextViewer(org.eclipse.jface.text.TextViewer)

Aggregations

TextViewer (org.eclipse.jface.text.TextViewer)17 StyledText (org.eclipse.swt.custom.StyledText)6 Document (org.eclipse.jface.text.Document)3 Control (org.eclipse.swt.widgets.Control)3 Shell (org.eclipse.swt.widgets.Shell)3 FindReplaceOption (com.cubrid.tool.editor.dialog.FindReplaceOption)2 IAction (org.eclipse.jface.action.IAction)2 IFindReplaceTarget (org.eclipse.jface.text.IFindReplaceTarget)2 ResourceBundle (java.util.ResourceBundle)1 IFindReplaceTargetExtension (org.eclipse.jface.text.IFindReplaceTargetExtension)1 IFindReplaceTargetExtension3 (org.eclipse.jface.text.IFindReplaceTargetExtension3)1 ITextViewer (org.eclipse.jface.text.ITextViewer)1 IUndoManager (org.eclipse.jface.text.IUndoManager)1 Region (org.eclipse.jface.text.Region)1 GridData (org.eclipse.swt.layout.GridData)1 Accessor (org.eclipse.text.tests.Accessor)1 Before (org.junit.Before)1 Test (org.junit.Test)1