Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
f990ec8d
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,发现更多精彩内容 >>
提交
f990ec8d
编写于
4月 16, 2016
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Attribute presentation override by transformers
Former-commit-id:
7ae70952
上级
77614a03
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
110 addition
and
20 deletion
+110
-20
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetValueController.java
...eaver/ui/controls/resultset/ResultSetValueController.java
+2
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDAttributeBinding.java
...src/org/jkiss/dbeaver/model/data/DBDAttributeBinding.java
+31
-16
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/transformers/EpochTimeAttributeTransformer.java
...impl/data/transformers/EpochTimeAttributeTransformer.java
+22
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/transformers/TransformerPresentationAttribute.java
...l/data/transformers/TransformerPresentationAttribute.java
+55
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetValueController.java
浏览文件 @
f990ec8d
...
...
@@ -30,6 +30,7 @@ import org.jkiss.dbeaver.model.data.DBDRowIdentifier;
import
org.jkiss.dbeaver.model.data.DBDValueHandler
;
import
org.jkiss.dbeaver.model.exec.DBCAttributeMetaData
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.data.IAttributeController
;
import
org.jkiss.dbeaver.ui.data.IRowController
;
...
...
@@ -162,7 +163,7 @@ public class ResultSetValueController implements IAttributeController, IRowContr
@Override
public
IValueManager
getValueManager
()
{
DBS
TypedObject
valueType
=
getValueTyp
e
();
DBS
AttributeBase
valueType
=
binding
.
getPresentationAttribut
e
();
return
DataManagerRegistry
.
findValueManager
(
getDataSourceContainer
(),
valueType
,
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDAttributeBinding.java
浏览文件 @
f990ec8d
...
...
@@ -44,15 +44,14 @@ public abstract class DBDAttributeBinding implements DBSObject, DBSAttributeBase
@NotNull
protected
DBDValueHandler
valueHandler
;
//@NotNull
//protected DBDValueRenderer valueRenderer
;
@Nullable
protected
DBSAttributeBase
presentationAttribute
;
@Nullable
private
List
<
DBDAttributeBinding
>
nestedBindings
;
protected
DBDAttributeBinding
(
@NotNull
DBDValueHandler
valueHandler
)
{
this
.
valueHandler
=
valueHandler
;
//this.valueRenderer = valueHandler;
}
@Nullable
...
...
@@ -85,11 +84,39 @@ public abstract class DBDAttributeBinding implements DBSObject, DBSAttributeBase
public
abstract
DBCAttributeMetaData
getMetaAttribute
();
/**
* Entity attribute (may be null)
* Entity attribute (may be null).
* It is always null if {@link #lateBinding(DBCSession, List)} wasn't called
*/
@Nullable
public
abstract
DBSEntityAttribute
getEntityAttribute
();
/**
* Most valuable attribute reference.
* @return resolved entity attribute or just meta attribute
*/
@NotNull
public
DBSAttributeBase
getAttribute
()
{
DBSEntityAttribute
attr
=
getEntityAttribute
();
return
attr
==
null
?
getMetaAttribute
()
:
attr
;
}
/**
* Presentation attribute.
* Usually the same as {@link #getAttribute()} but may be explicitly set by attribute transformers.
*/
@NotNull
public
DBSAttributeBase
getPresentationAttribute
()
{
if
(
presentationAttribute
!=
null
)
{
return
presentationAttribute
;
}
return
getAttribute
();
}
public
void
setPresentationAttribute
(
@Nullable
DBSAttributeBase
presentationAttribute
)
{
this
.
presentationAttribute
=
presentationAttribute
;
}
/**
* Row identifier (may be null)
*/
...
...
@@ -120,18 +147,6 @@ public abstract class DBDAttributeBinding implements DBSObject, DBSAttributeBase
return
valueHandler
;
}
// public void setValueRenderer(@NotNull DBDValueRenderer renderer) {
// this.valueRenderer = renderer;
// }
@NotNull
public
DBSAttributeBase
getAttribute
()
{
DBSEntityAttribute
attr
=
getEntityAttribute
();
return
attr
==
null
?
getMetaAttribute
()
:
attr
;
}
public
boolean
matches
(
DBSAttributeBase
attr
,
boolean
searchByName
)
{
if
(
attr
!=
null
&&
(
this
==
attr
||
getMetaAttribute
()
==
attr
||
getEntityAttribute
()
==
attr
))
{
return
true
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/transformers/EpochTimeAttributeTransformer.java
浏览文件 @
f990ec8d
...
...
@@ -21,13 +21,16 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPDataKind
;
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.DBCSession
;
import
org.jkiss.dbeaver.model.impl.data.ProxyValueHandler
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.utils.CommonUtils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -42,6 +45,8 @@ public class EpochTimeAttributeTransformer implements DBDAttributeTransformer {
static
final
Log
log
=
Log
.
getLog
(
EpochTimeAttributeTransformer
.
class
);
private
static
final
String
PROP_UNIT
=
"unit"
;
private
static
final
SimpleDateFormat
DEFAULT_TIME_FORMAT
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
ENGLISH
);
enum
EpochUnit
{
seconds
,
milliseconds
,
...
...
@@ -50,7 +55,9 @@ public class EpochTimeAttributeTransformer implements DBDAttributeTransformer {
@Override
public
void
transformAttribute
(
@NotNull
DBCSession
session
,
@NotNull
DBDAttributeBinding
attribute
,
@NotNull
List
<
Object
[]>
rows
,
@NotNull
Map
<
String
,
String
>
options
)
throws
DBException
{
// TODO: Change attribute type (to DATETIME)
attribute
.
setPresentationAttribute
(
new
TransformerPresentationAttribute
(
attribute
,
"EpochTime"
,
-
1
,
DBPDataKind
.
DATETIME
));
EpochUnit
unit
=
EpochUnit
.
milliseconds
;
if
(
options
.
containsKey
(
PROP_UNIT
))
{
try
{
...
...
@@ -78,10 +85,22 @@ public class EpochTimeAttributeTransformer implements DBDAttributeTransformer {
case
seconds:
dateValue
*=
1000
;
break
;
case
nanoseconds:
dateValue
/=
1000
;
break
;
}
return
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
ENGLISH
).
format
(
new
Date
(
dateValue
));
return
DEFAULT_TIME_FORMAT
.
format
(
new
Date
(
dateValue
));
}
return
DBUtils
.
getDefaultValueDisplayString
(
value
,
format
);
}
@Nullable
@Override
public
Object
getValueFromObject
(
@NotNull
DBCSession
session
,
@NotNull
DBSTypedObject
type
,
@Nullable
Object
object
,
boolean
copy
)
throws
DBCException
{
if
(
object
instanceof
String
)
{
try
{
return
DEFAULT_TIME_FORMAT
.
parse
((
String
)
object
).
getTime
();
}
catch
(
ParseException
e
)
{
log
.
error
(
"Error parsing time value"
,
e
);
}
}
return
super
.
getValueFromObject
(
session
,
type
,
object
,
copy
);
}
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/transformers/TransformerPresentationAttribute.java
0 → 100644
浏览文件 @
f990ec8d
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2016 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.impl.data.transformers
;
import
org.jkiss.dbeaver.model.DBPDataKind
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.impl.struct.AbstractAttribute
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
/**
* TransformerPresentationAttribute
*/
public
class
TransformerPresentationAttribute
extends
AbstractAttribute
{
private
final
DBPDataKind
dataKind
;
public
TransformerPresentationAttribute
(
DBDAttributeBinding
attribute
,
String
typeName
,
int
typeId
,
DBPDataKind
dataKind
)
{
super
(
attribute
.
getName
(),
typeName
,
typeId
,
attribute
.
getOrdinalPosition
(),
attribute
.
getMaxLength
(),
attribute
.
getScale
(),
attribute
.
getPrecision
(),
attribute
.
isRequired
(),
attribute
.
isAutoGenerated
());
this
.
dataKind
=
dataKind
;
}
@Override
public
DBPDataKind
getDataKind
()
{
return
dataKind
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录