Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
dbcab98b
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dbcab98b
编写于
6月 13, 2013
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Binary presentation in editors
Former-commit-id:
955b4a4a
上级
0fb14ec2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
16 deletion
+27
-16
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BinaryPresentationString.java
...iss/dbeaver/model/impl/data/BinaryPresentationString.java
+4
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentBytes.java
.../jkiss/dbeaver/model/impl/jdbc/data/JDBCContentBytes.java
+5
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
...dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
+10
-8
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/TextViewDialog.java
...src/org/jkiss/dbeaver/ui/dialogs/data/TextViewDialog.java
+5
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/utils/ContentUtils.java
...beaver.core/src/org/jkiss/dbeaver/utils/ContentUtils.java
+3
-3
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BinaryPresentationString.java
浏览文件 @
dbcab98b
...
...
@@ -19,6 +19,7 @@
package
org.jkiss.dbeaver.model.impl.data
;
import
org.jkiss.dbeaver.model.data.DBDBinaryPresentation
;
import
org.jkiss.dbeaver.utils.ContentUtils
;
/**
* String presentation
...
...
@@ -40,12 +41,13 @@ public class BinaryPresentationString implements DBDBinaryPresentation {
@Override
public
String
toString
(
byte
[]
bytes
,
int
offset
,
int
length
)
{
return
null
;
return
ContentUtils
.
convertToString
(
bytes
,
offset
,
length
)
;
}
@Override
public
byte
[]
toBytes
(
String
string
)
{
return
new
byte
[
0
]
;
return
ContentUtils
.
convertToBytes
(
string
)
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentBytes.java
浏览文件 @
dbcab98b
...
...
@@ -63,6 +63,11 @@ public class JDBCContentBytes extends JDBCContentAbstract implements DBDContentS
this
.
data
=
this
.
originalData
=
data
;
}
public
JDBCContentBytes
(
DBPDataSource
dataSource
,
String
data
)
{
super
(
dataSource
);
this
.
data
=
this
.
originalData
=
DBUtils
.
getBinaryPresentation
(
dataSource
).
toBytes
(
data
);
}
@Override
public
InputStream
getContentStream
()
throws
IOException
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
浏览文件 @
dbcab98b
...
...
@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.ext.IContentEditorPart
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.data.*
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
...
...
@@ -56,6 +57,7 @@ import org.jkiss.dbeaver.ui.editors.content.parts.ContentBinaryEditorPart;
import
org.jkiss.dbeaver.ui.editors.content.parts.ContentImageEditorPart
;
import
org.jkiss.dbeaver.ui.editors.content.parts.ContentTextEditorPart
;
import
org.jkiss.dbeaver.ui.editors.content.parts.ContentXMLEditorPart
;
import
org.jkiss.dbeaver.ui.preferences.PrefConstants
;
import
org.jkiss.dbeaver.ui.properties.PropertySourceAbstract
;
import
org.jkiss.dbeaver.utils.ContentUtils
;
import
org.jkiss.dbeaver.utils.MimeTypes
;
...
...
@@ -187,7 +189,7 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
case
java
.
sql
.
Types
.
BINARY
:
case
java
.
sql
.
Types
.
VARBINARY
:
case
java
.
sql
.
Types
.
LONGVARBINARY
:
return
new
JDBCContentBytes
(
context
.
getDataSource
(),
ContentUtils
.
convertToBytes
((
String
)
object
)
);
return
new
JDBCContentBytes
(
context
.
getDataSource
(),
(
String
)
object
);
default
:
// String by default
return
new
JDBCContentChars
(
context
.
getDataSource
(),
(
String
)
object
);
...
...
@@ -288,7 +290,8 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
if
(
cachedValue
==
null
)
{
stringValue
=
""
;
//$NON-NLS-1$
}
else
if
(
cachedValue
instanceof
byte
[])
{
stringValue
=
ContentUtils
.
convertToString
((
byte
[])
cachedValue
);
byte
[]
bytes
=
(
byte
[])
cachedValue
;
stringValue
=
DBUtils
.
getBinaryPresentation
(
controller
.
getDataSource
()).
toString
(
bytes
,
0
,
bytes
.
length
);
}
else
{
stringValue
=
cachedValue
.
toString
();
}
...
...
@@ -319,7 +322,7 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
}
else
{
return
new
JDBCContentBytes
(
valueController
.
getDataSource
(),
ContentUtils
.
convertToBytes
(
newValue
)
);
newValue
);
}
}
};
...
...
@@ -331,13 +334,12 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
{
// Open LOB editor
Object
value
=
controller
.
getValue
();
/*if (value instanceof DBDContentCached) {
DBDValueController
.
EditType
binaryEditType
=
DBDValueController
.
EditType
.
valueOf
(
controller
.
getDataSource
().
getContainer
().
getPreferenceStore
().
getString
(
PrefConstants
.
RESULT_SET_BINARY_EDITOR_TYPE
));
if
(
binaryEditType
!=
DBDValueController
.
EditType
.
EDITOR
&&
value
instanceof
DBDContentCached
)
{
// Use string editor for cached content
return
new
TextViewDialog
(
controller
);
} else */
// Always use separate editor
// content could be an image or something huge so it is not an option to open text editor
if
(
value
instanceof
DBDContent
)
{
}
else
if
(
value
instanceof
DBDContent
)
{
DBDContent
content
=
(
DBDContent
)
value
;
boolean
isText
=
ContentUtils
.
isTextContent
(
content
);
List
<
IContentEditorPart
>
parts
=
new
ArrayList
<
IContentEditorPart
>();
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/TextViewDialog.java
浏览文件 @
dbcab98b
...
...
@@ -293,9 +293,10 @@ public class TextViewDialog extends ValueViewDialog {
}
if
(
value
instanceof
byte
[])
{
// Binary
textEdit
.
setText
(
ContentUtils
.
convertToString
((
byte
[])
value
));
byte
[]
bytes
=
(
byte
[])
value
;
textEdit
.
setText
(
DBUtils
.
getBinaryPresentation
(
getValueController
().
getDataSource
()).
toString
(
bytes
,
0
,
bytes
.
length
));
if
(
hexEditControl
!=
null
)
{
hexEditControl
.
setContent
(
(
byte
[])
value
);
hexEditControl
.
setContent
(
bytes
);
}
}
else
{
// Should be string
...
...
@@ -307,7 +308,8 @@ public class TextViewDialog extends ValueViewDialog {
String
strValue
=
CommonUtils
.
toString
(
value
);
textEdit
.
setText
(
strValue
);
if
(
hexEditControl
!=
null
)
{
setBinaryContent
(
strValue
);
byte
[]
bytes
=
DBUtils
.
getBinaryPresentation
(
getValueController
().
getDataSource
()).
toBytes
(
strValue
);
hexEditControl
.
setContent
(
bytes
);
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/utils/ContentUtils.java
浏览文件 @
dbcab98b
...
...
@@ -550,10 +550,10 @@ public class ContentUtils {
return
fileEncoding
;
}
public
static
String
convertToString
(
byte
[]
bytes
)
public
static
String
convertToString
(
byte
[]
bytes
,
int
offset
,
int
length
)
{
char
[]
chars
=
new
char
[
bytes
.
length
];
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
char
[]
chars
=
new
char
[
length
];
for
(
int
i
=
offset
;
i
<
offset
+
length
;
i
++)
{
int
b
=
bytes
[
i
];
if
(
b
<
0
)
{
b
=
-
b
+
127
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录