Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
f2241344
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,发现更多精彩内容 >>
提交
f2241344
编写于
4月 12, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#5655 RSV: CopyAs command
上级
7cb703e7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
335 addition
and
22 deletion
+335
-22
plugins/org.jkiss.dbeaver.data.transfer/src/org/jkiss/dbeaver/tools/transfer/stream/StreamTransferConsumer.java
...dbeaver/tools/transfer/stream/StreamTransferConsumer.java
+0
-2
plugins/org.jkiss.dbeaver.data.transfer/src/org/jkiss/dbeaver/tools/transfer/wizard/DataTransferJob.java
.../jkiss/dbeaver/tools/transfer/wizard/DataTransferJob.java
+9
-6
plugins/org.jkiss.dbeaver.ui.editors.data/OSGI-INF/l10n/bundle.properties
...s.dbeaver.ui.editors.data/OSGI-INF/l10n/bundle.properties
+4
-1
plugins/org.jkiss.dbeaver.ui.editors.data/plugin.xml
plugins/org.jkiss.dbeaver.ui.editors.data/plugin.xml
+18
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetHandlerCopyAs.java
...dbeaver/ui/controls/resultset/ResultSetHandlerCopyAs.java
+250
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetHandlerOpenWith.java
...eaver/ui/controls/resultset/ResultSetHandlerOpenWith.java
+7
-3
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
.../jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
+47
-10
未找到文件。
plugins/org.jkiss.dbeaver.data.transfer/src/org/jkiss/dbeaver/tools/transfer/stream/StreamTransferConsumer.java
浏览文件 @
f2241344
...
...
@@ -185,8 +185,6 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
@Override
public
void
close
()
{
closeExporter
();
metaColumns
=
null
;
row
=
null
;
}
...
...
plugins/org.jkiss.dbeaver.data.transfer/src/org/jkiss/dbeaver/tools/transfer/wizard/DataTransferJob.java
浏览文件 @
f2241344
...
...
@@ -112,12 +112,15 @@ public class DataTransferJob extends AbstractJob {
//consumer.initTransfer(producer.getDatabaseObject(), consumerSettings, );
IDataTransferProcessor
processor
=
settings
.
getProcessor
()
==
null
?
null
:
settings
.
getProcessor
().
getInstance
();
producer
.
transferData
(
monitor
,
consumer
,
processor
,
nodeSettings
);
consumer
.
finishTransfer
(
monitor
,
false
);
try
{
producer
.
transferData
(
monitor
,
consumer
,
processor
,
nodeSettings
);
}
finally
{
consumer
.
finishTransfer
(
monitor
,
false
);
}
return
true
;
}
catch
(
Exception
e
)
{
new
DataTransferErrorJob
(
e
).
schedule
();
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/OSGI-INF/l10n/bundle.properties
浏览文件 @
f2241344
...
...
@@ -56,7 +56,10 @@ command.org.jkiss.dbeaver.core.resultset.grid.columnsFitScreen.name=Columns pack
command.org.jkiss.dbeaver.core.resultset.grid.columnsFitScreen.description
=
Resize columns to see maximum information
command.org.jkiss.dbeaver.core.resultset.openWith.name
=
Open With
command.org.jkiss.dbeaver.core.resultset.openWith.description
=
Open data in external application
command.org.jkiss.dbeaver.core.resultset.openWith.param.panelId.name
=
Processor
command.org.jkiss.dbeaver.core.resultset.openWith.param.processorId.name
=
Processor
command.org.jkiss.dbeaver.core.resultset.copyAs.name
=
Copy As
command.org.jkiss.dbeaver.core.resultset.copyAs.description
=
Copy data in clipboard using specified format
command.org.jkiss.dbeaver.core.resultset.copyAs.param.processorId.name
=
Processor
command.org.jkiss.dbeaver.core.resultset.export.name
=
Export data ...
command.org.jkiss.dbeaver.core.resultset.export.description
=
Export result set to file or another table
command.org.jkiss.dbeaver.core.resultset.row.first.name
=
First row
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/plugin.xml
浏览文件 @
f2241344
...
...
@@ -227,6 +227,14 @@
values=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetHandlerOpenWith$OpenWithParameterValues"
>
</commandParameter>
</command>
<command
id=
"org.jkiss.dbeaver.core.resultset.copyAs"
name=
"%command.org.jkiss.dbeaver.core.resultset.copyAs.name"
description=
"%command.org.jkiss.dbeaver.core.resultset.copyAs.description"
categoryId=
"org.jkiss.dbeaver.core.rs"
>
<commandParameter
id=
"processorId"
name=
"%command.org.jkiss.dbeaver.core.resultset.copyAs.param.processorId.name"
optional=
"false"
values=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetHandlerCopyAs$CopyAsParameterValues"
>
</commandParameter>
</command>
<command
id=
"org.jkiss.dbeaver.core.resultset.grid.toggleLayout"
name=
"%command.org.jkiss.dbeaver.core.resultset.grid.toggleLayout.name"
description=
"%command.org.jkiss.dbeaver.core.resultset.grid.toggleLayout.description"
categoryId=
"org.jkiss.dbeaver.core.rs"
/>
<command
id=
"org.jkiss.dbeaver.core.resultset.grid.copyColumnNames"
name=
"%command.org.jkiss.dbeaver.core.resultset.grid.copyColumnNames.name"
description=
"%command.org.jkiss.dbeaver.core.resultset.grid.copyColumnNames.description"
categoryId=
"org.jkiss.dbeaver.core.rs"
/>
<command
id=
"org.jkiss.dbeaver.core.resultset.grid.copyRowNames"
name=
"%command.org.jkiss.dbeaver.core.resultset.grid.copyRowNames.name"
description=
"%command.org.jkiss.dbeaver.core.resultset.grid.copyRowNames.description"
categoryId=
"org.jkiss.dbeaver.core.rs"
/>
...
...
@@ -292,6 +300,13 @@
</with>
</enabledWhen>
</handler>
<handler
commandId=
"org.jkiss.dbeaver.core.resultset.copyAs"
class=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetHandlerCopyAs"
>
<enabledWhen>
<with
variable=
"activePart"
>
<test
property=
"org.jkiss.dbeaver.core.resultset.hasData"
/>
</with>
</enabledWhen>
</handler>
<handler
commandId=
"org.jkiss.dbeaver.core.resultset.grid.toggleLayout"
class=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetHandlerMain"
>
<!--<activeWhen><reference definitionId="org.jkiss.dbeaver.core.ui.resultset.part"/></activeWhen>-->
</handler>
...
...
@@ -645,6 +660,9 @@
<menuContribution
allPopups=
"false"
locationURI=
"menu:org.jkiss.dbeaver.core.resultset.openWith"
>
<dynamic
id=
"org.jkiss.dbeaver.core.resultset.openWith"
class=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetHandlerOpenWith$OpenWithMenuContributor"
/>
</menuContribution>
<menuContribution
allPopups=
"false"
locationURI=
"menu:org.jkiss.dbeaver.core.resultset.copyAs"
>
<dynamic
id=
"org.jkiss.dbeaver.core.resultset.openWith"
class=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetHandlerCopyAs$CopyAsMenuContributor"
/>
</menuContribution>
</extension>
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetHandlerCopyAs.java
0 → 100644
浏览文件 @
f2241344
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.controls.resultset
;
import
org.eclipse.core.commands.AbstractHandler
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.core.commands.IParameterValues
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.jface.action.ContributionManager
;
import
org.eclipse.jface.action.IContributionItem
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.ui.actions.CompoundContributionItem
;
import
org.eclipse.ui.commands.IElementUpdater
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eclipse.ui.menus.UIElement
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.messages.ModelMessages
;
import
org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.runtime.AbstractJob
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor
;
import
org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings
;
import
org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer
;
import
org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor
;
import
org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor
;
import
org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry
;
import
org.jkiss.dbeaver.tools.transfer.stream.IStreamDataExporter
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamTransferConsumer
;
import
org.jkiss.dbeaver.ui.ActionUtils
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.*
;
/**
* Copy results in external format
*/
public
class
ResultSetHandlerCopyAs
extends
AbstractHandler
implements
IElementUpdater
{
private
static
final
Log
log
=
Log
.
getLog
(
ResultSetHandlerCopyAs
.
class
);
public
static
final
String
CMD_COPY_AS
=
"org.jkiss.dbeaver.core.resultset.copyAs"
;
public
static
final
String
PARAM_PROCESSOR_ID
=
"processorId"
;
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
IResultSetController
resultSet
=
ResultSetHandlerMain
.
getActiveResultSet
(
HandlerUtil
.
getActivePart
(
event
));
if
(
resultSet
==
null
)
{
return
null
;
}
DataTransferProcessorDescriptor
processor
=
getActiveProcessor
(
event
.
getParameter
(
PARAM_PROCESSOR_ID
));
if
(
processor
==
null
)
{
return
null
;
}
switch
(
event
.
getCommand
().
getId
())
{
case
CMD_COPY_AS:
openResultsWith
(
resultSet
,
processor
);
break
;
}
return
null
;
}
static
DataTransferProcessorDescriptor
getActiveProcessor
(
String
processorId
)
{
if
(
CommonUtils
.
isEmpty
(
processorId
))
{
DataTransferProcessorDescriptor
defaultAppProcessor
=
getDefaultProcessor
();
if
(
defaultAppProcessor
!=
null
)
{
return
defaultAppProcessor
;
}
}
else
{
return
DataTransferRegistry
.
getInstance
().
getProcessor
(
processorId
);
}
return
null
;
}
static
DataTransferProcessorDescriptor
getDefaultProcessor
()
{
DataTransferProcessorDescriptor
defaultAppProcessor
=
getDefaultAppProcessor
();
if
(
defaultAppProcessor
!=
null
)
{
return
defaultAppProcessor
;
}
return
null
;
}
private
static
void
openResultsWith
(
IResultSetController
resultSet
,
DataTransferProcessorDescriptor
processor
)
{
ResultSetDataContainerOptions
options
=
new
ResultSetDataContainerOptions
();
IResultSetSelection
rsSelection
=
resultSet
.
getSelection
();
List
<
ResultSetRow
>
rsSelectedRows
=
rsSelection
.
getSelectedRows
();
List
<
DBDAttributeBinding
>
rsSelectedAttributes
=
rsSelection
.
getSelectedAttributes
();
if
(
rsSelectedRows
.
size
()
>
1
||
rsSelectedAttributes
.
size
()
>
1
)
{
List
<
Long
>
selectedRows
=
new
ArrayList
<>();
for
(
ResultSetRow
selectedRow
:
rsSelectedRows
)
{
selectedRows
.
add
((
long
)
selectedRow
.
getRowNumber
());
}
List
<
String
>
selectedAttributes
=
new
ArrayList
<>();
for
(
DBDAttributeBinding
attributeBinding
:
rsSelectedAttributes
)
{
selectedAttributes
.
add
(
attributeBinding
.
getName
());
}
options
.
setSelectedRows
(
selectedRows
);
options
.
setSelectedColumns
(
selectedAttributes
);
}
ResultSetDataContainer
dataContainer
=
new
ResultSetDataContainer
(
resultSet
.
getDataContainer
(),
resultSet
.
getModel
(),
options
);
if
(
dataContainer
.
getDataSource
()
==
null
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Copy As "
+
processor
.
getName
(),
ModelMessages
.
error_not_connected_to_database
);
return
;
}
AbstractJob
exportJob
=
new
AbstractJob
(
"Copy As "
+
processor
.
getName
())
{
{
setUser
(
true
);
setSystem
(
false
);
}
@Override
protected
IStatus
run
(
DBRProgressMonitor
monitor
)
{
try
{
IDataTransferProcessor
processorInstance
=
processor
.
getInstance
();
if
(!(
processorInstance
instanceof
IStreamDataExporter
))
{
return
Status
.
CANCEL_STATUS
;
}
IStreamDataExporter
exporter
=
(
IStreamDataExporter
)
processorInstance
;
StreamTransferConsumer
consumer
=
new
StreamTransferConsumer
();
StreamConsumerSettings
settings
=
new
StreamConsumerSettings
();
settings
.
setOutputClipboard
(
true
);
settings
.
setOutputEncodingBOM
(
false
);
settings
.
setOpenFolderOnFinish
(
false
);
Map
<
Object
,
Object
>
properties
=
new
HashMap
<>();
for
(
DBPPropertyDescriptor
prop
:
processor
.
getProperties
())
{
properties
.
put
(
prop
.
getId
(),
prop
.
getDefaultValue
());
}
consumer
.
initTransfer
(
dataContainer
,
settings
,
new
IDataTransferConsumer
.
TransferParameters
(
processor
.
isBinaryFormat
()),
exporter
,
properties
);
DBDDataFilter
dataFilter
=
resultSet
.
getModel
().
getDataFilter
();
DatabaseTransferProducer
producer
=
new
DatabaseTransferProducer
(
dataContainer
,
dataFilter
);
DatabaseProducerSettings
producerSettings
=
new
DatabaseProducerSettings
();
producerSettings
.
setExtractType
(
DatabaseProducerSettings
.
ExtractType
.
SINGLE_QUERY
);
producerSettings
.
setQueryRowCount
(
false
);
producerSettings
.
setSelectedRowsOnly
(!
CommonUtils
.
isEmpty
(
options
.
getSelectedRows
()));
producerSettings
.
setSelectedColumnsOnly
(!
CommonUtils
.
isEmpty
(
options
.
getSelectedColumns
()));
producer
.
transferData
(
monitor
,
consumer
,
null
,
producerSettings
);
consumer
.
finishTransfer
(
monitor
,
false
);
consumer
.
finishTransfer
(
monitor
,
true
);
}
catch
(
Exception
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Error opening in "
+
processor
.
getAppName
(),
null
,
e
);
}
return
Status
.
OK_STATUS
;
}
};
exportJob
.
schedule
();
}
@Override
public
void
updateElement
(
UIElement
element
,
Map
parameters
)
{
// Put processor name in command label
DataTransferProcessorDescriptor
processor
=
getActiveProcessor
((
String
)
parameters
.
get
(
PARAM_PROCESSOR_ID
));
if
(
processor
!=
null
)
{
String
commandName
=
ActionUtils
.
findCommandName
(
CMD_COPY_AS
);
element
.
setText
(
commandName
+
" "
+
processor
.
getName
());
if
(!
CommonUtils
.
isEmpty
(
processor
.
getDescription
()))
{
element
.
setTooltip
(
processor
.
getDescription
());
}
if
(
processor
.
getIcon
()
!=
null
)
{
element
.
setIcon
(
DBeaverIcons
.
getImageDescriptor
(
processor
.
getIcon
()));
}
}
}
private
static
DataTransferProcessorDescriptor
getDefaultAppProcessor
()
{
List
<
DataTransferProcessorDescriptor
>
processors
=
new
ArrayList
<>();
for
(
final
DataTransferNodeDescriptor
consumerNode
:
DataTransferRegistry
.
getInstance
().
getNodes
(
DataTransferNodeDescriptor
.
NodeType
.
CONSUMER
))
{
for
(
DataTransferProcessorDescriptor
processor
:
consumerNode
.
getProcessors
())
{
if
(
processor
.
getAppFileExtension
()
!=
null
)
{
processors
.
add
(
processor
);
}
}
}
processors
.
sort
(
Comparator
.
comparingInt
(
DataTransferProcessorDescriptor:
:
getOrder
));
return
processors
.
isEmpty
()
?
null
:
processors
.
get
(
0
);
}
public
static
class
CopyAsParameterValues
implements
IParameterValues
{
@Override
public
Map
<
String
,
String
>
getParameterValues
()
{
final
Map
<
String
,
String
>
values
=
new
HashMap
<>();
for
(
final
DataTransferNodeDescriptor
consumerNode
:
DataTransferRegistry
.
getInstance
().
getNodes
(
DataTransferNodeDescriptor
.
NodeType
.
CONSUMER
))
{
for
(
DataTransferProcessorDescriptor
processor
:
consumerNode
.
getProcessors
())
{
values
.
put
(
processor
.
getName
(),
processor
.
getFullId
());
}
}
return
values
;
}
}
public
static
class
CopyAsMenuContributor
extends
CompoundContributionItem
{
@Override
protected
IContributionItem
[]
getContributionItems
()
{
final
ResultSetViewer
rsv
=
(
ResultSetViewer
)
ResultSetHandlerMain
.
getActiveResultSet
(
UIUtils
.
getActiveWorkbenchWindow
().
getActivePage
().
getActivePart
());
if
(
rsv
==
null
)
{
return
new
IContributionItem
[
0
];
}
ContributionManager
menu
=
new
MenuManager
();
rsv
.
fillCopyAsMenu
(
menu
);
return
menu
.
getItems
();
}
}
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetHandlerOpenWith.java
浏览文件 @
f2241344
...
...
@@ -22,7 +22,9 @@ import org.eclipse.core.commands.ExecutionException;
import
org.eclipse.core.commands.IParameterValues
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.jface.action.ContributionManager
;
import
org.eclipse.jface.action.IContributionItem
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.ui.actions.CompoundContributionItem
;
import
org.eclipse.ui.commands.IElementUpdater
;
import
org.eclipse.ui.handlers.HandlerUtil
;
...
...
@@ -191,8 +193,8 @@ public class ResultSetHandlerOpenWith extends AbstractHandler implements IElemen
DatabaseProducerSettings
producerSettings
=
new
DatabaseProducerSettings
();
producerSettings
.
setExtractType
(
DatabaseProducerSettings
.
ExtractType
.
SINGLE_QUERY
);
producerSettings
.
setQueryRowCount
(
false
);
producerSettings
.
setSelectedRowsOnly
(
true
);
producerSettings
.
setSelectedColumnsOnly
(
true
);
producerSettings
.
setSelectedRowsOnly
(
!
CommonUtils
.
isEmpty
(
options
.
getSelectedRows
())
);
producerSettings
.
setSelectedColumnsOnly
(
!
CommonUtils
.
isEmpty
(
options
.
getSelectedColumns
())
);
producer
.
transferData
(
monitor
,
consumer
,
null
,
producerSettings
);
...
...
@@ -270,7 +272,9 @@ public class ResultSetHandlerOpenWith extends AbstractHandler implements IElemen
if
(
rsv
==
null
)
{
return
new
IContributionItem
[
0
];
}
return
rsv
.
fillOpenWithMenu
().
getItems
();
ContributionManager
menu
=
new
MenuManager
();
rsv
.
fillOpenWithMenu
(
menu
);
return
menu
.
getItems
();
}
}
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
浏览文件 @
f2241344
...
...
@@ -1139,8 +1139,7 @@ public class ResultSetViewer extends Viewer
return
items
;
}
MenuManager
fillOpenWithMenu
()
{
MenuManager
openWithMenu
=
new
MenuManager
(
ActionUtils
.
findCommandName
(
ResultSetHandlerOpenWith
.
CMD_OPEN_WITH
));
void
fillOpenWithMenu
(
ContributionManager
openWithMenu
)
{
ResultSetDataContainerOptions
options
=
new
ResultSetDataContainerOptions
();
ResultSetDataContainer
dataContainer
=
new
ResultSetDataContainer
(
getDataContainer
(),
getModel
(),
options
);
...
...
@@ -1173,8 +1172,37 @@ public class ResultSetViewer extends Viewer
params
.
parameters
=
parameters
;
openWithMenu
.
add
(
new
CommandContributionItem
(
params
));
}
}
void
fillCopyAsMenu
(
ContributionManager
copyAsMenu
)
{
ResultSetDataContainerOptions
options
=
new
ResultSetDataContainerOptions
();
ResultSetDataContainer
dataContainer
=
new
ResultSetDataContainer
(
getDataContainer
(),
getModel
(),
options
);
List
<
DataTransferProcessorDescriptor
>
appProcessors
=
new
ArrayList
<>();
return
openWithMenu
;
for
(
final
DataTransferNodeDescriptor
consumerNode
:
DataTransferRegistry
.
getInstance
().
getAvailableConsumers
(
Collections
.
singleton
(
dataContainer
)))
{
appProcessors
.
addAll
(
consumerNode
.
getProcessors
());
}
appProcessors
.
sort
(
Comparator
.
comparing
(
DataTransferProcessorDescriptor:
:
getName
));
for
(
DataTransferProcessorDescriptor
processor
:
appProcessors
)
{
CommandContributionItemParameter
params
=
new
CommandContributionItemParameter
(
site
,
processor
.
getId
(),
ResultSetHandlerCopyAs
.
CMD_COPY_AS
,
CommandContributionItem
.
STYLE_RADIO
);
params
.
label
=
processor
.
getName
();
if
(
processor
.
getIcon
()
!=
null
)
{
params
.
icon
=
DBeaverIcons
.
getImageDescriptor
(
processor
.
getIcon
());
}
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
ResultSetHandlerCopyAs
.
PARAM_PROCESSOR_ID
,
processor
.
getFullId
());
params
.
parameters
=
parameters
;
copyAsMenu
.
add
(
new
CommandContributionItem
(
params
));
}
}
private
void
addDefaultPanelActions
()
{
...
...
@@ -2034,13 +2062,20 @@ public class ResultSetViewer extends Viewer
manager
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
IWorkbenchCommandConstants
.
EDIT_CUT
));
manager
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
IWorkbenchCommandConstants
.
EDIT_COPY
));
MenuManager
extCopyMenu
=
new
MenuManager
(
ActionUtils
.
findCommandName
(
ResultSetHandlerCopySpecial
.
CMD_COPY_SPECIAL
));
extCopyMenu
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
ResultSetHandlerCopySpecial
.
CMD_COPY_SPECIAL
));
extCopyMenu
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
ResultSetHandlerCopySpecial
.
CMD_COPY_COLUMN_NAMES
));
if
(
row
!=
null
)
{
extCopyMenu
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
ResultSetHandlerMain
.
CMD_COPY_ROW_NAMES
));
{
MenuManager
extCopyMenu
=
new
MenuManager
(
ActionUtils
.
findCommandName
(
ResultSetHandlerCopySpecial
.
CMD_COPY_SPECIAL
));
extCopyMenu
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
ResultSetHandlerCopySpecial
.
CMD_COPY_SPECIAL
));
extCopyMenu
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
ResultSetHandlerCopySpecial
.
CMD_COPY_COLUMN_NAMES
));
if
(
row
!=
null
)
{
extCopyMenu
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
ResultSetHandlerMain
.
CMD_COPY_ROW_NAMES
));
}
// Add copy commands for different formats
extCopyMenu
.
add
(
new
Separator
());
fillCopyAsMenu
(
extCopyMenu
);
manager
.
add
(
extCopyMenu
);
}
manager
.
add
(
extCopyMenu
);
manager
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
IWorkbenchCommandConstants
.
EDIT_PASTE
));
manager
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
IActionConstants
.
CMD_PASTE_SPECIAL
));
manager
.
add
(
new
Separator
());
...
...
@@ -2259,7 +2294,9 @@ public class ResultSetViewer extends Viewer
final
DBSDataContainer
dataContainer
=
getDataContainer
();
if
(
dataContainer
!=
null
&&
model
.
hasData
())
{
manager
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
ResultSetHandlerMain
.
CMD_EXPORT
));
manager
.
add
(
fillOpenWithMenu
());
MenuManager
openWithMenu
=
new
MenuManager
(
ActionUtils
.
findCommandName
(
ResultSetHandlerOpenWith
.
CMD_OPEN_WITH
));
fillOpenWithMenu
(
openWithMenu
);
manager
.
add
(
openWithMenu
);
}
manager
.
add
(
new
GroupMarker
(
"results_export"
));
manager
.
add
(
new
GroupMarker
(
NavigatorCommands
.
GROUP_TOOLS
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录