Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
f557cc69
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,发现更多精彩内容 >>
提交
f557cc69
编写于
2月 01, 2013
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Complex type model refactoring
Support of reference data type Complex object editor improved
上级
ab77730a
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
416 addition
and
34 deletion
+416
-34
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDArray.java
...eaver.core/src/org/jkiss/dbeaver/model/data/DBDArray.java
+0
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDComplexType.java
...core/src/org/jkiss/dbeaver/model/data/DBDComplexType.java
+2
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDReference.java
...r.core/src/org/jkiss/dbeaver/model/data/DBDReference.java
+24
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDStructure.java
...r.core/src/org/jkiss/dbeaver/model/data/DBDStructure.java
+0
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCArray.java
...src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCArray.java
+19
-10
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCArrayValueHandler.java
...s/dbeaver/model/impl/jdbc/data/JDBCArrayValueHandler.java
+1
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCReference.java
...org/jkiss/dbeaver/model/impl/jdbc/data/JDBCReference.java
+98
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCReferenceValueHandler.java
...eaver/model/impl/jdbc/data/JDBCReferenceValueHandler.java
+146
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStandardValueHandlerProvider.java
...odel/impl/jdbc/data/JDBCStandardValueHandlerProvider.java
+2
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStruct.java
...rc/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStruct.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStructValueHandler.java
.../dbeaver/model/impl/jdbc/data/JDBCStructValueHandler.java
+2
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCDataType.java
...rg/jkiss/dbeaver/model/impl/jdbc/struct/JDBCDataType.java
+3
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/struct/DBSDataKind.java
....core/src/org/jkiss/dbeaver/model/struct/DBSDataKind.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/ComplexObjectEditor.java
...rg/jkiss/dbeaver/ui/dialogs/data/ComplexObjectEditor.java
+72
-11
plugins/org.jkiss.dbeaver.erd/src/org/jkiss/dbeaver/ext/erd/model/DiagramObjectCollector.java
...g/jkiss/dbeaver/ext/erd/model/DiagramObjectCollector.java
+5
-0
plugins/org.jkiss.dbeaver.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java
...er.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java
+6
-1
plugins/org.jkiss.dbeaver.oracle/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.oracle/META-INF/MANIFEST.MF
+1
-1
plugins/org.jkiss.dbeaver.oracle/src/org/jkiss/dbeaver/ext/oracle/data/OracleXMLValueHandler.java
.../jkiss/dbeaver/ext/oracle/data/OracleXMLValueHandler.java
+23
-0
plugins/org.jkiss.dbeaver.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleDataTypeAttribute.java
...iss/dbeaver/ext/oracle/model/OracleDataTypeAttribute.java
+5
-0
plugins/org.jkiss.dbeaver.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleTableColumn.java
...org/jkiss/dbeaver/ext/oracle/model/OracleTableColumn.java
+4
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
f557cc69
...
...
@@ -1791,6 +1791,7 @@
<type
standard=
"STRUCT"
/>
<type
standard=
"ARRAY"
/>
<type
standard=
"REF"
/>
<type
standard=
"BLOB"
/>
<type
standard=
"CLOB"
/>
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDArray.java
浏览文件 @
f557cc69
...
...
@@ -30,8 +30,6 @@ import org.jkiss.dbeaver.model.struct.DBSTypedObject;
*/
public
interface
DBDArray
extends
DBDComplexType
{
DBSDataType
getElementType
();
Object
[]
getContents
()
throws
DBCException
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDComplexType.java
浏览文件 @
f557cc69
package
org.jkiss.dbeaver.model.data
;
import
org.jkiss.dbeaver.model.
DBPDataSourc
e
;
import
org.jkiss.dbeaver.model.
struct.DBSDataTyp
e
;
/**
* Complex type
*/
public
interface
DBDComplexType
extends
DBDValue
{
DBSDataType
getObjectDataType
();
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDReference.java
0 → 100644
浏览文件 @
f557cc69
package
org.jkiss.dbeaver.model.data
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSDataType
;
import
java.util.Collection
;
/**
* Reference to another object (usually DBDStructure).
*/
public
interface
DBDReference
extends
DBDComplexType
{
/**
* Retrieves referenced object.
* Object is retrieved in lazy way because references may point to owner objects in circular way.
* @return referenced object
* @throws DBCException
*/
Object
getReferencedObject
(
DBCExecutionContext
context
)
throws
DBCException
;
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDStructure.java
浏览文件 @
f557cc69
...
...
@@ -15,8 +15,6 @@ import java.util.Collection;
*/
public
interface
DBDStructure
extends
DBDComplexType
{
DBSDataType
getStructType
();
Collection
<
DBSAttributeBase
>
getAttributes
();
Object
getAttributeValue
(
DBSAttributeBase
attribute
)
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCArray.java
浏览文件 @
f557cc69
...
...
@@ -72,13 +72,17 @@ public class JDBCArray implements DBDArray, DBDValueCloneable {
Object
[]
contents
=
null
;
try
{
contents
=
extractDataFromArray
(
context
,
array
,
type
,
valueHandler
);
}
catch
(
Exception
e
)
{
try
{
contents
=
extractDataFromResultSet
(
context
,
array
,
type
,
valueHandler
);
}
catch
(
Exception
e1
)
{
log
.
warn
(
"Could not extract array data from JDBC array"
);
//$NON-NLS-1$
contents
=
extractDataFromArray
(
context
,
array
,
type
,
valueHandler
);
}
catch
(
SQLException
e
)
{
try
{
contents
=
extractDataFromResultSet
(
context
,
array
,
type
,
valueHandler
);
}
catch
(
SQLException
e1
)
{
throw
new
DBCException
(
"Error reading from array result set"
,
e1
);
//$NON-NLS-1$
}
}
}
catch
(
DBCException
e
)
{
log
.
warn
(
"Can't extract array data from JDBC array"
,
e
);
//$NON-NLS-1$
}
return
new
JDBCArray
(
type
,
contents
);
}
...
...
@@ -91,11 +95,16 @@ public class JDBCArray implements DBDArray, DBDValueCloneable {
}
try
{
DBCResultSet
resultSet
=
JDBCResultSetImpl
.
makeResultSet
(
context
,
dbResult
,
CoreMessages
.
model_jdbc_array_result_set
);
List
<
Object
>
data
=
new
ArrayList
<
Object
>();
while
(
dbResult
.
next
())
{
data
.
add
(
valueHandler
.
fetchValueObject
(
context
,
resultSet
,
type
,
0
));
try
{
List
<
Object
>
data
=
new
ArrayList
<
Object
>();
while
(
dbResult
.
next
())
{
// Fetch second column - it contains value
data
.
add
(
valueHandler
.
fetchValueObject
(
context
,
resultSet
,
type
,
1
));
}
return
data
.
toArray
();
}
finally
{
resultSet
.
close
();
}
return
data
.
toArray
();
}
finally
{
try
{
...
...
@@ -129,7 +138,7 @@ public class JDBCArray implements DBDArray, DBDValueCloneable {
}
@Override
public
DBSDataType
get
Element
Type
()
public
DBSDataType
get
ObjectData
Type
()
{
return
type
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCArrayValueHandler.java
浏览文件 @
f557cc69
...
...
@@ -154,14 +154,13 @@ public class JDBCArrayValueHandler extends JDBCAbstractValueHandler {
@Override
public
void
refreshValue
()
{
editor
.
setModel
((
DBDArray
)
valueController
.
getValue
());
editor
.
setModel
(
valueController
.
getDataSource
(),
(
DBDArray
)
valueController
.
getValue
());
}
@Override
protected
Tree
createControl
(
Composite
editPlaceholder
)
{
editor
=
new
ComplexObjectEditor
(
valueController
.
getEditPlaceholder
(),
SWT
.
BORDER
);
editor
.
setModel
((
DBDArray
)
valueController
.
getValue
());
return
editor
.
getTree
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCReference.java
0 → 100644
浏览文件 @
f557cc69
/*
* 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.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.data.DBDReference
;
import
org.jkiss.dbeaver.model.data.DBDValueHandler
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.struct.DBSDataType
;
import
java.sql.Ref
;
import
java.sql.SQLException
;
/**
* Reference holder
*/
public
class
JDBCReference
implements
DBDReference
{
static
final
Log
log
=
LogFactory
.
getLog
(
JDBCReference
.
class
);
private
DBSDataType
type
;
private
Ref
value
;
private
JDBCReference
()
{
}
public
JDBCReference
(
DBSDataType
type
,
Ref
value
)
throws
DBCException
{
this
.
type
=
type
;
this
.
value
=
value
;
}
public
Ref
getValue
()
throws
DBCException
{
return
value
;
}
@Override
public
boolean
isNull
()
{
return
value
==
null
;
}
@Override
public
void
release
()
{
type
=
null
;
value
=
null
;
}
@Override
public
DBSDataType
getObjectDataType
()
{
return
type
;
}
@Override
public
Object
getReferencedObject
(
DBCExecutionContext
context
)
throws
DBCException
{
try
{
Object
refValue
=
value
.
getObject
();
DBDValueHandler
valueHandler
=
DBUtils
.
findValueHandler
(
context
,
type
);
return
valueHandler
.
getValueFromObject
(
context
,
type
,
refValue
,
false
);
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
"Can't obtain object reference"
);
}
}
@Override
public
String
toString
()
{
try
{
return
"REF on "
+
value
.
getBaseTypeName
();
}
catch
(
SQLException
e
)
{
return
value
==
null
?
super
.
toString
()
:
value
.
toString
();
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCReferenceValueHandler.java
0 → 100644
浏览文件 @
f557cc69
/*
* 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.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.Ref
;
import
java.sql.SQLException
;
/**
* JDBC reference value handler.
* Handle STRUCT types.
*
* @author Serge Rider
*/
public
class
JDBCReferenceValueHandler
extends
JDBCAbstractValueHandler
{
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.
*/
@Override
public
synchronized
String
getValueDisplayString
(
DBSTypedObject
column
,
Object
value
,
DBDDisplayFormat
format
)
{
JDBCReference
reference
=
(
JDBCReference
)
value
;
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
,
JDBCPreparedStatement
statement
,
DBSTypedObject
paramType
,
int
paramIndex
,
Object
value
)
throws
DBCException
,
SQLException
{
JDBCReference
reference
=
(
JDBCReference
)
value
;
statement
.
setRef
(
paramIndex
,
reference
.
getValue
());
}
@Override
public
Class
getValueObjectType
()
{
return
Ref
.
class
;
}
@Override
public
JDBCReference
getValueFromObject
(
DBCExecutionContext
context
,
DBSTypedObject
type
,
Object
object
,
boolean
copy
)
throws
DBCException
{
String
typeName
;
try
{
if
(
object
instanceof
Ref
)
{
typeName
=
((
Ref
)
object
).
getBaseTypeName
();
}
else
{
typeName
=
type
.
getTypeName
();
}
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
);
}
DBSDataType
dataType
=
null
;
try
{
dataType
=
DBUtils
.
resolveDataType
(
context
.
getProgressMonitor
(),
context
.
getDataSource
(),
typeName
);
}
catch
(
DBException
e
)
{
log
.
error
(
"Error resolving data type '"
+
typeName
+
"'"
,
e
);
}
if
(
object
==
null
)
{
return
new
JDBCReference
(
dataType
,
null
);
}
else
if
(
object
instanceof
JDBCReference
)
{
return
(
JDBCReference
)
object
;
}
else
if
(
object
instanceof
Ref
)
{
return
new
JDBCReference
(
dataType
,
(
Ref
)
object
);
}
else
{
throw
new
DBCException
(
"Unsupported struct type: "
+
object
.
getClass
().
getName
());
}
}
@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/JDBCStandardValueHandlerProvider.java
浏览文件 @
f557cc69
...
...
@@ -63,6 +63,8 @@ public class JDBCStandardValueHandlerProvider implements DBDValueHandlerProvider
return
JDBCArrayValueHandler
.
INSTANCE
;
case
STRUCT:
return
JDBCStructValueHandler
.
INSTANCE
;
case
REFERENCE:
return
JDBCReferenceValueHandler
.
INSTANCE
;
default
:
return
null
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStruct.java
浏览文件 @
f557cc69
...
...
@@ -155,7 +155,7 @@ public class JDBCStruct implements DBDStructure, DBDValueCloneable {
}
@Override
public
DBSDataType
get
Struct
Type
()
public
DBSDataType
get
ObjectData
Type
()
{
return
type
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStructValueHandler.java
浏览文件 @
f557cc69
...
...
@@ -182,14 +182,14 @@ public class JDBCStructValueHandler extends JDBCAbstractValueHandler {
@Override
public
void
refreshValue
()
{
editor
.
setModel
((
DBDStructure
)
controller
.
getValue
());
editor
.
setModel
(
controller
.
getDataSource
(),
(
DBDStructure
)
controller
.
getValue
());
}
@Override
protected
Tree
createControl
(
Composite
editPlaceholder
)
{
editor
=
new
ComplexObjectEditor
(
controller
.
getEditPlaceholder
(),
SWT
.
BORDER
);
editor
.
setModel
((
DBDStructure
)
controller
.
getValue
());
editor
.
setModel
(
controller
.
getDataSource
(),
(
DBDStructure
)
controller
.
getValue
());
return
editor
.
getTree
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCDataType.java
浏览文件 @
f557cc69
...
...
@@ -220,6 +220,9 @@ public class JDBCDataType implements DBSDataType
case
Types
.
ROWID
:
// threat ROWID as string
return
DBSDataKind
.
STRING
;
case
Types
.
REF
:
return
DBSDataKind
.
REFERENCE
;
}
return
DBSDataKind
.
UNKNOWN
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/struct/DBSDataKind.java
浏览文件 @
f557cc69
...
...
@@ -33,5 +33,6 @@ public enum DBSDataKind
STRUCT
,
ARRAY
,
OBJECT
,
REFERENCE
,
UNKNOWN
,
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/ComplexObjectEditor.java
浏览文件 @
f557cc69
...
...
@@ -29,13 +29,20 @@ 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.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
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
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithResult
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Collection
;
/**
...
...
@@ -45,6 +52,8 @@ public class ComplexObjectEditor extends TreeViewer {
static
final
Log
log
=
LogFactory
.
getLog
(
ComplexObjectEditor
.
class
);
private
DBPDataSource
dataSource
;
public
ComplexObjectEditor
(
Composite
parent
,
int
style
)
{
super
(
parent
,
style
|
SWT
.
SINGLE
|
SWT
.
FULL_SELECTION
);
...
...
@@ -62,6 +71,9 @@ public class ComplexObjectEditor extends TreeViewer {
if
(!
packing
)
{
packing
=
true
;
UIUtils
.
packColumns
(
treeControl
,
true
,
new
float
[]{
0.2f
,
0.8f
});
if
(
treeControl
.
getColumn
(
0
).
getWidth
()
<
100
)
{
treeControl
.
getColumn
(
0
).
setWidth
(
100
);
}
treeControl
.
removeControlListener
(
this
);
}
}
...
...
@@ -85,12 +97,13 @@ public class ComplexObjectEditor extends TreeViewer {
super
.
setContentProvider
(
new
StructContentProvider
());
}
public
void
setModel
(
final
DBDComplexType
value
)
public
void
setModel
(
DBPDataSource
dataSource
,
final
DBDComplexType
value
)
{
getTree
().
setRedraw
(
false
);
try
{
this
.
dataSource
=
dataSource
;
setInput
(
value
);
expand
All
(
);
expand
ToLevel
(
2
);
}
finally
{
getTree
().
setRedraw
(
true
);
}
...
...
@@ -120,7 +133,7 @@ public class ComplexObjectEditor extends TreeViewer {
this
.
array
=
array
;
this
.
index
=
index
;
this
.
value
=
value
;
this
.
valueHandler
=
DBUtils
.
findValueHandler
(
array
.
get
ElementType
().
getDataSource
(),
array
.
getElement
Type
());
this
.
valueHandler
=
DBUtils
.
findValueHandler
(
array
.
get
ObjectDataType
().
getDataSource
(),
array
.
getObjectData
Type
());
}
}
...
...
@@ -163,7 +176,7 @@ public class ComplexObjectEditor extends TreeViewer {
int
index
=
0
;
for
(
DBSAttributeBase
attr
:
attributes
)
{
Object
value
=
structure
.
getAttributeValue
(
attr
);
children
[
index
++]
=
new
FieldInfo
(
structure
.
get
Struct
Type
().
getDataSource
(),
attr
,
value
);
children
[
index
++]
=
new
FieldInfo
(
structure
.
get
ObjectData
Type
().
getDataSource
(),
attr
,
value
);
}
return
children
;
}
catch
(
DBException
e
)
{
...
...
@@ -181,9 +194,38 @@ public class ComplexObjectEditor extends TreeViewer {
}
catch
(
DBCException
e
)
{
log
.
error
(
"Error getting array content"
,
e
);
}
}
else
if
(
parent
instanceof
DBDReference
)
{
final
DBDReference
reference
=
(
DBDReference
)
parent
;
DBRRunnableWithResult
<
Object
>
runnable
=
new
DBRRunnableWithResult
<
Object
>()
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
DBCExecutionContext
context
=
dataSource
.
openContext
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Read reference value"
);
try
{
result
=
reference
.
getReferencedObject
(
context
);
}
catch
(
DBCException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
finally
{
context
.
close
();
}
}
};
try
{
DBeaverUI
.
runInProgressService
(
runnable
);
}
catch
(
InvocationTargetException
e
)
{
UIUtils
.
showErrorDialog
(
getControl
().
getShell
(),
"Value read"
,
"Error read reference"
,
e
.
getTargetException
());
}
catch
(
InterruptedException
e
)
{
// ok
}
return
getChildren
(
runnable
.
getResult
());
}
else
if
(
parent
instanceof
FieldInfo
)
{
Object
value
=
((
FieldInfo
)
parent
).
value
;
if
(
value
instanceof
DBDStructure
||
value
instanceof
DBDArray
)
{
if
(
value
instanceof
DBDComplexType
)
{
return
getChildren
(
value
);
}
}
else
if
(
parent
instanceof
ArrayItem
)
{
Object
value
=
((
ArrayItem
)
parent
).
value
;
if
(
value
instanceof
DBDComplexType
)
{
return
getChildren
(
value
);
}
}
...
...
@@ -193,7 +235,12 @@ public class ComplexObjectEditor extends TreeViewer {
@Override
public
boolean
hasChildren
(
Object
parent
)
{
return
getChildren
(
parent
).
length
>
0
;
return
parent
instanceof
DBDStructure
||
parent
instanceof
DBDArray
||
parent
instanceof
DBDReference
||
(
parent
instanceof
FieldInfo
&&
hasChildren
(((
FieldInfo
)
parent
).
value
))
||
(
parent
instanceof
ArrayItem
&&
hasChildren
(((
ArrayItem
)
parent
).
value
));
}
}
...
...
@@ -212,20 +259,34 @@ public class ComplexObjectEditor extends TreeViewer {
if
(
isName
)
{
return
field
.
attribute
.
getName
();
}
if
(
field
.
value
instanceof
DBDStructure
)
{
return
""
;
}
return
field
.
valueHandler
.
getValueDisplayString
(
field
.
attribute
,
field
.
value
,
DBDDisplayFormat
.
UI
);
return
getValueText
(
field
.
valueHandler
,
field
.
attribute
,
field
.
value
);
}
else
if
(
obj
instanceof
ArrayItem
)
{
ArrayItem
item
=
(
ArrayItem
)
obj
;
if
(
isName
)
{
return
String
.
valueOf
(
item
.
index
);
}
return
item
.
valueHandler
.
getValueDisplayString
(
item
.
array
.
getElementType
(),
item
.
value
,
DBDDisplayFormat
.
UI
);
return
getValueText
(
item
.
valueHandler
,
item
.
array
.
getObjectDataType
(),
item
.
value
);
}
return
String
.
valueOf
(
columnIndex
);
}
private
String
getValueText
(
DBDValueHandler
valueHandler
,
DBSTypedObject
type
,
Object
value
)
{
if
(
value
instanceof
DBDArray
)
{
try
{
Object
[]
contents
=
((
DBDArray
)
value
).
getContents
();
return
"["
+
((
DBDArray
)
value
).
getObjectDataType
().
getName
()
+
" - "
+
String
.
valueOf
(
contents
==
null
?
0
:
contents
.
length
)
+
"]"
;
}
catch
(
DBCException
e
)
{
log
.
error
(
e
);
return
"N/A"
;
}
}
if
(
value
instanceof
DBDComplexType
)
{
return
"["
+
((
DBDComplexType
)
value
).
getObjectDataType
().
getName
()
+
"]"
;
}
return
valueHandler
.
getValueDisplayString
(
type
,
value
,
DBDDisplayFormat
.
UI
);
}
@Override
public
String
getToolTipText
(
Object
obj
)
{
...
...
plugins/org.jkiss.dbeaver.erd/src/org/jkiss/dbeaver/ext/erd/model/DiagramObjectCollector.java
浏览文件 @
f557cc69
...
...
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.DBPHiddenObject
;
import
org.jkiss.dbeaver.model.DBPNamedObject
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
...
...
@@ -114,6 +115,10 @@ public class DiagramObjectCollector {
{
Collection
<
DBSEntity
>
tables
=
collectTables
(
monitor
,
roots
);
for
(
DBSEntity
table
:
tables
)
{
if
(
table
instanceof
DBPHiddenObject
&&
((
DBPHiddenObject
)
table
).
isHidden
())
{
// Skip hidden tables
continue
;
}
addDiagramEntity
(
monitor
,
table
);
}
...
...
plugins/org.jkiss.dbeaver.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java
浏览文件 @
f557cc69
...
...
@@ -23,6 +23,7 @@ package org.jkiss.dbeaver.ext.erd.model;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.ext.erd.editor.ERDAttributeVisibility
;
import
org.jkiss.dbeaver.model.DBPHiddenObject
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.*
;
...
...
@@ -257,6 +258,10 @@ public class ERDEntity extends ERDObject<DBSEntity>
// usual thing in some systems like WMI/CIM model
continue
;
}
if
(
attribute
instanceof
DBPHiddenObject
&&
((
DBPHiddenObject
)
attribute
).
isHidden
())
{
// Skip hidden attributes
continue
;
}
switch
(
attributeVisibility
)
{
case
PRIMARY:
if
(!
idColumns
.
contains
(
attribute
))
{
...
...
@@ -264,7 +269,7 @@ public class ERDEntity extends ERDObject<DBSEntity>
}
break
;
case
KEYS:
if
(!
keyColumns
.
contains
(
attribute
))
{
if
(
keyColumns
==
null
||
!
keyColumns
.
contains
(
attribute
))
{
continue
;
}
break
;
...
...
plugins/org.jkiss.dbeaver.oracle/META-INF/MANIFEST.MF
浏览文件 @
f557cc69
...
...
@@ -14,5 +14,5 @@ Require-Bundle: org.eclipse.ui,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Serge Rieder
Bundle-ClassPath: .
,external:$DRIVERS_LOCATION$/oracle/ojdbc6.jar
Bundle-ClassPath: .
Bundle-Localization: plugin
plugins/org.jkiss.dbeaver.oracle/src/org/jkiss/dbeaver/ext/oracle/data/OracleXMLValueHandler.java
浏览文件 @
f557cc69
...
...
@@ -25,6 +25,9 @@ import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
import
org.jkiss.dbeaver.model.impl.jdbc.data.JDBCContentValueHandler
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Method
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLXML
;
...
...
@@ -44,6 +47,26 @@ public class OracleXMLValueHandler extends JDBCContentValueHandler {
object
=
resultSet
.
getObject
(
index
);
}
catch
(
SQLException
e
)
{
object
=
resultSet
.
getSQLXML
(
index
);
/*
try {
object = resultSet.getSQLXML(index);
} catch (SQLException e1) {
try {
ResultSet originalRS = resultSet.getOriginal();
Class<?> rsClass = originalRS.getClass().getClassLoader().loadClass("oracle.jdbc.OracleResultSet");
Method method = rsClass.getMethod("getOPAQUE", Integer.TYPE);
object = method.invoke(originalRS, index);
if (object != null) {
Class<?> xmlType = object.getClass().getClassLoader().loadClass("oracle.xdb.XMLType");
Method xmlConstructor = xmlType.getMethod("createXML", object.getClass());
object = xmlConstructor.invoke(null, object);
}
}
catch (Throwable e2) {
object = null;
}
}
*/
}
if
(
object
==
null
)
{
...
...
plugins/org.jkiss.dbeaver.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleDataTypeAttribute.java
浏览文件 @
f557cc69
...
...
@@ -26,6 +26,7 @@ import org.jkiss.dbeaver.model.struct.DBSDataType;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
java.sql.ResultSet
;
import
java.sql.Types
;
/**
* Oracle data type attribute
...
...
@@ -96,6 +97,10 @@ public class OracleDataTypeAttribute extends OracleDataTypeMember implements DBS
@Override
public
int
getTypeID
()
{
if
(
attrTypeMod
==
OracleDataTypeModifier
.
REF
)
{
// Explicitly say that we are reference
return
Types
.
REF
;
}
return
attrType
.
getTypeID
();
}
...
...
plugins/org.jkiss.dbeaver.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleTableColumn.java
浏览文件 @
f557cc69
...
...
@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.ui.DBIcon;
import
org.jkiss.dbeaver.ui.properties.IPropertyValueListProvider
;
import
java.sql.ResultSet
;
import
java.sql.Types
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -74,6 +75,9 @@ public class OracleTableColumn extends JDBCTableColumn<OracleTableBase> implemen
this
.
typeName
=
type
.
getFullQualifiedName
();
this
.
valueType
=
type
.
getTypeID
();
}
if
(
typeMod
==
OracleDataTypeModifier
.
REF
)
{
this
.
valueType
=
Types
.
REF
;
}
setMaxLength
(
JDBCUtils
.
safeGetLong
(
dbResult
,
"DATA_LENGTH"
));
setRequired
(!
"Y"
.
equals
(
JDBCUtils
.
safeGetString
(
dbResult
,
"NULLABLE"
)));
setScale
(
JDBCUtils
.
safeGetInt
(
dbResult
,
"DATA_SCALE"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录