Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
9fb51583
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,发现更多精彩内容 >>
提交
9fb51583
编写于
6月 12, 2014
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Value handlers/editors model
Former-commit-id:
73e73f13
上级
b1fe5cfc
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
574 addition
and
343 deletion
+574
-343
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDValueEditor.java
...core/src/org/jkiss/dbeaver/model/data/DBDValueEditor.java
+5
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BaseValueEditor.java
...rc/org/jkiss/dbeaver/model/impl/data/BaseValueEditor.java
+184
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BaseValueHandler.java
...c/org/jkiss/dbeaver/model/impl/data/BaseValueHandler.java
+1
-157
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BooleanInlineEditor.java
...rg/jkiss/dbeaver/model/impl/data/BooleanInlineEditor.java
+64
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BooleanPanelEditor.java
...org/jkiss/dbeaver/model/impl/data/BooleanPanelEditor.java
+56
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/DateTimeEditorHelper.java
...g/jkiss/dbeaver/model/impl/data/DateTimeEditorHelper.java
+36
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/DateTimeInlineEditor.java
...g/jkiss/dbeaver/model/impl/data/DateTimeInlineEditor.java
+126
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/DateTimeStandaloneEditor.java
...iss/dbeaver/model/impl/data/DateTimeStandaloneEditor.java
+15
-14
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/DefaultValueHandler.java
...rg/jkiss/dbeaver/model/impl/data/DefaultValueHandler.java
+7
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCBooleanValueHandler.java
...dbeaver/model/impl/jdbc/data/JDBCBooleanValueHandler.java
+4
-58
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCComplexValueHandler.java
...dbeaver/model/impl/jdbc/data/JDBCComplexValueHandler.java
+2
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
...dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCDateTimeValueHandler.java
...beaver/model/impl/jdbc/data/JDBCDateTimeValueHandler.java
+33
-99
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCNumberValueHandler.java
.../dbeaver/model/impl/jdbc/data/JDBCNumberValueHandler.java
+3
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCObjectValueHandler.java
.../dbeaver/model/impl/jdbc/data/JDBCObjectValueHandler.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStringValueHandler.java
.../dbeaver/model/impl/jdbc/data/JDBCStringValueHandler.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/sql/SQLQueryParameterBindDialog.java
...kiss/dbeaver/runtime/sql/SQLQueryParameterBindDialog.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/FilterValueEditDialog.java
.../dbeaver/ui/controls/resultset/FilterValueEditDialog.java
+4
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
.../jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
+3
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ViewValuePanel.java
...g/jkiss/dbeaver/ui/controls/resultset/ViewValuePanel.java
+3
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/ComplexObjectEditor.java
...rg/jkiss/dbeaver/ui/dialogs/data/ComplexObjectEditor.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/ValueViewDialog.java
...rc/org/jkiss/dbeaver/ui/dialogs/data/ValueViewDialog.java
+10
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/content/ContentEditor.java
...c/org/jkiss/dbeaver/ui/editors/content/ContentEditor.java
+5
-0
plugins/org.jkiss.dbeaver.mysql/src/org/jkiss/dbeaver/ext/mysql/data/MySQLEnumValueHandler.java
...g/jkiss/dbeaver/ext/mysql/data/MySQLEnumValueHandler.java
+3
-2
plugins/org.jkiss.dbeaver.mysql/src/org/jkiss/dbeaver/ext/mysql/data/MySQLSetValueHandler.java
...rg/jkiss/dbeaver/ext/mysql/data/MySQLSetValueHandler.java
+2
-1
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/data/DBDValueEditor.java
浏览文件 @
9fb51583
...
...
@@ -29,6 +29,11 @@ import org.jkiss.dbeaver.DBException;
*/
public
interface
DBDValueEditor
{
/**
* Create editor control(s)
*/
void
createControl
();
/**
* Gets control which actually performs edit
* @return control reference
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BaseValueEditor.java
0 → 100644
浏览文件 @
9fb51583
/*
* Copyright (C) 2010-2014 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.data
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.*
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.ToolBar
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.data.DBDValueEditor
;
import
org.jkiss.dbeaver.ui.DBIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
/**
* BaseValueEditor
*/
public
abstract
class
BaseValueEditor
<
T
extends
Control
>
implements
DBDValueEditor
{
protected
final
DBDValueController
valueController
;
protected
T
control
;
private
boolean
activated
;
protected
BaseValueEditor
(
final
DBDValueController
valueController
)
{
this
.
valueController
=
valueController
;
}
public
void
createControl
()
{
this
.
control
=
createControl
(
valueController
.
getEditPlaceholder
());
if
(
this
.
control
!=
null
)
{
initInlineControl
(
this
.
control
);
}
ToolBar
editToolBar
=
valueController
.
getEditToolBar
();
if
(
editToolBar
!=
null
)
{
if
(!
valueController
.
isReadOnly
())
{
UIUtils
.
createToolItem
(
editToolBar
,
"Save changes"
,
DBIcon
.
SAVE
.
getImage
(),
new
Action
(
"Save"
)
{
@Override
public
void
run
()
{
saveValue
();
}
});
}
}
}
@Override
public
Control
getControl
()
{
return
control
;
}
protected
abstract
T
createControl
(
Composite
editPlaceholder
);
protected
void
initInlineControl
(
final
Control
inlineControl
)
{
boolean
isInline
=
(
valueController
.
getEditType
()
==
DBDValueController
.
EditType
.
INLINE
);
// Panel controls
inlineControl
.
addFocusListener
(
new
FocusListener
()
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
if
(!
activated
)
{
UIUtils
.
enableHostEditorKeyBindings
(
valueController
.
getValueSite
(),
false
);
activated
=
true
;
}
}
@Override
public
void
focusLost
(
FocusEvent
e
)
{
if
(
activated
)
{
UIUtils
.
enableHostEditorKeyBindings
(
valueController
.
getValueSite
(),
true
);
activated
=
false
;
}
}
});
inlineControl
.
addDisposeListener
(
new
DisposeListener
()
{
@Override
public
void
widgetDisposed
(
DisposeEvent
e
)
{
if
(
activated
)
{
UIUtils
.
enableHostEditorKeyBindings
(
valueController
.
getValueSite
(),
true
);
activated
=
false
;
}
}
});
// if (!isInline) {
// inlineControl.setBackground(valueController.getEditPlaceholder().getBackground());
// }
if
(
isInline
)
{
inlineControl
.
setFont
(
valueController
.
getEditPlaceholder
().
getFont
());
// There is a bug in windows. First time date control gain focus it renders cell editor incorrectly.
// Let's focus on it in async mode
inlineControl
.
getDisplay
().
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
inlineControl
.
isDisposed
())
{
inlineControl
.
setFocus
();
}
}
});
inlineControl
.
addTraverseListener
(
new
TraverseListener
()
{
@Override
public
void
keyTraversed
(
TraverseEvent
e
)
{
if
(
e
.
detail
==
SWT
.
TRAVERSE_RETURN
)
{
saveValue
();
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
else
if
(
e
.
detail
==
SWT
.
TRAVERSE_ESCAPE
)
{
valueController
.
closeInlineEditor
();
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
else
if
(
e
.
detail
==
SWT
.
TRAVERSE_TAB_NEXT
||
e
.
detail
==
SWT
.
TRAVERSE_TAB_PREVIOUS
)
{
saveValue
();
valueController
.
nextInlineEditor
(
e
.
detail
==
SWT
.
TRAVERSE_TAB_NEXT
);
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
}
});
inlineControl
.
addFocusListener
(
new
FocusAdapter
()
{
@Override
public
void
focusLost
(
FocusEvent
e
)
{
// Check new focus control in async mode
// (because right now focus is still on edit control)
inlineControl
.
getDisplay
().
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
inlineControl
.
isDisposed
())
{
return
;
}
Control
newFocus
=
inlineControl
.
getDisplay
().
getFocusControl
();
if
(
newFocus
!=
null
)
{
for
(
Control
fc
=
newFocus
.
getParent
();
fc
!=
null
;
fc
=
fc
.
getParent
())
{
if
(
fc
==
valueController
.
getEditPlaceholder
())
{
// New focus is still a child of inline placeholder - do not close it
return
;
}
}
}
saveValue
();
}
});
}
});
}
}
private
void
saveValue
()
{
try
{
Object
newValue
=
extractEditorValue
();
valueController
.
closeInlineEditor
();
valueController
.
updateValue
(
newValue
);
}
catch
(
DBException
e
)
{
UIUtils
.
showErrorDialog
(
getControl
().
getShell
(),
"Value save"
,
"Can't save edited value"
,
e
);
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BaseValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -18,22 +18,14 @@
*/
package
org.jkiss.dbeaver.model.impl.data
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.*
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.ToolBar
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
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.DBCLogicalOperator
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.DBIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.properties.PropertySourceAbstract
;
/**
...
...
@@ -73,155 +65,7 @@ public abstract class BaseValueHandler implements DBDValueHandler {
return
DBUtils
.
getDefaultOperators
(
attribute
);
}
protected
abstract
class
ValueEditor
<
T
extends
Control
>
implements
DBDValueEditor
{
protected
final
DBDValueController
valueController
;
protected
final
T
control
;
private
boolean
activated
;
protected
ValueEditor
(
final
DBDValueController
valueController
)
{
this
.
valueController
=
valueController
;
this
.
control
=
createControl
(
valueController
.
getEditPlaceholder
());
if
(
this
.
control
!=
null
)
{
initInlineControl
(
this
.
control
);
}
ToolBar
editToolBar
=
valueController
.
getEditToolBar
();
if
(
editToolBar
!=
null
)
{
if
(!
valueController
.
isReadOnly
())
{
UIUtils
.
createToolItem
(
editToolBar
,
"Save changes"
,
DBIcon
.
SAVE
.
getImage
(),
new
Action
(
"Save"
)
{
@Override
public
void
run
()
{
saveValue
();
}
});
}
}
}
@Override
public
Control
getControl
()
{
return
control
;
}
protected
abstract
T
createControl
(
Composite
editPlaceholder
);
protected
void
initInlineControl
(
final
Control
inlineControl
)
{
boolean
isInline
=
(
valueController
.
getEditType
()
==
DBDValueController
.
EditType
.
INLINE
);
// Panel controls
inlineControl
.
addFocusListener
(
new
FocusListener
()
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
if
(!
activated
)
{
UIUtils
.
enableHostEditorKeyBindings
(
valueController
.
getValueSite
(),
false
);
activated
=
true
;
}
}
@Override
public
void
focusLost
(
FocusEvent
e
)
{
if
(
activated
)
{
UIUtils
.
enableHostEditorKeyBindings
(
valueController
.
getValueSite
(),
true
);
activated
=
false
;
}
}
});
inlineControl
.
addDisposeListener
(
new
DisposeListener
()
{
@Override
public
void
widgetDisposed
(
DisposeEvent
e
)
{
if
(
activated
)
{
UIUtils
.
enableHostEditorKeyBindings
(
valueController
.
getValueSite
(),
true
);
activated
=
false
;
}
}
});
// if (!isInline) {
// inlineControl.setBackground(valueController.getEditPlaceholder().getBackground());
// }
if
(
isInline
)
{
inlineControl
.
setFont
(
valueController
.
getEditPlaceholder
().
getFont
());
// There is a bug in windows. First time date control gain focus it renders cell editor incorrectly.
// Let's focus on it in async mode
inlineControl
.
getDisplay
().
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
inlineControl
.
isDisposed
())
{
inlineControl
.
setFocus
();
}
}
});
inlineControl
.
addTraverseListener
(
new
TraverseListener
()
{
@Override
public
void
keyTraversed
(
TraverseEvent
e
)
{
if
(
e
.
detail
==
SWT
.
TRAVERSE_RETURN
)
{
saveValue
();
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
else
if
(
e
.
detail
==
SWT
.
TRAVERSE_ESCAPE
)
{
valueController
.
closeInlineEditor
();
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
else
if
(
e
.
detail
==
SWT
.
TRAVERSE_TAB_NEXT
||
e
.
detail
==
SWT
.
TRAVERSE_TAB_PREVIOUS
)
{
saveValue
();
valueController
.
nextInlineEditor
(
e
.
detail
==
SWT
.
TRAVERSE_TAB_NEXT
);
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
}
});
inlineControl
.
addFocusListener
(
new
FocusAdapter
()
{
@Override
public
void
focusLost
(
FocusEvent
e
)
{
// Check new focus control in async mode
// (because right now focus is still on edit control)
inlineControl
.
getDisplay
().
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
inlineControl
.
isDisposed
())
{
return
;
}
Control
newFocus
=
inlineControl
.
getDisplay
().
getFocusControl
();
if
(
newFocus
!=
null
)
{
for
(
Control
fc
=
newFocus
.
getParent
();
fc
!=
null
;
fc
=
fc
.
getParent
())
{
if
(
fc
==
valueController
.
getEditPlaceholder
())
{
// New focus is still a child of inline placeholder - do not close it
return
;
}
}
}
saveValue
();
}
});
}
});
}
}
private
void
saveValue
()
{
try
{
Object
newValue
=
extractEditorValue
();
valueController
.
closeInlineEditor
();
valueController
.
updateValue
(
newValue
);
}
catch
(
DBException
e
)
{
UIUtils
.
showErrorDialog
(
getControl
().
getShell
(),
"Value save"
,
"Can't save edited value"
,
e
);
}
}
}
protected
abstract
class
ValueEditorEx
<
T
extends
Control
>
extends
ValueEditor
<
T
>
implements
DBDValueEditorStandalone
{
protected
abstract
static
class
ValueEditorEx
<
T
extends
Control
>
extends
BaseValueEditor
<
T
>
implements
DBDValueEditorStandalone
{
protected
ValueEditorEx
(
final
DBDValueController
valueController
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BooleanInlineEditor.java
0 → 100644
浏览文件 @
9fb51583
/*
* Copyright (C) 2010-2014 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.data
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
/**
* BooleanInlineEditor
*/
public
class
BooleanInlineEditor
extends
BaseValueEditor
<
Combo
>
{
public
BooleanInlineEditor
(
DBDValueController
controller
)
{
super
(
controller
);
}
@Override
protected
Combo
createControl
(
Composite
editPlaceholder
)
{
final
Combo
editor
=
new
Combo
(
editPlaceholder
,
SWT
.
READ_ONLY
);
editor
.
add
(
"FALSE"
);
editor
.
add
(
"TRUE"
);
editor
.
setEnabled
(!
valueController
.
isReadOnly
());
return
editor
;
}
@Override
public
Object
extractEditorValue
()
{
switch
(
control
.
getSelectionIndex
())
{
case
0
:
return
Boolean
.
FALSE
;
case
1
:
return
Boolean
.
TRUE
;
default
:
return
null
;
}
}
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
control
.
setText
(
value
==
null
?
"FALSE"
:
value
.
toString
().
toUpperCase
());
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/BooleanPanelEditor.java
0 → 100644
浏览文件 @
9fb51583
/*
* Copyright (C) 2010-2014 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.data
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.List
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
/**
* BooleanPanelEditor
*/
public
class
BooleanPanelEditor
extends
BaseValueEditor
<
List
>
{
public
BooleanPanelEditor
(
DBDValueController
controller
)
{
super
(
controller
);
}
@Override
public
Object
extractEditorValue
()
{
return
control
.
getSelectionIndex
()
==
1
;
}
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
control
.
setSelection
(
Boolean
.
TRUE
.
equals
(
value
)
?
1
:
0
);
}
@Override
protected
List
createControl
(
Composite
editPlaceholder
)
{
final
List
editor
=
new
List
(
valueController
.
getEditPlaceholder
(),
SWT
.
SINGLE
|
SWT
.
READ_ONLY
);
editor
.
add
(
"FALSE"
);
editor
.
add
(
"TRUE"
);
return
editor
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/DateTimeEditorHelper.java
0 → 100644
浏览文件 @
9fb51583
/*
* Copyright (C) 2010-2014 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.data
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
/**
* DateTimeEditorHelper
*/
public
interface
DateTimeEditorHelper
{
boolean
isTimestamp
(
DBDValueController
valueController
);
boolean
isTime
(
DBDValueController
valueController
);
boolean
isDate
(
DBDValueController
valueController
);
Object
getValueFromMillis
(
DBDValueController
valueController
,
long
ms
);
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/DateTimeInlineEditor.java
0 → 100644
浏览文件 @
9fb51583
/*
* Copyright (C) 2010-2014 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.data
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.DateTime
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
* DateTimeInlineEditor
*/
public
class
DateTimeInlineEditor
extends
BaseValueEditor
<
DateTime
>
{
private
final
DateTimeEditorHelper
helper
;
private
DateTime
dateEditor
;
private
DateTime
timeEditor
;
public
DateTimeInlineEditor
(
DBDValueController
controller
,
DateTimeEditorHelper
helper
)
{
super
(
controller
);
this
.
helper
=
helper
;
}
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
if
(
value
instanceof
Date
)
{
Calendar
cl
=
Calendar
.
getInstance
();
cl
.
setTime
((
Date
)
value
);
if
(
dateEditor
!=
null
)
{
dateEditor
.
setDate
(
cl
.
get
(
Calendar
.
YEAR
),
cl
.
get
(
Calendar
.
MONTH
),
cl
.
get
(
Calendar
.
DAY_OF_MONTH
));
}
if
(
timeEditor
!=
null
)
{
timeEditor
.
setTime
(
cl
.
get
(
Calendar
.
HOUR_OF_DAY
),
cl
.
get
(
Calendar
.
MINUTE
),
cl
.
get
(
Calendar
.
SECOND
));
}
}
}
@Override
protected
DateTime
createControl
(
Composite
editPlaceholder
)
{
boolean
inline
=
valueController
.
getEditType
()
==
DBDValueController
.
EditType
.
INLINE
;
final
Composite
dateTimeGroup
=
inline
?
valueController
.
getEditPlaceholder
()
:
new
Composite
(
valueController
.
getEditPlaceholder
(),
SWT
.
BORDER
);
if
(!
inline
)
{
dateTimeGroup
.
setLayout
(
new
GridLayout
(
2
,
false
));
}
boolean
isDate
=
helper
.
isDate
(
valueController
);
boolean
isTime
=
helper
.
isTime
(
valueController
);
boolean
isTimeStamp
=
helper
.
isTimestamp
(
valueController
)
||
(!
isDate
&&
!
isTime
);
if
(!
inline
&&
(
isDate
||
isTimeStamp
))
{
UIUtils
.
createControlLabel
(
dateTimeGroup
,
"Date"
);
}
if
(
isDate
||
isTimeStamp
)
{
dateEditor
=
new
DateTime
(
dateTimeGroup
,
(
inline
?
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
MEDIUM
|
SWT
.
BORDER
:
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
LONG
));
dateEditor
.
setEnabled
(!
valueController
.
isReadOnly
());
}
if
(!
inline
&&
(
isTime
||
isTimeStamp
))
{
UIUtils
.
createControlLabel
(
dateTimeGroup
,
"Time"
);
}
if
(
isTime
||
isTimeStamp
)
{
timeEditor
=
new
DateTime
(
dateTimeGroup
,
(
inline
?
SWT
.
BORDER
:
SWT
.
NONE
)
|
SWT
.
TIME
|
SWT
.
LONG
);
timeEditor
.
setEnabled
(!
valueController
.
isReadOnly
());
}
if
(
dateEditor
!=
null
)
{
if
(
timeEditor
!=
null
)
{
initInlineControl
(
timeEditor
);
}
return
dateEditor
;
}
return
timeEditor
;
}
@Override
public
Object
extractEditorValue
()
{
Calendar
cl
=
getCalendarFromControls
(
dateEditor
,
timeEditor
);
return
helper
.
getValueFromMillis
(
valueController
,
cl
.
getTimeInMillis
());
}
public
static
Calendar
getCalendarFromControls
(
DateTime
dateEditor
,
DateTime
timeEditor
)
{
Calendar
cl
=
Calendar
.
getInstance
();
cl
.
clear
();
if
(
dateEditor
!=
null
)
{
cl
.
set
(
Calendar
.
YEAR
,
dateEditor
.
getYear
());
cl
.
set
(
Calendar
.
MONTH
,
dateEditor
.
getMonth
());
cl
.
set
(
Calendar
.
DAY_OF_MONTH
,
dateEditor
.
getDay
());
}
if
(
timeEditor
!=
null
)
{
cl
.
set
(
Calendar
.
HOUR_OF_DAY
,
timeEditor
.
getHours
());
cl
.
set
(
Calendar
.
MINUTE
,
timeEditor
.
getMinutes
());
cl
.
set
(
Calendar
.
SECOND
,
timeEditor
.
getSeconds
());
cl
.
set
(
Calendar
.
MILLISECOND
,
0
);
}
return
cl
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/
ui/dialogs/data/DateTimeViewDialog
.java
→
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/
model/impl/data/DateTimeStandaloneEditor
.java
浏览文件 @
9fb51583
...
...
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.
ui.dialogs
.data
;
package
org.jkiss.dbeaver.
model.impl
.data
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.SelectionAdapter
;
...
...
@@ -29,9 +29,8 @@ import org.eclipse.swt.widgets.Control;
import
org.eclipse.swt.widgets.DateTime
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.impl.jdbc.data.JDBCDateTimeValueHandler
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.data.ValueViewDialog
;
import
java.util.Calendar
;
import
java.util.Date
;
...
...
@@ -39,32 +38,33 @@ import java.util.Date;
/**
* DateTimeViewDialog
*/
public
class
DateTime
ViewDialog
extends
ValueViewDialog
{
public
class
DateTime
StandaloneEditor
extends
ValueViewDialog
{
private
final
DateTimeEditorHelper
helper
;
private
DateTime
dateEditor
;
private
DateTime
timeEditor
;
public
DateTime
ViewDialog
(
DBDValueController
valueControll
er
)
{
public
DateTime
StandaloneEditor
(
DBDValueController
valueController
,
DateTimeEditorHelper
help
er
)
{
super
(
valueController
);
this
.
helper
=
helper
;
}
@Override
protected
Control
createDialogArea
(
Composite
parent
)
{
Object
value
=
getValueController
().
getValue
();
DBDValueController
valueController
=
getValueController
();
Object
value
=
valueController
.
getValue
();
DBSTypedObject
valueType
=
getValueController
().
getValueType
();
boolean
isDate
=
valueType
.
getTypeID
()
==
java
.
sql
.
Types
.
DATE
;
boolean
isTime
=
valueType
.
getTypeID
()
==
java
.
sql
.
Types
.
TIME
;
boolean
isTimeStamp
=
valueType
.
getTypeID
()
==
java
.
sql
.
Types
.
TIMESTAMP
;
boolean
isDate
=
helper
.
isDate
(
valueController
);
boolean
isTime
=
helper
.
isTime
(
valueController
);
boolean
isTimeStamp
=
helper
.
isTimestamp
(
valueController
);
Composite
dialogGroup
=
(
Composite
)
super
.
createDialogArea
(
parent
);
Composite
panel
=
UIUtils
.
createPlaceholder
(
dialogGroup
,
isTimeStamp
?
2
:
3
);
panel
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
int
style
=
SWT
.
BORDER
;
if
(
getValueController
()
.
isReadOnly
())
{
if
(
valueController
.
isReadOnly
())
{
style
|=
SWT
.
READ_ONLY
;
}
...
...
@@ -95,7 +95,7 @@ public class DateTimeViewDialog extends ValueViewDialog {
gd
.
horizontalSpan
=
2
;
button
.
setLayoutData
(
gd
);
}
button
.
setEnabled
(!
getValueController
()
.
isReadOnly
());
button
.
setEnabled
(!
valueController
.
isReadOnly
());
button
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
...
...
@@ -125,7 +125,8 @@ public class DateTimeViewDialog extends ValueViewDialog {
@Override
public
Object
extractEditorValue
()
{
return
JDBCDateTimeValueHandler
.
getDate
(
dateEditor
,
timeEditor
);
long
ms
=
DateTimeInlineEditor
.
getCalendarFromControls
(
dateEditor
,
timeEditor
).
getTimeInMillis
();
return
helper
.
getValueFromMillis
(
getValueController
(),
ms
);
}
@Override
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/data/DefaultValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -82,7 +82,13 @@ public class DefaultValueHandler extends BaseValueHandler {
case
INLINE:
case
PANEL:
return
new
DBDValueEditor
()
{
private
Text
control
=
new
Text
(
controller
.
getEditPlaceholder
(),
SWT
.
BORDER
);
private
Text
control
;
@Override
public
void
createControl
()
{
control
=
new
Text
(
controller
.
getEditPlaceholder
(),
SWT
.
BORDER
);
}
@Override
public
Control
getControl
()
{
return
control
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCBooleanValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -20,12 +20,7 @@ package org.jkiss.dbeaver.model.impl.jdbc.data;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.List
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.data.DBDValueEditor
;
...
...
@@ -34,6 +29,8 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.data.BooleanInlineEditor
;
import
org.jkiss.dbeaver.model.impl.data.BooleanPanelEditor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.dialogs.data.DefaultValueViewDialog
;
...
...
@@ -102,60 +99,9 @@ public class JDBCBooleanValueHandler extends JDBCAbstractValueHandler {
{
switch
(
controller
.
getEditType
())
{
case
INLINE:
{
return
new
ValueEditor
<
Combo
>(
controller
)
{
@Override
protected
Combo
createControl
(
Composite
editPlaceholder
)
{
final
Combo
editor
=
new
Combo
(
editPlaceholder
,
SWT
.
READ_ONLY
);
editor
.
add
(
"FALSE"
);
editor
.
add
(
"TRUE"
);
editor
.
setEnabled
(!
valueController
.
isReadOnly
());
return
editor
;
}
@Override
public
Object
extractEditorValue
()
{
switch
(
control
.
getSelectionIndex
())
{
case
0
:
return
Boolean
.
FALSE
;
case
1
:
return
Boolean
.
TRUE
;
default
:
return
null
;
}
}
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
control
.
setText
(
value
==
null
?
"FALSE"
:
value
.
toString
().
toUpperCase
());
}
};
}
return
new
BooleanInlineEditor
(
controller
);
case
PANEL:
{
return
new
ValueEditor
<
List
>(
controller
)
{
@Override
public
Object
extractEditorValue
()
{
return
control
.
getSelectionIndex
()
==
1
;
}
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
control
.
setSelection
(
Boolean
.
TRUE
.
equals
(
value
)
?
1
:
0
);
}
@Override
protected
List
createControl
(
Composite
editPlaceholder
)
{
final
List
editor
=
new
List
(
valueController
.
getEditPlaceholder
(),
SWT
.
SINGLE
|
SWT
.
READ_ONLY
);
editor
.
add
(
"FALSE"
);
editor
.
add
(
"TRUE"
);
return
editor
;
}
};
}
return
new
BooleanPanelEditor
(
controller
);
case
EDITOR:
return
new
DefaultValueViewDialog
(
controller
);
default
:
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCComplexValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -26,7 +26,6 @@ import org.eclipse.swt.widgets.Tree;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.data.DBDComplexValue
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.data.DBDValueEditor
;
...
...
@@ -35,10 +34,10 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.data.BaseValueEditor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.dialogs.data.ComplexObjectEditor
;
import
org.jkiss.dbeaver.ui.dialogs.data.DefaultValueViewDialog
;
import
org.jkiss.dbeaver.ui.properties.PropertySourceAbstract
;
import
java.sql.SQLException
;
...
...
@@ -110,7 +109,7 @@ public abstract class JDBCComplexValueHandler extends JDBCAbstractValueHandler {
{
switch
(
controller
.
getEditType
())
{
case
PANEL:
return
new
ValueEditor
<
Tree
>(
controller
)
{
return
new
Base
ValueEditor
<
Tree
>(
controller
)
{
ComplexObjectEditor
editor
;
@Override
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCContentValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -44,6 +44,7 @@ import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import
org.jkiss.dbeaver.model.impl.BytesContentStorage
;
import
org.jkiss.dbeaver.model.impl.ExternalContentStorage
;
import
org.jkiss.dbeaver.model.impl.StringContentStorage
;
import
org.jkiss.dbeaver.model.impl.data.BaseValueEditor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
...
...
@@ -282,7 +283,7 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
if
(
controller
.
getValue
()
instanceof
DBDContentCached
)
{
final
boolean
isText
=
ContentUtils
.
isTextContent
(((
DBDContent
)
controller
.
getValue
()));
// String editor
return
new
ValueEditor
<
Text
>(
controller
)
{
return
new
Base
ValueEditor
<
Text
>(
controller
)
{
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCDateTimeValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -20,10 +20,6 @@ package org.jkiss.dbeaver.model.impl.jdbc.data;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.DateTime
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
...
...
@@ -34,10 +30,11 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.data.DateTimeEditorHelper
;
import
org.jkiss.dbeaver.model.impl.data.DateTimeInlineEditor
;
import
org.jkiss.dbeaver.model.impl.data.DateTimeStandaloneEditor
;
import
org.jkiss.dbeaver.model.impl.data.DefaultDataFormatter
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.data.DateTimeViewDialog
;
import
org.jkiss.dbeaver.ui.properties.PropertySourceAbstract
;
import
java.sql.SQLException
;
...
...
@@ -50,7 +47,7 @@ import java.util.Date;
/**
* JDBC string value handler
*/
public
class
JDBCDateTimeValueHandler
extends
JDBCAbstractValueHandler
{
public
class
JDBCDateTimeValueHandler
extends
JDBCAbstractValueHandler
implements
DateTimeEditorHelper
{
public
static
final
String
TYPE_NAME_DATE
=
"date"
;
//$NON-NLS-1$
public
static
final
String
TYPE_NAME_TIME
=
"time"
;
//$NON-NLS-1$
...
...
@@ -124,72 +121,9 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
switch
(
controller
.
getEditType
())
{
case
INLINE:
case
PANEL:
return
new
ValueEditor
<
DateTime
>(
controller
)
{
DateTime
dateEditor
;
DateTime
timeEditor
;
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
if
(
value
instanceof
Date
)
{
Calendar
cl
=
Calendar
.
getInstance
();
cl
.
setTime
((
Date
)
value
);
if
(
dateEditor
!=
null
)
{
dateEditor
.
setDate
(
cl
.
get
(
Calendar
.
YEAR
),
cl
.
get
(
Calendar
.
MONTH
),
cl
.
get
(
Calendar
.
DAY_OF_MONTH
));
}
if
(
timeEditor
!=
null
)
{
timeEditor
.
setTime
(
cl
.
get
(
Calendar
.
HOUR_OF_DAY
),
cl
.
get
(
Calendar
.
MINUTE
),
cl
.
get
(
Calendar
.
SECOND
));
}
}
}
@Override
protected
DateTime
createControl
(
Composite
editPlaceholder
)
{
boolean
inline
=
valueController
.
getEditType
()
==
DBDValueController
.
EditType
.
INLINE
;
final
Composite
dateTimeGroup
=
inline
?
valueController
.
getEditPlaceholder
()
:
new
Composite
(
valueController
.
getEditPlaceholder
(),
SWT
.
BORDER
);
if
(!
inline
)
{
dateTimeGroup
.
setLayout
(
new
GridLayout
(
2
,
false
));
}
boolean
isDate
=
valueController
.
getValueType
().
getTypeID
()
==
java
.
sql
.
Types
.
DATE
;
boolean
isTime
=
valueController
.
getValueType
().
getTypeID
()
==
java
.
sql
.
Types
.
TIME
;
boolean
isTimeStamp
=
valueController
.
getValueType
().
getTypeID
()
==
java
.
sql
.
Types
.
TIMESTAMP
||
(!
isDate
&&
!
isTime
);
if
(!
inline
&&
(
isDate
||
isTimeStamp
))
{
UIUtils
.
createControlLabel
(
dateTimeGroup
,
"Date"
);
}
if
(
isDate
||
isTimeStamp
)
{
dateEditor
=
new
DateTime
(
dateTimeGroup
,
(
inline
?
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
MEDIUM
|
SWT
.
BORDER
:
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
LONG
));
dateEditor
.
setEnabled
(!
valueController
.
isReadOnly
());
}
if
(!
inline
&&
(
isTime
||
isTimeStamp
))
{
UIUtils
.
createControlLabel
(
dateTimeGroup
,
"Time"
);
}
if
(
isTime
||
isTimeStamp
)
{
timeEditor
=
new
DateTime
(
dateTimeGroup
,
(
inline
?
SWT
.
BORDER
:
SWT
.
NONE
)
|
SWT
.
TIME
|
SWT
.
LONG
);
timeEditor
.
setEnabled
(!
valueController
.
isReadOnly
());
}
if
(
dateEditor
!=
null
)
{
if
(
timeEditor
!=
null
)
{
initInlineControl
(
timeEditor
);
}
return
dateEditor
;
}
return
timeEditor
;
}
@Override
public
Object
extractEditorValue
()
{
return
getDate
(
dateEditor
,
timeEditor
);
}
};
return
new
DateTimeInlineEditor
(
controller
,
this
);
case
EDITOR:
return
new
DateTime
ViewDialog
(
controller
);
return
new
DateTime
StandaloneEditor
(
controller
,
this
);
default
:
return
null
;
}
...
...
@@ -200,7 +134,7 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
public
String
getValueDisplayString
(
@NotNull
DBSTypedObject
column
,
Object
value
,
@NotNull
DBDDisplayFormat
format
)
{
if
(
value
==
null
)
{
return
super
.
getValueDisplayString
(
column
,
value
,
format
);
return
super
.
getValueDisplayString
(
column
,
null
,
format
);
}
if
(
value
instanceof
Date
&&
format
==
DBDDisplayFormat
.
NATIVE
)
{
Calendar
cal
=
Calendar
.
getInstance
();
...
...
@@ -279,8 +213,7 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
{
manager
.
add
(
new
Action
(
CoreMessages
.
model_jdbc_set_to_current_time
)
{
@Override
public
void
run
()
{
public
void
run
()
{
controller
.
updateValue
(
new
Date
());
}
});
...
...
@@ -297,30 +230,6 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
getFormatter
(
controller
.
getValueType
()).
getPattern
());
}
public
static
Date
getDate
(
DateTime
dateEditor
,
DateTime
timeEditor
)
{
Calendar
cl
=
Calendar
.
getInstance
();
cl
.
clear
();
if
(
dateEditor
!=
null
)
{
cl
.
set
(
Calendar
.
YEAR
,
dateEditor
.
getYear
());
cl
.
set
(
Calendar
.
MONTH
,
dateEditor
.
getMonth
());
cl
.
set
(
Calendar
.
DAY_OF_MONTH
,
dateEditor
.
getDay
());
}
if
(
timeEditor
!=
null
)
{
cl
.
set
(
Calendar
.
HOUR_OF_DAY
,
timeEditor
.
getHours
());
cl
.
set
(
Calendar
.
MINUTE
,
timeEditor
.
getMinutes
());
cl
.
set
(
Calendar
.
SECOND
,
timeEditor
.
getSeconds
());
cl
.
set
(
Calendar
.
MILLISECOND
,
0
);
}
if
(
timeEditor
==
null
)
{
return
new
java
.
sql
.
Date
(
cl
.
getTimeInMillis
());
}
else
if
(
dateEditor
==
null
)
{
return
new
java
.
sql
.
Time
(
cl
.
getTimeInMillis
());
}
else
{
return
new
Timestamp
(
cl
.
getTimeInMillis
());
}
}
@Nullable
private
static
java
.
sql
.
Time
getTimeValue
(
Object
value
)
{
...
...
@@ -385,4 +294,29 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
}
}
@Override
public
boolean
isTimestamp
(
DBDValueController
valueController
)
{
return
valueController
.
getValueType
().
getTypeID
()
==
java
.
sql
.
Types
.
TIMESTAMP
;
}
@Override
public
boolean
isTime
(
DBDValueController
valueController
)
{
return
valueController
.
getValueType
().
getTypeID
()
==
java
.
sql
.
Types
.
TIME
;
}
@Override
public
boolean
isDate
(
DBDValueController
valueController
)
{
return
valueController
.
getValueType
().
getTypeID
()
==
java
.
sql
.
Types
.
DATE
;
}
@Override
public
Object
getValueFromMillis
(
DBDValueController
valueController
,
long
ms
)
{
if
(
isTimestamp
(
valueController
))
{
return
new
Timestamp
(
ms
);
}
else
if
(
isTime
(
valueController
))
{
return
new
java
.
sql
.
Time
(
ms
);
}
else
{
return
new
java
.
sql
.
Date
(
ms
);
}
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCNumberValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.data.BaseValueEditor
;
import
org.jkiss.dbeaver.model.impl.data.DefaultDataFormatter
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.UIUtils
;
...
...
@@ -220,7 +221,7 @@ public class JDBCNumberValueHandler extends JDBCAbstractValueHandler {
case
INLINE:
case
PANEL:
if
(
controller
.
getValueType
().
getDataKind
()
==
DBPDataKind
.
BOOLEAN
)
{
return
new
ValueEditor
<
Combo
>(
controller
)
{
return
new
Base
ValueEditor
<
Combo
>(
controller
)
{
@Override
protected
Combo
createControl
(
Composite
editPlaceholder
)
{
...
...
@@ -249,7 +250,7 @@ public class JDBCNumberValueHandler extends JDBCAbstractValueHandler {
}
};
}
else
{
return
new
ValueEditor
<
Text
>(
controller
)
{
return
new
Base
ValueEditor
<
Text
>(
controller
)
{
@Override
protected
Text
createControl
(
Composite
editPlaceholder
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCObjectValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.data.BaseValueEditor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.dialogs.data.CursorViewDialog
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -131,7 +132,7 @@ public class JDBCObjectValueHandler extends JDBCAbstractValueHandler {
{
switch
(
controller
.
getEditType
())
{
case
PANEL:
return
new
ValueEditor
<
Text
>(
controller
)
{
return
new
Base
ValueEditor
<
Text
>(
controller
)
{
@Override
protected
Text
createControl
(
Composite
editPlaceholder
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/jdbc/data/JDBCStringValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -31,6 +31,7 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.data.BaseValueEditor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.dialogs.data.TextViewDialog
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -76,7 +77,7 @@ public class JDBCStringValueHandler extends JDBCAbstractValueHandler {
switch
(
controller
.
getEditType
())
{
case
INLINE:
case
PANEL:
return
new
ValueEditor
<
Text
>(
controller
)
{
return
new
Base
ValueEditor
<
Text
>(
controller
)
{
@Override
protected
Text
createControl
(
Composite
editPlaceholder
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/sql/SQLQueryParameterBindDialog.java
浏览文件 @
9fb51583
...
...
@@ -191,6 +191,7 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
try
{
DBDValueEditor
editor
=
valueHandler
.
createEditor
(
valueController
);
if
(
editor
!=
null
)
{
editor
.
createControl
();
tableEditor
.
minimumHeight
=
placeholder
.
computeSize
(
SWT
.
DEFAULT
,
SWT
.
DEFAULT
).
y
;
tableEditor
.
setEditor
(
placeholder
,
item
,
3
);
}
else
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/FilterValueEditDialog.java
浏览文件 @
9fb51583
...
...
@@ -80,7 +80,10 @@ class FilterValueEditDialog extends BaseDialog {
label
.
setText
(
valueController
.
getBinding
().
getName
()
+
" "
+
operator
.
getStringValue
()
+
" :"
);
try
{
editor
=
valueController
.
getValueHandler
().
createEditor
(
valueController
);
editor
.
primeEditorValue
(
valueController
.
getValue
());
if
(
editor
!=
null
)
{
editor
.
createControl
();
editor
.
primeEditorValue
(
valueController
.
getValue
());
}
}
catch
(
DBException
e
)
{
log
.
error
(
"Can't create inline value editor"
,
e
);
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
浏览文件 @
9fb51583
...
...
@@ -1368,6 +1368,9 @@ public class ResultSetViewer extends Viewer
UIUtils
.
showErrorDialog
(
site
.
getShell
(),
"Cannot edit value"
,
null
,
e
);
return
null
;
}
if
(
editor
!=
null
)
{
editor
.
createControl
();
}
if
(
editor
instanceof
DBDValueEditorStandalone
)
{
valueController
.
registerEditor
((
DBDValueEditorStandalone
)
editor
);
// show dialog in separate job to avoid block
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ViewValuePanel.java
浏览文件 @
9fb51583
...
...
@@ -110,7 +110,9 @@ abstract class ViewValuePanel extends Composite {
return
;
}
fillStandardToolBar
();
if
(
valueViewer
==
null
)
{
if
(
valueViewer
!=
null
)
{
valueViewer
.
createControl
();
}
else
{
final
Composite
placeholder
=
UIUtils
.
createPlaceholder
(
viewPlaceholder
,
1
);
placeholder
.
setBackground
(
placeholder
.
getDisplay
().
getSystemColor
(
SWT
.
COLOR_WIDGET_BACKGROUND
));
placeholder
.
addPaintListener
(
new
PaintListener
()
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/ComplexObjectEditor.java
浏览文件 @
9fb51583
...
...
@@ -201,6 +201,7 @@ public class ComplexObjectEditor extends TreeViewer {
try
{
curCellEditor
=
valueHandler
.
createEditor
(
valueController
);
if
(
curCellEditor
!=
null
)
{
curCellEditor
.
createControl
();
if
(
curCellEditor
instanceof
DBDValueEditorStandalone
)
{
((
DBDValueEditorStandalone
)
curCellEditor
).
showValueEditor
();
}
else
if
(
curCellEditor
.
getControl
()
!=
null
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/data/ValueViewDialog.java
浏览文件 @
9fb51583
...
...
@@ -101,6 +101,11 @@ public abstract class ValueViewDialog extends Dialog implements DBDValueEditorSt
dialogCount
++;
}
@Override
public
void
createControl
()
{
}
protected
IDialogSettings
getDialogSettings
()
{
return
dialogSettings
;
...
...
@@ -115,7 +120,7 @@ public abstract class ValueViewDialog extends Dialog implements DBDValueEditorSt
protected
DBDValueEditor
createPanelEditor
(
final
Composite
placeholder
)
throws
DBException
{
return
valueController
.
getValueHandler
().
createEditor
(
new
DBDValueController
()
{
DBDValueEditor
editor
=
valueController
.
getValueHandler
().
createEditor
(
new
DBDValueController
()
{
@Override
public
DBPDataSource
getDataSource
()
{
...
...
@@ -202,6 +207,10 @@ public abstract class ValueViewDialog extends Dialog implements DBDValueEditorSt
{
}
});
if
(
editor
!=
null
)
{
editor
.
createControl
();
}
return
editor
;
}
public
DBDValueController
getValueController
()
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/content/ContentEditor.java
浏览文件 @
9fb51583
...
...
@@ -454,6 +454,11 @@ public class ContentEditor extends MultiPageAbstractEditor implements IDataSourc
return
input
==
null
?
null
:
input
.
getValueController
();
}
@Override
public
void
createControl
()
{
}
@Override
public
Control
getControl
()
{
...
...
plugins/org.jkiss.dbeaver.mysql/src/org/jkiss/dbeaver/ext/mysql/data/MySQLEnumValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -36,6 +36,7 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.data.BaseValueEditor
;
import
org.jkiss.dbeaver.model.impl.jdbc.data.JDBCAbstractValueHandler
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
...
...
@@ -130,7 +131,7 @@ public class MySQLEnumValueHandler extends JDBCAbstractValueHandler {
switch
(
controller
.
getEditType
())
{
case
INLINE:
{
return
new
ValueEditor
<
Combo
>(
controller
)
{
return
new
Base
ValueEditor
<
Combo
>(
controller
)
{
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
...
...
@@ -171,7 +172,7 @@ public class MySQLEnumValueHandler extends JDBCAbstractValueHandler {
}
case
PANEL:
{
return
new
ValueEditor
<
List
>(
controller
)
{
return
new
Base
ValueEditor
<
List
>(
controller
)
{
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
...
...
plugins/org.jkiss.dbeaver.mysql/src/org/jkiss/dbeaver/ext/mysql/data/MySQLSetValueHandler.java
浏览文件 @
9fb51583
...
...
@@ -26,6 +26,7 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.ext.mysql.model.MySQLTableColumn
;
import
org.jkiss.dbeaver.model.data.DBDValueController
;
import
org.jkiss.dbeaver.model.data.DBDValueEditor
;
import
org.jkiss.dbeaver.model.impl.data.BaseValueEditor
;
import
org.jkiss.dbeaver.ui.dialogs.data.DefaultValueViewDialog
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -49,7 +50,7 @@ public class MySQLSetValueHandler extends MySQLEnumValueHandler {
case
PANEL:
final
MySQLTableColumn
column
=
((
MySQLTypeEnum
)
controller
.
getValue
()).
getColumn
();
return
new
ValueEditor
<
org
.
eclipse
.
swt
.
widgets
.
List
>(
controller
)
{
return
new
Base
ValueEditor
<
org
.
eclipse
.
swt
.
widgets
.
List
>(
controller
)
{
@Override
public
void
primeEditorValue
(
@Nullable
Object
value
)
throws
DBException
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录