Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
301d7f8d
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,发现更多精彩内容 >>
提交
301d7f8d
编写于
10月 24, 2015
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Boolean value editor/renderer redesign/fix
上级
7241cfdc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
58 deletion
+59
-58
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/CustomCheckboxCellEditor.java
...g/jkiss/dbeaver/ui/controls/CustomCheckboxCellEditor.java
+23
-19
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/ObjectViewerRenderer.java
...c/org/jkiss/dbeaver/ui/controls/ObjectViewerRenderer.java
+8
-6
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
...c/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
+23
-33
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBConstants.java
...beaver.model/src/org/jkiss/dbeaver/model/DBConstants.java
+2
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
...ss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
+3
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/CustomCheckboxCellEditor.java
浏览文件 @
301d7f8d
...
...
@@ -20,20 +20,23 @@ package org.jkiss.dbeaver.ui.controls;
import
org.eclipse.core.runtime.Assert
;
import
org.eclipse.jface.viewers.CellEditor
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.CCombo
;
import
org.eclipse.swt.events.FocusAdapter
;
import
org.eclipse.swt.events.FocusEvent
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.
Button
;
import
org.eclipse.swt.widgets.
Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.jkiss.dbeaver.model.DBConstants
;
import
org.jkiss.utils.CommonUtils
;
/**
* Checkbox cell editor
*/
public
class
CustomCheckboxCellEditor
extends
CellEditor
{
private
Button
checkbox
;
private
CCombo
combo
;
public
CustomCheckboxCellEditor
(
Composite
parent
)
{
this
(
parent
,
SWT
.
NONE
);
...
...
@@ -54,21 +57,22 @@ public class CustomCheckboxCellEditor extends CellEditor {
gl
.
marginWidth
=
0
;
placeholder
.
setLayout
(
gl
);
c
heckbox
=
new
Button
(
placeholder
,
SWT
.
CHECK
);
final
GridData
gd
=
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
|
GridData
.
VERTICAL_ALIGN_CENTER
);
gd
.
verticalIndent
=
2
;
gd
.
horizontalIndent
=
4
;
c
ombo
=
new
CCombo
(
placeholder
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
final
GridData
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
|
GridData
.
VERTICAL_ALIGN_CENTER
);
//
gd.verticalIndent = 2;
//
gd.horizontalIndent = 4;
gd
.
grabExcessHorizontalSpace
=
true
;
checkbox
.
setLayoutData
(
gd
);
checkbox
.
setFont
(
parent
.
getFont
());
checkbox
.
addFocusListener
(
new
FocusAdapter
()
{
combo
.
add
(
DBConstants
.
BOOLEAN_PROP_NO
);
combo
.
add
(
DBConstants
.
BOOLEAN_PROP_YES
);
combo
.
setLayoutData
(
gd
);
combo
.
setFont
(
parent
.
getFont
());
combo
.
addFocusListener
(
new
FocusAdapter
()
{
@Override
public
void
focusLost
(
FocusEvent
e
)
{
public
void
focusLost
(
FocusEvent
e
)
{
applyEditorValue
();
}
});
// c
heckbox
.addSelectionListener(new SelectionAdapter() {
// c
ombo
.addSelectionListener(new SelectionAdapter() {
// public void widgetDefaultSelected(SelectionEvent event) {
// applyEditorValue();
// }
...
...
@@ -82,15 +86,15 @@ public class CustomCheckboxCellEditor extends CellEditor {
}
@Override
protected
Object
doGetValue
()
{
return
c
heckbox
.
getSelection
()
;
protected
Boolean
doGetValue
()
{
return
c
ombo
.
getSelectionIndex
()
>
0
;
}
@Override
protected
void
doSetFocus
()
{
c
heckbox
.
setFocus
();
//c
heckbox.setSelection(!checkbox
.getSelection());
// c
heckbox
.getDisplay().asyncExec(new Runnable() {
c
ombo
.
setFocus
();
//c
ombo.setSelection(!combo
.getSelection());
// c
ombo
.getDisplay().asyncExec(new Runnable() {
// public void run()
// {
// applyEditorValue();
...
...
@@ -100,8 +104,8 @@ public class CustomCheckboxCellEditor extends CellEditor {
@Override
protected
void
doSetValue
(
Object
value
)
{
Assert
.
isTrue
(
c
heckbox
!=
null
&&
(
value
instanceof
Boolean
));
c
heckbox
.
setSelection
((
Boolean
)
value
);
Assert
.
isTrue
(
c
ombo
!=
null
&&
(
value
instanceof
Boolean
));
c
ombo
.
select
(
CommonUtils
.
toBoolean
(
value
)
?
1
:
0
);
}
@Override
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/ObjectViewerRenderer.java
浏览文件 @
301d7f8d
...
...
@@ -27,6 +27,7 @@ import org.eclipse.swt.graphics.*;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPNamedObject
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.ui.ImageUtils
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
...
...
@@ -170,17 +171,17 @@ public abstract class ObjectViewerRenderer {
Object
cellValue
=
getCellValue
(
element
,
columnIndex
);
if
(
cellValue
!=
null
)
{
GC
gc
=
event
.
gc
;
if
(
cellValue
instanceof
Boolean
)
{
/*
if (cellValue instanceof Boolean) {
//int columnWidth = UIUtils.getColumnWidth(item);
int columnHeight = isTree ? getTree().getItemHeight() : getTable().getItemHeight();
Image image = (Boolean)cellValue ?
(editable ? ImageUtils.getImageCheckboxEnabledOn() : ImageUtils.getImageCheckboxDisabledOn()) :
(editable ? ImageUtils.getImageCheckboxEnabledOff() : ImageUtils.getImageCheckboxDisabledOff());
final Rectangle imageBounds = image.getBounds();
gc
.
drawImage
(
image
,
event
.
x
+
4
/*(columnWidth - imageBounds.width) / 2*/
,
event
.
y
+
(
columnHeight
-
imageBounds
.
height
)
/
2
);
gc.drawImage(image, event.x + 4
*//*(columnWidth - imageBounds.width) / 2*//*
, event.y + (columnHeight - imageBounds.height) / 2);
event.doit = false;
// System.out.println("PAINT " + cellValue + " " + System.currentTimeMillis());
}
else
if
(
isHyperlink
(
cellValue
))
{
} else
*/
if
(
isHyperlink
(
cellValue
))
{
// Print link
boolean
isSelected
=
gc
.
getBackground
().
equals
(
selectionBackgroundColor
);
prepareLinkStyle
(
cellValue
,
isSelected
?
gc
.
getForeground
()
:
null
);
...
...
@@ -318,11 +319,12 @@ public abstract class ObjectViewerRenderer {
public
static
String
getCellString
(
@Nullable
Object
value
)
{
if
(
value
==
null
||
value
instanceof
Boolean
)
{
if
(
value
==
null
)
{
return
""
;
}
if
(
value
instanceof
DBPNamedObject
)
{
}
else
if
(
value
instanceof
DBPNamedObject
)
{
value
=
((
DBPNamedObject
)
value
).
getName
();
}
else
if
(
value
instanceof
Boolean
)
{
value
=
DBUtils
.
getBooleanString
((
Boolean
)
value
);
}
return
GeneralUtils
.
makeDisplayString
(
value
).
toString
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
浏览文件 @
301d7f8d
...
...
@@ -32,9 +32,7 @@ import org.eclipse.swt.widgets.*;
import
org.eclipse.ui.views.properties.IPropertySource2
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.DBPObject
;
import
org.jkiss.dbeaver.model.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.DBPPropertySource
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.runtime.properties.IPropertySourceEditable
;
...
...
@@ -220,7 +218,7 @@ public class PropertyTreeViewer extends TreeViewer {
}
TreeNode
category
=
(
parent
!=
null
?
parent
:
categories
.
get
(
categoryName
));
if
(
category
==
null
)
{
category
=
new
TreeNode
(
parent
,
propertySource
,
categoryName
);
category
=
new
TreeNode
(
null
,
propertySource
,
categoryName
);
categories
.
put
(
categoryName
,
category
);
}
TreeNode
propNode
=
new
TreeNode
(
category
,
propertySource
,
prop
);
...
...
@@ -247,7 +245,7 @@ public class PropertyTreeViewer extends TreeViewer {
}
PropertySourceCollection
psc
=
new
PropertySourceCollection
(
collection
);
for
(
DBPPropertyDescriptor
pd
:
psc
.
getPropertyDescriptors2
())
{
TreeNode
itemNode
=
new
TreeNode
(
propNode
,
psc
,
pd
);
new
TreeNode
(
propNode
,
psc
,
pd
);
}
}
}
...
...
@@ -278,10 +276,8 @@ public class PropertyTreeViewer extends TreeViewer {
{
if
(
node
instanceof
TreeNode
)
{
TreeNode
treeNode
=
(
TreeNode
)
node
;
if
(
treeNode
.
propertySource
instanceof
DBPPropertySource
)
{
((
DBPPropertySource
)
treeNode
.
propertySource
).
resetPropertyValueToDefault
(
treeNode
.
property
.
getId
());
}
else
{
treeNode
.
propertySource
.
resetPropertyValue
(
treeNode
.
property
.
getId
());
if
(
treeNode
.
propertySource
!=
null
)
{
treeNode
.
propertySource
.
resetPropertyValueToDefault
(
treeNode
.
property
.
getId
());
}
treeNode
.
parent
.
children
.
remove
(
treeNode
);
handlePropertyRemove
(
treeNode
);
...
...
@@ -295,11 +291,6 @@ public class PropertyTreeViewer extends TreeViewer {
super
.
refresh
();
}
public
DBPPropertyDescriptor
getSelectedProperty
()
{
return
selectedProperty
;
}
private
void
disposeOldEditor
()
{
if
(
curCellEditor
!=
null
)
{
...
...
@@ -486,19 +477,19 @@ public class PropertyTreeViewer extends TreeViewer {
});
}
if
(
isPropertyChanged
(
prop
)
&&
prop
.
isEditable
())
{
if
(
prop
.
propertySource
instanceof
IPropertySource2
&&
!
((
IPropertySource2
)
prop
.
propertySource
)
.
isPropertyResettable
(
prop
.
property
.
getId
()))
{
if
(
prop
.
propertySource
instanceof
IPropertySource2
&&
!
prop
.
propertySource
.
isPropertyResettable
(
prop
.
property
.
getId
()))
{
// it is not resettable
}
else
{
manager
.
add
(
new
ActionResetProperty
(
prop
,
false
));
if
(!
isCustomProperty
(
prop
.
property
)
&&
prop
.
propertySource
instanceof
DBPPropertySource
)
{
if
(!
isCustomProperty
(
prop
.
property
))
{
manager
.
add
(
new
ActionResetProperty
(
prop
,
true
));
}
}
}
manager
.
add
(
new
Separator
());
contributeContextMenu
(
manager
,
object
,
prop
.
category
!=
null
?
prop
.
category
:
prop
.
property
.
getCategory
(),
prop
.
property
);
}
contributeContextMenu
(
manager
,
object
,
prop
.
category
!=
null
?
prop
.
category
:
prop
.
property
.
getCategory
(),
prop
.
property
);
}
}
});
...
...
@@ -612,10 +603,10 @@ public class PropertyTreeViewer extends TreeViewer {
boolean
isEditable
()
{
if
(
property
instanceof
DBPPropertyDescriptor
)
{
return
((
DBPPropertyDescriptor
)
property
)
.
isEditable
(
propertySource
.
getEditableValue
());
if
(
property
!=
null
)
{
return
property
.
isEditable
(
propertySource
.
getEditableValue
());
}
else
{
return
property
!=
null
;
return
false
;
}
}
}
...
...
@@ -690,10 +681,11 @@ public class PropertyTreeViewer extends TreeViewer {
}
else
{
if
(
node
.
property
!=
null
)
{
final
Object
propertyValue
=
getPropertyValue
(
node
);
if
(
propertyValue
==
null
||
propertyValue
instanceof
Boolean
||
renderer
.
isHyperlink
(
propertyValue
))
{
if
(
propertyValue
==
null
||
renderer
.
isHyperlink
(
propertyValue
))
{
return
""
;
//$NON-NLS-1$
}
if
(
BeanUtils
.
isCollectionType
(
propertyValue
.
getClass
()))
{
}
else
if
(
propertyValue
instanceof
Boolean
)
{
return
DBUtils
.
getBooleanString
((
Boolean
)
propertyValue
);
}
else
if
(
BeanUtils
.
isCollectionType
(
propertyValue
.
getClass
()))
{
return
""
;
}
return
CommonUtils
.
toString
(
propertyValue
);
...
...
@@ -735,11 +727,6 @@ public class PropertyTreeViewer extends TreeViewer {
boolean
changed
=
false
;
if
(
node
.
property
!=
null
)
{
changed
=
node
.
isEditable
()
&&
isPropertyChanged
(
node
);
/*
if (((DBPProperty)element).isRequired() && cell.getColumnIndex() == 0) {
cell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
}
*/
}
if
(
extraLabelProvider
instanceof
IFontProvider
)
{
cell
.
setFont
(((
IFontProvider
)
extraLabelProvider
).
getFont
(
node
.
property
));
...
...
@@ -807,10 +794,12 @@ public class PropertyTreeViewer extends TreeViewer {
@Override
public
void
run
()
{
if
(
toDefault
&&
prop
.
propertySource
instanceof
DBPPropertySource
)
{
((
DBPPropertySource
)
prop
.
propertySource
).
resetPropertyValueToDefault
(
prop
.
property
.
getId
());
}
else
{
prop
.
propertySource
.
resetPropertyValue
(
prop
.
property
.
getId
());
if
(
prop
.
propertySource
!=
null
)
{
if
(
toDefault
)
{
prop
.
propertySource
.
resetPropertyValueToDefault
(
prop
.
property
.
getId
());
}
else
{
prop
.
propertySource
.
resetPropertyValue
(
prop
.
property
.
getId
());
}
}
handlePropertyChange
(
prop
);
PropertyTreeViewer
.
this
.
update
(
prop
,
null
);
...
...
@@ -839,4 +828,5 @@ public class PropertyTreeViewer extends TreeViewer {
}
}
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBConstants.java
浏览文件 @
301d7f8d
...
...
@@ -49,4 +49,6 @@ public class DBConstants {
"number"
//NON-NLS-1
};
public
static
final
String
BOOLEAN_PROP_YES
=
"yes"
;
public
static
final
String
BOOLEAN_PROP_NO
=
"no"
;
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
浏览文件 @
301d7f8d
...
...
@@ -1400,4 +1400,7 @@ public final class DBUtils {
return
(
Class
<
T
>)
Class
.
forName
(
className
,
true
,
dataSource
.
getContainer
().
getDriver
().
getClassLoader
());
}
public
static
String
getBooleanString
(
boolean
propertyValue
)
{
return
propertyValue
?
DBConstants
.
BOOLEAN_PROP_YES
:
DBConstants
.
BOOLEAN_PROP_NO
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录