Search in sources :

Example 1 with StyledTextFindReplaceTarget

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();
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) StyledTextFindReplaceTarget(org.jkiss.dbeaver.ui.controls.StyledTextFindReplaceTarget) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Aggregations

SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 ScrollBar (org.eclipse.swt.widgets.ScrollBar)1 StyledTextFindReplaceTarget (org.jkiss.dbeaver.ui.controls.StyledTextFindReplaceTarget)1