Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
de0ae386
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,发现更多精彩内容 >>
提交
de0ae386
编写于
6月 25, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bootstrap SQL queries edit
Former-commit-id:
7c89694a
上级
7553c619
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
206 addition
and
19 deletion
+206
-19
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/DBPConnectionBootstrap.java
...e/src/org/jkiss/dbeaver/model/DBPConnectionBootstrap.java
+5
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/struct/DBSDataSourceContainer.java
...rg/jkiss/dbeaver/model/struct/DBSDataSourceContainer.java
+0
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
.../src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
+0
-12
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/ConnectionPageGeneral.java
.../dbeaver/ui/dialogs/connection/ConnectionPageGeneral.java
+31
-5
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/EditBootstrapQueriesDialog.java
...ver/ui/dialogs/connection/EditBootstrapQueriesDialog.java
+170
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/DBPConnectionBootstrap.java
浏览文件 @
de0ae386
...
...
@@ -50,6 +50,11 @@ public class DBPConnectionBootstrap
return
initQueries
;
}
public
void
setInitQueries
(
Collection
<
String
>
queries
)
{
initQueries
.
clear
();
initQueries
.
addAll
(
queries
);
}
public
String
getDefaultObjectName
()
{
return
defaultObjectName
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/struct/DBSDataSourceContainer.java
浏览文件 @
de0ae386
...
...
@@ -77,8 +77,6 @@ public interface DBSDataSourceContainer extends DBSObject, DBDPreferences
void
setDefaultTransactionsIsolation
(
DBPTransactionIsolation
isolationLevel
);
String
getDefaultActiveObject
();
/**
* Search for object filter which corresponds specified object type and parent object.
* Search filter which match any super class or interface implemented by specified type.
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
浏览文件 @
de0ae386
...
...
@@ -328,7 +328,6 @@ public class DataSourceDescriptor
connectionInfo
.
getBootstrap
().
setDefaultAutoCommit
(
null
);
}
else
{
connectionInfo
.
getBootstrap
().
setDefaultAutoCommit
(
autoCommit
);
//preferenceStore.setValue(DBeaverPreferences.DEFAULT_AUTO_COMMIT, autoCommit);
}
}
...
...
@@ -352,9 +351,6 @@ public class DataSourceDescriptor
@Override
public
Integer
getDefaultTransactionsIsolation
()
{
// if (preferenceStore.contains(DBeaverPreferences.DEFAULT_ISOLATION)) {
// return preferenceStore.getInt(DBeaverPreferences.DEFAULT_ISOLATION);
// }
return
connectionInfo
.
getBootstrap
().
getDefaultTransactionIsolation
();
}
...
...
@@ -364,10 +360,8 @@ public class DataSourceDescriptor
try
{
if
(
isolationLevel
==
null
)
{
connectionInfo
.
getBootstrap
().
setDefaultTransactionIsolation
(
null
);
//preferenceStore.setToDefault(DBeaverPreferences.DEFAULT_ISOLATION);
}
else
{
connectionInfo
.
getBootstrap
().
setDefaultTransactionIsolation
(
isolationLevel
.
getCode
());
//preferenceStore.setValue(DBeaverPreferences.DEFAULT_ISOLATION, isolationLevel.getCode());
if
(
dataSource
!=
null
)
{
DBeaverUI
.
runInProgressService
(
new
DBRRunnableWithProgress
()
{
@Override
...
...
@@ -397,14 +391,8 @@ public class DataSourceDescriptor
}
}
@Override
public
String
getDefaultActiveObject
()
{
return
connectionInfo
.
getBootstrap
().
getDefaultObjectName
();
//preferenceStore.getString(DBeaverPreferences.DEFAULT_ACTIVE_OBJECT);
}
public
void
setDefaultActiveObject
(
String
defaultActiveObject
)
{
connectionInfo
.
getBootstrap
().
setDefaultObjectName
(
defaultActiveObject
);
//preferenceStore.setValue(DBeaverPreferences.DEFAULT_ACTIVE_OBJECT, defaultActiveObject);
}
public
Collection
<
FilterMapping
>
getObjectFilters
()
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/ConnectionPageGeneral.java
浏览文件 @
de0ae386
...
...
@@ -44,6 +44,7 @@ import org.jkiss.dbeaver.model.struct.rdb.DBSTable;
import
org.jkiss.dbeaver.registry.DataSourceDescriptor
;
import
org.jkiss.dbeaver.registry.DataSourceProviderRegistry
;
import
org.jkiss.dbeaver.runtime.AbstractJob
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.IHelpContextIds
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.CImageCombo
;
...
...
@@ -51,9 +52,7 @@ import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage;
import
org.jkiss.dbeaver.ui.preferences.PrefPageConnectionTypes
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.StringTokenizer
;
import
java.util.*
;
/**
* General connection page (common for all connection types)
...
...
@@ -79,6 +78,8 @@ class ConnectionPageGeneral extends ActiveWizardPage<ConnectionWizard> {
private
Group
filtersGroup
;
private
boolean
activated
=
false
;
private
java
.
util
.
List
<
DBPTransactionIsolation
>
supportedLevels
=
new
ArrayList
<
DBPTransactionIsolation
>();
private
java
.
util
.
List
<
String
>
bootstrapQueries
;
private
boolean
ignoreBootstrapErrors
;
private
static
class
FilterInfo
{
final
Class
<?>
type
;
...
...
@@ -103,6 +104,8 @@ class ConnectionPageGeneral extends ActiveWizardPage<ConnectionWizard> {
filters
.
add
(
new
FilterInfo
(
DBSCatalog
.
class
,
CoreMessages
.
dialog_connection_wizard_final_filter_catalogs
));
filters
.
add
(
new
FilterInfo
(
DBSSchema
.
class
,
CoreMessages
.
dialog_connection_wizard_final_filter_schemas_users
));
filters
.
add
(
new
FilterInfo
(
DBSTable
.
class
,
CoreMessages
.
dialog_connection_wizard_final_filter_tables
));
bootstrapQueries
=
new
ArrayList
<
String
>();
}
ConnectionPageGeneral
(
ConnectionWizard
wizard
,
DataSourceDescriptor
dataSourceDescriptor
)
...
...
@@ -113,6 +116,8 @@ class ConnectionPageGeneral extends ActiveWizardPage<ConnectionWizard> {
for
(
FilterInfo
filterInfo
:
filters
)
{
filterInfo
.
filter
=
dataSourceDescriptor
.
getObjectFilter
(
filterInfo
.
type
,
null
,
false
);
}
bootstrapQueries
=
dataSourceDescriptor
.
getConnectionConfiguration
().
getBootstrap
().
getInitQueries
();
ignoreBootstrapErrors
=
dataSourceDescriptor
.
getConnectionConfiguration
().
getBootstrap
().
isIgnoreErrors
();
}
@Override
...
...
@@ -356,9 +361,28 @@ class ConnectionPageGeneral extends ActiveWizardPage<ConnectionWizard> {
isolationLevel
=
UIUtils
.
createLabelCombo
(
txnGroup
,
"Isolation level"
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
isolationLevel
.
setToolTipText
(
"Default transaction isolation level."
);
defaultSchema
=
UIUtils
.
createLabelCombo
(
txnGroup
,
"Default schema
/catalog
"
,
SWT
.
DROP_DOWN
);
defaultSchema
=
UIUtils
.
createLabelCombo
(
txnGroup
,
"Default schema"
,
SWT
.
DROP_DOWN
);
defaultSchema
.
setToolTipText
(
"Name of schema or catalog which will be set as default."
);
UIUtils
.
createControlLabel
(
txnGroup
,
"Bootstrap queries"
);
Button
queriesConfigButton
=
UIUtils
.
createPushButton
(
txnGroup
,
"Configure ..."
,
DBeaverIcons
.
getImage
(
DBIcon
.
SQL_SCRIPT
));
if
(
dataSourceDescriptor
!=
null
&&
!
CommonUtils
.
isEmpty
(
dataSourceDescriptor
.
getConnectionConfiguration
().
getBootstrap
().
getInitQueries
()))
{
queriesConfigButton
.
setFont
(
boldFont
);
}
queriesConfigButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
EditBootstrapQueriesDialog
dialog
=
new
EditBootstrapQueriesDialog
(
getShell
(),
bootstrapQueries
,
ignoreBootstrapErrors
);
if
(
dialog
.
open
()
==
IDialogConstants
.
OK_ID
)
{
bootstrapQueries
=
dialog
.
getQueries
();
ignoreBootstrapErrors
=
dialog
.
isIgnoreErrors
();
}
}
});
}
{
...
...
@@ -395,7 +419,6 @@ class ConnectionPageGeneral extends ActiveWizardPage<ConnectionWizard> {
filterInfo
.
link
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
//DBSObjectFilter filter =
EditObjectFilterDialog
dialog
=
new
EditObjectFilterDialog
(
getShell
(),
filterInfo
.
title
,
...
...
@@ -496,6 +519,9 @@ class ConnectionPageGeneral extends ActiveWizardPage<ConnectionWizard> {
dataSource
.
setObjectFilter
(
filterInfo
.
type
,
null
,
filterInfo
.
filter
);
}
}
DBPConnectionBootstrap
bootstrap
=
dataSource
.
getConnectionConfiguration
().
getBootstrap
();
bootstrap
.
setIgnoreErrors
(
ignoreBootstrapErrors
);
bootstrap
.
setInitQueries
(
bootstrapQueries
);
}
private
void
configureEvents
()
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/EditBootstrapQueriesDialog.java
0 → 100644
浏览文件 @
de0ae386
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.ui.dialogs.connection
;
import
org.eclipse.swt.SWT
;
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.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.ui.IHelpContextIds
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.CustomTableEditor
;
import
org.jkiss.dbeaver.ui.dialogs.EditTextDialog
;
import
org.jkiss.dbeaver.ui.dialogs.HelpEnabledDialog
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
* Object filter edit dialog
*/
public
class
EditBootstrapQueriesDialog
extends
HelpEnabledDialog
{
public
static
final
int
SHOW_GLOBAL_FILTERS_ID
=
1000
;
private
List
<
String
>
queries
;
private
boolean
ignoreErrors
;
private
Table
queriesTable
;
private
Button
ignoreErrorButton
;
public
EditBootstrapQueriesDialog
(
Shell
shell
,
Collection
<
String
>
queries
,
boolean
ignoreErrors
)
{
super
(
shell
,
IHelpContextIds
.
CTX_EDIT_OBJECT_FILTERS
);
this
.
queries
=
new
ArrayList
<
String
>(
queries
);
this
.
ignoreErrors
=
ignoreErrors
;
}
@Override
protected
Control
createDialogArea
(
Composite
parent
)
{
getShell
().
setText
(
"Bootstrap SQL queries"
);
Composite
composite
=
(
Composite
)
super
.
createDialogArea
(
parent
);
Group
group
=
UIUtils
.
createControlGroup
(
composite
,
"SQL Queries"
,
2
,
GridData
.
FILL_BOTH
,
0
);
queriesTable
=
new
Table
(
group
,
SWT
.
SINGLE
|
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
final
GridData
gd
=
new
GridData
(
GridData
.
FILL_BOTH
);
gd
.
widthHint
=
300
;
gd
.
heightHint
=
100
;
queriesTable
.
setLayoutData
(
gd
);
queriesTable
.
setLinesVisible
(
true
);
final
TableColumn
valueColumn
=
UIUtils
.
createTableColumn
(
queriesTable
,
SWT
.
LEFT
,
"SQL"
);
valueColumn
.
setWidth
(
300
);
for
(
String
value
:
queries
)
{
new
TableItem
(
queriesTable
,
SWT
.
LEFT
).
setText
(
value
);
}
final
CustomTableEditor
tableEditor
=
new
CustomTableEditor
(
queriesTable
)
{
@Override
protected
Control
createEditor
(
Table
table
,
int
index
,
TableItem
item
)
{
Text
editor
=
new
Text
(
table
,
SWT
.
BORDER
);
editor
.
setText
(
item
.
getText
());
return
editor
;
}
@Override
protected
void
saveEditorValue
(
Control
control
,
int
index
,
TableItem
item
)
{
item
.
setText
(((
Text
)
control
).
getText
());
}
};
Composite
buttonsGroup
=
UIUtils
.
createPlaceholder
(
group
,
1
,
5
);
buttonsGroup
.
setLayoutData
(
new
GridData
(
GridData
.
VERTICAL_ALIGN_BEGINNING
));
final
Button
addButton
=
new
Button
(
buttonsGroup
,
SWT
.
PUSH
);
addButton
.
setText
(
CoreMessages
.
dialog_filter_button_add
);
addButton
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
addButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
tableEditor
.
closeEditor
();
String
sql
=
EditTextDialog
.
editText
(
getShell
(),
"Enter SQL"
,
""
);
if
(
sql
!=
null
)
{
TableItem
newItem
=
new
TableItem
(
queriesTable
,
SWT
.
LEFT
);
newItem
.
setText
(
sql
);
queriesTable
.
setSelection
(
newItem
);
UIUtils
.
packColumns
(
queriesTable
,
true
);
}
}
});
final
Button
removeButton
=
new
Button
(
buttonsGroup
,
SWT
.
PUSH
);
removeButton
.
setText
(
CoreMessages
.
dialog_filter_button_remove
);
removeButton
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
removeButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
int
selectionIndex
=
queriesTable
.
getSelectionIndex
();
if
(
selectionIndex
>=
0
)
{
tableEditor
.
closeEditor
();
queriesTable
.
remove
(
selectionIndex
);
removeButton
.
setEnabled
(
queriesTable
.
getSelectionIndex
()
>=
0
);
}
}
});
removeButton
.
setEnabled
(
false
);
queriesTable
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
int
selectionIndex
=
queriesTable
.
getSelectionIndex
();
removeButton
.
setEnabled
(
selectionIndex
>=
0
);
}
});
ignoreErrorButton
=
UIUtils
.
createCheckbox
(
composite
,
"Ignore SQL errors"
,
ignoreErrors
);
UIUtils
.
packColumns
(
queriesTable
,
true
);
return
composite
;
}
private
List
<
String
>
collectValues
(
Table
table
)
{
List
<
String
>
values
=
new
ArrayList
<
String
>();
for
(
TableItem
item
:
table
.
getItems
())
{
String
value
=
item
.
getText
().
trim
();
if
(
value
.
isEmpty
()
||
value
.
equals
(
"%"
))
{
//$NON-NLS-1$
continue
;
}
values
.
add
(
value
);
}
return
values
;
}
@Override
protected
void
okPressed
()
{
ignoreErrors
=
ignoreErrorButton
.
getSelection
();
queries
=
collectValues
(
queriesTable
);
super
.
okPressed
();
}
@Override
protected
void
cancelPressed
()
{
super
.
cancelPressed
();
}
public
List
<
String
>
getQueries
()
{
return
queries
;
}
public
boolean
isIgnoreErrors
()
{
return
ignoreErrors
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录