Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
f6bd082d
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,发现更多精彩内容 >>
提交
f6bd082d
编写于
5月 31, 2014
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Duplicate proposals filtering
Former-commit-id:
30981462
上级
5799f0ce
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
93 addition
and
17 deletion
+93
-17
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverPreferencesInitializer.java
...org/jkiss/dbeaver/core/DBeaverPreferencesInitializer.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLPreferenceConstants.java
.../jkiss/dbeaver/ui/editors/sql/SQLPreferenceConstants.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLCompletionProcessor.java
...dbeaver/ui/editors/sql/syntax/SQLCompletionProcessor.java
+57
-16
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLCompletionProposal.java
.../dbeaver/ui/editors/sql/syntax/SQLCompletionProposal.java
+28
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageSQLEditor.java
...c/org/jkiss/dbeaver/ui/preferences/PrefPageSQLEditor.java
+6
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverPreferencesInitializer.java
浏览文件 @
f6bd082d
...
...
@@ -102,6 +102,7 @@ public class DBeaverPreferencesInitializer extends AbstractPreferenceInitializer
RuntimeUtils
.
setDefaultPreferenceValue
(
store
,
SQLPreferenceConstants
.
AUTO_ACTIVATION_DELAY
,
500
);
RuntimeUtils
.
setDefaultPreferenceValue
(
store
,
SQLPreferenceConstants
.
INSERT_SINGLE_PROPOSALS_AUTO
,
true
);
RuntimeUtils
.
setDefaultPreferenceValue
(
store
,
SQLPreferenceConstants
.
PROPOSAL_INSERT_CASE
,
SQLPreferenceConstants
.
PROPOSAL_CASE_DEFAULT
);
RuntimeUtils
.
setDefaultPreferenceValue
(
store
,
SQLPreferenceConstants
.
HIDE_DUPLICATE_PROPOSALS
,
true
);
RuntimeUtils
.
setDefaultPreferenceValue
(
store
,
SQLPreferenceConstants
.
SQLEDITOR_CLOSE_SINGLE_QUOTES
,
true
);
RuntimeUtils
.
setDefaultPreferenceValue
(
store
,
SQLPreferenceConstants
.
SQLEDITOR_CLOSE_DOUBLE_QUOTES
,
true
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLPreferenceConstants.java
浏览文件 @
f6bd082d
...
...
@@ -25,6 +25,7 @@ public class SQLPreferenceConstants
public
static
final
String
ENABLE_AUTO_ACTIVATION
=
"enable.auto.activation"
;
public
static
final
String
AUTO_ACTIVATION_DELAY
=
"auto.activation.delay"
;
public
static
final
String
PROPOSAL_INSERT_CASE
=
"proposal.insert.case"
;
public
static
final
String
HIDE_DUPLICATE_PROPOSALS
=
"hide.duplicate.proposals"
;
// Syntax Validation
public
static
final
String
SYNTAX_VALIDATION
=
"syntax.validation"
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLCompletionProcessor.java
浏览文件 @
f6bd082d
...
...
@@ -97,7 +97,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
this
.
activeQuery
=
null
;
this
.
wordDetector
=
new
SQLWordPartDetector
(
viewer
.
getDocument
(),
editor
.
getSyntaxManager
(),
documentOffset
);
final
List
<
ICompletionProposal
>
proposals
=
new
ArrayList
<
I
CompletionProposal
>();
final
List
<
SQLCompletionProposal
>
proposals
=
new
ArrayList
<
SQL
CompletionProposal
>();
final
String
wordPart
=
wordDetector
.
getWordPart
();
QueryType
queryType
=
null
;
...
...
@@ -148,15 +148,16 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
keyWord
,
keyWord
+
" ("
+
keywordType
.
name
()
+
")"
,
null
,
false
));
false
,
null
));
}
}
// Remove duplications
for
(
int
i
=
0
;
i
<
proposals
.
size
();
i
++)
{
I
CompletionProposal
proposal
=
proposals
.
get
(
i
);
SQL
CompletionProposal
proposal
=
proposals
.
get
(
i
);
for
(
int
j
=
i
+
1
;
j
<
proposals
.
size
();
)
{
I
CompletionProposal
proposal2
=
proposals
.
get
(
j
);
SQL
CompletionProposal
proposal2
=
proposals
.
get
(
j
);
if
(
proposal
.
getDisplayString
().
equals
(
proposal2
.
getDisplayString
()))
{
proposals
.
remove
(
j
);
}
else
{
...
...
@@ -164,12 +165,38 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
}
}
}
DBSObject
selectedObject
=
getSelectedObject
(
editor
.
getDataSource
());
boolean
hideDups
=
getPreferences
().
getBoolean
(
SQLPreferenceConstants
.
HIDE_DUPLICATE_PROPOSALS
)
&&
selectedObject
!=
null
;
if
(
hideDups
)
{
for
(
int
i
=
0
;
i
<
proposals
.
size
();
i
++)
{
SQLCompletionProposal
proposal
=
proposals
.
get
(
i
);
for
(
int
j
=
0
;
j
<
proposals
.
size
();
)
{
SQLCompletionProposal
proposal2
=
proposals
.
get
(
j
);
if
(
i
!=
j
&&
proposal
.
hasStructObject
()
&&
proposal2
.
hasStructObject
()
&&
CommonUtils
.
equalObjects
(
proposal
.
getObject
().
getName
(),
proposal2
.
getObject
().
getName
())
&&
proposal
.
getObjectContainer
()
==
selectedObject
)
{
proposals
.
remove
(
j
);
}
else
{
j
++;
}
}
}
}
if
(
hideDups
)
{
// Remove duplicates from non-active schema
if
(
selectedObject
instanceof
DBSObjectContainer
)
{
//List<ICompletionProposal>
}
}
return
proposals
.
toArray
(
new
ICompletionProposal
[
proposals
.
size
()]);
}
private
void
makeStructureProposals
(
final
DBRProgressMonitor
monitor
,
final
List
<
I
CompletionProposal
>
proposals
,
final
List
<
SQL
CompletionProposal
>
proposals
,
final
String
wordPart
,
final
QueryType
queryType
)
{
...
...
@@ -227,7 +254,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
private
void
makeStructureProposals
(
DBRProgressMonitor
monitor
,
DBPDataSource
dataSource
,
List
<
I
CompletionProposal
>
proposals
)
List
<
SQL
CompletionProposal
>
proposals
)
{
final
DBSObjectContainer
rootContainer
=
DBUtils
.
getAdapter
(
DBSObjectContainer
.
class
,
dataSource
);
if
(
rootContainer
==
null
)
{
...
...
@@ -441,7 +468,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
DBRProgressMonitor
monitor
,
DBSObject
parent
,
@Nullable
String
startPart
,
List
<
I
CompletionProposal
>
proposals
)
List
<
SQL
CompletionProposal
>
proposals
)
{
if
(
startPart
!=
null
)
{
startPart
=
wordDetector
.
removeQuotes
(
startPart
).
toUpperCase
();
...
...
@@ -475,7 +502,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
DBSStructureAssistant
assistant
,
@Nullable
DBSObjectContainer
rootSC
,
String
objectName
,
List
<
I
CompletionProposal
>
proposals
)
List
<
SQL
CompletionProposal
>
proposals
)
{
try
{
Collection
<
DBSObjectReference
>
references
=
assistant
.
findObjectsByMask
(
...
...
@@ -493,13 +520,13 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
}
}
private
I
CompletionProposal
makeProposalsFromObject
(
DBRProgressMonitor
monitor
,
DBSObject
object
)
private
SQL
CompletionProposal
makeProposalsFromObject
(
DBRProgressMonitor
monitor
,
DBSObject
object
)
{
DBNNode
node
=
DBeaverCore
.
getInstance
().
getNavigatorModel
().
getNodeByObject
(
monitor
,
object
,
false
);
return
makeProposalsFromObject
(
object
,
node
==
null
?
null
:
node
.
getNodeIconDefault
());
}
private
I
CompletionProposal
makeProposalsFromObject
(
DBPNamedObject
object
,
@Nullable
Image
objectIcon
)
private
SQL
CompletionProposal
makeProposalsFromObject
(
DBPNamedObject
object
,
@Nullable
Image
objectIcon
)
{
String
objectFullName
=
DBUtils
.
getObjectFullName
(
object
);
...
...
@@ -550,23 +577,36 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
objectFullName
,
info
.
toString
(),
objectIcon
,
isSingleObject
);
isSingleObject
,
object
);
}
private
IPreferenceStore
getPreferences
()
{
IPreferenceStore
store
=
null
;
SQLDataSource
dataSource
=
editor
.
getDataSource
();
if
(
dataSource
!=
null
)
{
store
=
dataSource
.
getContainer
().
getPreferenceStore
();
}
if
(
store
==
null
)
{
store
=
DBeaverCore
.
getGlobalPreferenceStore
();
}
return
store
;
}
/*
* Turns the vector into an Array of ICompletionProposal objects
*/
protected
I
CompletionProposal
createCompletionProposal
(
protected
SQL
CompletionProposal
createCompletionProposal
(
String
replaceString
,
String
displayString
,
String
description
,
@Nullable
Image
image
,
boolean
isObject
)
boolean
isObject
,
@Nullable
DBPNamedObject
object
)
{
IPreferenceStore
store
=
DBeaverCore
.
getGlobalPreferenceStore
();
IPreferenceStore
store
=
getPreferences
();
SQLDataSource
dataSource
=
editor
.
getDataSource
();
if
(
dataSource
!=
null
)
{
store
=
dataSource
.
getContainer
().
getPreferenceStore
();
if
(
isObject
)
{
// Escape replace string if required
replaceString
=
DBUtils
.
getQuotedIdentifier
(
dataSource
,
replaceString
);
...
...
@@ -600,7 +640,8 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
// relative to replacementOffset
image
,
//image to display
new
ContextInformation
(
image
,
displayString
,
displayString
),
//the context information associated with this proposal
description
);
description
,
object
);
}
/**
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLCompletionProposal.java
浏览文件 @
f6bd082d
...
...
@@ -30,6 +30,9 @@ import org.eclipse.jface.text.contentassist.IContextInformation;
import
org.eclipse.swt.graphics.Image
;
import
org.eclipse.swt.graphics.Point
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPNamedObject
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.DBSObjectReference
;
import
org.jkiss.utils.CommonUtils
;
/**
...
...
@@ -60,6 +63,8 @@ public class SQLCompletionProposal implements ICompletionProposal, ICompletionPr
/** The additional info of this proposal. */
private
String
additionalProposalInfo
;
private
DBPNamedObject
object
;
public
SQLCompletionProposal
(
SQLSyntaxManager
syntaxManager
,
String
displayString
,
...
...
@@ -68,7 +73,8 @@ public class SQLCompletionProposal implements ICompletionProposal, ICompletionPr
int
cursorPosition
,
@Nullable
Image
image
,
IContextInformation
contextInformation
,
String
additionalProposalInfo
)
String
additionalProposalInfo
,
DBPNamedObject
object
)
{
this
.
syntaxManager
=
syntaxManager
;
this
.
displayString
=
displayString
;
...
...
@@ -86,6 +92,12 @@ public class SQLCompletionProposal implements ICompletionProposal, ICompletionPr
this
.
additionalProposalInfo
=
additionalProposalInfo
;
setPosition
(
wordDetector
);
this
.
object
=
object
;
}
public
DBPNamedObject
getObject
()
{
return
object
;
}
private
void
setPosition
(
SQLWordPartDetector
wordDetector
)
...
...
@@ -191,4 +203,19 @@ public class SQLCompletionProposal implements ICompletionProposal, ICompletionPr
return
false
;
}
}
public
boolean
hasStructObject
()
{
return
object
instanceof
DBSObject
||
object
instanceof
DBSObjectReference
;
}
public
DBSObject
getObjectContainer
()
{
if
(
object
instanceof
DBSObject
)
{
return
((
DBSObject
)
object
).
getParentObject
();
}
else
if
(
object
instanceof
DBSObjectReference
)
{
return
((
DBSObjectReference
)
object
).
getContainer
();
}
else
{
return
null
;
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageSQLEditor.java
浏览文件 @
f6bd082d
...
...
@@ -60,6 +60,7 @@ public class PrefPageSQLEditor extends TargetPrefPage
private
Spinner
csAutoActivationDelaySpinner
;
private
Button
csAutoInsertCheck
;
private
Combo
csInsertCase
;
private
Button
csHideDuplicates
;
private
Map
<
RulerColumnDescriptor
,
Button
>
rulerChecks
=
new
HashMap
<
RulerColumnDescriptor
,
Button
>();
private
Button
acSingleQuotesCheck
;
private
Button
acDoubleQuotesCheck
;
...
...
@@ -177,6 +178,8 @@ public class PrefPageSQLEditor extends TargetPrefPage
csInsertCase
.
add
(
"Default"
);
csInsertCase
.
add
(
"Upper case"
);
csInsertCase
.
add
(
"Lower case"
);
csHideDuplicates
=
UIUtils
.
createLabelCheckbox
(
assistGroup
,
"Hide duplicate names\nfrom non-active schemas"
,
false
);
}
// Autoclose
...
...
@@ -227,6 +230,7 @@ public class PrefPageSQLEditor extends TargetPrefPage
csAutoActivationDelaySpinner
.
setSelection
(
store
.
getInt
(
SQLPreferenceConstants
.
AUTO_ACTIVATION_DELAY
));
csAutoInsertCheck
.
setSelection
(
store
.
getBoolean
(
SQLPreferenceConstants
.
INSERT_SINGLE_PROPOSALS_AUTO
));
csInsertCase
.
select
(
store
.
getInt
(
SQLPreferenceConstants
.
PROPOSAL_INSERT_CASE
));
csHideDuplicates
.
setSelection
(
store
.
getBoolean
(
SQLPreferenceConstants
.
HIDE_DUPLICATE_PROPOSALS
));
acSingleQuotesCheck
.
setSelection
(
store
.
getBoolean
(
SQLPreferenceConstants
.
SQLEDITOR_CLOSE_SINGLE_QUOTES
));
acDoubleQuotesCheck
.
setSelection
(
store
.
getBoolean
(
SQLPreferenceConstants
.
SQLEDITOR_CLOSE_DOUBLE_QUOTES
));
acBracketsCheck
.
setSelection
(
store
.
getBoolean
(
SQLPreferenceConstants
.
SQLEDITOR_CLOSE_BRACKETS
));
...
...
@@ -254,6 +258,7 @@ public class PrefPageSQLEditor extends TargetPrefPage
store
.
setValue
(
SQLPreferenceConstants
.
AUTO_ACTIVATION_DELAY
,
csAutoActivationDelaySpinner
.
getSelection
());
store
.
setValue
(
SQLPreferenceConstants
.
INSERT_SINGLE_PROPOSALS_AUTO
,
csAutoInsertCheck
.
getSelection
());
store
.
setValue
(
SQLPreferenceConstants
.
PROPOSAL_INSERT_CASE
,
csInsertCase
.
getSelectionIndex
());
store
.
setValue
(
SQLPreferenceConstants
.
HIDE_DUPLICATE_PROPOSALS
,
csHideDuplicates
.
getSelection
());
store
.
setValue
(
DBeaverPreferences
.
SCRIPT_COMMIT_TYPE
,
CommonUtils
.
fromOrdinal
(
SQLScriptCommitType
.
class
,
commitTypeCombo
.
getSelectionIndex
()).
name
());
store
.
setValue
(
DBeaverPreferences
.
SCRIPT_COMMIT_LINES
,
commitLinesText
.
getSelection
());
...
...
@@ -287,6 +292,7 @@ public class PrefPageSQLEditor extends TargetPrefPage
store
.
setToDefault
(
SQLPreferenceConstants
.
AUTO_ACTIVATION_DELAY
);
store
.
setToDefault
(
SQLPreferenceConstants
.
INSERT_SINGLE_PROPOSALS_AUTO
);
store
.
setToDefault
(
SQLPreferenceConstants
.
PROPOSAL_INSERT_CASE
);
store
.
setToDefault
(
SQLPreferenceConstants
.
HIDE_DUPLICATE_PROPOSALS
);
store
.
setToDefault
(
DBeaverPreferences
.
SCRIPT_COMMIT_TYPE
);
store
.
setToDefault
(
DBeaverPreferences
.
SCRIPT_COMMIT_LINES
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录