Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
12f07b1a
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,发现更多精彩内容 >>
提交
12f07b1a
编写于
1月 23, 2013
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Image content viewer
Use plain text control for text content
上级
9268fd60
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
38 deletion
+46
-38
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
...dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
+44
-20
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/imageview/ImageEditor.java
.../org/jkiss/dbeaver/ui/controls/imageview/ImageEditor.java
+1
-9
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/imageview/ImageViewer.java
.../org/jkiss/dbeaver/ui/controls/imageview/ImageViewer.java
+1
-9
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
浏览文件 @
12f07b1a
...
...
@@ -23,10 +23,11 @@ import org.apache.commons.logging.LogFactory;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.StyledText
;
import
org.eclipse.swt.graphics.Image
;
import
org.eclipse.swt.graphics.ImageData
;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.swt.widgets.Text
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
...
...
@@ -43,10 +44,8 @@ import org.jkiss.dbeaver.model.impl.StringContentStorage;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.ui.DBIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.imageview.ImageEditor
;
import
org.jkiss.dbeaver.ui.controls.imageview.ImageViewer
;
import
org.jkiss.dbeaver.ui.editors.binary.BinaryContent
;
import
org.jkiss.dbeaver.ui.editors.binary.HexEditControl
;
...
...
@@ -349,8 +348,8 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
try
{
DBDContent
content
=
(
DBDContent
)
valueController
.
getValue
();
DBDContentStorage
data
=
content
.
getContents
(
monitor
);
if
(
control
instanceof
Styled
Text
)
{
StyledText
text
=
(
Styled
Text
)
control
;
if
(
control
instanceof
Text
)
{
Text
text
=
(
Text
)
control
;
StringWriter
buffer
=
new
StringWriter
();
if
(
data
!=
null
)
{
ContentUtils
.
copyStreams
(
data
.
getContentReader
(),
-
1
,
buffer
,
monitor
);
...
...
@@ -379,8 +378,8 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
{
DBDContent
content
=
(
DBDContent
)
valueController
.
getValue
();
try
{
if
(
control
instanceof
Styled
Text
)
{
StyledText
styledText
=
(
Styled
Text
)
control
;
if
(
control
instanceof
Text
)
{
Text
styledText
=
(
Text
)
control
;
content
.
updateContents
(
monitor
,
new
StringContentStorage
(
styledText
.
getText
()));
...
...
@@ -408,21 +407,16 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
{
DBDContent
content
=
(
DBDContent
)
valueController
.
getValue
();
if
(
ContentUtils
.
isTextContent
(
content
))
{
return
new
StyledText
(
editPlaceholder
,
SWT
.
BORDER
);
Text
text
=
new
Text
(
editPlaceholder
,
SWT
.
BORDER
|
SWT
.
MULTI
|
SWT
.
WRAP
|
SWT
.
V_SCROLL
);
text
.
setEditable
(!
valueController
.
isReadOnly
());
return
text
;
}
else
{
boolean
isImage
=
false
;
ImageDetector
imageDetector
=
new
ImageDetector
(
content
)
;
if
(!
content
.
isNull
())
{
try
{
ImageData
imageData
=
new
ImageData
(
content
.
getContents
(
VoidProgressMonitor
.
INSTANCE
).
getContentStream
());
new
Image
(
editPlaceholder
.
getDisplay
(),
imageData
).
dispose
();
isImage
=
true
;
}
catch
(
Exception
e
)
{
// this is not an image
}
DBeaverUI
.
runInUI
(
valueController
.
getValueSite
().
getWorkbenchWindow
(),
imageDetector
);
}
if
(
i
sImage
)
{
if
(
i
mageDetector
.
isImage
()
)
{
return
new
ImageViewer
(
editPlaceholder
,
SWT
.
BORDER
);
}
else
{
return
new
HexEditControl
(
editPlaceholder
,
SWT
.
BORDER
);
...
...
@@ -540,4 +534,34 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
}
}
private
static
class
ImageDetector
implements
DBRRunnableWithProgress
{
private
final
DBDContent
content
;
private
boolean
isImage
;
private
ImageDetector
(
DBDContent
content
)
{
this
.
content
=
content
;
}
public
boolean
isImage
()
{
return
isImage
;
}
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
if
(!
content
.
isNull
())
{
try
{
new
ImageData
(
content
.
getContents
(
monitor
).
getContentStream
());
isImage
=
true
;
}
catch
(
Exception
e
)
{
// this is not an image
}
}
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/imageview/ImageEditor.java
浏览文件 @
12f07b1a
...
...
@@ -32,15 +32,7 @@ import org.jkiss.dbeaver.ui.UIUtils;
import
java.io.InputStream
;
/**
* A scrollable image canvas that extends org.eclipse.swt.graphics.Canvas.
* <p/>
* It requires Eclipse (version >= 2.1) on Win32/win32; Linux/gtk; MacOSX/carbon.
* <p/>
* This implementation using the pure SWT, no UI AWT package is used. For
* convenience, I put everything into one class. However, the best way to
* implement this is to use inheritance to create multiple hierarchies.
*
* @author Chengdong Li: cli4@uky.edu
* Image editor, based on image viewer.
*/
public
class
ImageEditor
extends
ImageViewer
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/imageview/ImageViewer.java
浏览文件 @
12f07b1a
...
...
@@ -33,15 +33,7 @@ import org.jkiss.dbeaver.ui.UIUtils;
import
java.io.InputStream
;
/**
* A scrollable image canvas that extends org.eclipse.swt.graphics.Canvas.
* <p/>
* It requires Eclipse (version >= 2.1) on Win32/win32; Linux/gtk; MacOSX/carbon.
* <p/>
* This implementation using the pure SWT, no UI AWT package is used. For
* convenience, I put everything into one class. However, the best way to
* implement this is to use inheritance to create multiple hierarchies.
*
* @author Chengdong Li: cli4@uky.edu
* Image viewer control
*/
public
class
ImageViewer
extends
Composite
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录