Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
4502ac92
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,发现更多精彩内容 >>
提交
4502ac92
编写于
6月 26, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SQL presentation panels
Former-commit-id:
fe863a86
上级
7896b142
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
157 addition
and
499 deletion
+157
-499
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferNodeDescriptor.java
...dbeaver/registry/transfer/DataTransferNodeDescriptor.java
+0
-214
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferProcessorDescriptor.java
...er/registry/transfer/DataTransferProcessorDescriptor.java
+0
-143
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferRegistry.java
...jkiss/dbeaver/registry/transfer/DataTransferRegistry.java
+0
-131
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
....core/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
+65
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/registry/SQLPresentationDescriptor.java
...er/ui/editors/sql/registry/SQLPresentationDescriptor.java
+12
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/registry/SQLPresentationPanelDescriptor.java
.../editors/sql/registry/SQLPresentationPanelDescriptor.java
+80
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferNodeDescriptor.java
已删除
100644 → 0
浏览文件 @
7896b142
/*
* 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.registry.transfer
;
import
org.eclipse.core.runtime.IAdaptable
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.jface.wizard.IWizardPage
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.model.impl.AbstractDescriptor
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferNode
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferSettings
;
import
org.jkiss.utils.ArrayUtils
;
import
java.util.*
;
/**
* DataTransferNodeDescriptor
*/
public
class
DataTransferNodeDescriptor
extends
AbstractDescriptor
{
private
static
final
Log
log
=
Log
.
getLog
(
DataTransferNodeDescriptor
.
class
);
enum
NodeType
{
PRODUCER
,
CONSUMER
}
@NotNull
private
final
String
id
;
@NotNull
private
final
String
name
;
private
final
String
description
;
@NotNull
private
final
DBPImage
icon
;
private
final
NodeType
nodeType
;
private
final
ObjectType
implType
;
private
final
ObjectType
settingsType
;
private
final
List
<
ObjectType
>
sourceTypes
=
new
ArrayList
<>();
private
final
List
<
ObjectType
>
pageTypes
=
new
ArrayList
<>();
private
final
List
<
DataTransferProcessorDescriptor
>
processors
=
new
ArrayList
<>();
public
DataTransferNodeDescriptor
(
IConfigurationElement
config
)
{
super
(
config
);
this
.
id
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
this
.
name
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_LABEL
);
this
.
description
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_DESCRIPTION
);
this
.
icon
=
iconToImage
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_ICON
),
DBIcon
.
TYPE_UNKNOWN
);
this
.
nodeType
=
NodeType
.
valueOf
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_TYPE
).
toUpperCase
(
Locale
.
ENGLISH
));
this
.
implType
=
new
ObjectType
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_CLASS
));
this
.
settingsType
=
new
ObjectType
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_SETTINGS
));
loadNodeConfigurations
(
config
);
}
void
loadNodeConfigurations
(
IConfigurationElement
config
)
{
for
(
IConfigurationElement
typeCfg
:
ArrayUtils
.
safeArray
(
config
.
getChildren
(
RegistryConstants
.
ATTR_SOURCE_TYPE
)))
{
sourceTypes
.
add
(
new
ObjectType
(
typeCfg
.
getAttribute
(
RegistryConstants
.
ATTR_TYPE
)));
}
for
(
IConfigurationElement
pageConfig
:
ArrayUtils
.
safeArray
(
config
.
getChildren
(
RegistryConstants
.
TAG_PAGE
)))
{
pageTypes
.
add
(
new
ObjectType
(
pageConfig
.
getAttribute
(
RegistryConstants
.
ATTR_CLASS
)));
}
for
(
IConfigurationElement
processorConfig
:
ArrayUtils
.
safeArray
(
config
.
getChildren
(
RegistryConstants
.
TAG_PROCESSOR
)))
{
processors
.
add
(
new
DataTransferProcessorDescriptor
(
this
,
processorConfig
));
}
processors
.
sort
(
Comparator
.
comparing
(
DataTransferProcessorDescriptor:
:
getName
));
}
public
String
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
public
String
getDescription
()
{
return
description
;
}
@NotNull
public
DBPImage
getIcon
()
{
return
icon
;
}
public
Class
<?
extends
IDataTransferNode
>
getNodeClass
()
{
return
implType
.
getObjectClass
(
IDataTransferNode
.
class
);
}
public
IDataTransferNode
createNode
()
throws
DBException
{
implType
.
checkObjectClass
(
IDataTransferNode
.
class
);
try
{
return
implType
.
getObjectClass
(
IDataTransferNode
.
class
).
newInstance
();
}
catch
(
Throwable
e
)
{
throw
new
DBException
(
"Can't create data transformer node"
,
e
);
}
}
public
IDataTransferSettings
createSettings
()
throws
DBException
{
settingsType
.
checkObjectClass
(
IDataTransferSettings
.
class
);
try
{
return
settingsType
.
getObjectClass
(
IDataTransferSettings
.
class
).
newInstance
();
}
catch
(
Throwable
e
)
{
throw
new
DBException
(
"Can't create node settings"
,
e
);
}
}
public
IWizardPage
[]
createWizardPages
()
{
List
<
IWizardPage
>
pages
=
new
ArrayList
<>();
for
(
ObjectType
type
:
pageTypes
)
{
try
{
type
.
checkObjectClass
(
IWizardPage
.
class
);
pages
.
add
(
type
.
getObjectClass
(
IWizardPage
.
class
).
newInstance
());
}
catch
(
Throwable
e
)
{
log
.
error
(
"Can't create wizard page"
,
e
);
}
}
return
pages
.
toArray
(
new
IWizardPage
[
pages
.
size
()]);
}
public
NodeType
getNodeType
()
{
return
nodeType
;
}
public
boolean
appliesToType
(
Class
objectType
)
{
if
(!
sourceTypes
.
isEmpty
())
{
for
(
ObjectType
sourceType
:
sourceTypes
)
{
if
(
sourceType
.
matchesType
(
objectType
))
{
return
true
;
}
}
}
for
(
DataTransferProcessorDescriptor
processor
:
processors
)
{
if
(
processor
.
appliesToType
(
objectType
))
{
return
true
;
}
}
return
false
;
}
/**
* Returns data exporter which supports ALL specified object types
* @param surceObjects object types
* @return list of editors
*/
public
Collection
<
DataTransferProcessorDescriptor
>
getAvailableProcessors
(
Collection
<
DBSObject
>
surceObjects
)
{
List
<
DataTransferProcessorDescriptor
>
editors
=
new
ArrayList
<>();
for
(
DataTransferProcessorDescriptor
descriptor
:
processors
)
{
boolean
supports
=
true
;
for
(
DBSObject
sourceObject
:
surceObjects
)
{
if
(!
descriptor
.
appliesToType
(
sourceObject
.
getClass
()))
{
boolean
adapts
=
false
;
if
(
sourceObject
instanceof
IAdaptable
)
{
if
(
descriptor
.
adaptsToType
((
IAdaptable
)
sourceObject
))
{
adapts
=
true
;
}
}
if
(!
adapts
)
{
supports
=
false
;
break
;
}
}
}
if
(
supports
)
{
editors
.
add
(
descriptor
);
}
}
return
editors
;
}
public
DataTransferProcessorDescriptor
getProcessor
(
String
id
)
{
for
(
DataTransferProcessorDescriptor
descriptor
:
processors
)
{
if
(
descriptor
.
getId
().
equals
(
id
))
{
return
descriptor
;
}
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferProcessorDescriptor.java
已删除
100644 → 0
浏览文件 @
7896b142
/*
* 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.registry.transfer
;
import
org.eclipse.core.runtime.IAdaptable
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.model.app.DBPRegistryDescriptor
;
import
org.jkiss.dbeaver.model.impl.AbstractDescriptor
;
import
org.jkiss.dbeaver.model.impl.PropertyDescriptor
;
import
org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* DataTransferProcessorDescriptor
*/
public
class
DataTransferProcessorDescriptor
extends
AbstractDescriptor
implements
DBPRegistryDescriptor
<
IDataTransferProcessor
>
{
private
final
DataTransferNodeDescriptor
node
;
private
final
String
id
;
private
final
ObjectType
processorType
;
private
final
List
<
ObjectType
>
sourceTypes
=
new
ArrayList
<>();
private
final
String
name
;
private
final
String
description
;
@NotNull
private
final
DBPImage
icon
;
private
final
List
<
DBPPropertyDescriptor
>
properties
=
new
ArrayList
<>();
private
boolean
isBinary
;
DataTransferProcessorDescriptor
(
DataTransferNodeDescriptor
node
,
IConfigurationElement
config
)
{
super
(
config
);
this
.
node
=
node
;
this
.
id
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
this
.
processorType
=
new
ObjectType
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_CLASS
));
this
.
name
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_LABEL
);
this
.
description
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_DESCRIPTION
);
this
.
icon
=
iconToImage
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_ICON
),
DBIcon
.
TYPE_UNKNOWN
);
this
.
isBinary
=
CommonUtils
.
getBoolean
(
config
.
getAttribute
(
"binary"
),
false
);
for
(
IConfigurationElement
typeCfg
:
ArrayUtils
.
safeArray
(
config
.
getChildren
(
RegistryConstants
.
ATTR_SOURCE_TYPE
)))
{
sourceTypes
.
add
(
new
ObjectType
(
typeCfg
.
getAttribute
(
RegistryConstants
.
ATTR_TYPE
)));
}
for
(
IConfigurationElement
prop
:
ArrayUtils
.
safeArray
(
config
.
getChildren
(
PropertyDescriptor
.
TAG_PROPERTY_GROUP
)))
{
properties
.
addAll
(
PropertyDescriptor
.
extractProperties
(
prop
));
}
}
public
String
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
public
String
getDescription
()
{
return
description
;
}
@NotNull
public
DBPImage
getIcon
()
{
return
icon
;
}
public
List
<
DBPPropertyDescriptor
>
getProperties
()
{
return
properties
;
}
boolean
appliesToType
(
Class
objectType
)
{
if
(
sourceTypes
.
isEmpty
())
{
return
true
;
}
for
(
ObjectType
sourceType
:
sourceTypes
)
{
if
(
sourceType
.
matchesType
(
objectType
))
{
return
true
;
}
}
return
false
;
}
public
boolean
adaptsToType
(
IAdaptable
adaptable
)
{
if
(
sourceTypes
.
isEmpty
())
{
return
true
;
}
for
(
ObjectType
sourceType
:
sourceTypes
)
{
if
(
adaptable
.
getAdapter
(
sourceType
.
getObjectClass
())
!=
null
)
{
return
true
;
}
}
return
false
;
}
public
IDataTransferProcessor
getInstance
()
{
try
{
processorType
.
checkObjectClass
(
IDataTransferProcessor
.
class
);
Class
<?
extends
IDataTransferProcessor
>
clazz
=
processorType
.
getObjectClass
(
IDataTransferProcessor
.
class
);
return
clazz
.
newInstance
();
}
catch
(
Exception
e
)
{
throw
new
IllegalStateException
(
"Can't instantiate data exporter"
,
e
);
}
}
public
DataTransferNodeDescriptor
getNode
()
{
return
node
;
}
public
boolean
isBinaryFormat
()
{
return
isBinary
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferRegistry.java
已删除
100644 → 0
浏览文件 @
7896b142
/*
* 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.registry.transfer
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.core.runtime.IExtensionRegistry
;
import
org.eclipse.core.runtime.Platform
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferNode
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.List
;
/**
* EntityEditorsRegistry
*/
public
class
DataTransferRegistry
{
public
static
final
String
EXTENSION_ID
=
"org.jkiss.dbeaver.dataTransfer"
;
//$NON-NLS-1$
private
static
DataTransferRegistry
instance
=
null
;
private
static
final
Log
log
=
Log
.
getLog
(
DataTransferRegistry
.
class
);
public
synchronized
static
DataTransferRegistry
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
DataTransferRegistry
(
Platform
.
getExtensionRegistry
());
}
return
instance
;
}
private
List
<
DataTransferNodeDescriptor
>
nodes
=
new
ArrayList
<>();
private
DataTransferRegistry
(
IExtensionRegistry
registry
)
{
// Load datasource providers from external plugins
IConfigurationElement
[]
extElements
=
registry
.
getConfigurationElementsFor
(
EXTENSION_ID
);
for
(
IConfigurationElement
ext
:
extElements
)
{
// Load main nodes
if
(
RegistryConstants
.
TAG_NODE
.
equals
(
ext
.
getName
()))
{
if
(!
CommonUtils
.
isEmpty
(
ext
.
getAttribute
(
RegistryConstants
.
ATTR_REF
)))
{
continue
;
}
nodes
.
add
(
new
DataTransferNodeDescriptor
(
ext
));
}
}
// Load references
for
(
IConfigurationElement
ext
:
extElements
)
{
if
(
RegistryConstants
.
TAG_NODE
.
equals
(
ext
.
getName
()))
{
String
nodeReference
=
ext
.
getAttribute
(
RegistryConstants
.
ATTR_REF
);
if
(
CommonUtils
.
isEmpty
(
nodeReference
))
{
continue
;
}
DataTransferNodeDescriptor
refNode
=
getNodeById
(
nodeReference
);
if
(
refNode
==
null
)
{
log
.
error
(
"Referenced data transfer node '"
+
nodeReference
+
"' not found"
);
}
else
{
refNode
.
loadNodeConfigurations
(
ext
);
}
}
}
nodes
.
sort
(
Comparator
.
comparing
(
DataTransferNodeDescriptor:
:
getName
));
}
public
List
<
DataTransferNodeDescriptor
>
getAvailableProducers
(
Collection
<
DBSObject
>
sourceObjects
)
{
return
getAvailableNodes
(
DataTransferNodeDescriptor
.
NodeType
.
PRODUCER
,
sourceObjects
);
}
public
List
<
DataTransferNodeDescriptor
>
getAvailableConsumers
(
Collection
<
DBSObject
>
sourceObjects
)
{
return
getAvailableNodes
(
DataTransferNodeDescriptor
.
NodeType
.
CONSUMER
,
sourceObjects
);
}
List
<
DataTransferNodeDescriptor
>
getAvailableNodes
(
DataTransferNodeDescriptor
.
NodeType
nodeType
,
Collection
<
DBSObject
>
sourceObjects
)
{
List
<
DataTransferNodeDescriptor
>
result
=
new
ArrayList
<>();
for
(
DataTransferNodeDescriptor
node
:
nodes
)
{
if
(
node
.
getNodeType
()
==
nodeType
)
{
for
(
DBSObject
sourceObject
:
sourceObjects
)
{
if
(
node
.
appliesToType
(
sourceObject
.
getClass
()))
{
result
.
add
(
node
);
break
;
}
}
}
}
return
result
;
}
public
DataTransferNodeDescriptor
getNodeByType
(
Class
<?
extends
IDataTransferNode
>
type
)
{
for
(
DataTransferNodeDescriptor
node
:
nodes
)
{
if
(
node
.
getNodeClass
().
equals
(
type
))
{
return
node
;
}
}
return
null
;
}
public
DataTransferNodeDescriptor
getNodeById
(
String
id
)
{
for
(
DataTransferNodeDescriptor
node
:
nodes
)
{
if
(
node
.
getId
().
equals
(
id
))
{
return
node
;
}
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
浏览文件 @
4502ac92
...
...
@@ -83,8 +83,6 @@ import org.jkiss.dbeaver.model.sql.*;
import
org.jkiss.dbeaver.model.struct.DBSDataContainer
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.DBSObjectSelector
;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationDescriptor
;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationRegistry
;
import
org.jkiss.dbeaver.runtime.sql.SQLQueryJob
;
import
org.jkiss.dbeaver.runtime.sql.SQLQueryListener
;
import
org.jkiss.dbeaver.runtime.sql.SQLResultsConsumer
;
...
...
@@ -105,6 +103,9 @@ import org.jkiss.dbeaver.ui.editors.EditorUtils;
import
org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput
;
import
org.jkiss.dbeaver.ui.editors.StringEditorInput
;
import
org.jkiss.dbeaver.ui.editors.sql.log.SQLLogPanel
;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationDescriptor
;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor
;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationRegistry
;
import
org.jkiss.dbeaver.ui.editors.text.ScriptPositionColumn
;
import
org.jkiss.dbeaver.ui.views.SQLResultsView
;
import
org.jkiss.dbeaver.ui.views.plan.ExplainPlanViewer
;
...
...
@@ -139,6 +140,8 @@ public class SQLEditor extends SQLEditorBase implements
private
static
final
int
SQL_EDITOR_CONTROL_INDEX
=
1
;
private
static
final
int
EXTRA_CONTROL_INDEX
=
0
;
private
static
final
String
PANEL_ITEM_PREFIX
=
"SQLPanelToggle:"
;
private
static
Image
IMG_DATA_GRID
=
DBeaverIcons
.
getImage
(
UIIcon
.
SQL_PAGE_DATA_GRID
);
private
static
Image
IMG_DATA_GRID_LOCKED
=
DBeaverIcons
.
getImage
(
UIIcon
.
SQL_PAGE_DATA_GRID_LOCKED
);
private
static
Image
IMG_EXPLAIN_PLAN
=
DBeaverIcons
.
getImage
(
UIIcon
.
SQL_PAGE_EXPLAIN_PLAN
);
...
...
@@ -149,6 +152,7 @@ public class SQLEditor extends SQLEditorBase implements
private
static
final
String
TOOLBAR_CONTRIBUTION_ID
=
"toolbar:org.jkiss.dbeaver.ui.editors.sql.toolbar.side"
;
private
static
final
String
TOOLBAR_GROUP_TOP
=
"top"
;
private
static
final
String
TOOLBAR_GROUP_ADDITIONS
=
IWorkbenchActionConstants
.
MB_ADDITIONS
;
private
static
final
String
TOOLBAR_GROUP_PANELS
=
"panelToggles"
;
public
static
final
String
VAR_CONNECTION_NAME
=
"connectionName"
;
public
static
final
String
VAR_FILE_NAME
=
"fileName"
;
...
...
@@ -590,6 +594,7 @@ public class SQLEditor extends SQLEditorBase implements
sideToolBar
.
add
(
new
ToolbarSeparatorContribution
(
false
));
sideToolBar
.
add
(
ActionUtils
.
makeCommandContribution
(
getSite
(),
CoreCommands
.
CMD_SQL_SHOW_OUTPUT
,
CommandContributionItem
.
STYLE_CHECK
));
sideToolBar
.
add
(
ActionUtils
.
makeCommandContribution
(
getSite
(),
CoreCommands
.
CMD_SQL_SHOW_LOG
,
CommandContributionItem
.
STYLE_CHECK
));
sideToolBar
.
add
(
new
GroupMarker
(
TOOLBAR_GROUP_PANELS
));
final
IMenuService
menuService
=
getSite
().
getService
(
IMenuService
.
class
);
if
(
menuService
!=
null
)
{
int
prevSize
=
sideToolBar
.
getSize
();
...
...
@@ -753,6 +758,9 @@ public class SQLEditor extends SQLEditorBase implements
}
}
/////////////////////////////////////////////////////////////
// Panels
private
void
showExtraView
(
final
String
commandId
,
String
name
,
String
toolTip
,
Image
image
,
Control
view
)
{
ToolItem
viewItem
=
getViewToolItem
(
commandId
);
if
(
viewItem
==
null
)
{
...
...
@@ -874,6 +882,29 @@ public class SQLEditor extends SQLEditorBase implements
presentationSash
.
setMaximizedControl
(
null
);
}
}
// Show presentation panels
boolean
sideBarChanged
=
false
;
if
(
getExtraPresentationState
()
==
SQLEditorPresentation
.
ActivationType
.
HIDDEN
)
{
// Remove all presentation panel toggles
for
(
SQLPresentationPanelDescriptor
panelDescriptor
:
extraPresentationDescriptor
.
getPanels
())
{
if
(
sideToolBar
.
remove
(
PANEL_ITEM_PREFIX
+
panelDescriptor
.
getId
())
!=
null
)
{
sideBarChanged
=
true
;
}
}
}
else
{
// Check and add presentation panel toggles
for
(
SQLPresentationPanelDescriptor
panelDescriptor
:
extraPresentationDescriptor
.
getPanels
())
{
if
(
sideToolBar
.
find
(
PANEL_ITEM_PREFIX
+
panelDescriptor
.
getId
())
==
null
)
{
sideBarChanged
=
true
;
sideToolBar
.
insertAfter
(
TOOLBAR_GROUP_PANELS
,
new
PresentationPanelToggleAction
(
panelDescriptor
));
}
}
}
if
(
sideBarChanged
)
{
sideToolBar
.
update
(
true
);
sideToolBar
.
getControl
().
getParent
().
layout
(
true
);
}
}
private
Control
getExtraPresentationControl
()
{
...
...
@@ -927,15 +958,6 @@ public class SQLEditor extends SQLEditorBase implements
}
}
@Override
public
void
init
(
IEditorSite
site
,
IEditorInput
editorInput
)
throws
PartInitException
{
super
.
init
(
site
,
editorInput
);
updateResultSetOrientation
();
}
private
void
updateResultSetOrientation
()
{
try
{
resultSetOrientation
=
ResultSetOrientation
.
valueOf
(
getActivePreferenceStore
().
getString
(
SQLPreferenceConstants
.
RESULT_SET_ORIENTATION
));
...
...
@@ -947,6 +969,38 @@ public class SQLEditor extends SQLEditorBase implements
}
}
private
class
PresentationPanelToggleAction
extends
Action
{
private
SQLPresentationPanelDescriptor
panel
;
public
PresentationPanelToggleAction
(
SQLPresentationPanelDescriptor
panel
)
{
super
(
panel
.
getLabel
(),
Action
.
AS_CHECK_BOX
);
setId
(
PANEL_ITEM_PREFIX
+
panel
.
getId
());
if
(
panel
.
getIcon
()
!=
null
)
{
setImageDescriptor
(
DBeaverIcons
.
getImageDescriptor
(
panel
.
getIcon
()));
}
if
(
panel
.
getDescription
()
!=
null
)
{
setToolTipText
(
panel
.
getDescription
());
}
this
.
panel
=
panel
;
}
@Override
public
void
run
()
{
}
}
/////////////////////////////////////////////////////////////
// Initialization
@Override
public
void
init
(
IEditorSite
site
,
IEditorInput
editorInput
)
throws
PartInitException
{
super
.
init
(
site
,
editorInput
);
updateResultSetOrientation
();
}
@Override
protected
void
doSetInput
(
IEditorInput
editorInput
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/registry/SQLPresentationDescriptor.java
浏览文件 @
4502ac92
...
...
@@ -25,6 +25,8 @@ import org.jkiss.dbeaver.registry.RegistryConstants;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorPresentation
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
/**
...
...
@@ -40,6 +42,7 @@ public class SQLPresentationDescriptor extends AbstractContextDescriptor {
private
final
ObjectType
implClass
;
private
final
DBPImage
icon
;
private
final
SQLEditorPresentation
.
ActivationType
activationType
;
private
final
List
<
SQLPresentationPanelDescriptor
>
panels
=
new
ArrayList
<>();
public
SQLPresentationDescriptor
(
IConfigurationElement
config
)
{
...
...
@@ -55,6 +58,11 @@ public class SQLPresentationDescriptor extends AbstractContextDescriptor {
}
else
{
this
.
activationType
=
SQLEditorPresentation
.
ActivationType
.
valueOf
(
activationStr
.
toUpperCase
(
Locale
.
ENGLISH
));
}
for
(
IConfigurationElement
panelConfig
:
config
.
getChildren
(
"panel"
))
{
// Load functions
SQLPresentationPanelDescriptor
presentationDescriptor
=
new
SQLPresentationPanelDescriptor
(
panelConfig
);
this
.
panels
.
add
(
presentationDescriptor
);
}
}
public
String
getId
()
{
...
...
@@ -77,6 +85,10 @@ public class SQLPresentationDescriptor extends AbstractContextDescriptor {
return
activationType
;
}
public
List
<
SQLPresentationPanelDescriptor
>
getPanels
()
{
return
panels
;
}
public
SQLEditorPresentation
createPresentation
()
throws
DBException
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/registry/SQLPresentationPanelDescriptor.java
0 → 100644
浏览文件 @
4502ac92
/*
* 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.editors.sql.registry
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.registry.AbstractContextDescriptor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorPresentation
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorPresentationPanel
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.Locale
;
/**
* SQLPresentationPanelDescriptor
*/
public
class
SQLPresentationPanelDescriptor
extends
AbstractContextDescriptor
{
private
final
String
id
;
private
final
String
label
;
private
final
String
description
;
private
final
ObjectType
implClass
;
private
final
DBPImage
icon
;
private
final
boolean
isSingleton
;
public
SQLPresentationPanelDescriptor
(
IConfigurationElement
config
)
{
super
(
config
);
this
.
id
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
this
.
label
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_LABEL
);
this
.
description
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_DESCRIPTION
);
this
.
implClass
=
new
ObjectType
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_CLASS
));
this
.
icon
=
iconToImage
(
config
.
getAttribute
(
RegistryConstants
.
ATTR_ICON
));
this
.
isSingleton
=
CommonUtils
.
getBoolean
(
config
.
getAttribute
(
"singleton"
),
true
);
}
public
String
getId
()
{
return
id
;
}
public
String
getLabel
()
{
return
label
;
}
public
String
getDescription
()
{
return
description
;
}
public
DBPImage
getIcon
()
{
return
icon
;
}
public
boolean
isSingleton
()
{
return
isSingleton
;
}
public
SQLEditorPresentationPanel
createPanel
()
throws
DBException
{
return
implClass
.
createInstance
(
SQLEditorPresentationPanel
.
class
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录