Search in sources :

Example 6 with StringContentStorage

use of org.jkiss.dbeaver.model.data.storage.StringContentStorage in project dbeaver by dbeaver.

the class AbstractTextPanelEditor method extractEditorValue.

@Override
public void extractEditorValue(@NotNull DBRProgressMonitor monitor, @NotNull StyledText control, @NotNull DBDContent value) throws DBException {
    if (valueController.getValue() instanceof DBDContent) {
        monitor.beginTask("Extract text", 1);
        try {
            monitor.subTask("Extracting text from editor");
            editor.doSave(RuntimeUtils.getNestedMonitor(monitor));
            final IEditorInput editorInput = editor.getEditorInput();
            if (editorInput instanceof ContentEditorInput) {
                final ContentEditorInput contentEditorInput = (ContentEditorInput) editorInput;
                contentEditorInput.updateContentFromFile(monitor, value);
            }
        } catch (Exception e) {
            throw new DBException("Error extracting text from editor", e);
        } finally {
            monitor.done();
        }
    } else {
        value.updateContents(monitor, new StringContentStorage(control.getText()));
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBDContent(org.jkiss.dbeaver.model.data.DBDContent) ContentEditorInput(org.jkiss.dbeaver.ui.editors.content.ContentEditorInput) StringContentStorage(org.jkiss.dbeaver.model.data.storage.StringContentStorage) IEditorInput(org.eclipse.ui.IEditorInput) PartInitException(org.eclipse.ui.PartInitException) DBException(org.jkiss.dbeaver.DBException)

Aggregations

StringContentStorage (org.jkiss.dbeaver.model.data.storage.StringContentStorage)6 DBException (org.jkiss.dbeaver.DBException)4 DBDContent (org.jkiss.dbeaver.model.data.DBDContent)4 IOException (java.io.IOException)2 Reader (java.io.Reader)2 StringWriter (java.io.StringWriter)2 IEditorInput (org.eclipse.ui.IEditorInput)2 PartInitException (org.eclipse.ui.PartInitException)2 BytesContentStorage (org.jkiss.dbeaver.model.data.storage.BytesContentStorage)2 DBCException (org.jkiss.dbeaver.model.exec.DBCException)2 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)2 ContentEditorInput (org.jkiss.dbeaver.ui.editors.content.ContentEditorInput)2