use of org.jkiss.dbeaver.model.data.DBDBinaryFormatter in project dbeaver by serge-rider.
the class DBValueFormatting method formatBinaryString.
public static String formatBinaryString(@NotNull DBPDataSource dataSource, @NotNull byte[] data, @NotNull DBDDisplayFormat format, boolean forceLimit) {
DBDBinaryFormatter formatter;
if (format == DBDDisplayFormat.NATIVE && dataSource instanceof SQLDataSource) {
formatter = ((SQLDataSource) dataSource).getSQLDialect().getNativeBinaryFormatter();
} else {
formatter = getBinaryPresentation(dataSource);
}
// Convert bytes to string
int length = data.length;
if (format == DBDDisplayFormat.UI || forceLimit) {
int maxLength = dataSource.getContainer().getPreferenceStore().getInt(ModelPreferences.RESULT_SET_BINARY_STRING_MAX_LEN);
if (length > maxLength) {
length = maxLength;
}
}
String string = formatter.toString(data, 0, length);
if (format == DBDDisplayFormat.NATIVE || length == data.length) {
// Do not append ... for native formatter - it may contain expressions
return string;
}
return string + "..." + " [" + data.length + "]";
}
use of org.jkiss.dbeaver.model.data.DBDBinaryFormatter in project dbeaver by serge-rider.
the class PrefPageResultSetBinaries method loadPreferences.
@Override
protected void loadPreferences(DBPPreferenceStore store) {
try {
memoryContentSize.setSelection(store.getInt(DBeaverPreferences.MEMORY_CONTENT_MAX_SIZE));
binaryStringMaxLength.setSelection(store.getInt(ModelPreferences.RESULT_SET_BINARY_STRING_MAX_LEN));
DBDBinaryFormatter formatter = DBValueFormatting.getBinaryPresentation(store.getString(ModelPreferences.RESULT_SET_BINARY_PRESENTATION));
for (int i = 0; i < binaryPresentationCombo.getItemCount(); i++) {
if (binaryPresentationCombo.getItem(i).equals(formatter.getTitle())) {
binaryPresentationCombo.select(i);
break;
}
}
IValueController.EditType editorType = IValueController.EditType.valueOf(store.getString(DBeaverPreferences.RESULT_SET_BINARY_EDITOR_TYPE));
if (editorType == IValueController.EditType.EDITOR) {
binaryEditorType.select(0);
} else {
binaryEditorType.select(1);
}
UIUtils.setComboSelection(encodingCombo, store.getString(ModelPreferences.CONTENT_HEX_ENCODING));
contentCacheClob.setSelection(store.getBoolean(ModelPreferences.CONTENT_CACHE_CLOB));
contentCacheBlob.setSelection(store.getBoolean(ModelPreferences.CONTENT_CACHE_BLOB));
contentCacheMaxSize.setSelection(store.getInt(ModelPreferences.CONTENT_CACHE_MAX_SIZE));
editLongAsLobCheck.setSelection(store.getBoolean(DBeaverPreferences.RS_EDIT_LONG_AS_LOB));
maxTextContentSize.setSelection(store.getInt(DBeaverPreferences.RS_EDIT_MAX_TEXT_SIZE));
commitOnEditApplyCheck.setSelection(store.getBoolean(DBeaverPreferences.RS_COMMIT_ON_EDIT_APPLY));
commitOnContentApplyCheck.setSelection(store.getBoolean(DBeaverPreferences.RS_COMMIT_ON_CONTENT_APPLY));
} catch (Exception e) {
log.warn(e);
}
}
use of org.jkiss.dbeaver.model.data.DBDBinaryFormatter in project dbeaver by serge-rider.
the class PrefPageResultSetBinaries method savePreferences.
@Override
protected void savePreferences(DBPPreferenceStore store) {
try {
store.setValue(DBeaverPreferences.MEMORY_CONTENT_MAX_SIZE, memoryContentSize.getSelection());
String presentationTitle = binaryPresentationCombo.getItem(binaryPresentationCombo.getSelectionIndex());
for (DBDBinaryFormatter formatter : DBConstants.BINARY_FORMATS) {
if (formatter.getTitle().equals(presentationTitle)) {
store.setValue(ModelPreferences.RESULT_SET_BINARY_PRESENTATION, formatter.getId());
break;
}
}
store.setValue(ModelPreferences.RESULT_SET_BINARY_STRING_MAX_LEN, binaryStringMaxLength.getSelection());
store.setValue(DBeaverPreferences.RESULT_SET_BINARY_EDITOR_TYPE, binaryEditorType.getSelectionIndex() == 0 ? IValueController.EditType.EDITOR.name() : IValueController.EditType.PANEL.name());
store.setValue(ModelPreferences.CONTENT_HEX_ENCODING, UIUtils.getComboSelection(encodingCombo));
store.setValue(ModelPreferences.CONTENT_CACHE_CLOB, contentCacheClob.getSelection());
store.setValue(ModelPreferences.CONTENT_CACHE_BLOB, contentCacheBlob.getSelection());
store.setValue(ModelPreferences.CONTENT_CACHE_MAX_SIZE, contentCacheMaxSize.getSelection());
store.setValue(DBeaverPreferences.RS_EDIT_LONG_AS_LOB, editLongAsLobCheck.getSelection());
store.setValue(DBeaverPreferences.RS_EDIT_MAX_TEXT_SIZE, maxTextContentSize.getSelection());
store.setValue(DBeaverPreferences.RS_COMMIT_ON_EDIT_APPLY, commitOnEditApplyCheck.getSelection());
store.setValue(DBeaverPreferences.RS_COMMIT_ON_CONTENT_APPLY, commitOnContentApplyCheck.getSelection());
} catch (Exception e) {
log.warn(e);
}
PrefUtils.savePreferenceStore(store);
}
Aggregations