Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
3bffdcb4
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,发现更多精彩内容 >>
提交
3bffdcb4
编写于
12月 04, 2017
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#2130 SQL formatters config UI (revert)
Former-commit-id:
2e70b714
上级
0e345be6
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
116 addition
and
52 deletion
+116
-52
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/BaseFormatterConfigurationPage.java
...ui/editors/sql/format/BaseFormatterConfigurationPage.java
+10
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/tokenized/ConfigurationPage.java
...er/ui/editors/sql/format/tokenized/ConfigurationPage.java
+0
-39
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/tokenized/SQLTokenizedConfigurationPage.java
...s/sql/format/tokenized/SQLTokenizedConfigurationPage.java
+77
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLFormattingStrategy.java
.../dbeaver/ui/editors/sql/syntax/SQLFormattingStrategy.java
+1
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageSQLFormat.java
...c/org/jkiss/dbeaver/ui/preferences/PrefPageSQLFormat.java
+3
-7
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPIdentifierCase.java
....model/src/org/jkiss/dbeaver/model/DBPIdentifierCase.java
+6
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/format/SQLFormatterConfiguration.java
...s/dbeaver/model/sql/format/SQLFormatterConfiguration.java
+18
-1
未找到文件。
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
3bffdcb4
...
...
@@ -3302,7 +3302,7 @@
</extension>
<extension
point=
"org.jkiss.dbeaver.sqlFormatter"
>
<formatter
id=
"default"
class=
"org.jkiss.dbeaver.model.sql.format.tokenized.SQLTokenizedFormatter"
configurerClass=
"org.jkiss.dbeaver.ui.editors.sql.format.tokenized.ConfigurationPage"
label=
"Default SQL formatter"
description=
"Default tokenized SQL formatter"
/>
<formatter
id=
"default"
class=
"org.jkiss.dbeaver.model.sql.format.tokenized.SQLTokenizedFormatter"
configurerClass=
"org.jkiss.dbeaver.ui.editors.sql.format.tokenized.
SQLTokenized
ConfigurationPage"
label=
"Default SQL formatter"
description=
"Default tokenized SQL formatter"
/>
<formatter
id=
"external"
class=
"org.jkiss.dbeaver.model.sql.format.external.SQLExternalFormatter"
label=
"External formatter"
description=
"External formatter. Uses configurable command-line executable to format SQL queries"
/>
</extension>
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/BaseFormatterConfigurationPage.java
浏览文件 @
3bffdcb4
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.ui.editors.sql.format
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.wizard.IWizardPage
;
import
org.eclipse.jface.wizard.Wizard
;
import
org.eclipse.jface.wizard.WizardDialog
;
import
org.eclipse.swt.layout.GridLayout
;
...
...
@@ -44,7 +45,7 @@ public abstract class BaseFormatterConfigurationPage extends ActiveWizardPage im
public
final
void
createControl
(
Composite
parent
)
{
setTitle
(
"SQL Format Configuration"
);
setDescription
(
getWizard
().
getFormaterName
());
Composite
composite
=
createFormatSettings
(
parent
);
Composite
composite
=
createFormatSettings
(
parent
,
getWizard
().
getConfiguration
()
);
...
...
@@ -56,7 +57,9 @@ public abstract class BaseFormatterConfigurationPage extends ActiveWizardPage im
return
(
ConfigWizard
)
super
.
getWizard
();
}
protected
abstract
Composite
createFormatSettings
(
Composite
parent
);
protected
abstract
Composite
createFormatSettings
(
Composite
parent
,
SQLFormatterConfiguration
configuration
);
protected
abstract
void
saveFormatSettings
(
SQLFormatterConfiguration
configuration
);
@Override
public
boolean
configure
(
String
formatName
,
SQLFormatter
formatter
,
SQLFormatterConfiguration
configuration
)
{
...
...
@@ -89,6 +92,11 @@ public abstract class BaseFormatterConfigurationPage extends ActiveWizardPage im
@Override
public
boolean
performFinish
()
{
for
(
IWizardPage
page
:
getPages
())
{
if
(
page
instanceof
BaseFormatterConfigurationPage
)
{
((
BaseFormatterConfigurationPage
)
page
).
saveFormatSettings
(
this
.
configuration
);
}
}
return
true
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/tokenized/ConfigurationPage.java
已删除
100644 → 0
浏览文件 @
0e345be6
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 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.editors.sql.format.tokenized
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Button
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Group
;
import
org.eclipse.swt.widgets.Spinner
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.editors.sql.format.BaseFormatterConfigurationPage
;
public
class
ConfigurationPage
extends
BaseFormatterConfigurationPage
{
@Override
protected
Composite
createFormatSettings
(
Composite
parent
)
{
Group
settings
=
UIUtils
.
createControlGroup
(
parent
,
"Settings"
,
2
,
GridData
.
FILL_HORIZONTAL
,
0
);
Button
useSpaces
=
UIUtils
.
createCheckbox
(
settings
,
"Insert spaces for tabs"
,
"Insert spaces for tabs"
,
false
,
2
);
Spinner
indentSize
=
UIUtils
.
createLabelSpinner
(
settings
,
"Indent size"
,
"Insert spaces for tabs"
,
4
,
0
,
100
);
return
parent
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/tokenized/SQLTokenizedConfigurationPage.java
0 → 100644
浏览文件 @
3bffdcb4
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 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.editors.sql.format.tokenized
;
import
org.eclipse.jface.preference.IPreferenceStore
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.ui.internal.editors.text.EditorsPlugin
;
import
org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBPIdentifierCase
;
import
org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.editors.sql.format.BaseFormatterConfigurationPage
;
public
class
SQLTokenizedConfigurationPage
extends
BaseFormatterConfigurationPage
{
private
Spinner
indentSizeSpinner
;
private
Button
useSpacesCheck
;
private
Button
compactFormatCheck
;
private
Combo
keywordCaseCombo
;
@Override
protected
Composite
createFormatSettings
(
Composite
parent
,
SQLFormatterConfiguration
configuration
)
{
Group
settings
=
UIUtils
.
createControlGroup
(
parent
,
"Settings"
,
2
,
GridData
.
FILL_HORIZONTAL
,
0
);
keywordCaseCombo
=
UIUtils
.
createLabelCombo
(
settings
,
CoreMessages
.
pref_page_sql_format_label_keyword_case
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
keywordCaseCombo
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
keywordCaseCombo
.
add
(
"Default"
);
for
(
DBPIdentifierCase
c
:
DBPIdentifierCase
.
values
())
{
keywordCaseCombo
.
add
(
DBPIdentifierCase
.
capitalizeCaseName
(
c
.
name
()));
}
DBPIdentifierCase
keywordCase
=
configuration
.
getKeywordCase
();
if
(
keywordCase
==
null
)
{
keywordCaseCombo
.
select
(
0
);
}
else
{
UIUtils
.
setComboSelection
(
keywordCaseCombo
,
DBPIdentifierCase
.
capitalizeCaseName
(
keywordCase
.
name
()));
}
IPreferenceStore
preferenceStore
=
getPreferenceStore
();
boolean
useSpaces
=
preferenceStore
.
getBoolean
(
AbstractDecoratedTextEditorPreferenceConstants
.
EDITOR_SPACES_FOR_TABS
);
int
tabWidth
=
preferenceStore
.
getInt
(
AbstractDecoratedTextEditorPreferenceConstants
.
EDITOR_TAB_WIDTH
);
this
.
indentSizeSpinner
=
UIUtils
.
createLabelSpinner
(
settings
,
"Indent size"
,
"Insert spaces for tabs"
,
tabWidth
,
0
,
100
);
this
.
useSpacesCheck
=
UIUtils
.
createCheckbox
(
settings
,
"Insert spaces for tabs"
,
"Insert spaces for tabs"
,
useSpaces
,
2
);
this
.
compactFormatCheck
=
UIUtils
.
createCheckbox
(
settings
,
"Compact formatting"
,
"Compact formatting. Less line feeds and indentation"
,
false
,
2
);
return
parent
;
}
@Override
protected
void
saveFormatSettings
(
SQLFormatterConfiguration
configuration
)
{
// Save formatter settings
}
private
IPreferenceStore
getPreferenceStore
()
{
return
EditorsPlugin
.
getDefault
().
getPreferenceStore
();
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLFormattingStrategy.java
浏览文件 @
3bffdcb4
...
...
@@ -57,9 +57,8 @@ public class SQLFormattingStrategy extends ContextBasedFormattingStrategy
SQLFormatterConfiguration
configuration
=
new
SQLFormatterConfiguration
(
sqlSyntax
);
configuration
.
setIndentString
(
indentPrefixes
[
0
]);
SQLFormatter
formatter
=
SQLFormatterConfigurationRegistry
.
getInstance
().
create
AndConfigure
Formatter
(
configuration
);
SQLFormatter
formatter
=
SQLFormatterConfigurationRegistry
.
getInstance
().
createFormatter
(
configuration
);
if
(
formatter
==
null
)
{
//DBeaverUI.getInstance().showError("SQL Format", "Can't create SQL formatter. See error log.");
return
content
;
}
return
formatter
.
format
(
content
,
configuration
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageSQLFormat.java
浏览文件 @
3bffdcb4
...
...
@@ -153,7 +153,7 @@ public class PrefPageSQLFormat extends TargetPrefPage
formatterSelector
=
UIUtils
.
createLabelCombo
(
formatterPanel
,
CoreMessages
.
pref_page_sql_format_label_formatter
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
formatters
=
SQLFormatterConfigurationRegistry
.
getInstance
().
getFormatters
();
for
(
SQLFormatterDescriptor
formatterDesc
:
formatters
)
{
formatterSelector
.
add
(
capitalizeCaseName
(
formatterDesc
.
getLabel
()));
formatterSelector
.
add
(
DBPIdentifierCase
.
capitalizeCaseName
(
formatterDesc
.
getLabel
()));
}
formatterSelector
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
...
...
@@ -172,7 +172,7 @@ public class PrefPageSQLFormat extends TargetPrefPage
keywordCaseCombo
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
keywordCaseCombo
.
add
(
"Database"
);
for
(
DBPIdentifierCase
c
:
DBPIdentifierCase
.
values
())
{
keywordCaseCombo
.
add
(
capitalizeCaseName
(
c
.
name
()));
keywordCaseCombo
.
add
(
DBPIdentifierCase
.
capitalizeCaseName
(
c
.
name
()));
}
keywordCaseCombo
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
...
...
@@ -277,7 +277,7 @@ public class PrefPageSQLFormat extends TargetPrefPage
if
(
CommonUtils
.
isEmpty
(
caseName
))
{
keywordCaseCombo
.
select
(
0
);
}
else
{
UIUtils
.
setComboSelection
(
keywordCaseCombo
,
capitalizeCaseName
(
caseName
));
UIUtils
.
setComboSelection
(
keywordCaseCombo
,
DBPIdentifierCase
.
capitalizeCaseName
(
caseName
));
}
externalCmdText
.
setText
(
store
.
getString
(
ModelPreferences
.
SQL_FORMAT_EXTERNAL_CMD
));
...
...
@@ -352,10 +352,6 @@ public class PrefPageSQLFormat extends TargetPrefPage
defaultGroup
.
getParent
().
layout
();
}
private
static
String
capitalizeCaseName
(
String
name
)
{
return
CommonUtils
.
capitalizeWord
(
name
.
toLowerCase
(
Locale
.
ENGLISH
));
}
private
void
formatSQL
()
{
try
{
try
(
final
InputStream
sqlStream
=
getClass
().
getResourceAsStream
(
FORMAT_FILE_NAME
))
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPIdentifierCase.java
浏览文件 @
3bffdcb4
...
...
@@ -17,6 +17,8 @@
package
org.jkiss.dbeaver.model
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.Locale
;
/**
...
...
@@ -45,6 +47,10 @@ public enum DBPIdentifierCase {
}
};
public
static
String
capitalizeCaseName
(
String
name
)
{
return
CommonUtils
.
capitalizeWord
(
name
.
toLowerCase
(
Locale
.
ENGLISH
));
}
public
abstract
String
transform
(
String
value
);
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/format/SQLFormatterConfiguration.java
浏览文件 @
3bffdcb4
...
...
@@ -46,12 +46,20 @@ public class SQLFormatterConfiguration {
private
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
/**
* Create formatter config with default (set in properties) formatter
*/
public
SQLFormatterConfiguration
(
SQLSyntaxManager
syntaxManager
)
{
this
(
syntaxManager
,
CommonUtils
.
notEmpty
(
syntaxManager
.
getPreferenceStore
().
getString
(
ModelPreferences
.
SQL_FORMAT_FORMATTER
)).
toUpperCase
(
Locale
.
ENGLISH
));
}
public
SQLFormatterConfiguration
(
SQLSyntaxManager
syntaxManager
,
String
formatterId
)
{
this
.
syntaxManager
=
syntaxManager
;
this
.
keywordCase
=
syntaxManager
.
getKeywordCase
();
this
.
formatterId
=
CommonUtils
.
notEmpty
(
syntaxManager
.
getPreferenceStore
().
getString
(
ModelPreferences
.
SQL_FORMAT_FORMATTER
)).
toUpperCase
(
Locale
.
ENGLISH
)
;
this
.
formatterId
=
formatterId
;
}
public
SQLSyntaxManager
getSyntaxManager
()
...
...
@@ -113,4 +121,13 @@ public class SQLFormatterConfiguration {
public
DBPPreferenceStore
getPreferenceStore
()
{
return
syntaxManager
.
getPreferenceStore
();
}
public
void
loadSettings
()
{
}
public
void
saveSettings
()
{
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录