Search in sources :

Example 1 with BinaryContent

use of org.jkiss.dbeaver.ui.editors.binary.BinaryContent in project dbeaver by serge-rider.

the class TextViewDialog method getBinaryContent.

private byte[] getBinaryContent() {
    BinaryContent content = hexEditControl.getContent();
    ByteBuffer buffer = ByteBuffer.allocate((int) content.length());
    try {
        content.get(buffer, 0);
    } catch (IOException e) {
        log.error(e);
    }
    return buffer.array();
}
Also used : IOException(java.io.IOException) BinaryContent(org.jkiss.dbeaver.ui.editors.binary.BinaryContent) ByteBuffer(java.nio.ByteBuffer)

Example 2 with BinaryContent

use of org.jkiss.dbeaver.ui.editors.binary.BinaryContent 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()));
}
Also used : BytesContentStorage(org.jkiss.dbeaver.model.impl.BytesContentStorage) IOException(java.io.IOException) BinaryContent(org.jkiss.dbeaver.ui.editors.binary.BinaryContent) ByteBuffer(java.nio.ByteBuffer)

Aggregations

IOException (java.io.IOException)2 ByteBuffer (java.nio.ByteBuffer)2 BinaryContent (org.jkiss.dbeaver.ui.editors.binary.BinaryContent)2 BytesContentStorage (org.jkiss.dbeaver.model.impl.BytesContentStorage)1