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);
}
}
}
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;
}
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());
}
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);
}
}
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);
}
}
Aggregations