use of org.jkiss.dbeaver.model.impl.BytesContentStorage in project dbeaver by serge-rider.
the class BinaryPanelEditor method extractEditorValue.
@Override
public void extractEditorValue(@NotNull DBRProgressMonitor monitor, @NotNull HexEditControl control, @NotNull DBDContent value) throws DBException {
BinaryContent binaryContent = control.getContent();
ByteBuffer buffer = ByteBuffer.allocate((int) binaryContent.length());
try {
binaryContent.get(buffer, 0);
} catch (IOException e) {
log.error(e);
}
value.updateContents(monitor, new BytesContentStorage(buffer.array(), GeneralUtils.getDefaultFileEncoding()));
}
use of org.jkiss.dbeaver.model.impl.BytesContentStorage 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(VoidProgressMonitor.INSTANCE, new StringContentStorage(newValue));
} else {
content.updateContents(VoidProgressMonitor.INSTANCE, new BytesContentStorage(newValue.getBytes(GeneralUtils.getDefaultFileEncoding()), GeneralUtils.getDefaultFileEncoding()));
}
} catch (Exception e) {
log.error(e);
}
return content;
}
use of org.jkiss.dbeaver.model.impl.BytesContentStorage in project dbeaver by serge-rider.
the class DBDDocumentContentProxy method updateDocument.
@Override
public void updateDocument(@NotNull DBRProgressMonitor monitor, @NotNull InputStream stream, String encoding) throws DBException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ContentUtils.copyStreams(stream, -1, baos, monitor);
content.updateContents(monitor, new BytesContentStorage(baos.toByteArray(), encoding));
document.updateDocument(monitor, new ByteArrayInputStream(baos.toByteArray()), encoding);
} catch (IOException e) {
throw new DBException("Error transforming XML document", e);
}
}
Aggregations