use of org.jkiss.dbeaver.model.data.storage.BytesContentStorage in project dbeaver by dbeaver.
the class BinaryPanelEditor method extractEditorValue.
@Override
public void extractEditorValue(@NotNull DBRProgressMonitor monitor, @NotNull HexEditControl control, @NotNull DBDContent value) throws DBException {
BinaryContent binaryContent = control.getContent();
if (binaryContent != null) {
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.data.storage.BytesContentStorage in project dbeaver by dbeaver.
the class DBDDocumentContentProxy method updateDocument.
@Override
public void updateDocument(@NotNull DBRProgressMonitor monitor, @NotNull InputStream stream, Charset charset) throws DBException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ContentUtils.copyStreams(stream, -1, baos, monitor);
content.updateContents(monitor, new BytesContentStorage(baos.toByteArray(), charset));
document.updateDocument(monitor, new ByteArrayInputStream(baos.toByteArray()), charset);
} catch (IOException e) {
throw new DBException("Error transforming XML document", e);
}
}
use of org.jkiss.dbeaver.model.data.storage.BytesContentStorage 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.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();
if (binaryContent != null) {
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.data.storage.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(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