Search in sources :

Example 11 with TextViewer

use of org.eclipse.jface.text.TextViewer in project dbeaver by serge-rider.

the class BaseTextEditor method enableUndoManager.

public void enableUndoManager(boolean enable) {
    TextViewer textViewer = getTextViewer();
    final IUndoManager undoManager = textViewer.getUndoManager();
    if (undoManager != null) {
        if (!enable) {
            undoManager.disconnect();
        } else {
            undoManager.connect(textViewer);
        }
    }
}
Also used : IUndoManager(org.eclipse.jface.text.IUndoManager) TextViewer(org.eclipse.jface.text.TextViewer)

Example 12 with TextViewer

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

the class TextEditorFindReplaceMediator method findAndSelect.

/**
	 * Find and select the searched string
	 *
	 * @param start start position.
	 * @param isWrap is warp search.
	 * @param isForward is forward
	 * @return the location of string.
	 */
public static int findAndSelect(int start, boolean isForward, FindReplaceOption option) {
    TextViewer st = getCurrentTextEditor();
    if (st == null) {
        return -1;
    }
    IFindReplaceTargetExtension findReplace = getFindAndReplaceInterface1();
    if (findReplace == null) {
        return -1;
    }
    if (option.isSearchAll()) {
        findReplace.setScope(null);
    } else {
        findReplace.setScope(new Region(st.getSelectedRange().x, st.getSelectedRange().y));
    }
    int widgetOffset = start >= 0 ? start : st.getTextWidget().getCaretOffset();
    widgetOffset = isForward ? widgetOffset : (widgetOffset - option.getSearchedStr().length() - 1);
    IFindReplaceTargetExtension3 target = getFindAndReplaceInterface2();
    if (target == null) {
        return -1;
    }
    int result = target.findAndSelect(widgetOffset, option.getSearchedStr(), isForward, option.isCaseSensitive(), option.isWholeWord(), option.isRegularExpressions());
    if (result < 0 && option.isWrapSearch()) {
        result = target.findAndSelect(isForward ? 0 : st.getTextWidget().getText().length() - 1, option.getSearchedStr(), isForward, option.isCaseSensitive(), option.isWholeWord(), option.isRegularExpressions());
    }
    return result;
}
Also used : IFindReplaceTargetExtension3(org.eclipse.jface.text.IFindReplaceTargetExtension3) Region(org.eclipse.jface.text.Region) IFindReplaceTargetExtension(org.eclipse.jface.text.IFindReplaceTargetExtension) TextViewer(org.eclipse.jface.text.TextViewer)

Example 13 with TextViewer

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

the class FindReplaceDialog method updateButtons.

/**
	 * Update the buttons status.
	 * 
	 */
public void updateButtons() {
    if (findText == null || findText.isDisposed()) {
        return;
    }
    TextViewer textViewer = TextEditorFindReplaceMediator.getCurrentTextEditor();
    boolean isCanFind = textViewer != null && findText.getText().length() > 0;
    boolean isCanReplace = isCanFind && textViewer.isEditable() && textViewer.getTextWidget().isEnabled();
    btnFind.setEnabled(isCanFind);
    btnReplaceAndFind.setEnabled(isCanReplace && isTextSelected());
    btnReplace.setEnabled(isCanReplace && isTextSelected());
    btnReplaceAll.setEnabled(isCanReplace);
    btnWholeWord.setEnabled(!btnRegularExpressions.getSelection());
    btnIncremental.setEnabled(!btnRegularExpressions.getSelection());
}
Also used : TextViewer(org.eclipse.jface.text.TextViewer)

Example 14 with TextViewer

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

the class UndoAction method focusGained.

/**
	 * Notifies that the focus gained event
	 * 
	 * @param event an event containing information about the focus change
	 */
public void focusGained(FocusEvent event) {
    setEnabled(false);
    if (event.getSource() instanceof StyledText) {
        StyledText stext = (StyledText) event.getSource();
        Object obj = stext.getData(SQLEditorComposite.SQL_EDITOR_FLAG);
        boolean isEnabled = obj instanceof TextViewer;
        if (isEnabled) {
            TextViewer viewer = (TextViewer) obj;
            isEnabled = viewer.getUndoManager() != null && viewer.getUndoManager().undoable();
        }
        setEnabled(isEnabled);
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) TextViewer(org.eclipse.jface.text.TextViewer)

Example 15 with TextViewer

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

the class GotoLineAction method focusGained.

public void focusGained(FocusEvent event) {
    setEnabled(false);
    if (event.getSource() instanceof StyledText) {
        StyledText stext = (StyledText) event.getSource();
        Object obj = stext.getData(SQLEditorComposite.SQL_EDITOR_FLAG);
        setEnabled(obj instanceof TextViewer);
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) 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