use of org.jkiss.dbeaver.model.data.storage.StringContentStorage in project dbeaver by serge-rider.
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()));
}
}
use of org.jkiss.dbeaver.model.data.storage.StringContentStorage in project dbeaver by serge-rider.
the class StringContent method updateContents.
@Override
public boolean updateContents(DBRProgressMonitor monitor, DBDContentStorage storage) throws DBException {
try {
try (Reader reader = storage.getContentReader()) {
StringWriter sw = new StringWriter((int) storage.getContentLength());
ContentUtils.copyStreams(reader, storage.getContentLength(), sw, monitor);
this.storage = new StringContentStorage(sw.toString());
}
} catch (IOException e) {
throw new DBCException("IO error while reading content", e);
}
return true;
}
use of org.jkiss.dbeaver.model.data.storage.StringContentStorage in project dbeaver by dbeaver.
the class StringContent method updateContents.
@Override
public boolean updateContents(DBRProgressMonitor monitor, DBDContentStorage storage) throws DBException {
try {
try (Reader reader = storage.getContentReader()) {
StringWriter sw = new StringWriter((int) storage.getContentLength());
ContentUtils.copyStreams(reader, storage.getContentLength(), sw, monitor);
this.storage = new StringContentStorage(sw.toString());
}
} catch (IOException e) {
throw new DBCException("IO error while reading content", e);
}
return true;
}
use of org.jkiss.dbeaver.model.data.storage.StringContentStorage in project dbeaver by dbeaver.
the class ContentInlineEditor method extractEditorValue.
@Override
public Object extractEditorValue() {
String newValue = control.getText();
final DBDContent content = (DBDContent) valueController.getValue();
assert content != null;
try {
if (isText) {
content.updateContents(new VoidProgressMonitor(), new StringContentStorage(newValue));
} else {
content.updateContents(new VoidProgressMonitor(), new BytesContentStorage(newValue.getBytes(GeneralUtils.getDefaultFileEncoding()), GeneralUtils.getDefaultFileEncoding()));
}
} catch (Exception e) {
log.error(e);
}
return content;
}
use of org.jkiss.dbeaver.model.data.storage.StringContentStorage in project dbeaver by serge-rider.
the class ContentInlineEditor method extractEditorValue.
@Override
public Object extractEditorValue() {
String newValue = control.getText();
final DBDContent content = (DBDContent) valueController.getValue();
assert content != null;
try {
if (isText) {
content.updateContents(new VoidProgressMonitor(), new StringContentStorage(newValue));
} else {
content.updateContents(new VoidProgressMonitor(), new BytesContentStorage(newValue.getBytes(GeneralUtils.getDefaultFileEncoding()), GeneralUtils.getDefaultFileEncoding()));
}
} catch (Exception e) {
log.error(e);
}
return content;
}
Aggregations