Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
1e723e25
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
1e723e25
编写于
2月 03, 2013
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Complex types value handler
上级
b9421d7d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
140 addition
and
248 deletion
+140
-248
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCArrayValueHandler.java
...s/dbeaver/model/impl/jdbc/data/JDBCArrayValueHandler.java
+2
-105
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCComplexValueHandler.java
...dbeaver/model/impl/jdbc/data/JDBCComplexValueHandler.java
+136
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCReferenceValueHandler.java
...eaver/model/impl/jdbc/data/JDBCReferenceValueHandler.java
+1
-26
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStructValueHandler.java
.../dbeaver/model/impl/jdbc/data/JDBCStructValueHandler.java
+1
-117
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCArrayValueHandler.java
浏览文件 @
1e723e25
...
...
@@ -20,29 +20,14 @@ package org.jkiss.dbeaver.model.impl.jdbc.data;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Tree
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.data.DBDArray
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.data.DBDValueEditor
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.dialogs.data.ComplexObjectEditor
;
import
org.jkiss.dbeaver.ui.dialogs.data.DefaultValueViewDialog
;
import
org.jkiss.dbeaver.ui.properties.PropertySourceAbstract
;
import
java.sql.Array
;
import
java.sql.SQLException
;
/**
* JDBC Array value handler.
...
...
@@ -50,46 +35,16 @@ import java.sql.SQLException;
*
* @author Serge Rider
*/
public
class
JDBCArrayValueHandler
extends
JDBC
Abstract
ValueHandler
{
public
class
JDBCArrayValueHandler
extends
JDBC
Complex
ValueHandler
{
static
final
Log
log
=
LogFactory
.
getLog
(
JDBCArrayValueHandler
.
class
);
public
static
final
JDBCArrayValueHandler
INSTANCE
=
new
JDBCArrayValueHandler
();
@Override
protected
Object
fetchColumnValue
(
DBCExecutionContext
context
,
JDBCResultSet
resultSet
,
DBSTypedObject
type
,
int
index
)
throws
DBCException
,
SQLException
{
Object
value
=
resultSet
.
getObject
(
index
);
return
getValueFromObject
(
context
,
type
,
value
,
false
);
}
@Override
protected
void
bindParameter
(
JDBCExecutionContext
context
,
JDBCPreparedStatement
statement
,
DBSTypedObject
paramType
,
int
paramIndex
,
Object
value
)
throws
DBCException
,
SQLException
{
throw
new
DBCException
(
CoreMessages
.
model_jdbc_exception_unsupported_value_type_
+
value
);
}
@Override
public
int
getFeatures
()
{
return
FEATURE_VIEWER
|
FEATURE_EDITOR
;
}
@Override
public
Class
getValueObjectType
()
{
return
DBD
Array
.
class
;
return
Array
.
class
;
}
@Override
...
...
@@ -118,63 +73,5 @@ public class JDBCArrayValueHandler extends JDBCAbstractValueHandler {
return
super
.
getValueDisplayString
(
column
,
value
,
format
);
}
@Override
public
void
fillContextMenu
(
IMenuManager
menuManager
,
final
DBDValueController
controller
)
throws
DBCException
{
}
@Override
public
void
fillProperties
(
PropertySourceAbstract
propertySource
,
DBDValueController
controller
)
{
try
{
Object
value
=
controller
.
getValue
();
if
(
value
instanceof
DBDArray
)
{
/*
propertySource.addProperty(
"array_length",
"Length",
((DBDArray)value).getLength());
*/
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"Could not extract array value information"
,
e
);
}
}
@Override
public
DBDValueEditor
createEditor
(
DBDValueController
controller
)
throws
DBException
{
switch
(
controller
.
getEditType
())
{
case
PANEL:
return
new
ValueEditor
<
Tree
>(
controller
)
{
ComplexObjectEditor
editor
;
@Override
public
void
refreshValue
()
{
editor
.
setModel
(
valueController
.
getDataSource
(),
(
DBDArray
)
valueController
.
getValue
());
}
@Override
protected
Tree
createControl
(
Composite
editPlaceholder
)
{
editor
=
new
ComplexObjectEditor
(
valueController
.
getEditPlaceholder
(),
SWT
.
BORDER
);
return
editor
.
getTree
();
}
@Override
public
Object
extractValue
(
DBRProgressMonitor
monitor
)
{
return
editor
.
getInput
();
}
};
case
EDITOR:
return
new
DefaultValueViewDialog
(
controller
);
default
:
return
null
;
}
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCComplexValueHandler.java
0 → 100644
浏览文件 @
1e723e25
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.model.impl.jdbc.data
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Tree
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.data.DBDComplexType
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.data.DBDValueEditor
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.dialogs.data.ComplexObjectEditor
;
import
org.jkiss.dbeaver.ui.dialogs.data.DefaultValueViewDialog
;
import
org.jkiss.dbeaver.ui.properties.PropertySourceAbstract
;
import
java.sql.SQLException
;
/**
* Complex value handler.
* Handle complex types.
*
* @author Serge Rider
*/
public
abstract
class
JDBCComplexValueHandler
extends
JDBCAbstractValueHandler
{
static
final
Log
log
=
LogFactory
.
getLog
(
JDBCComplexValueHandler
.
class
);
@Override
public
int
getFeatures
()
{
return
FEATURE_VIEWER
|
FEATURE_EDITOR
|
FEATURE_SHOW_ICON
;
}
@Override
protected
Object
fetchColumnValue
(
DBCExecutionContext
context
,
JDBCResultSet
resultSet
,
DBSTypedObject
type
,
int
index
)
throws
DBCException
,
SQLException
{
Object
value
=
resultSet
.
getObject
(
index
);
return
getValueFromObject
(
context
,
type
,
value
,
false
);
}
@Override
protected
void
bindParameter
(
JDBCExecutionContext
context
,
JDBCPreparedStatement
statement
,
DBSTypedObject
paramType
,
int
paramIndex
,
Object
value
)
throws
DBCException
,
SQLException
{
throw
new
DBCException
(
"Unsupported value type: "
+
value
);
}
@Override
public
void
fillProperties
(
PropertySourceAbstract
propertySource
,
DBDValueController
controller
)
{
try
{
Object
value
=
controller
.
getValue
();
if
(
value
instanceof
DBDComplexType
)
{
propertySource
.
addProperty
(
"object_type"
,
//$NON-NLS-1$
CoreMessages
.
model_jdbc_type_name
,
((
DBDComplexType
)
value
).
getObjectDataType
().
getName
());
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"Could not extract complex type information"
,
e
);
//$NON-NLS-1$
}
}
@Override
public
DBDValueEditor
createEditor
(
final
DBDValueController
controller
)
throws
DBException
{
switch
(
controller
.
getEditType
())
{
case
PANEL:
return
new
ValueEditor
<
Tree
>(
controller
)
{
ComplexObjectEditor
editor
;
@Override
public
void
refreshValue
()
{
editor
.
setModel
(
controller
.
getDataSource
(),
(
DBDComplexType
)
controller
.
getValue
());
}
@Override
protected
Tree
createControl
(
Composite
editPlaceholder
)
{
editor
=
new
ComplexObjectEditor
(
controller
.
getEditPlaceholder
(),
SWT
.
BORDER
);
editor
.
setModel
(
controller
.
getDataSource
(),
(
DBDComplexType
)
controller
.
getValue
());
return
editor
.
getTree
();
}
@Override
public
Object
extractValue
(
DBRProgressMonitor
monitor
)
{
return
editor
.
getInput
();
}
};
case
EDITOR:
return
new
DefaultValueViewDialog
(
controller
);
default
:
return
null
;
}
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCReferenceValueHandler.java
浏览文件 @
1e723e25
...
...
@@ -53,18 +53,12 @@ import java.sql.SQLException;
*
* @author Serge Rider
*/
public
class
JDBCReferenceValueHandler
extends
JDBC
Abstract
ValueHandler
{
public
class
JDBCReferenceValueHandler
extends
JDBC
Complex
ValueHandler
{
static
final
Log
log
=
LogFactory
.
getLog
(
JDBCReferenceValueHandler
.
class
);
public
static
final
JDBCReferenceValueHandler
INSTANCE
=
new
JDBCReferenceValueHandler
();
@Override
public
int
getFeatures
()
{
return
FEATURE_VIEWER
|
FEATURE_EDITOR
|
FEATURE_SHOW_ICON
;
}
/**
* NumberFormat is not thread safe thus this method is synchronized.
*/
...
...
@@ -75,18 +69,6 @@ public class JDBCReferenceValueHandler extends JDBCAbstractValueHandler {
return
reference
==
null
||
reference
.
isNull
()
?
DBConstants
.
NULL_VALUE_LABEL
:
reference
.
toString
();
}
@Override
protected
Object
fetchColumnValue
(
DBCExecutionContext
context
,
JDBCResultSet
resultSet
,
DBSTypedObject
type
,
int
index
)
throws
DBCException
,
SQLException
{
Ref
value
=
resultSet
.
getRef
(
index
);
return
getValueFromObject
(
context
,
type
,
value
,
false
);
}
@Override
protected
void
bindParameter
(
JDBCExecutionContext
context
,
...
...
@@ -136,11 +118,4 @@ public class JDBCReferenceValueHandler extends JDBCAbstractValueHandler {
}
}
@Override
public
DBDValueEditor
createEditor
(
final
DBDValueController
controller
)
throws
DBException
{
return
null
;
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStructValueHandler.java
浏览文件 @
1e723e25
...
...
@@ -20,29 +20,14 @@ package org.jkiss.dbeaver.model.impl.jdbc.data;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Tree
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBConstants
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.model.data.DBDStructure
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.data.DBDValueEditor
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSDataType
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.dialogs.data.ComplexObjectEditor
;
import
org.jkiss.dbeaver.ui.dialogs.data.DefaultValueViewDialog
;
import
org.jkiss.dbeaver.ui.properties.PropertySourceAbstract
;
import
java.sql.SQLException
;
import
java.sql.Struct
;
...
...
@@ -53,18 +38,12 @@ import java.sql.Struct;
*
* @author Serge Rider
*/
public
class
JDBCStructValueHandler
extends
JDBC
Abstract
ValueHandler
{
public
class
JDBCStructValueHandler
extends
JDBC
Complex
ValueHandler
{
static
final
Log
log
=
LogFactory
.
getLog
(
JDBCStructValueHandler
.
class
);
public
static
final
JDBCStructValueHandler
INSTANCE
=
new
JDBCStructValueHandler
();
@Override
public
int
getFeatures
()
{
return
FEATURE_VIEWER
|
FEATURE_EDITOR
|
FEATURE_SHOW_ICON
;
}
/**
* NumberFormat is not thread safe thus this method is synchronized.
*/
...
...
@@ -75,30 +54,6 @@ public class JDBCStructValueHandler extends JDBCAbstractValueHandler {
return
struct
==
null
||
struct
.
isNull
()
?
DBConstants
.
NULL_VALUE_LABEL
:
struct
.
getStringRepresentation
();
}
@Override
protected
Object
fetchColumnValue
(
DBCExecutionContext
context
,
JDBCResultSet
resultSet
,
DBSTypedObject
type
,
int
index
)
throws
DBCException
,
SQLException
{
Object
value
=
resultSet
.
getObject
(
index
);
return
getValueFromObject
(
context
,
type
,
value
,
false
);
}
@Override
protected
void
bindParameter
(
JDBCExecutionContext
context
,
JDBCPreparedStatement
statement
,
DBSTypedObject
paramType
,
int
paramIndex
,
Object
value
)
throws
DBCException
,
SQLException
{
throw
new
DBCException
(
"Unsupported value type: "
+
value
);
}
@Override
public
Class
getValueObjectType
()
{
...
...
@@ -135,75 +90,4 @@ public class JDBCStructValueHandler extends JDBCAbstractValueHandler {
}
}
/*
public String getValueDisplayString(DBSTypedObject column, Object value)
{
if (value instanceof JDBCStruct) {
String displayString = value.toString();
if (displayString != null) {
return displayString;
}
}
return super.getValueDisplayString(column, value);
}
*/
@Override
public
void
fillContextMenu
(
IMenuManager
menuManager
,
final
DBDValueController
controller
)
throws
DBCException
{
}
@Override
public
void
fillProperties
(
PropertySourceAbstract
propertySource
,
DBDValueController
controller
)
{
try
{
Object
value
=
controller
.
getValue
();
if
(
value
instanceof
JDBCStruct
)
{
propertySource
.
addProperty
(
"sql_type"
,
//$NON-NLS-1$
CoreMessages
.
model_jdbc_type_name
,
((
JDBCStruct
)
value
).
getTypeName
());
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"Could not extract struct value information"
,
e
);
//$NON-NLS-1$
}
}
@Override
public
DBDValueEditor
createEditor
(
final
DBDValueController
controller
)
throws
DBException
{
switch
(
controller
.
getEditType
())
{
case
PANEL:
return
new
ValueEditor
<
Tree
>(
controller
)
{
ComplexObjectEditor
editor
;
@Override
public
void
refreshValue
()
{
editor
.
setModel
(
controller
.
getDataSource
(),
(
DBDStructure
)
controller
.
getValue
());
}
@Override
protected
Tree
createControl
(
Composite
editPlaceholder
)
{
editor
=
new
ComplexObjectEditor
(
controller
.
getEditPlaceholder
(),
SWT
.
BORDER
);
editor
.
setModel
(
controller
.
getDataSource
(),
(
DBDStructure
)
controller
.
getValue
());
return
editor
.
getTree
();
}
@Override
public
Object
extractValue
(
DBRProgressMonitor
monitor
)
{
return
editor
.
getInput
();
}
};
case
EDITOR:
return
new
DefaultValueViewDialog
(
controller
);
default
:
return
null
;
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录