Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
2c5975c0
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,发现更多精彩内容 >>
提交
2c5975c0
编写于
6月 28, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Column controller typing
Former-commit-id:
d10b5488
上级
9ffe7ef5
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
74 addition
and
43 deletion
+74
-43
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/IColumnTextProvider.java
...rc/org/jkiss/dbeaver/ui/controls/IColumnTextProvider.java
+26
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/ViewerColumnController.java
...org/jkiss/dbeaver/ui/controls/ViewerColumnController.java
+48
-43
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/IColumnTextProvider.java
0 → 100644
浏览文件 @
2c5975c0
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui.controls
;
/**
* IColumnTextProvider
*/
public
interface
IColumnTextProvider
<
ELEMENT
>
{
String
getText
(
ELEMENT
element
);
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/ViewerColumnController.java
浏览文件 @
2c5975c0
...
...
@@ -46,7 +46,7 @@ import java.util.List;
/**
* Tree/table viewer column controller
*/
public
class
ViewerColumnController
{
public
class
ViewerColumnController
<
ELEMENT
>
{
private
static
final
Log
log
=
Log
.
getLog
(
ViewerColumnController
.
class
);
...
...
@@ -73,9 +73,7 @@ public class ViewerColumnController {
control
.
setData
(
DATA_KEY
,
this
);
if
(
control
instanceof
Tree
||
control
instanceof
Table
)
{
menuListener
=
new
Listener
()
{
@Override
public
void
handleEvent
(
Event
event
)
{
menuListener
=
event
->
{
Point
pt
=
control
.
getDisplay
().
map
(
null
,
control
,
new
Point
(
event
.
x
,
event
.
y
));
Rectangle
clientArea
=
((
Composite
)
control
).
getClientArea
();
if
(
RuntimeUtils
.
isPlatformMacOS
())
{
...
...
@@ -87,7 +85,6 @@ public class ViewerColumnController {
clickOnHeader
=
clientArea
.
y
<=
pt
.
y
&&
pt
.
y
<
(
clientArea
.
y
+
((
Table
)
control
).
getHeaderHeight
());
}
}
}
};
control
.
addListener
(
SWT
.
MenuDetect
,
menuListener
);
}
...
...
@@ -120,6 +117,16 @@ public class ViewerColumnController {
});
}
public
void
addColumn
(
String
name
,
String
description
,
int
style
,
boolean
defaultVisible
,
boolean
required
,
IColumnTextProvider
<
ELEMENT
>
labelProvider
)
{
addColumn
(
name
,
description
,
style
,
defaultVisible
,
required
,
false
,
null
,
new
CellLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
cell
.
setText
(
labelProvider
.
getText
((
ELEMENT
)
cell
.
getElement
()));
}
},
null
);
}
public
void
addColumn
(
String
name
,
String
description
,
int
style
,
boolean
defaultVisible
,
boolean
required
,
CellLabelProvider
labelProvider
)
{
addColumn
(
name
,
description
,
style
,
defaultVisible
,
required
,
false
,
null
,
labelProvider
,
null
);
...
...
@@ -317,13 +324,12 @@ public class ViewerColumnController {
if
(
columnInfo
.
labelProvider
instanceof
ILazyLabelProvider
)
{
hasLazyColumns
=
true
;
}
else
if
(
columnInfo
.
labelProvider
instanceof
ILabelProvider
)
{
columnInfo
.
sortListener
=
new
SortListener
(
columnInfo
);
columnInfo
.
sortListener
=
new
SortListener
(
viewer
,
columnInfo
);
columnInfo
.
column
.
addListener
(
SWT
.
Selection
,
columnInfo
.
sortListener
);
}
}
if
(
hasLazyColumns
)
{
viewer
.
getControl
().
addListener
(
SWT
.
PaintItem
,
new
Listener
()
{
public
void
handleEvent
(
Event
event
)
{
viewer
.
getControl
().
addListener
(
SWT
.
PaintItem
,
event
->
{
if
(
viewer
instanceof
TreeViewer
)
{
TreeColumn
column
=
((
TreeViewer
)
viewer
).
getTree
().
getColumn
(
event
.
index
);
if
(((
ColumnInfo
)
column
.
getData
()).
labelProvider
instanceof
ILazyLabelProvider
&&
...
...
@@ -343,7 +349,6 @@ public class ViewerColumnController {
}
}
}
}
});
}
...
...
@@ -357,7 +362,7 @@ public class ViewerColumnController {
visibleList
.
add
(
column
);
}
}
Collections
.
sort
(
visibleList
,
new
ColumnInfoComparator
());
visibleList
.
sort
(
new
ColumnInfoComparator
());
return
visibleList
;
}
...
...
@@ -504,19 +509,17 @@ public class ViewerColumnController {
UIUtils
.
createControlLabel
(
composite
,
"Select columns you want to display"
);
List
<
ColumnInfo
>
orderedList
=
new
ArrayList
<>(
columns
);
Collections
.
sort
(
orderedList
,
new
ColumnInfoComparator
());
orderedList
.
sort
(
new
ColumnInfoComparator
());
colTable
=
new
Table
(
composite
,
SWT
.
BORDER
|
SWT
.
CHECK
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
colTable
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
colTable
.
setLinesVisible
(
true
);
colTable
.
addListener
(
SWT
.
Selection
,
new
Listener
()
{
public
void
handleEvent
(
Event
event
)
{
colTable
.
addListener
(
SWT
.
Selection
,
event
->
{
if
(
event
.
detail
==
SWT
.
CHECK
)
{
if
(((
TableItem
)
event
.
item
).
getGrayed
())
{
((
TableItem
)
event
.
item
).
setChecked
(
true
);
event
.
doit
=
false
;
}
}
}
});
final
TableColumn
nameColumn
=
new
TableColumn
(
colTable
,
SWT
.
LEFT
);
nameColumn
.
setText
(
"Name"
);
...
...
@@ -594,13 +597,15 @@ public class ViewerColumnController {
}
}
private
class
SortListener
implements
Listener
private
static
class
SortListener
implements
Listener
{
ColumnViewer
viewer
;
ColumnInfo
columnInfo
;
int
sortDirection
=
SWT
.
DOWN
;
Item
prevColumn
=
null
;
public
SortListener
(
ColumnInfo
columnInfo
)
{
public
SortListener
(
ColumnViewer
viewer
,
ColumnInfo
columnInfo
)
{
this
.
viewer
=
viewer
;
this
.
columnInfo
=
columnInfo
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录