use of org.jkiss.dbeaver.ui.controls.StyledTextFindReplaceTarget in project dbeaver by serge-rider.
the class PlainTextPresentation method createPresentation.
@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
super.createPresentation(controller, parent);
UIUtils.createHorizontalLine(parent);
text = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
text.setBlockSelection(true);
text.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_IBEAM));
text.setMargins(4, 4, 4, 4);
text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
text.setLayoutData(new GridData(GridData.FILL_BOTH));
text.addCaretListener(new CaretListener() {
@Override
public void caretMoved(CaretEvent event) {
onCursorChange(event.caretOffset);
}
});
text.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
curSelection = text.getSelectionText();
fireSelectionChanged(new PlainTextSelectionImpl());
}
});
final ScrollBar verticalBar = text.getVerticalBar();
verticalBar.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (verticalBar.getSelection() + verticalBar.getPageIncrement() >= verticalBar.getMaximum()) {
if (controller.getPreferenceStore().getBoolean(DBeaverPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT) && !controller.isRecordMode() && controller.isHasMoreData()) {
controller.readNextSegment();
}
}
}
});
findReplaceTarget = new StyledTextFindReplaceTarget(text);
UIUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), text);
applyThemeSettings();
registerContextMenu();
trackPresentationControl();
}
Aggregations