Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
595d50aa
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,发现更多精彩内容 >>
提交
595d50aa
编写于
1月 18, 2016
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Data type registry
上级
d4f73944
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
486 addition
and
455 deletion
+486
-455
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
....dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
+3
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataTypeTransformerDescriptor.java
...jkiss/dbeaver/registry/DataTypeTransformerDescriptor.java
+0
-149
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeAbstractDescriptor.java
...dbeaver/registry/datatype/DataTypeAbstractDescriptor.java
+170
-149
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeProviderDescriptor.java
...dbeaver/registry/datatype/DataTypeProviderDescriptor.java
+33
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeProviderRegistry.java
...s/dbeaver/registry/datatype/DataTypeProviderRegistry.java
+124
-116
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeRendererDescriptor.java
...dbeaver/registry/datatype/DataTypeRendererDescriptor.java
+48
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeTransformerDescriptor.java
...aver/registry/datatype/DataTypeTransformerDescriptor.java
+35
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPApplication.java
...ver.model/src/org/jkiss/dbeaver/model/DBPApplication.java
+2
-2
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDRegistry.java
...r.model/src/org/jkiss/dbeaver/model/data/DBDRegistry.java
+36
-36
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDRegistryDescriptor.java
...c/org/jkiss/dbeaver/model/data/DBDRegistryDescriptor.java
+34
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
浏览文件 @
595d50aa
...
...
@@ -9,6 +9,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: org.jkiss.dbeaver,
org.jkiss.dbeaver.core,
org.jkiss.dbeaver.registry,
org.jkiss.dbeaver.registry.datatype,
org.jkiss.dbeaver.registry.driver,
org.jkiss.dbeaver.registry.editor,
org.jkiss.dbeaver.registry.encode,
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
浏览文件 @
595d50aa
...
...
@@ -31,7 +31,7 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.model.DBPApplication
;
import
org.jkiss.dbeaver.model.DBPPreferenceStore
;
import
org.jkiss.dbeaver.model.DBPProjectManager
;
import
org.jkiss.dbeaver.model.data.DBD
ValueHandler
Registry
;
import
org.jkiss.dbeaver.model.data.DBDRegistry
;
import
org.jkiss.dbeaver.model.edit.DBERegistry
;
import
org.jkiss.dbeaver.model.navigator.DBNModel
;
import
org.jkiss.dbeaver.model.qm.QMController
;
...
...
@@ -40,7 +40,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableContext
;
import
org.jkiss.dbeaver.model.runtime.OSDescriptor
;
import
org.jkiss.dbeaver.registry.DataSourceProviderRegistry
;
import
org.jkiss.dbeaver.registry.DataTypeProviderRegistry
;
import
org.jkiss.dbeaver.registry.
datatype.
DataTypeProviderRegistry
;
import
org.jkiss.dbeaver.registry.PluginServiceRegistry
;
import
org.jkiss.dbeaver.registry.ProjectRegistry
;
import
org.jkiss.dbeaver.registry.editor.EntityEditorsRegistry
;
...
...
@@ -360,7 +360,7 @@ public class DBeaverCore implements DBPApplication {
@NotNull
@Override
public
DBD
ValueHandler
Registry
getValueHandlerRegistry
()
{
public
DBDRegistry
getValueHandlerRegistry
()
{
return
DataTypeProviderRegistry
.
getInstance
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataTypeTransformerDescriptor.java
已删除
100644 → 0
浏览文件 @
d4f73944
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.data.DBDAttributeTransformer
;
import
org.jkiss.dbeaver.model.data.DBDValueHandlerProvider
;
import
org.jkiss.dbeaver.model.impl.AbstractDescriptor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
java.lang.reflect.Field
;
import
java.util.HashSet
;
import
java.util.Locale
;
import
java.util.Set
;
/**
* DataTypeTransformerDescriptor
*/
public
class
DataTypeTransformerDescriptor
extends
AbstractDescriptor
{
static
final
Log
log
=
Log
.
getLog
(
DataTypeTransformerDescriptor
.
class
);
private
String
id
;
private
ObjectType
implType
;
private
Set
<
Object
>
supportedTypes
=
new
HashSet
<>();
private
Set
<
DataSourceProviderDescriptor
>
supportedDataSources
=
new
HashSet
<>();
private
DBDAttributeTransformer
instance
;
public
DataTypeTransformerDescriptor
(
IConfigurationElement
config
)
{
super
(
config
);
this
.
id
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
this
.
implType
=
new
ObjectType
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_CLASS
));
IConfigurationElement
[]
typeElements
=
config
.
getChildren
(
RegistryConstants
.
TAG_TYPE
);
for
(
IConfigurationElement
typeElement
:
typeElements
)
{
String
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_NAME
);
if
(
typeName
!=
null
)
{
supportedTypes
.
add
(
typeName
.
toLowerCase
(
Locale
.
ENGLISH
));
}
else
{
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_STANDARD
);
if
(
typeName
==
null
)
{
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
if
(
typeName
==
null
)
{
log
.
warn
(
"Type element without name or standard type reference"
);
//$NON-NLS-1$
continue
;
}
try
{
int
typeNumber
=
Integer
.
parseInt
(
typeName
);
supportedTypes
.
add
(
typeNumber
);
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
"Type ID must be an integer while '"
+
typeName
+
"' was specified"
);
//$NON-NLS-1$
}
}
else
{
try
{
Field
typeField
=
java
.
sql
.
Types
.
class
.
getField
(
typeName
);
int
typeNumber
=
typeField
.
getInt
(
null
);
supportedTypes
.
add
(
typeNumber
);
}
catch
(
NoSuchFieldException
e
)
{
log
.
warn
(
"Standard type '"
+
typeName
+
"' not found in "
+
java
.
sql
.
Types
.
class
.
getName
(),
e
);
//$NON-NLS-1$
}
catch
(
IllegalAccessException
e
)
{
log
.
warn
(
"Standard type '"
+
typeName
+
"' cannot be accessed"
,
e
);
//$NON-NLS-1$
}
}
}
}
IConfigurationElement
[]
dsElements
=
config
.
getChildren
(
RegistryConstants
.
TAG_DATASOURCE
);
for
(
IConfigurationElement
dsElement
:
dsElements
)
{
String
dsId
=
dsElement
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
if
(
dsId
==
null
)
{
log
.
warn
(
"Datasource reference with null ID"
);
//$NON-NLS-1$
continue
;
}
DataSourceProviderDescriptor
dsProvider
=
DataSourceProviderRegistry
.
getInstance
().
getDataSourceProvider
(
dsId
);
if
(
dsProvider
==
null
)
{
log
.
warn
(
"Datasource provider '"
+
dsId
+
"' not found. Bad data type mapping."
);
//$NON-NLS-1$
continue
;
}
supportedDataSources
.
add
(
dsProvider
);
}
}
public
String
getId
()
{
return
id
;
}
public
DBDAttributeTransformer
getInstance
()
{
if
(
instance
==
null
&&
implType
!=
null
)
{
try
{
this
.
instance
=
implType
.
createInstance
(
DBDAttributeTransformer
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Can't instantiate attribute transformer '"
+
this
.
id
+
"'"
,
e
);
//$NON-NLS-1$
}
}
return
instance
;
}
public
boolean
supportsType
(
DBSTypedObject
typedObject
)
{
String
typeName
=
typedObject
.
getTypeName
();
return
supportedTypes
.
contains
(
typedObject
.
getTypeID
())
||
(
typeName
!=
null
&&
supportedTypes
.
contains
(
typeName
.
toLowerCase
(
Locale
.
ENGLISH
)))
||
supportedTypes
.
contains
(
typedObject
.
getDataKind
());
}
public
Set
<
Object
>
getSupportedTypes
()
{
return
supportedTypes
;
}
public
boolean
isDefault
()
{
return
supportedDataSources
.
isEmpty
();
}
public
boolean
supportsDataSource
(
DataSourceProviderDescriptor
descriptor
)
{
return
supportedDataSources
.
contains
(
descriptor
);
}
public
Set
<
DataSourceProviderDescriptor
>
getSupportedDataSources
()
{
return
supportedDataSources
;
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/
DataTypeProvider
Descriptor.java
→
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/
datatype/DataTypeAbstract
Descriptor.java
浏览文件 @
595d50aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry
;
import
org.jkiss.dbeaver.Log
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.model.data.DBDValueHandlerProvider
;
import
org.jkiss.dbeaver.model.impl.AbstractDescriptor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
java.lang.reflect.Field
;
import
java.util.HashSet
;
import
java.util.Locale
;
import
java.util.Set
;
/**
* DataTypeProviderDescriptor
*/
public
class
DataTypeProviderDescriptor
extends
AbstractDescriptor
{
static
final
Log
log
=
Log
.
getLog
(
DataTypeProviderDescriptor
.
class
);
private
static
final
String
ALL_TYPES_PATTERN
=
"*"
;
private
String
id
;
private
ObjectType
implType
;
private
Set
<
Object
>
supportedTypes
=
new
HashSet
<>();
private
Set
<
DataSourceProviderDescriptor
>
supportedDataSources
=
new
HashSet
<>();
private
DBDValueHandlerProvider
instance
;
public
DataTypeProviderDescriptor
(
IConfigurationElement
config
)
{
super
(
config
);
this
.
id
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
this
.
implType
=
new
ObjectType
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_CLASS
));
IConfigurationElement
[]
typeElements
=
config
.
getChildren
(
RegistryConstants
.
TAG_TYPE
);
for
(
IConfigurationElement
typeElement
:
typeElements
)
{
String
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_NAME
);
if
(
typeName
!=
null
)
{
supportedTypes
.
add
(
typeName
.
toLowerCase
(
Locale
.
ENGLISH
));
}
else
{
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_STANDARD
);
if
(
typeName
==
null
)
{
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
if
(
typeName
==
null
)
{
log
.
warn
(
"Type element without name or standard type reference"
);
//$NON-NLS-1$
continue
;
}
try
{
int
typeNumber
=
Integer
.
parseInt
(
typeName
);
supportedTypes
.
add
(
typeNumber
);
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
"Type ID must be an integer while '"
+
typeName
+
"' was specified"
);
//$NON-NLS-1$
}
}
else
{
try
{
Field
typeField
=
java
.
sql
.
Types
.
class
.
getField
(
typeName
);
int
typeNumber
=
typeField
.
getInt
(
null
);
supportedTypes
.
add
(
typeNumber
);
}
catch
(
NoSuchFieldException
e
)
{
log
.
warn
(
"Standard type '"
+
typeName
+
"' not found in "
+
java
.
sql
.
Types
.
class
.
getName
(),
e
);
//$NON-NLS-1$
}
catch
(
IllegalAccessException
e
)
{
log
.
warn
(
"Standard type '"
+
typeName
+
"' cannot be accessed"
,
e
);
//$NON-NLS-1$
}
}
}
}
IConfigurationElement
[]
dsElements
=
config
.
getChildren
(
RegistryConstants
.
TAG_DATASOURCE
);
for
(
IConfigurationElement
dsElement
:
dsElements
)
{
String
dsId
=
dsElement
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
if
(
dsId
==
null
)
{
log
.
warn
(
"Datasource reference with null ID"
);
//$NON-NLS-1$
continue
;
}
DataSourceProviderDescriptor
dsProvider
=
DataSourceProviderRegistry
.
getInstance
().
getDataSourceProvider
(
dsId
);
if
(
dsProvider
==
null
)
{
log
.
warn
(
"Datasource provider '"
+
dsId
+
"' not found. Bad data type mapping."
);
//$NON-NLS-1$
continue
;
}
supportedDataSources
.
add
(
dsProvider
);
}
}
public
String
getId
()
{
return
id
;
}
public
DBDValueHandlerProvider
getInstance
()
{
if
(
instance
==
null
&&
implType
!=
null
)
{
try
{
this
.
instance
=
implType
.
createInstance
(
DBDValueHandlerProvider
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Can't instantiate data type provider '"
+
this
.
id
+
"'"
,
e
);
//$NON-NLS-1$
}
}
return
instance
;
}
public
boolean
supportsType
(
DBSTypedObject
typedObject
)
{
String
typeName
=
typedObject
.
getTypeName
();
return
supportedTypes
.
contains
(
typedObject
.
getTypeID
())
||
(
typeName
!=
null
&&
supportedTypes
.
contains
(
typeName
.
toLowerCase
(
Locale
.
ENGLISH
)))
||
supportedTypes
.
contains
(
ALL_TYPES_PATTERN
);
}
public
Set
<
Object
>
getSupportedTypes
()
{
return
supportedTypes
;
}
public
boolean
isDefault
()
{
return
supportedDataSources
.
isEmpty
();
}
public
boolean
supportsDataSource
(
DataSourceProviderDescriptor
descriptor
)
{
return
supportedDataSources
.
contains
(
descriptor
);
}
public
Set
<
DataSourceProviderDescriptor
>
getSupportedDataSources
()
{
return
supportedDataSources
;
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry.datatype
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.data.DBDRegistryDescriptor
;
import
org.jkiss.dbeaver.model.impl.AbstractDescriptor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.registry.DataSourceProviderDescriptor
;
import
org.jkiss.dbeaver.registry.DataSourceProviderRegistry
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
java.lang.reflect.Field
;
import
java.util.HashSet
;
import
java.util.Locale
;
import
java.util.Set
;
/**
* DataTypeAbstractDescriptor
*/
public
abstract
class
DataTypeAbstractDescriptor
<
DESCRIPTOR
>
extends
AbstractDescriptor
implements
DBDRegistryDescriptor
<
DESCRIPTOR
>
{
private
static
final
Log
log
=
Log
.
getLog
(
DataTypeProviderDescriptor
.
class
);
public
static
final
String
ALL_TYPES_PATTERN
=
"*"
;
private
final
Class
<
DESCRIPTOR
>
instanceType
;
private
final
String
id
;
private
final
String
name
;
private
final
String
description
;
private
ObjectType
implType
;
private
Set
<
Object
>
supportedTypes
=
new
HashSet
<>();
private
Set
<
DataSourceProviderDescriptor
>
supportedDataSources
=
new
HashSet
<>();
protected
DESCRIPTOR
instance
;
public
DataTypeAbstractDescriptor
(
IConfigurationElement
config
,
Class
<
DESCRIPTOR
>
instanceType
)
{
super
(
config
);
this
.
instanceType
=
instanceType
;
this
.
id
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
this
.
name
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_NAME
);
this
.
description
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_DESCRIPTION
);
this
.
implType
=
new
ObjectType
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_CLASS
));
IConfigurationElement
[]
typeElements
=
config
.
getChildren
(
RegistryConstants
.
TAG_TYPE
);
for
(
IConfigurationElement
typeElement
:
typeElements
)
{
String
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_NAME
);
if
(
typeName
!=
null
)
{
supportedTypes
.
add
(
typeName
.
toLowerCase
(
Locale
.
ENGLISH
));
}
else
{
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_STANDARD
);
if
(
typeName
==
null
)
{
typeName
=
typeElement
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
if
(
typeName
==
null
)
{
log
.
warn
(
"Type element without name or standard type reference"
);
//$NON-NLS-1$
continue
;
}
try
{
int
typeNumber
=
Integer
.
parseInt
(
typeName
);
supportedTypes
.
add
(
typeNumber
);
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
"Type ID must be an integer while '"
+
typeName
+
"' was specified"
);
//$NON-NLS-1$
}
}
else
{
try
{
Field
typeField
=
java
.
sql
.
Types
.
class
.
getField
(
typeName
);
int
typeNumber
=
typeField
.
getInt
(
null
);
supportedTypes
.
add
(
typeNumber
);
}
catch
(
NoSuchFieldException
e
)
{
log
.
warn
(
"Standard type '"
+
typeName
+
"' not found in "
+
java
.
sql
.
Types
.
class
.
getName
(),
e
);
//$NON-NLS-1$
}
catch
(
IllegalAccessException
e
)
{
log
.
warn
(
"Standard type '"
+
typeName
+
"' cannot be accessed"
,
e
);
//$NON-NLS-1$
}
}
}
}
IConfigurationElement
[]
dsElements
=
config
.
getChildren
(
RegistryConstants
.
TAG_DATASOURCE
);
for
(
IConfigurationElement
dsElement
:
dsElements
)
{
String
dsId
=
dsElement
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
if
(
dsId
==
null
)
{
log
.
warn
(
"Datasource reference with null ID"
);
//$NON-NLS-1$
continue
;
}
DataSourceProviderDescriptor
dsProvider
=
DataSourceProviderRegistry
.
getInstance
().
getDataSourceProvider
(
dsId
);
if
(
dsProvider
==
null
)
{
log
.
warn
(
"Datasource provider '"
+
dsId
+
"' not found. Bad data type mapping."
);
//$NON-NLS-1$
continue
;
}
supportedDataSources
.
add
(
dsProvider
);
}
}
@Override
public
String
getId
()
{
return
id
;
}
@Override
public
String
getName
()
{
return
name
;
}
@Override
public
String
getDescription
()
{
return
description
;
}
@Override
public
DESCRIPTOR
getInstance
()
{
if
(
instance
==
null
&&
implType
!=
null
)
{
try
{
this
.
instance
=
implType
.
createInstance
(
instanceType
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Can't instantiate data type provider '"
+
this
.
id
+
"'"
,
e
);
//$NON-NLS-1$
}
}
return
instance
;
}
public
boolean
supportsType
(
DBSTypedObject
typedObject
)
{
String
typeName
=
typedObject
.
getTypeName
();
return
supportedTypes
.
contains
(
typedObject
.
getTypeID
())
||
(
typeName
!=
null
&&
supportedTypes
.
contains
(
typeName
.
toLowerCase
(
Locale
.
ENGLISH
)))
||
supportedTypes
.
contains
(
ALL_TYPES_PATTERN
);
}
public
Set
<
Object
>
getSupportedTypes
()
{
return
supportedTypes
;
}
public
boolean
isDefault
()
{
return
supportedDataSources
.
isEmpty
();
}
public
boolean
supportsDataSource
(
DataSourceProviderDescriptor
descriptor
)
{
return
supportedDataSources
.
contains
(
descriptor
);
}
public
Set
<
DataSourceProviderDescriptor
>
getSupportedDataSources
()
{
return
supportedDataSources
;
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeProviderDescriptor.java
0 → 100644
浏览文件 @
595d50aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry.datatype
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.model.data.DBDValueHandlerProvider
;
/**
* DataTypeProviderDescriptor
*/
public
class
DataTypeProviderDescriptor
extends
DataTypeAbstractDescriptor
<
DBDValueHandlerProvider
>
{
public
DataTypeProviderDescriptor
(
IConfigurationElement
config
)
{
super
(
config
,
DBDValueHandlerProvider
.
class
);
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataTypeProviderRegistry.java
→
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/
datatype/
DataTypeProviderRegistry.java
浏览文件 @
595d50aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.core.runtime.IExtensionRegistry
;
import
org.eclipse.core.runtime.Platform
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.connection.DBPDriver
;
import
org.jkiss.dbeaver.model.data.DBDAttributeTransformer
;
import
org.jkiss.dbeaver.model.data.DBDValueHandlerProvider
;
import
org.jkiss.dbeaver.model.data.DBDValueHandlerRegistry
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.registry.driver.DriverDescriptor
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* DataTypeProviderRegistry
*/
public
class
DataTypeProviderRegistry
implements
DBDValueHandlerRegistry
{
static
final
Log
log
=
Log
.
getLog
(
DataTypeProviderRegistry
.
class
);
public
static
final
String
EXTENSION_ID
=
"org.jkiss.dbeaver.dataTypeProvider"
;
//$NON-NLS-1$
private
static
DataTypeProviderRegistry
instance
=
null
;
public
synchronized
static
DataTypeProviderRegistry
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
DataTypeProviderRegistry
();
instance
.
loadExtensions
(
Platform
.
getExtensionRegistry
());
}
return
instance
;
}
private
final
List
<
DataTypeProviderDescriptor
>
dataTypeProviders
=
new
ArrayList
<>();
private
DataTypeProviderRegistry
()
{
}
public
void
loadExtensions
(
IExtensionRegistry
registry
)
{
// Load data type providers from external plugins
{
IConfigurationElement
[]
extElements
=
registry
.
getConfigurationElementsFor
(
EXTENSION_ID
);
for
(
IConfigurationElement
ext
:
extElements
)
{
if
(
"provider"
.
equals
(
ext
.
getName
()))
{
DataTypeProviderDescriptor
provider
=
new
DataTypeProviderDescriptor
(
ext
);
dataTypeProviders
.
add
(
provider
);
}
else
if
(
"transformer"
.
equals
(
ext
.
getName
()))
{
}
}
}
}
public
void
dispose
()
{
this
.
dataTypeProviders
.
clear
();
}
////////////////////////////////////////////////////
// DataType providers
@Nullable
public
DBDValueHandlerProvider
getDataTypeProvider
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
)
{
DBPDriver
driver
=
dataSource
.
getContainer
().
getDriver
();
if
(!(
driver
instanceof
DriverDescriptor
))
{
log
.
warn
(
"Bad datasource specified (driver is not recognized by registry) - "
+
dataSource
);
return
null
;
}
DataSourceProviderDescriptor
dsProvider
=
((
DriverDescriptor
)
driver
).
getProviderDescriptor
();
// First try to find type provider for specific datasource type
for
(
DataTypeProviderDescriptor
dtProvider
:
dataTypeProviders
)
{
if
(!
dtProvider
.
isDefault
()
&&
dtProvider
.
supportsDataSource
(
dsProvider
)
&&
dtProvider
.
supportsType
(
typedObject
))
{
return
dtProvider
.
getInstance
();
}
}
// Find in default providers
for
(
DataTypeProviderDescriptor
dtProvider
:
dataTypeProviders
)
{
if
(
dtProvider
.
isDefault
()
&&
dtProvider
.
supportsType
(
typedObject
))
{
return
dtProvider
.
getInstance
();
}
}
return
null
;
}
public
DBDAttributeTransformer
[]
findTransformers
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
)
{
return
null
;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry.datatype
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.core.runtime.IExtensionRegistry
;
import
org.eclipse.core.runtime.Platform
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.connection.DBPDriver
;
import
org.jkiss.dbeaver.model.data.DBDRegistry
;
import
org.jkiss.dbeaver.model.data.DBDValueHandlerProvider
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.registry.DataSourceProviderDescriptor
;
import
org.jkiss.dbeaver.registry.driver.DriverDescriptor
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* DataTypeProviderRegistry
*/
public
class
DataTypeProviderRegistry
implements
DBDRegistry
{
static
final
Log
log
=
Log
.
getLog
(
DataTypeProviderRegistry
.
class
);
public
static
final
String
EXTENSION_ID
=
"org.jkiss.dbeaver.dataTypeProvider"
;
//$NON-NLS-1$
private
static
DataTypeProviderRegistry
instance
=
null
;
public
synchronized
static
DataTypeProviderRegistry
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
DataTypeProviderRegistry
();
instance
.
loadExtensions
(
Platform
.
getExtensionRegistry
());
}
return
instance
;
}
private
final
List
<
DataTypeProviderDescriptor
>
dataTypeProviders
=
new
ArrayList
<>();
private
final
List
<
DataTypeTransformerDescriptor
>
dataTypeTransformers
=
new
ArrayList
<>();
private
final
List
<
DataTypeRendererDescriptor
>
dataTypeRenderers
=
new
ArrayList
<>();
private
DataTypeProviderRegistry
()
{
}
public
void
loadExtensions
(
IExtensionRegistry
registry
)
{
// Load data type providers from external plugins
{
IConfigurationElement
[]
extElements
=
registry
.
getConfigurationElementsFor
(
EXTENSION_ID
);
for
(
IConfigurationElement
ext
:
extElements
)
{
if
(
"provider"
.
equals
(
ext
.
getName
()))
{
DataTypeProviderDescriptor
provider
=
new
DataTypeProviderDescriptor
(
ext
);
dataTypeProviders
.
add
(
provider
);
}
else
if
(
"transformer"
.
equals
(
ext
.
getName
()))
{
dataTypeTransformers
.
add
(
new
DataTypeTransformerDescriptor
(
ext
));
}
else
if
(
"renderer"
.
equals
(
ext
.
getName
()))
{
dataTypeRenderers
.
add
(
new
DataTypeRendererDescriptor
(
ext
));
}
}
}
}
public
void
dispose
()
{
this
.
dataTypeProviders
.
clear
();
}
////////////////////////////////////////////////////
// DataType providers
@Nullable
public
DBDValueHandlerProvider
getDataTypeProvider
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
)
{
DBPDriver
driver
=
dataSource
.
getContainer
().
getDriver
();
if
(!(
driver
instanceof
DriverDescriptor
))
{
log
.
warn
(
"Bad datasource specified (driver is not recognized by registry) - "
+
dataSource
);
return
null
;
}
DataSourceProviderDescriptor
dsProvider
=
((
DriverDescriptor
)
driver
).
getProviderDescriptor
();
// First try to find type provider for specific datasource type
for
(
DataTypeProviderDescriptor
dtProvider
:
dataTypeProviders
)
{
if
(!
dtProvider
.
isDefault
()
&&
dtProvider
.
supportsDataSource
(
dsProvider
)
&&
dtProvider
.
supportsType
(
typedObject
))
{
return
dtProvider
.
getInstance
();
}
}
// Find in default providers
for
(
DataTypeProviderDescriptor
dtProvider
:
dataTypeProviders
)
{
if
(
dtProvider
.
isDefault
()
&&
dtProvider
.
supportsType
(
typedObject
))
{
return
dtProvider
.
getInstance
();
}
}
return
null
;
}
@Override
public
DataTypeTransformerDescriptor
[]
findTransformers
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
)
{
for
(
DataTypeTransformerDescriptor
descriptor
:
dataTypeTransformers
)
{
//descriptor.supportsDataSource()
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeRendererDescriptor.java
0 → 100644
浏览文件 @
595d50aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry.datatype
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.model.data.DBDValueRenderer
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
/**
* DataTypeRendererDescriptor
*/
public
class
DataTypeRendererDescriptor
extends
DataTypeAbstractDescriptor
<
DBDValueRenderer
>
{
private
String
name
;
private
String
description
;
public
DataTypeRendererDescriptor
(
IConfigurationElement
config
)
{
super
(
config
,
DBDValueRenderer
.
class
);
this
.
name
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_NAME
);
this
.
description
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_DESCRIPTION
);
}
public
String
getName
()
{
return
name
;
}
public
String
getDescription
()
{
return
description
;
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/datatype/DataTypeTransformerDescriptor.java
0 → 100644
浏览文件 @
595d50aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry.datatype
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.model.data.DBDAttributeTransformer
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
/**
* DataTypeTransformerDescriptor
*/
public
class
DataTypeTransformerDescriptor
extends
DataTypeAbstractDescriptor
<
DBDAttributeTransformer
>
{
public
DataTypeTransformerDescriptor
(
IConfigurationElement
config
)
{
super
(
config
,
DBDAttributeTransformer
.
class
);
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPApplication.java
浏览文件 @
595d50aa
...
...
@@ -21,7 +21,7 @@ package org.jkiss.dbeaver.model;
import
org.eclipse.core.resources.IProject
;
import
org.eclipse.core.resources.IWorkspace
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.data.DBD
ValueHandler
Registry
;
import
org.jkiss.dbeaver.model.data.DBDRegistry
;
import
org.jkiss.dbeaver.model.edit.DBERegistry
;
import
org.jkiss.dbeaver.model.navigator.DBNModel
;
import
org.jkiss.dbeaver.model.qm.QMController
;
...
...
@@ -51,7 +51,7 @@ public interface DBPApplication
QMController
getQueryManager
();
@NotNull
DBD
ValueHandler
Registry
getValueHandlerRegistry
();
DBDRegistry
getValueHandlerRegistry
();
@NotNull
DBERegistry
getEditorsRegistry
();
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBD
ValueHandler
Registry.java
→
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDRegistry.java
浏览文件 @
595d50aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.model.data
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
/**
* DBDValueHandlerRegistry
*/
public
interface
DBD
ValueHandlerRegistry
{
@Nullable
DBDValueHandlerProvider
getDataTypeProvider
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
);
@Nullable
DBD
AttributeTransformer
[]
findTransformers
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
);
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.model.data
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
/**
* DBDValueHandlerRegistry
*/
public
interface
DBD
Registry
{
@Nullable
DBDValueHandlerProvider
getDataTypeProvider
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
);
@Nullable
DBD
RegistryDescriptor
<
DBDAttributeTransformer
>[]
findTransformers
(
DBPDataSource
dataSource
,
DBSTypedObject
typedObject
);
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDRegistryDescriptor.java
0 → 100644
浏览文件 @
595d50aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.model.data
;
/**
* DBDRegistryDescriptor
*/
public
interface
DBDRegistryDescriptor
<
TYPE
>
{
String
getId
();
String
getName
();
String
getDescription
();
TYPE
getInstance
();
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录