Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
e4d34558
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,发现更多精彩内容 >>
提交
e4d34558
编写于
4月 14, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Data transfer processors model refactoring. Binary format support.
XLSX exporter refactoring.
上级
cfc42a8b
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
137 addition
and
553 deletion
+137
-553
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferNodeDescriptor.java
...dbeaver/registry/transfer/DataTransferNodeDescriptor.java
+7
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferProcessorDescriptor.java
...er/registry/transfer/DataTransferProcessorDescriptor.java
+7
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferRegistry.java
...jkiss/dbeaver/registry/transfer/DataTransferRegistry.java
+25
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/IDataTransferConsumer.java
...g/jkiss/dbeaver/tools/transfer/IDataTransferConsumer.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/database/DatabaseTransferConsumer.java
...ver/tools/transfer/database/DatabaseTransferConsumer.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/stream/StreamConsumerPageOutput.java
...eaver/tools/transfer/stream/StreamConsumerPageOutput.java
+13
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/stream/StreamTransferConsumer.java
...dbeaver/tools/transfer/stream/StreamTransferConsumer.java
+51
-44
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/wizard/DataTransferPageFinal.java
.../dbeaver/tools/transfer/wizard/DataTransferPageFinal.java
+7
-4
plugins/org.jkiss.dbeaver.data.office/plugin.xml
plugins/org.jkiss.dbeaver.data.office/plugin.xml
+10
-17
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/DataExporterXLSX.java
...rg/jkiss/dbeaver/data/office/export/DataExporterXLSX.java
+7
-2
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOIConsumerPageOutput.java
...eaver/data/office/export/StreamPOIConsumerPageOutput.java
+0
-212
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOIConsumerPageSettings.java
...ver/data/office/export/StreamPOIConsumerPageSettings.java
+0
-197
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOIConsumerSettings.java
...dbeaver/data/office/export/StreamPOIConsumerSettings.java
+0
-26
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOITransferConsumer.java
...dbeaver/data/office/export/StreamPOITransferConsumer.java
+0
-27
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/handlers/OpenSpreadsheetHandler.java
.../dbeaver/data/office/handlers/OpenSpreadsheetHandler.java
+8
-14
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferNodeDescriptor.java
浏览文件 @
e4d34558
...
...
@@ -30,10 +30,7 @@ import org.jkiss.dbeaver.tools.transfer.IDataTransferNode;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferSettings
;
import
org.jkiss.utils.ArrayUtils
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.*
;
/**
* DataTransferNodeDescriptor
...
...
@@ -72,6 +69,11 @@ public class DataTransferNodeDescriptor extends AbstractDescriptor
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
)));
}
...
...
@@ -81,6 +83,7 @@ public class DataTransferNodeDescriptor extends AbstractDescriptor
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
()
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferProcessorDescriptor.java
浏览文件 @
e4d34558
...
...
@@ -28,6 +28,7 @@ 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
;
...
...
@@ -46,6 +47,7 @@ public class DataTransferProcessorDescriptor extends AbstractDescriptor implemen
@NotNull
private
final
DBPImage
icon
;
private
final
List
<
DBPPropertyDescriptor
>
properties
=
new
ArrayList
<>();
private
boolean
isBinary
;
DataTransferProcessorDescriptor
(
DataTransferNodeDescriptor
node
,
IConfigurationElement
config
)
{
...
...
@@ -56,6 +58,7 @@ public class DataTransferProcessorDescriptor extends AbstractDescriptor implemen
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
)));
...
...
@@ -119,4 +122,8 @@ public class DataTransferProcessorDescriptor extends AbstractDescriptor implemen
{
return
node
;
}
public
boolean
isBinaryFormat
()
{
return
isBinary
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/transfer/DataTransferRegistry.java
浏览文件 @
e4d34558
...
...
@@ -20,11 +20,14 @@ 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.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
;
/**
...
...
@@ -36,6 +39,8 @@ public class DataTransferRegistry {
private
static
DataTransferRegistry
instance
=
null
;
private
static
final
Log
log
=
Log
.
getLog
(
DataTransferRegistry
.
class
);
public
synchronized
static
DataTransferRegistry
getInstance
()
{
if
(
instance
==
null
)
{
...
...
@@ -51,10 +56,30 @@ public class DataTransferRegistry {
// 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
<
Class
<?>>
objectTypes
)
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/IDataTransferConsumer.java
浏览文件 @
e4d34558
...
...
@@ -30,7 +30,7 @@ public interface IDataTransferConsumer<SETTINGS extends IDataTransferSettings, P
extends
IDataTransferNode
<
SETTINGS
>,
DBDDataReceiver
{
void
initTransfer
(
DBSObject
sourceObject
,
SETTINGS
settings
,
PROCESSOR
processor
,
Map
<
Object
,
Object
>
processorProperties
);
void
initTransfer
(
DBSObject
sourceObject
,
SETTINGS
settings
,
boolean
isBinary
,
PROCESSOR
processor
,
Map
<
Object
,
Object
>
processorProperties
);
void
startTransfer
(
DBRProgressMonitor
monitor
)
throws
DBException
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/database/DatabaseTransferConsumer.java
浏览文件 @
e4d34558
...
...
@@ -239,7 +239,7 @@ public class DatabaseTransferConsumer implements IDataTransferConsumer<DatabaseC
}
@Override
public
void
initTransfer
(
DBSObject
sourceObject
,
DatabaseConsumerSettings
settings
,
IDataTransferProcessor
processor
,
Map
<
Object
,
Object
>
processorProperties
)
public
void
initTransfer
(
DBSObject
sourceObject
,
DatabaseConsumerSettings
settings
,
boolean
isBinary
,
IDataTransferProcessor
processor
,
Map
<
Object
,
Object
>
processorProperties
)
{
this
.
sourceObject
=
(
DBSDataContainer
)
sourceObject
;
this
.
settings
=
settings
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/stream/StreamConsumerPageOutput.java
浏览文件 @
e4d34558
...
...
@@ -191,13 +191,15 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar
}
private
void
toggleClipboardOutput
()
{
boolean
clipboard
=
clipboardCheck
.
getSelection
();
boolean
isBinary
=
getWizard
().
getSettings
().
getProcessor
().
isBinaryFormat
();
boolean
clipboard
=
!
isBinary
&&
clipboardCheck
.
getSelection
();
directoryText
.
setEnabled
(!
clipboard
);
fileNameText
.
setEnabled
(!
clipboard
);
compressCheckbox
.
setEnabled
(!
clipboard
);
encodingCombo
.
setEnabled
(!
clipboard
);
encodingBOMLabel
.
setEnabled
(!
clipboard
);
encodingBOMCheckbox
.
setEnabled
(!
clipboard
);
encodingCombo
.
setEnabled
(!
isBinary
&&
!
clipboard
);
encodingBOMLabel
.
setEnabled
(!
isBinary
&&
!
clipboard
);
encodingBOMCheckbox
.
setEnabled
(!
isBinary
&&
!
clipboard
);
showFolderCheckbox
.
setEnabled
(!
clipboard
);
execProcessCheckbox
.
setEnabled
(!
clipboard
);
execProcessText
.
setEnabled
(!
clipboard
);
...
...
@@ -212,6 +214,8 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar
@Override
public
void
activatePage
()
{
boolean
isBinary
=
getWizard
().
getSettings
().
getProcessor
().
isBinaryFormat
();
final
StreamConsumerSettings
settings
=
getWizard
().
getPageSettings
(
this
,
StreamConsumerSettings
.
class
);
clipboardCheck
.
setSelection
(
settings
.
isOutputClipboard
());
...
...
@@ -224,6 +228,11 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar
execProcessCheckbox
.
setSelection
(
settings
.
isExecuteProcessOnFinish
());
execProcessText
.
setText
(
CommonUtils
.
toString
(
settings
.
getFinishProcessCommand
()));
if
(
isBinary
)
{
clipboardCheck
.
setSelection
(
false
);
encodingBOMCheckbox
.
setSelection
(
false
);
}
updatePageCompletion
();
toggleClipboardOutput
();
toggleExecProcessControls
();
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/stream/StreamTransferConsumer.java
浏览文件 @
e4d34558
...
...
@@ -86,6 +86,7 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
private
StreamExportSite
exportSite
;
private
Map
<
Object
,
Object
>
processorProperties
;
private
StringWriter
outputBuffer
;
private
boolean
isBinary
;
private
boolean
initialized
=
false
;
public
StreamTransferConsumer
()
...
...
@@ -208,7 +209,7 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
// Open output streams
boolean
outputClipboard
=
settings
.
isOutputClipboard
();
outputFile
=
outputClipboard
?
null
:
makeOutputFile
();
outputFile
=
!
isBinary
&&
outputClipboard
?
null
:
makeOutputFile
();
try
{
if
(
outputClipboard
)
{
this
.
outputBuffer
=
new
StringWriter
(
2048
);
...
...
@@ -222,11 +223,13 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
zipStream
.
putNextEntry
(
new
ZipEntry
(
getOutputFileName
()));
StreamTransferConsumer
.
this
.
outputStream
=
zipStream
;
}
this
.
writer
=
new
PrintWriter
(
new
OutputStreamWriter
(
this
.
outputStream
,
settings
.
getOutputEncoding
()),
true
);
if
(!
isBinary
)
{
this
.
writer
=
new
PrintWriter
(
new
OutputStreamWriter
(
this
.
outputStream
,
settings
.
getOutputEncoding
()),
true
);
}
}
// Check for BOM
if
(!
outputClipboard
&&
settings
.
isOutputEncodingBOM
())
{
if
(!
isBinary
&&
!
outputClipboard
&&
settings
.
isOutputEncodingBOM
())
{
byte
[]
bom
=
GeneralUtils
.
getCharsetBOM
(
settings
.
getOutputEncoding
());
if
(
bom
!=
null
)
{
outputStream
.
write
(
bom
);
...
...
@@ -287,9 +290,10 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
}
@Override
public
void
initTransfer
(
DBSObject
sourceObject
,
StreamConsumerSettings
settings
,
IStreamDataExporter
processor
,
Map
<
Object
,
Object
>
processorProperties
)
public
void
initTransfer
(
DBSObject
sourceObject
,
StreamConsumerSettings
settings
,
boolean
isBinary
,
IStreamDataExporter
processor
,
Map
<
Object
,
Object
>
processorProperties
)
{
this
.
sourceObject
=
sourceObject
;
this
.
isBinary
=
isBinary
;
this
.
processor
=
processor
;
this
.
settings
=
settings
;
this
.
processorProperties
=
processorProperties
;
...
...
@@ -320,16 +324,13 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
return
;
}
if
(
settings
.
isOutputClipboard
())
{
if
(
!
isBinary
&&
settings
.
isOutputClipboard
())
{
if
(
outputBuffer
!=
null
)
{
DBeaverUI
.
syncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
TextTransfer
textTransfer
=
TextTransfer
.
getInstance
();
new
Clipboard
(
DBeaverUI
.
getDisplay
()).
setContents
(
new
Object
[]{
outputBuffer
.
toString
()},
new
Transfer
[]{
textTransfer
});
}
DBeaverUI
.
syncExec
(()
->
{
TextTransfer
textTransfer
=
TextTransfer
.
getInstance
();
new
Clipboard
(
DBeaverUI
.
getDisplay
()).
setContents
(
new
Object
[]{
outputBuffer
.
toString
()},
new
Transfer
[]{
textTransfer
});
});
outputBuffer
=
null
;
}
...
...
@@ -494,40 +495,46 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
@Override
public
void
writeBinaryData
(
@NotNull
DBDContentStorage
cs
)
throws
IOException
{
try
(
final
InputStream
stream
=
cs
.
getContentStream
())
{
exportSite
.
flush
();
final
DBPDataSource
dataSource
=
sourceObject
.
getDataSource
();
if
(
dataSource
instanceof
SQLDataSource
)
{
ByteArrayOutputStream
buffer
=
new
ByteArrayOutputStream
((
int
)
cs
.
getContentLength
());
IOUtils
.
copyStream
(
stream
,
buffer
);
final
byte
[]
bytes
=
buffer
.
toByteArray
();
final
String
binaryString
=
((
SQLDataSource
)
dataSource
).
getSQLDialect
().
getNativeBinaryFormatter
().
toString
(
bytes
,
0
,
bytes
.
length
);
writer
.
write
(
binaryString
);
}
else
{
switch
(
settings
.
getLobEncoding
())
{
case
BASE64:
{
Base64
.
encode
(
stream
,
cs
.
getContentLength
(),
writer
);
break
;
}
case
HEX:
{
writer
.
write
(
"0x"
);
//$NON-NLS-1$
byte
[]
buffer
=
new
byte
[
5000
];
for
(;
;
)
{
int
count
=
stream
.
read
(
buffer
);
if
(
count
<=
0
)
{
break
;
if
(
isBinary
)
{
try
(
final
InputStream
stream
=
cs
.
getContentStream
())
{
IOUtils
.
copyStream
(
stream
,
exportSite
.
getOutputStream
());
}
}
else
{
try
(
final
InputStream
stream
=
cs
.
getContentStream
())
{
exportSite
.
flush
();
final
DBPDataSource
dataSource
=
sourceObject
.
getDataSource
();
if
(
dataSource
instanceof
SQLDataSource
)
{
ByteArrayOutputStream
buffer
=
new
ByteArrayOutputStream
((
int
)
cs
.
getContentLength
());
IOUtils
.
copyStream
(
stream
,
buffer
);
final
byte
[]
bytes
=
buffer
.
toByteArray
();
final
String
binaryString
=
((
SQLDataSource
)
dataSource
).
getSQLDialect
().
getNativeBinaryFormatter
().
toString
(
bytes
,
0
,
bytes
.
length
);
writer
.
write
(
binaryString
);
}
else
{
switch
(
settings
.
getLobEncoding
())
{
case
BASE64:
{
Base64
.
encode
(
stream
,
cs
.
getContentLength
(),
writer
);
break
;
}
case
HEX:
{
writer
.
write
(
"0x"
);
//$NON-NLS-1$
byte
[]
buffer
=
new
byte
[
5000
];
for
(;
;
)
{
int
count
=
stream
.
read
(
buffer
);
if
(
count
<=
0
)
{
break
;
}
GeneralUtils
.
writeBytesAsHex
(
writer
,
buffer
,
0
,
count
);
}
GeneralUtils
.
writeBytesAsHex
(
writer
,
buffer
,
0
,
count
)
;
break
;
}
break
;
default
:
// Binary stream
try
(
Reader
reader
=
new
InputStreamReader
(
stream
,
cs
.
getCharset
()))
{
IOUtils
.
copyText
(
reader
,
writer
);
}
break
;
}
default
:
// Binary stream
try
(
Reader
reader
=
new
InputStreamReader
(
stream
,
cs
.
getCharset
()))
{
IOUtils
.
copyText
(
reader
,
writer
);
}
break
;
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/wizard/DataTransferPageFinal.java
浏览文件 @
e4d34558
...
...
@@ -27,6 +27,7 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.registry.transfer.DataTransferProcessorDescriptor
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor
;
import
org.jkiss.dbeaver.tools.transfer.IDataTransferSettings
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
...
...
@@ -85,11 +86,12 @@ class DataTransferPageFinal extends ActiveWizardPage<DataTransferWizard> {
List
<
DataTransferPipe
>
dataPipes
=
settings
.
getDataPipes
();
for
(
DataTransferPipe
pipe
:
dataPipes
)
{
IDataTransferSettings
consumerSettings
=
settings
.
getNodeSettings
(
pipe
.
getConsumer
());
DataTransferProcessorDescriptor
processorDescriptor
=
settings
.
getProcessor
();
IDataTransferProcessor
processor
=
null
;
if
(
settings
.
getProcessor
()
!=
null
)
{
if
(
processorDescriptor
!=
null
)
{
// Processor is optional
try
{
processor
=
settings
.
getProcessor
()
.
getInstance
();
processor
=
processorDescriptor
.
getInstance
();
}
catch
(
Throwable
e
)
{
log
.
error
(
"Can't create processor"
,
e
);
continue
;
...
...
@@ -98,6 +100,7 @@ class DataTransferPageFinal extends ActiveWizardPage<DataTransferWizard> {
pipe
.
getConsumer
().
initTransfer
(
pipe
.
getProducer
().
getSourceObject
(),
consumerSettings
,
processorDescriptor
!=
null
&&
processorDescriptor
.
isBinaryFormat
(),
processor
,
processor
==
null
?
null
:
...
...
@@ -108,8 +111,8 @@ class DataTransferPageFinal extends ActiveWizardPage<DataTransferWizard> {
item
.
setImage
(
0
,
DBeaverIcons
.
getImage
(
settings
.
getProducer
().
getIcon
()));
}
item
.
setText
(
1
,
pipe
.
getConsumer
().
getTargetName
());
if
(
settings
.
getProcessor
()
!=
null
&&
settings
.
getProcessor
()
.
getIcon
()
!=
null
)
{
item
.
setImage
(
1
,
DBeaverIcons
.
getImage
(
settings
.
getProcessor
()
.
getIcon
()));
if
(
processorDescriptor
!=
null
&&
processorDescriptor
.
getIcon
()
!=
null
)
{
item
.
setImage
(
1
,
DBeaverIcons
.
getImage
(
processorDescriptor
.
getIcon
()));
}
else
if
(
settings
.
getConsumer
()
!=
null
&&
settings
.
getConsumer
().
getIcon
()
!=
null
)
{
item
.
setImage
(
1
,
DBeaverIcons
.
getImage
(
settings
.
getConsumer
().
getIcon
()));
}
...
...
plugins/org.jkiss.dbeaver.data.office/plugin.xml
浏览文件 @
e4d34558
...
...
@@ -3,21 +3,14 @@
<plugin>
<extension
point=
"org.jkiss.dbeaver.dataTransfer"
>
<node
type=
"consumer"
id=
"poi_consumer"
class=
"org.jkiss.dbeaver.data.office.export.StreamPOITransferConsumer"
icon=
"icons/file/file.png"
label=
"%dataTransfer.consumer.stream.name"
description=
"%dataTransfer.consumer.stream.description"
settings=
"org.jkiss.dbeaver.data.office.export.StreamPOIConsumerSettings"
>
<page
class=
"org.jkiss.dbeaver.data.office.export.StreamPOIConsumerPageSettings"
/>
<page
class=
"org.jkiss.dbeaver.data.office.export.StreamPOIConsumerPageOutput"
/>
<processor
id=
"stream.xlsx"
class=
"org.jkiss.dbeaver.data.office.export.DataExporterXLSX"
description=
"%dataTransfer.processor.xlsx.description"
icon=
"icons/excel.png"
label=
"%dataTransfer.processor.xlsx.name"
>
<node
ref=
"stream_consumer"
>
<processor
id=
"stream.xlsx"
class=
"org.jkiss.dbeaver.data.office.export.DataExporterXLSX"
description=
"%dataTransfer.processor.xlsx.description"
icon=
"icons/excel.png"
label=
"%dataTransfer.processor.xlsx.name"
binary=
"true"
>
<propertyGroup
label=
"%dataTransfer.processor.xlsx.propertyGroup.general.label"
>
<property
id=
"rownumber"
label=
"%dataTransfer.processor.xlsx.property.rowNumber.name"
type=
"boolean"
description=
"%dataTransfer.processor.xlsx.property.rowNumber.description"
defaultValue=
"yes"
required=
"false"
/>
<property
id=
"border"
label=
"%dataTransfer.processor.xlsx.property.border.name"
type=
"string"
description=
"%dataTransfer.processor.xlsx.property.border.description"
defaultValue=
"THIN"
required=
"false"
validValues=
"NONE,THIN,THICK"
/>
...
...
@@ -30,9 +23,9 @@
<property
id=
"exportSql"
label=
"%dataTransfer.processor.xlsx.property.exportSql.name"
type=
"boolean"
description=
"%dataTransfer.processor.xlsx.property.exportSql.description"
defaultValue=
"false"
required=
"false"
/>
<property
id=
"splitSqlText"
label=
"%dataTransfer.processor.xlsx.property.splitSqlText.name"
type=
"boolean"
description=
"%dataTransfer.processor.xlsx.property.splitSqlText.description"
defaultValue=
"false"
required=
"false"
/>
<property
id=
"splitByRowCount"
label=
"%dataTransfer.processor.xlsx.property.splitByRowCount.name"
type=
"integer"
description=
"%dataTransfer.processor.xlsx.property.splitByRowCount.description"
defaultValue=
"1048575"
required=
"false"
/>
<property
id=
"splitByColNum"
label=
"%dataTransfer.processor.xlsx.property.splitByColNum.name"
type=
"integer"
description=
"%dataTransfer.processor.xlsx.property.splitByColNum.description"
defaultValue=
""
required=
"false"
/>
<property
id=
"splitByColNum"
label=
"%dataTransfer.processor.xlsx.property.splitByColNum.name"
type=
"integer"
description=
"%dataTransfer.processor.xlsx.property.splitByColNum.description"
defaultValue=
"
0
"
required=
"false"
/>
</propertyGroup>
</processor>
</processor>
</node>
</extension>
...
...
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/DataExporterXLSX.java
浏览文件 @
e4d34558
...
...
@@ -110,7 +110,7 @@ public class DataExporterXLSX extends StreamExporterAbstract {
properties
.
put
(
DataExporterXLSX
.
PROP_EXPORT_SQL
,
false
);
properties
.
put
(
DataExporterXLSX
.
PROP_SPLIT_SQLTEXT
,
false
);
properties
.
put
(
DataExporterXLSX
.
PROP_SPLIT_BYROWCOUNT
,
EXCEL2007MAXROWS
);
properties
.
put
(
DataExporterXLSX
.
PROP_SPLIT_BYCOL
,
-
1
);
properties
.
put
(
DataExporterXLSX
.
PROP_SPLIT_BYCOL
,
0
);
return
properties
;
}
...
...
@@ -317,6 +317,11 @@ public class DataExporterXLSX extends StreamExporterAbstract {
super
.
dispose
();
}
@Override
public
boolean
isTextExporter
()
{
return
false
;
}
@Override
public
void
exportHeader
(
DBCSession
session
)
throws
DBException
,
IOException
{
...
...
@@ -425,7 +430,7 @@ public class DataExporterXLSX extends StreamExporterAbstract {
}
private
Worksheet
getWsh
(
Object
[]
row
)
{
Object
colValue
=
((
splitByCol
<
0
)
||
(
splitByCol
>=
columns
.
size
()))
?
""
:
row
[
splitByCol
];
Object
colValue
=
((
splitByCol
<
=
0
)
||
(
splitByCol
>=
columns
.
size
()))
?
""
:
row
[
splitByCol
];
Worksheet
w
=
worksheets
.
get
(
colValue
);
if
(
w
==
null
)
{
w
=
createSheet
(
colValue
);
...
...
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOIConsumerPageOutput.java
已删除
100644 → 0
浏览文件 @
cfc42a8b
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com)
* Copyright (C) 2017 Adolfo Suarez (agustavo@gmail.com)
*
* 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.data.office.export
;
import
org.eclipse.jface.fieldassist.SimpleContentProposalProvider
;
import
org.eclipse.jface.fieldassist.TextContentAdapter
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.ModifyEvent
;
import
org.eclipse.swt.events.ModifyListener
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Button
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Group
;
import
org.eclipse.swt.widgets.Label
;
import
org.eclipse.swt.widgets.Text
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage
;
import
org.jkiss.dbeaver.ui.dialogs.DialogUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.CommonUtils
;
/**
* @author Andrey.Hitrin
*
*/
public
class
StreamPOIConsumerPageOutput
extends
ActiveWizardPage
<
DataTransferWizard
>
{
private
Text
directoryText
;
private
Text
fileNameText
;
private
Button
showFolderCheckbox
;
private
Button
execProcessCheckbox
;
private
Text
execProcessText
;
public
StreamPOIConsumerPageOutput
()
{
super
(
CoreMessages
.
data_transfer_wizard_output_name
);
setTitle
(
CoreMessages
.
data_transfer_wizard_output_title
);
setDescription
(
CoreMessages
.
data_transfer_wizard_output_description
);
setPageComplete
(
false
);
}
@Override
public
void
createControl
(
Composite
parent
)
{
initializeDialogUnits
(
parent
);
Composite
composite
=
new
Composite
(
parent
,
SWT
.
NULL
);
GridLayout
gl
=
new
GridLayout
();
gl
.
marginHeight
=
0
;
gl
.
marginWidth
=
0
;
composite
.
setLayout
(
gl
);
composite
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
final
StreamPOIConsumerSettings
settings
=
getWizard
().
getPageSettings
(
this
,
StreamPOIConsumerSettings
.
class
);
{
Group
generalSettings
=
UIUtils
.
createControlGroup
(
composite
,
CoreMessages
.
data_transfer_wizard_output_group_general
,
5
,
GridData
.
FILL_HORIZONTAL
,
0
);
directoryText
=
DialogUtils
.
createOutputFolderChooser
(
generalSettings
,
null
,
new
ModifyListener
()
{
@Override
public
void
modifyText
(
ModifyEvent
e
)
{
settings
.
setOutputFolder
(
directoryText
.
getText
());
updatePageCompletion
();
}
});
((
GridData
)
directoryText
.
getParent
().
getLayoutData
()).
horizontalSpan
=
4
;
UIUtils
.
createControlLabel
(
generalSettings
,
CoreMessages
.
data_transfer_wizard_output_label_file_name_pattern
);
fileNameText
=
new
Text
(
generalSettings
,
SWT
.
BORDER
);
GridData
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
);
gd
.
horizontalSpan
=
4
;
UIUtils
.
setContentProposalToolTip
(
fileNameText
,
"Output file name pattern"
,
StreamPOITransferConsumer
.
VARIABLE_TABLE
,
StreamPOITransferConsumer
.
VARIABLE_TIMESTAMP
,
StreamPOITransferConsumer
.
VARIABLE_PROJECT
);
fileNameText
.
setLayoutData
(
gd
);
fileNameText
.
addModifyListener
(
new
ModifyListener
()
{
@Override
public
void
modifyText
(
ModifyEvent
e
)
{
settings
.
setOutputFilePattern
(
fileNameText
.
getText
());
updatePageCompletion
();
}
});
UIUtils
.
installContentProposal
(
fileNameText
,
new
TextContentAdapter
(),
new
SimpleContentProposalProvider
(
new
String
[]
{
GeneralUtils
.
variablePattern
(
StreamPOITransferConsumer
.
VARIABLE_TABLE
),
GeneralUtils
.
variablePattern
(
StreamPOITransferConsumer
.
VARIABLE_TIMESTAMP
),
GeneralUtils
.
variablePattern
(
StreamPOITransferConsumer
.
VARIABLE_PROJECT
)
}));
{
new
Label
(
generalSettings
,
SWT
.
NONE
);
}
}
{
Group
resultsSettings
=
UIUtils
.
createControlGroup
(
composite
,
"Results"
,
2
,
GridData
.
FILL_HORIZONTAL
,
0
);
showFolderCheckbox
=
UIUtils
.
createCheckbox
(
resultsSettings
,
CoreMessages
.
data_transfer_wizard_output_checkbox_open_folder
,
true
);
showFolderCheckbox
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
settings
.
setOpenFolderOnFinish
(
showFolderCheckbox
.
getSelection
());
}
});
showFolderCheckbox
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
,
GridData
.
VERTICAL_ALIGN_BEGINNING
,
false
,
false
,
2
,
1
));
execProcessCheckbox
=
UIUtils
.
createCheckbox
(
resultsSettings
,
"Execute process on finish"
,
true
);
execProcessCheckbox
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
settings
.
setExecuteProcessOnFinish
(
execProcessCheckbox
.
getSelection
());
toggleExecProcessControls
();
updatePageCompletion
();
}
});
execProcessText
=
new
Text
(
resultsSettings
,
SWT
.
BORDER
);
execProcessText
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
execProcessText
.
addModifyListener
(
new
ModifyListener
()
{
@Override
public
void
modifyText
(
ModifyEvent
e
)
{
settings
.
setFinishProcessCommand
(
execProcessText
.
getText
());
updatePageCompletion
();
}
});
UIUtils
.
setContentProposalToolTip
(
execProcessText
,
"Process command line"
,
StreamPOITransferConsumer
.
VARIABLE_FILE
,
StreamPOITransferConsumer
.
VARIABLE_TABLE
,
StreamPOITransferConsumer
.
VARIABLE_TIMESTAMP
,
StreamPOITransferConsumer
.
VARIABLE_PROJECT
);
UIUtils
.
installContentProposal
(
execProcessText
,
new
TextContentAdapter
(),
new
SimpleContentProposalProvider
(
new
String
[]
{
GeneralUtils
.
variablePattern
(
StreamPOITransferConsumer
.
VARIABLE_TABLE
),
GeneralUtils
.
variablePattern
(
StreamPOITransferConsumer
.
VARIABLE_TIMESTAMP
),
GeneralUtils
.
variablePattern
(
StreamPOITransferConsumer
.
VARIABLE_PROJECT
),
GeneralUtils
.
variablePattern
(
StreamPOITransferConsumer
.
VARIABLE_FILE
)
}));
}
setControl
(
composite
);
}
private
void
toggleExecProcessControls
()
{
final
boolean
isExecCommand
=
execProcessCheckbox
.
getSelection
();
execProcessText
.
setEnabled
(
isExecCommand
);
}
@Override
public
void
activatePage
()
{
final
StreamPOIConsumerSettings
settings
=
getWizard
().
getPageSettings
(
this
,
StreamPOIConsumerSettings
.
class
);
directoryText
.
setText
(
CommonUtils
.
toString
(
settings
.
getOutputFolder
()));
fileNameText
.
setText
(
CommonUtils
.
toString
(
settings
.
getOutputFilePattern
()));
showFolderCheckbox
.
setSelection
(
settings
.
isOpenFolderOnFinish
());
execProcessCheckbox
.
setSelection
(
settings
.
isExecuteProcessOnFinish
());
execProcessText
.
setText
(
CommonUtils
.
toString
(
settings
.
getFinishProcessCommand
()));
updatePageCompletion
();
toggleExecProcessControls
();
}
@Override
protected
boolean
determinePageCompletion
()
{
final
StreamPOIConsumerSettings
settings
=
getWizard
().
getPageSettings
(
this
,
StreamPOIConsumerSettings
.
class
);
boolean
valid
=
true
;
if
(
CommonUtils
.
isEmpty
(
settings
.
getOutputFolder
()))
{
valid
=
false
;
}
if
(
CommonUtils
.
isEmpty
(
settings
.
getOutputFilePattern
()))
{
valid
=
false
;
}
if
(
settings
.
isExecuteProcessOnFinish
()
&&
CommonUtils
.
isEmpty
(
settings
.
getFinishProcessCommand
()))
{
return
false
;
}
//To avoid problem with BOM
//Do not TOUCH !!!
settings
.
setOutputEncodingBOM
(
false
);
return
valid
;
}
}
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOIConsumerPageSettings.java
已删除
100644 → 0
浏览文件 @
cfc42a8b
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.data.office.export
;
import
org.eclipse.jface.preference.PreferenceDialog
;
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.layout.GridLayout
;
import
org.eclipse.swt.widgets.Button
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Group
;
import
org.eclipse.ui.dialogs.PreferencesUtil
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatterProfile
;
import
org.jkiss.dbeaver.registry.formatter.DataFormatterRegistry
;
import
org.jkiss.dbeaver.registry.transfer.DataTransferProcessorDescriptor
;
import
org.jkiss.dbeaver.runtime.properties.PropertySourceCustom
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerPageSettings
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.preferences.PrefPageDataFormat
;
import
org.jkiss.dbeaver.ui.properties.PropertyTreeViewer
;
/**
* @author Andrey.Hitrin
*
*/
public
class
StreamPOIConsumerPageSettings
extends
StreamConsumerPageSettings
{
private
PropertyTreeViewer
propsEditor
;
private
Combo
formatProfilesCombo
;
private
PropertySourceCustom
propertySource
;
public
StreamPOIConsumerPageSettings
()
{
super
();
setTitle
(
CoreMessages
.
data_transfer_wizard_settings_title
);
setDescription
(
CoreMessages
.
data_transfer_wizard_settings_description
);
setPageComplete
(
false
);
}
@Override
public
void
createControl
(
Composite
parent
)
{
initializeDialogUnits
(
parent
);
final
StreamConsumerSettings
settings
=
getWizard
().
getPageSettings
(
this
,
StreamConsumerSettings
.
class
);
Composite
composite
=
new
Composite
(
parent
,
SWT
.
NULL
);
GridLayout
gl
=
new
GridLayout
();
gl
.
marginHeight
=
0
;
gl
.
marginWidth
=
0
;
composite
.
setLayout
(
gl
);
composite
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
{
Group
generalSettings
=
new
Group
(
composite
,
SWT
.
NONE
);
generalSettings
.
setText
(
CoreMessages
.
data_transfer_wizard_settings_group_general
);
gl
=
new
GridLayout
(
4
,
false
);
generalSettings
.
setLayout
(
gl
);
generalSettings
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
{
Composite
formattingGroup
=
UIUtils
.
createPlaceholder
(
generalSettings
,
3
);
GridData
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
);
gd
.
horizontalSpan
=
4
;
formattingGroup
.
setLayoutData
(
gd
);
UIUtils
.
createControlLabel
(
formattingGroup
,
CoreMessages
.
data_transfer_wizard_settings_label_formatting
);
formatProfilesCombo
=
new
Combo
(
formattingGroup
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
gd
=
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
);
gd
.
widthHint
=
200
;
formatProfilesCombo
.
setLayoutData
(
gd
);
formatProfilesCombo
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
if
(
formatProfilesCombo
.
getSelectionIndex
()
>
0
)
{
settings
.
setFormatterProfile
(
DataFormatterRegistry
.
getInstance
().
getCustomProfile
(
UIUtils
.
getComboSelection
(
formatProfilesCombo
)));
}
else
{
settings
.
setFormatterProfile
(
null
);
}
}
});
Button
profilesManageButton
=
new
Button
(
formattingGroup
,
SWT
.
PUSH
);
profilesManageButton
.
setText
(
CoreMessages
.
data_transfer_wizard_settings_button_edit
);
profilesManageButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
PreferenceDialog
propDialog
=
PreferencesUtil
.
createPropertyDialogOn
(
getShell
(),
DataFormatterRegistry
.
getInstance
(),
PrefPageDataFormat
.
PAGE_ID
,
null
,
getSelectedFormatterProfile
(),
PreferencesUtil
.
OPTION_NONE
);
if
(
propDialog
!=
null
)
{
propDialog
.
open
();
reloadFormatProfiles
();
}
}
});
reloadFormatProfiles
();
}
}
Group
exporterSettings
=
new
Group
(
composite
,
SWT
.
NONE
);
exporterSettings
.
setText
(
CoreMessages
.
data_transfer_wizard_settings_group_exporter
);
exporterSettings
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
exporterSettings
.
setLayout
(
new
GridLayout
(
1
,
false
));
propsEditor
=
new
PropertyTreeViewer
(
exporterSettings
,
SWT
.
BORDER
);
setControl
(
composite
);
}
private
Object
getSelectedFormatterProfile
()
{
DataFormatterRegistry
registry
=
DataFormatterRegistry
.
getInstance
();
int
selectionIndex
=
formatProfilesCombo
.
getSelectionIndex
();
if
(
selectionIndex
<
0
)
{
return
null
;
}
else
if
(
selectionIndex
==
0
)
{
return
registry
.
getGlobalProfile
();
}
else
{
return
registry
.
getCustomProfile
(
UIUtils
.
getComboSelection
(
formatProfilesCombo
));
}
}
private
void
reloadFormatProfiles
()
{
DataFormatterRegistry
registry
=
DataFormatterRegistry
.
getInstance
();
formatProfilesCombo
.
removeAll
();
formatProfilesCombo
.
add
(
CoreMessages
.
data_transfer_wizard_settings_listbox_formatting_item_default
);
for
(
DBDDataFormatterProfile
profile
:
registry
.
getCustomProfiles
())
{
formatProfilesCombo
.
add
(
profile
.
getProfileName
());
}
final
StreamConsumerSettings
settings
=
getWizard
().
getPageSettings
(
this
,
StreamConsumerSettings
.
class
);
DBDDataFormatterProfile
formatterProfile
=
settings
.
getFormatterProfile
();
if
(
formatterProfile
!=
null
)
{
if
(!
UIUtils
.
setComboSelection
(
formatProfilesCombo
,
formatterProfile
.
getProfileName
()))
{
formatProfilesCombo
.
select
(
0
);
}
}
else
{
formatProfilesCombo
.
select
(
0
);
}
}
@Override
public
void
activatePage
()
{
final
StreamConsumerSettings
settings
=
getWizard
().
getPageSettings
(
this
,
StreamConsumerSettings
.
class
);
DataTransferProcessorDescriptor
processor
=
getWizard
().
getSettings
().
getProcessor
();
propertySource
=
new
PropertySourceCustom
(
processor
.
getProperties
(),
getWizard
().
getSettings
().
getProcessorProperties
());
propsEditor
.
loadProperties
(
propertySource
);
updatePageCompletion
();
}
@Override
public
void
deactivatePage
()
{
getWizard
().
getSettings
().
setProcessorProperties
(
propertySource
.
getPropertiesWithDefaults
());
}
@Override
protected
boolean
determinePageCompletion
()
{
return
true
;
}
}
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOIConsumerSettings.java
已删除
100644 → 0
浏览文件 @
cfc42a8b
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.data.office.export
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings
;
/**
* @author Andrey.Hitrin
*
*/
public
class
StreamPOIConsumerSettings
extends
StreamConsumerSettings
{
}
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/StreamPOITransferConsumer.java
已删除
100644 → 0
浏览文件 @
cfc42a8b
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.data.office.export
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamTransferConsumer
;
/**
* @author Andrey.Hitrin
*
*/
public
class
StreamPOITransferConsumer
extends
StreamTransferConsumer
{
}
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/handlers/OpenSpreadsheetHandler.java
浏览文件 @
e4d34558
...
...
@@ -22,17 +22,16 @@ import org.eclipse.core.commands.ExecutionException;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.data.office.export.DataExporterXLSX
;
import
org.jkiss.dbeaver.data.office.export.StreamPOIConsumerSettings
;
import
org.jkiss.dbeaver.data.office.export.StreamPOITransferConsumer
;
import
org.jkiss.dbeaver.model.runtime.AbstractJob
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSDataContainer
;
import
org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings
;
import
org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings
;
import
org.jkiss.dbeaver.tools.transfer.stream.StreamTransferConsumer
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.resultset.IResultSetController
;
import
org.jkiss.dbeaver.ui.controls.resultset.ResultSetCommandHandler
;
...
...
@@ -44,8 +43,6 @@ import java.util.Map;
public
class
OpenSpreadsheetHandler
extends
AbstractHandler
{
private
static
final
Log
log
=
Log
.
getLog
(
OpenSpreadsheetHandler
.
class
);
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
...
...
@@ -79,8 +76,8 @@ public class OpenSpreadsheetHandler extends AbstractHandler
DataExporterXLSX
exporter
=
new
DataExporterXLSX
();
Stream
POITransferConsumer
consumer
=
new
StreamPOI
TransferConsumer
();
Stream
POIConsumerSettings
settings
=
new
StreamPOI
ConsumerSettings
();
Stream
TransferConsumer
consumer
=
new
Stream
TransferConsumer
();
Stream
ConsumerSettings
settings
=
new
Stream
ConsumerSettings
();
settings
.
setOutputEncodingBOM
(
false
);
settings
.
setOpenFolderOnFinish
(
false
);
...
...
@@ -88,7 +85,7 @@ public class OpenSpreadsheetHandler extends AbstractHandler
settings
.
setOutputFilePattern
(
tempFile
.
getName
());
Map
<
Object
,
Object
>
properties
=
DataExporterXLSX
.
getDefaultProperties
();
consumer
.
initTransfer
(
dataContainer
,
settings
,
exporter
,
properties
);
consumer
.
initTransfer
(
dataContainer
,
settings
,
true
,
exporter
,
properties
);
DatabaseTransferProducer
producer
=
new
DatabaseTransferProducer
(
dataContainer
);
DatabaseProducerSettings
producerSettings
=
new
DatabaseProducerSettings
();
...
...
@@ -99,12 +96,9 @@ public class OpenSpreadsheetHandler extends AbstractHandler
consumer
.
finishTransfer
(
monitor
,
false
);
DBeaverUI
.
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
UIUtils
.
launchProgram
(
tempFile
.
getAbsolutePath
()))
{
DBeaverUI
.
getInstance
().
showError
(
"Open XLSX"
,
"Can't open XLSX file '"
+
tempFile
.
getAbsolutePath
()
+
"'"
);
}
DBeaverUI
.
asyncExec
(()
->
{
if
(!
UIUtils
.
launchProgram
(
tempFile
.
getAbsolutePath
()))
{
DBeaverUI
.
getInstance
().
showError
(
"Open XLSX"
,
"Can't open XLSX file '"
+
tempFile
.
getAbsolutePath
()
+
"'"
);
}
});
}
catch
(
Exception
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录