Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
9b47720a
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,发现更多精彩内容 >>
提交
9b47720a
编写于
2月 12, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#1716 Number format fix. Minimum fraction digits number depends on column settings.
上级
4f7db504
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
36 addition
and
23 deletion
+36
-23
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/formatter/DataFormatterProfile.java
...kiss/dbeaver/registry/formatter/DataFormatterProfile.java
+3
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/data/editors/NumberInlineEditor.java
...org/jkiss/dbeaver/ui/data/editors/NumberInlineEditor.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDataFormat.java
.../org/jkiss/dbeaver/ui/preferences/PrefPageDataFormat.java
+1
-1
plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/data/DB2DecFloatValueHandler.java
...g/jkiss/dbeaver/ext/db2/data/DB2DecFloatValueHandler.java
+2
-2
plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/data/DB2ValueHandlerProvider.java
...g/jkiss/dbeaver/ext/db2/data/DB2ValueHandlerProvider.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDDataFormatter.java
...el/src/org/jkiss/dbeaver/model/data/DBDDataFormatter.java
+2
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDDataFormatterProfile.java
...org/jkiss/dbeaver/model/data/DBDDataFormatterProfile.java
+2
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/DateTimeCustomValueHandler.java
...s/dbeaver/model/impl/data/DateTimeCustomValueHandler.java
+4
-4
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/formatters/DateTimeDataFormatter.java
...ver/model/impl/data/formatters/DateTimeDataFormatter.java
+2
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/formatters/DefaultDataFormatter.java
...aver/model/impl/data/formatters/DefaultDataFormatter.java
+2
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/formatters/NumberDataFormatter.java
...eaver/model/impl/data/formatters/NumberDataFormatter.java
+7
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/data/handlers/JDBCNumberValueHandler.java
...model/impl/jdbc/data/handlers/JDBCNumberValueHandler.java
+5
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/data/handlers/JDBCStandardValueHandlerProvider.java
.../jdbc/data/handlers/JDBCStandardValueHandlerProvider.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/exec/JDBCPreparedStatementImpl.java
...eaver/model/impl/jdbc/exec/JDBCPreparedStatementImpl.java
+3
-3
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/formatter/DataFormatterProfile.java
浏览文件 @
9b47720a
...
...
@@ -22,6 +22,7 @@ import org.jkiss.dbeaver.model.impl.preferences.SimplePreferenceStore;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceListener
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceStore
;
import
org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.utils.PrefUtils
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -184,7 +185,7 @@ public class DataFormatterProfile implements DBDDataFormatterProfile, DBPPrefere
}
@Override
public
DBDDataFormatter
createFormatter
(
String
typeId
)
public
DBDDataFormatter
createFormatter
(
String
typeId
,
DBSTypedObject
type
)
throws
IllegalAccessException
,
InstantiationException
,
IllegalArgumentException
{
DataFormatterDescriptor
descriptor
=
DataFormatterRegistry
.
getInstance
().
getDataFormatter
(
typeId
);
...
...
@@ -202,7 +203,7 @@ public class DataFormatterProfile implements DBDDataFormatterProfile, DBPPrefere
if
(
props
!=
null
&&
!
props
.
isEmpty
())
{
formatterProps
.
putAll
(
props
);
}
formatter
.
init
(
locale
,
formatterProps
);
formatter
.
init
(
type
,
locale
,
formatterProps
);
return
formatter
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/data/editors/NumberInlineEditor.java
浏览文件 @
9b47720a
...
...
@@ -99,7 +99,7 @@ public class NumberInlineEditor extends BaseValueEditor<Text> {
curValue
.
getClass
()
:
valueController
.
getValueHandler
().
getValueObjectType
(
valueController
.
getValueType
());
try
{
return
DBValueFormatting
.
convertStringToNumber
(
text
,
hintType
,
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_NUMBER
));
return
DBValueFormatting
.
convertStringToNumber
(
text
,
hintType
,
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_NUMBER
,
valueController
.
getValueType
()
));
}
catch
(
Exception
e
)
{
log
.
error
(
e
);
return
null
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDataFormat.java
浏览文件 @
9b47720a
...
...
@@ -305,7 +305,7 @@ public class PrefPageDataFormat extends TargetPrefPage
if
(
props
!=
null
&&
!
props
.
isEmpty
())
{
formatterProps
.
putAll
(
props
);
}
formatter
.
init
(
profileLocale
,
formatterProps
);
formatter
.
init
(
null
,
profileLocale
,
formatterProps
);
String
sampleValue
=
formatter
.
formatValue
(
formatterDescriptor
.
getSample
().
getSampleValue
());
sampleText
.
setText
(
sampleValue
);
...
...
plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/data/DB2DecFloatValueHandler.java
浏览文件 @
9b47720a
...
...
@@ -36,8 +36,8 @@ public class DB2DecFloatValueHandler extends JDBCNumberValueHandler {
final
static
int
DECFLOAT_SPECIALVALUE_ENCOUNTERED
=
-
4231
;
public
DB2DecFloatValueHandler
(
DBDDataFormatterProfile
formatterProfile
)
{
super
(
formatterProfile
);
public
DB2DecFloatValueHandler
(
DB
STypedObject
type
,
DB
DDataFormatterProfile
formatterProfile
)
{
super
(
type
,
formatterProfile
);
}
@Nullable
...
...
plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/data/DB2ValueHandlerProvider.java
浏览文件 @
9b47720a
...
...
@@ -37,7 +37,7 @@ public class DB2ValueHandlerProvider implements DBDValueHandlerProvider {
{
final
String
typeName
=
typedObject
.
getTypeName
();
if
(
DB2Constants
.
TYPE_NAME_DECFLOAT
.
equals
(
typeName
))
{
return
new
DB2DecFloatValueHandler
(
preferences
.
getDataFormatterProfile
());
return
new
DB2DecFloatValueHandler
(
typedObject
,
preferences
.
getDataFormatterProfile
());
}
else
if
(
typeName
.
contains
(
"TIMESTAMP"
)
||
typedObject
.
getDataKind
()
==
DBPDataKind
.
DATETIME
)
{
return
new
DB2TimestampValueHandler
(
preferences
.
getDataFormatterProfile
());
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDDataFormatter.java
浏览文件 @
9b47720a
...
...
@@ -18,6 +18,7 @@
package
org.jkiss.dbeaver.model.data
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
java.text.ParseException
;
import
java.util.Locale
;
...
...
@@ -33,7 +34,7 @@ public interface DBDDataFormatter {
String
TYPE_NAME_TIME
=
"time"
;
//$NON-NLS-1$
String
TYPE_NAME_TIMESTAMP
=
"timestamp"
;
//$NON-NLS-1$
void
init
(
Locale
locale
,
Map
<
Object
,
Object
>
properties
);
void
init
(
@Nullable
DBSTypedObject
type
,
Locale
locale
,
Map
<
Object
,
Object
>
properties
);
@Nullable
String
getPattern
();
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDDataFormatterProfile.java
浏览文件 @
9b47720a
...
...
@@ -18,6 +18,7 @@
package
org.jkiss.dbeaver.model.data
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceStore
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
java.io.IOException
;
import
java.util.Locale
;
...
...
@@ -48,6 +49,6 @@ public interface DBDDataFormatterProfile {
void
saveProfile
()
throws
IOException
;
DBDDataFormatter
createFormatter
(
String
typeId
)
throws
IllegalAccessException
,
InstantiationException
,
IllegalArgumentException
;
DBDDataFormatter
createFormatter
(
String
typeId
,
DBSTypedObject
type
)
throws
IllegalAccessException
,
InstantiationException
,
IllegalArgumentException
;
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/DateTimeCustomValueHandler.java
浏览文件 @
9b47720a
...
...
@@ -50,7 +50,7 @@ public abstract class DateTimeCustomValueHandler extends DateTimeValueHandler {
if
(
object
==
null
)
{
return
null
;
}
else
if
(
object
instanceof
Date
)
{
return
(
Date
)
(
copy
?
((
Date
)
object
).
clone
()
:
object
)
;
return
copy
?
((
Date
)
object
).
clone
()
:
object
;
}
else
if
(
object
instanceof
String
)
{
String
strValue
=
(
String
)
object
;
try
{
...
...
@@ -89,10 +89,10 @@ public abstract class DateTimeCustomValueHandler extends DateTimeValueHandler {
}
}
pr
otected
DBDDataFormatter
getFormatter
(
String
typeId
)
pr
ivate
DBDDataFormatter
getFormatter
(
DBSTypedObject
typedObject
,
String
typeId
)
{
try
{
return
formatterProfile
.
createFormatter
(
typeId
);
return
formatterProfile
.
createFormatter
(
typeId
,
typedObject
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Can't create formatter for datetime value handler"
,
e
);
//$NON-NLS-1$
return
DefaultDataFormatter
.
INSTANCE
;
...
...
@@ -103,7 +103,7 @@ public abstract class DateTimeCustomValueHandler extends DateTimeValueHandler {
protected
DBDDataFormatter
getFormatter
(
DBSTypedObject
column
)
{
if
(
formatter
==
null
)
{
formatter
=
getFormatter
(
getFormatterId
(
column
));
formatter
=
getFormatter
(
column
,
getFormatterId
(
column
));
}
return
formatter
;
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/formatters/DateTimeDataFormatter.java
浏览文件 @
9b47720a
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.model.impl.data.formatters
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatter
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.time.ExtendedDateFormat
;
...
...
@@ -36,7 +37,7 @@ public class DateTimeDataFormatter implements DBDDataFormatter {
private
FieldPosition
position
;
@Override
public
void
init
(
Locale
locale
,
Map
<
Object
,
Object
>
properties
)
public
void
init
(
DBSTypedObject
type
,
Locale
locale
,
Map
<
Object
,
Object
>
properties
)
{
pattern
=
CommonUtils
.
toString
(
properties
.
get
(
PROP_PATTERN
));
dateFormat
=
new
ExtendedDateFormat
(
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/formatters/DefaultDataFormatter.java
浏览文件 @
9b47720a
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.model.impl.data.formatters
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatter
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
java.util.Locale
;
import
java.util.Map
;
...
...
@@ -30,7 +31,7 @@ public class DefaultDataFormatter implements DBDDataFormatter {
}
@Override
public
void
init
(
Locale
locale
,
Map
<
Object
,
Object
>
properties
)
public
void
init
(
DBSTypedObject
type
,
Locale
locale
,
Map
<
Object
,
Object
>
properties
)
{
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/formatters/NumberDataFormatter.java
浏览文件 @
9b47720a
...
...
@@ -18,6 +18,7 @@ package org.jkiss.dbeaver.model.impl.data.formatters;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatter
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.utils.CommonUtils
;
import
java.math.BigDecimal
;
...
...
@@ -37,7 +38,7 @@ public class NumberDataFormatter implements DBDDataFormatter {
private
FieldPosition
position
;
@Override
public
void
init
(
Locale
locale
,
Map
<
Object
,
Object
>
properties
)
public
void
init
(
DBSTypedObject
type
,
Locale
locale
,
Map
<
Object
,
Object
>
properties
)
{
numberFormat
=
(
DecimalFormat
)
NumberFormat
.
getNumberInstance
(
locale
);
Object
useGrouping
=
properties
.
get
(
NumberFormatSample
.
PROP_USE_GROUPING
);
...
...
@@ -68,6 +69,11 @@ public class NumberDataFormatter implements DBDDataFormatter {
// just skip it
}
}
if
(
type
!=
null
)
{
if
(
type
.
getScale
()
!=
null
&&
type
.
getScale
()
>
0
)
{
numberFormat
.
setMinimumFractionDigits
(
type
.
getScale
());
}
}
buffer
=
new
StringBuffer
();
position
=
new
FieldPosition
(
0
);
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/data/handlers/JDBCNumberValueHandler.java
浏览文件 @
9b47720a
...
...
@@ -43,12 +43,14 @@ import java.sql.Types;
public
class
JDBCNumberValueHandler
extends
JDBCAbstractValueHandler
{
private
static
final
Log
log
=
Log
.
getLog
(
JDBCNumberValueHandler
.
class
);
private
DBSTypedObject
type
;
private
DBDDataFormatter
formatter
;
public
JDBCNumberValueHandler
(
DBDDataFormatterProfile
formatterProfile
)
public
JDBCNumberValueHandler
(
DB
STypedObject
type
,
DB
DDataFormatterProfile
formatterProfile
)
{
this
.
type
=
type
;
try
{
formatter
=
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_NUMBER
);
formatter
=
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_NUMBER
,
type
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Can't create formatter for number value handler"
,
e
);
//$NON-NLS-1$
formatter
=
DefaultDataFormatter
.
INSTANCE
;
...
...
@@ -334,4 +336,4 @@ public class JDBCNumberValueHandler extends JDBCAbstractValueHandler {
}
}
}
\ No newline at end of file
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/data/handlers/JDBCStandardValueHandlerProvider.java
浏览文件 @
9b47720a
...
...
@@ -44,7 +44,7 @@ public class JDBCStandardValueHandlerProvider implements DBDValueHandlerProvider
return
JDBCStringValueHandler
.
INSTANCE
;
}
case
NUMERIC:
return
new
JDBCNumberValueHandler
(
preferences
.
getDataFormatterProfile
());
return
new
JDBCNumberValueHandler
(
typedObject
,
preferences
.
getDataFormatterProfile
());
case
DATETIME:
return
new
JDBCDateTimeValueHandler
(
preferences
.
getDataFormatterProfile
());
case
BINARY:
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/exec/JDBCPreparedStatementImpl.java
浏览文件 @
9b47720a
...
...
@@ -157,11 +157,11 @@ public class JDBCPreparedStatementImpl extends JDBCStatementImpl<PreparedStateme
try
{
DBDDataFormatterProfile
formatterProfile
=
getSession
().
getDataSource
().
getDataFormatterProfile
();
if
(
value
instanceof
Date
)
{
return
SQLUtils
.
quoteString
(
connection
.
getDataSource
(),
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_DATE
).
formatValue
(
value
));
return
SQLUtils
.
quoteString
(
connection
.
getDataSource
(),
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_DATE
,
null
).
formatValue
(
value
));
}
else
if
(
value
instanceof
Time
)
{
return
SQLUtils
.
quoteString
(
connection
.
getDataSource
(),
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_TIME
).
formatValue
(
value
));
return
SQLUtils
.
quoteString
(
connection
.
getDataSource
(),
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_TIME
,
null
).
formatValue
(
value
));
}
else
{
return
SQLUtils
.
quoteString
(
connection
.
getDataSource
(),
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_TIMESTAMP
).
formatValue
(
value
));
return
SQLUtils
.
quoteString
(
connection
.
getDataSource
(),
formatterProfile
.
createFormatter
(
DBDDataFormatter
.
TYPE_NAME_TIMESTAMP
,
null
).
formatValue
(
value
));
}
}
catch
(
Exception
e
)
{
log
.
debug
(
"Error formatting date ["
+
value
+
"]"
,
e
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录