Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
c8312c4d
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,发现更多精彩内容 >>
提交
c8312c4d
编写于
6月 02, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Table editor - proposals
上级
a096cbbb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
82 addition
and
18 deletion
+82
-18
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/StringEditorTable.java
.../src/org/jkiss/dbeaver/ui/controls/StringEditorTable.java
+24
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingConfigDialog.java
...ntrols/resultset/panel/grouping/GroupingConfigDialog.java
+15
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingResultsContainer.java
...ls/resultset/panel/grouping/GroupingResultsContainer.java
+9
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/EditObjectFilterDialog.java
...dbeaver/ui/dialogs/connection/EditObjectFilterDialog.java
+2
-2
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/UIUtils.java
...rg.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/UIUtils.java
+3
-1
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/CustomTableEditor.java
.../src/org/jkiss/dbeaver/ui/controls/CustomTableEditor.java
+29
-10
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/StringEditorTable.java
浏览文件 @
c8312c4d
...
...
@@ -16,6 +16,9 @@
*/
package
org.jkiss.dbeaver.ui.controls
;
import
org.eclipse.jface.fieldassist.ContentProposalAdapter
;
import
org.eclipse.jface.fieldassist.IContentProposalProvider
;
import
org.eclipse.jface.fieldassist.TextContentAdapter
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.ControlAdapter
;
import
org.eclipse.swt.events.ControlEvent
;
...
...
@@ -23,6 +26,8 @@ import org.eclipse.swt.events.SelectionAdapter;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
...
...
@@ -37,7 +42,15 @@ import java.util.List;
*/
public
class
StringEditorTable
{
public
static
Table
createEditableList
(
Composite
parent
,
String
name
,
List
<
String
>
values
,
DBPImage
icon
)
{
private
static
Button
removeButton
;
public
static
Table
createEditableList
(
@NotNull
Composite
parent
,
@NotNull
String
name
,
@Nullable
List
<
String
>
values
,
@Nullable
DBPImage
icon
,
@Nullable
IContentProposalProvider
proposalProvider
)
{
Group
group
=
UIUtils
.
createControlGroup
(
parent
,
name
,
2
,
GridData
.
FILL_BOTH
,
0
);
final
Table
valueTable
=
new
Table
(
group
,
SWT
.
SINGLE
|
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
...
...
@@ -69,6 +82,14 @@ public class StringEditorTable {
protected
Control
createEditor
(
Table
table
,
int
index
,
TableItem
item
)
{
Text
editor
=
new
Text
(
table
,
SWT
.
BORDER
);
editor
.
setText
(
item
.
getText
());
if
(
proposalProvider
!=
null
)
{
setProposalAdapter
(
UIUtils
.
installContentProposal
(
editor
,
new
TextContentAdapter
(),
proposalProvider
,
true
,
false
));
}
return
editor
;
}
@Override
...
...
@@ -92,10 +113,11 @@ public class StringEditorTable {
valueTable
.
setSelection
(
newItem
);
tableEditor
.
closeEditor
();
tableEditor
.
showEditor
(
newItem
);
removeButton
.
setEnabled
(
true
);
}
});
final
Button
removeButton
=
new
Button
(
buttonsGroup
,
SWT
.
PUSH
);
removeButton
=
new
Button
(
buttonsGroup
,
SWT
.
PUSH
);
removeButton
.
setText
(
CoreMessages
.
dialog_filter_button_remove
);
removeButton
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
removeButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingConfigDialog.java
浏览文件 @
c8312c4d
...
...
@@ -17,13 +17,18 @@
package
org.jkiss.dbeaver.ui.controls.resultset.panel.grouping
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.fieldassist.IContentProposalProvider
;
import
org.eclipse.jface.fieldassist.SimpleContentProposalProvider
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.StringEditorTable
;
import
org.jkiss.dbeaver.ui.dialogs.BaseDialog
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
...
...
@@ -54,8 +59,16 @@ class GroupingConfigDialog extends BaseDialog
{
Composite
composite
=
super
.
createDialogArea
(
parent
);
columnsTable
=
StringEditorTable
.
createEditableList
(
composite
,
"Columns"
,
resultsContainer
.
getGroupAttributes
(),
DBIcon
.
TREE_ATTRIBUTE
);
functionsTable
=
StringEditorTable
.
createEditableList
(
composite
,
"Functions"
,
resultsContainer
.
getGroupFunctions
(),
DBIcon
.
TREE_FUNCTION
);
List
<
String
>
proposals
=
new
ArrayList
<>();
for
(
DBDAttributeBinding
attr
:
resultsContainer
.
getOwnerPresentation
().
getController
().
getModel
().
getAttributes
())
{
proposals
.
add
(
attr
.
getName
());
}
IContentProposalProvider
proposalProvider
=
new
SimpleContentProposalProvider
(
proposals
.
toArray
(
new
String
[
0
]));
columnsTable
=
StringEditorTable
.
createEditableList
(
composite
,
"Columns"
,
resultsContainer
.
getGroupAttributes
(),
DBIcon
.
TREE_ATTRIBUTE
,
proposalProvider
);
Collections
.
addAll
(
proposals
,
"COUNT"
,
"AVG"
,
"MAX"
,
"MIN"
,
"SUM"
);
proposalProvider
=
new
SimpleContentProposalProvider
(
proposals
.
toArray
(
new
String
[
0
]));
functionsTable
=
StringEditorTable
.
createEditableList
(
composite
,
"Functions"
,
resultsContainer
.
getGroupFunctions
(),
DBIcon
.
TREE_FUNCTION
,
proposalProvider
);
return
composite
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingResultsContainer.java
浏览文件 @
c8312c4d
...
...
@@ -35,6 +35,10 @@ import java.util.List;
public
class
GroupingResultsContainer
implements
IResultSetContainer
{
public
static
final
String
FUNCTION_COUNT
=
"COUNT"
;
public
static
final
String
DEFAULT_FUNCTION
=
FUNCTION_COUNT
+
"(*)"
;
private
final
IResultSetPresentation
presentation
;
private
GroupingDataContainer
dataContainer
;
private
ResultSetViewer
groupingViewer
;
...
...
@@ -52,7 +56,11 @@ public class GroupingResultsContainer implements IResultSetContainer {
private
void
initDefaultSettings
()
{
this
.
groupAttributes
.
clear
();
this
.
groupFunctions
.
clear
();
addGroupingFunctions
(
Collections
.
singletonList
(
"COUNT(*)"
));
addGroupingFunctions
(
Collections
.
singletonList
(
DEFAULT_FUNCTION
));
}
public
IResultSetPresentation
getOwnerPresentation
()
{
return
presentation
;
}
public
List
<
String
>
getGroupAttributes
()
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/EditObjectFilterDialog.java
浏览文件 @
c8312c4d
...
...
@@ -99,8 +99,8 @@ public class EditObjectFilterDialog extends HelpEnabledDialog {
blockControl
=
UIUtils
.
createPlaceholder
(
composite
,
1
);
blockControl
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
includeTable
=
StringEditorTable
.
createEditableList
(
blockControl
,
CoreMessages
.
dialog_filter_list_include
,
filter
.
getInclude
(),
null
);
excludeTable
=
StringEditorTable
.
createEditableList
(
blockControl
,
CoreMessages
.
dialog_filter_list_exclude
,
filter
.
getExclude
(),
null
);
includeTable
=
StringEditorTable
.
createEditableList
(
blockControl
,
CoreMessages
.
dialog_filter_list_include
,
filter
.
getInclude
(),
null
,
null
);
excludeTable
=
StringEditorTable
.
createEditableList
(
blockControl
,
CoreMessages
.
dialog_filter_list_exclude
,
filter
.
getExclude
(),
null
,
null
);
UIUtils
.
createInfoLabel
(
blockControl
,
CoreMessages
.
dialog_connection_edit_wizard_general_filter_hint_text
);
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/UIUtils.java
浏览文件 @
c8312c4d
...
...
@@ -1585,7 +1585,7 @@ public class UIUtils {
installContentProposal
(
control
,
contentAdapter
,
provider
,
false
,
true
);
}
public
static
void
installContentProposal
(
Control
control
,
IControlContentAdapter
contentAdapter
,
IContentProposalProvider
provider
,
boolean
autoActivation
,
boolean
insertAfter
)
{
public
static
ContentProposalAdapter
installContentProposal
(
Control
control
,
IControlContentAdapter
contentAdapter
,
IContentProposalProvider
provider
,
boolean
autoActivation
,
boolean
insertAfter
)
{
try
{
KeyStroke
keyStroke
=
autoActivation
?
null
:
KeyStroke
.
getInstance
(
"Ctrl+Space"
);
final
ContentProposalAdapter
proposalAdapter
=
new
ContentProposalAdapter
(
...
...
@@ -1596,8 +1596,10 @@ public class UIUtils {
autoActivation
?
".abcdefghijklmnopqrstuvwxyz_$("
.
toCharArray
()
:
".("
.
toCharArray
());
proposalAdapter
.
setProposalAcceptanceStyle
(
insertAfter
?
ContentProposalAdapter
.
PROPOSAL_INSERT
:
ContentProposalAdapter
.
PROPOSAL_REPLACE
);
proposalAdapter
.
setPopupSize
(
new
Point
(
300
,
200
));
return
proposalAdapter
;
}
catch
(
ParseException
e
)
{
log
.
error
(
"Error installing filters content assistant"
);
return
null
;
}
}
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/CustomTableEditor.java
浏览文件 @
c8312c4d
...
...
@@ -16,6 +16,7 @@
*/
package
org.jkiss.dbeaver.ui.controls
;
import
org.eclipse.jface.fieldassist.ContentProposalAdapter
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.TableEditor
;
import
org.eclipse.swt.events.*
;
...
...
@@ -32,23 +33,34 @@ public abstract class CustomTableEditor implements MouseListener, TraverseListen
private
final
Table
table
;
private
final
TableEditor
tableEditor
;
private
ContentProposalAdapter
proposalAdapter
;
private
int
columnIndex
;
protected
int
firstTraverseIndex
=
-
1
,
lastTraverseIndex
=
-
1
;
protected
boolean
editOnEnter
=
true
;
public
CustomTableEditor
(
Table
table
)
{
this
(
table
,
null
);
}
public
CustomTableEditor
(
Table
table
,
ContentProposalAdapter
proposalAdapter
)
{
this
.
table
=
table
;
this
.
proposalAdapter
=
proposalAdapter
;
tableEditor
=
new
TableEditor
(
table
);
tableEditor
.
horizontalAlignment
=
SWT
.
CENTER
;
tableEditor
.
verticalAlignment
=
SWT
.
TOP
;
tableEditor
.
grabHorizontal
=
true
;
//tableEditor.grabVertical = true;
tableEditor
.
minimumWidth
=
50
;
table
.
addMouseListener
(
this
);
table
.
addTraverseListener
(
this
);
}
public
void
setProposalAdapter
(
ContentProposalAdapter
proposalAdapter
)
{
this
.
proposalAdapter
=
proposalAdapter
;
}
@Override
public
void
mouseDoubleClick
(
MouseEvent
e
)
{
...
...
@@ -68,12 +80,7 @@ public abstract class CustomTableEditor implements MouseListener, TraverseListen
final
TableItem
item
=
table
.
getItem
(
new
Point
(
e
.
x
,
e
.
y
));
if
(
item
!=
null
)
{
columnIndex
=
UIUtils
.
getColumnAtPos
(
item
,
e
.
x
,
e
.
y
);
UIUtils
.
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
showEditor
(
item
);
}
});
UIUtils
.
asyncExec
(()
->
showEditor
(
item
));
}
}
...
...
@@ -94,13 +101,19 @@ public abstract class CustomTableEditor implements MouseListener, TraverseListen
@Override
public
void
focusLost
(
FocusEvent
e
)
{
saveEditorValue
(
editor
,
columnIndex
,
tableEditor
.
getItem
());
closeEditor
();
if
(!
isProposalPopupActive
())
{
closeEditor
();
}
}
});
editor
.
addTraverseListener
(
this
);
tableEditor
.
setEditor
(
editor
,
item
,
columnIndex
);
}
private
boolean
isProposalPopupActive
()
{
return
proposalAdapter
!=
null
&&
proposalAdapter
.
isProposalPopupOpen
();
}
public
void
closeEditor
()
{
Control
oldEditor
=
this
.
tableEditor
.
getEditor
();
if
(
oldEditor
!=
null
)
oldEditor
.
dispose
();
...
...
@@ -116,7 +129,9 @@ public abstract class CustomTableEditor implements MouseListener, TraverseListen
if
(
e
.
detail
==
SWT
.
TRAVERSE_RETURN
)
{
if
(
editor
!=
null
)
{
saveEditorValue
(
editor
,
columnIndex
,
tableEditor
.
getItem
());
closeEditor
();
if
(!
isProposalPopupActive
())
{
this
.
closeEditor
();
}
}
else
if
(
editOnEnter
)
{
TableItem
[]
selection
=
table
.
getSelection
();
if
(
selection
!=
null
&&
selection
.
length
>=
1
)
{
...
...
@@ -131,7 +146,9 @@ public abstract class CustomTableEditor implements MouseListener, TraverseListen
TableItem
item
=
tableEditor
.
getItem
();
if
(
item
!=
null
)
{
saveEditorValue
(
editor
,
columnIndex
,
item
);
closeEditor
();
if
(!
isProposalPopupActive
())
{
this
.
closeEditor
();
}
int
lastColumn
=
lastTraverseIndex
>
0
?
lastTraverseIndex
:
table
.
getColumnCount
()
-
1
;
if
(
columnIndex
<
lastColumn
)
{
...
...
@@ -153,7 +170,9 @@ public abstract class CustomTableEditor implements MouseListener, TraverseListen
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
}
else
if
(
e
.
detail
==
SWT
.
TRAVERSE_ESCAPE
&&
editor
!=
null
)
{
closeEditor
();
if
(!
isProposalPopupActive
())
{
this
.
closeEditor
();
}
e
.
doit
=
false
;
e
.
detail
=
SWT
.
TRAVERSE_NONE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录