Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
d1fcb8d0
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,发现更多精彩内容 >>
提交
d1fcb8d0
编写于
12月 20, 2017
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#2663 Property viewer columns repack fix
Former-commit-id:
5e930e64
上级
db78c4f6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
99 deletion
+70
-99
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
...c/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
+70
-99
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
浏览文件 @
d1fcb8d0
...
...
@@ -95,19 +95,6 @@ public class PropertyTreeViewer extends TreeViewer {
}
treeControl
.
setHeaderVisible
(
true
);
treeControl
.
setLinesVisible
(
true
);
treeControl
.
addControlListener
(
new
ControlAdapter
()
{
private
boolean
packing
=
false
;
@Override
public
void
controlResized
(
ControlEvent
e
)
{
if
(!
packing
)
{
packing
=
true
;
UIUtils
.
packColumns
(
treeControl
,
true
,
new
float
[]{
0.1f
,
0.9f
});
}
}
});
treeControl
.
addListener
(
SWT
.
PaintItem
,
new
PaintListener
());
this
.
boldFont
=
UIUtils
.
makeBoldFont
(
treeControl
.
getFont
());
...
...
@@ -225,7 +212,8 @@ public class PropertyTreeViewer extends TreeViewer {
}
disposeOldEditor
();
UIUtils
.
packColumns
(
getTree
(),
true
,
new
float
[]{
0.5f
,
0.5f
});
DBeaverUI
.
asyncExec
(()
->
UIUtils
.
packColumns
(
getTree
(),
true
,
new
float
[]{
0.5f
,
0.5f
}));
}
private
Map
<
String
,
TreeNode
>
loadTreeNodes
(
@Nullable
DBRProgressMonitor
monitor
,
TreeNode
parent
,
DBPPropertySource
propertySource
)
...
...
@@ -363,24 +351,20 @@ public class PropertyTreeViewer extends TreeViewer {
}
}
});
treeControl
.
addTraverseListener
(
new
TraverseListener
()
{
@Override
public
void
keyTraversed
(
TraverseEvent
e
)
{
if
(
e
.
detail
==
SWT
.
TRAVERSE_RETURN
)
{
// Set focus on editor
if
(
curCellEditor
!=
null
)
{
curCellEditor
.
setFocus
();
}
else
{
final
TreeItem
[]
selection
=
treeControl
.
getSelection
();
if
(
selection
.
length
==
0
)
{
return
;
}
showEditor
(
selection
[
0
],
true
);
treeControl
.
addTraverseListener
(
e
->
{
if
(
e
.
detail
==
SWT
.
TRAVERSE_RETURN
)
{
// Set focus on editor
if
(
curCellEditor
!=
null
)
{
curCellEditor
.
setFocus
();
}
else
{
final
TreeItem
[]
selection
=
treeControl
.
getSelection
();
if
(
selection
.
length
==
0
)
{
return
;
}
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
showEditor
(
selection
[
0
],
true
);
}
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
});
}
...
...
@@ -442,22 +426,18 @@ public class PropertyTreeViewer extends TreeViewer {
cellEditor
.
activate
();
final
Control
editorControl
=
cellEditor
.
getControl
();
if
(
editorControl
!=
null
)
{
editorControl
.
addTraverseListener
(
new
TraverseListener
()
{
@Override
public
void
keyTraversed
(
TraverseEvent
e
)
{
/*if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
cellEditorListener.applyEditorValue();
disposeOldEditor();
} else */
if
(
e
.
detail
==
SWT
.
TRAVERSE_ESCAPE
)
{
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
disposeOldEditor
();
if
(
prop
.
isEditable
())
{
new
ActionResetProperty
(
prop
,
false
).
run
();
}
editorControl
.
addTraverseListener
(
e
->
{
/*if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
cellEditorListener.applyEditorValue();
disposeOldEditor();
} else */
if
(
e
.
detail
==
SWT
.
TRAVERSE_ESCAPE
)
{
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
disposeOldEditor
();
if
(
prop
.
isEditable
())
{
new
ActionResetProperty
(
prop
,
false
).
run
();
}
}
});
...
...
@@ -480,52 +460,48 @@ public class PropertyTreeViewer extends TreeViewer {
// Register context menu
{
MenuManager
menuMgr
=
new
MenuManager
();
menuMgr
.
addMenuListener
(
new
IMenuListener
()
{
@Override
public
void
menuAboutToShow
(
final
IMenuManager
manager
)
{
final
IStructuredSelection
selection
=
PropertyTreeViewer
.
this
.
getStructuredSelection
();
menuMgr
.
addMenuListener
(
manager
->
{
final
IStructuredSelection
selection
=
PropertyTreeViewer
.
this
.
getStructuredSelection
();
if
(
selection
.
isEmpty
())
{
return
;
}
final
Object
object
=
selection
.
getFirstElement
();
if
(
object
instanceof
TreeNode
)
{
final
TreeNode
prop
=
(
TreeNode
)
object
;
if
(
prop
.
property
!=
null
)
{
final
String
stringValue
=
CommonUtils
.
toString
(
getPropertyValue
(
prop
));
if
(!
CommonUtils
.
isEmpty
(
stringValue
))
{
manager
.
add
(
new
Action
(
CoreMessages
.
ui_properties_tree_viewer_action_copy_value
)
{
@Override
public
void
run
()
{
UIUtils
.
setClipboardContents
(
Display
.
getDefault
(),
TextTransfer
.
getInstance
(),
stringValue
);
}
});
}
if
(
isPropertyChanged
(
prop
)
&&
prop
.
isEditable
())
{
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
))
{
manager
.
add
(
new
ActionResetProperty
(
prop
,
true
));
}
if
(
selection
.
isEmpty
())
{
return
;
}
final
Object
object
=
selection
.
getFirstElement
();
if
(
object
instanceof
TreeNode
)
{
final
TreeNode
prop
=
(
TreeNode
)
object
;
if
(
prop
.
property
!=
null
)
{
final
String
stringValue
=
CommonUtils
.
toString
(
getPropertyValue
(
prop
));
if
(!
CommonUtils
.
isEmpty
(
stringValue
))
{
manager
.
add
(
new
Action
(
CoreMessages
.
ui_properties_tree_viewer_action_copy_value
)
{
@Override
public
void
run
()
{
UIUtils
.
setClipboardContents
(
Display
.
getDefault
(),
TextTransfer
.
getInstance
(),
stringValue
);
}
});
}
if
(
isPropertyChanged
(
prop
)
&&
prop
.
isEditable
())
{
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
))
{
manager
.
add
(
new
ActionResetProperty
(
prop
,
true
));
}
}
}
manager
.
add
(
new
Separator
());
contributeContextMenu
(
manager
,
object
,
prop
.
category
!=
null
?
prop
.
category
:
(
prop
.
property
==
null
?
null
:
prop
.
property
.
getCategory
()),
prop
.
property
);
}
manager
.
add
(
new
Separator
());
contributeContextMenu
(
manager
,
object
,
prop
.
category
!=
null
?
prop
.
category
:
(
prop
.
property
==
null
?
null
:
prop
.
property
.
getCategory
()),
prop
.
property
);
}
});
...
...
@@ -590,7 +566,7 @@ public class PropertyTreeViewer extends TreeViewer {
getTree
().
notifyListeners
(
SWT
.
Modify
,
event
);
}
pr
otected
void
handlePropertyCreate
(
TreeNode
prop
)
pr
ivate
void
handlePropertyCreate
(
TreeNode
prop
)
{
handlePropertyChange
(
prop
);
super
.
refresh
(
prop
.
parent
);
...
...
@@ -599,7 +575,7 @@ public class PropertyTreeViewer extends TreeViewer {
super
.
setSelection
(
new
StructuredSelection
(
prop
));
}
pr
otected
void
handlePropertyRemove
(
TreeNode
prop
)
pr
ivate
void
handlePropertyRemove
(
TreeNode
prop
)
{
handlePropertyChange
(
prop
);
super
.
refresh
(
prop
.
parent
);
...
...
@@ -609,7 +585,7 @@ public class PropertyTreeViewer extends TreeViewer {
this
.
expandMode
=
expandMode
;
}
p
ublic
void
setExpandSingleRoot
(
boolean
expandSingleRoot
)
{
p
rotected
void
setExpandSingleRoot
(
boolean
expandSingleRoot
)
{
this
.
expandSingleRoot
=
expandSingleRoot
;
}
...
...
@@ -646,13 +622,8 @@ public class PropertyTreeViewer extends TreeViewer {
this
(
parent
,
propertySource
,
null
,
category
);
}
boolean
isEditable
()
{
if
(
property
!=
null
)
{
return
property
.
isEditable
(
propertySource
.
getEditableValue
());
}
else
{
return
false
;
}
boolean
isEditable
()
{
return
property
!=
null
&&
property
.
isEditable
(
propertySource
.
getEditableValue
());
}
@Override
...
...
@@ -728,7 +699,7 @@ public class PropertyTreeViewer extends TreeViewer {
private
class
PropsLabelProvider
extends
CellLabelProvider
{
private
final
boolean
isName
;
public
PropsLabelProvider
(
boolean
isName
)
PropsLabelProvider
(
boolean
isName
)
{
this
.
isName
=
isName
;
}
...
...
@@ -879,7 +850,7 @@ public class PropertyTreeViewer extends TreeViewer {
private
final
TreeNode
prop
;
private
final
boolean
toDefault
;
public
ActionResetProperty
(
TreeNode
prop
,
boolean
toDefault
)
ActionResetProperty
(
TreeNode
prop
,
boolean
toDefault
)
{
super
(
CoreMessages
.
ui_properties_tree_viewer_action_reset_value
+
(!
toDefault
?
""
:
CoreMessages
.
ui_properties_tree_viewer__to_default
));
//$NON-NLS-2$
this
.
prop
=
prop
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录