Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
4d4140d2
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,发现更多精彩内容 >>
未验证
提交
4d4140d2
编写于
12月 01, 2017
作者:
S
Serge Rider
提交者:
GitHub
12月 01, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2581 from juliardi/devel
create navicat import connection
上级
e38ddf53
683be859
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
367 addition
and
0 deletion
+367
-0
plugins/org.jkiss.dbeaver.ext.import-config/plugin.xml
plugins/org.jkiss.dbeaver.ext.import-config/plugin.xml
+8
-0
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardNavicat.java
...ort_config/wizards/navicat/ConfigImportWizardNavicat.java
+69
-0
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardPageNavicatConnections.java
...rds/navicat/ConfigImportWizardPageNavicatConnections.java
+109
-0
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardPageNavicatDriver.java
.../wizards/navicat/ConfigImportWizardPageNavicatDriver.java
+91
-0
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardPageNavicatSettings.java
...izards/navicat/ConfigImportWizardPageNavicatSettings.java
+90
-0
未找到文件。
plugins/org.jkiss.dbeaver.ext.import-config/plugin.xml
浏览文件 @
4d4140d2
...
...
@@ -36,6 +36,14 @@
icon=
"icons/dbvis.png"
>
<description>
DBVisualizer
</description>
</wizard>
<wizard
category=
"org.jkiss.dbeaver.import_config.third-party"
class=
"org.jkiss.dbeaver.ext.import_config.wizards.navicat.ConfigImportWizardNavicat"
id=
"org.jkiss.dbeaver.import_config.navicat"
name=
"Navicat"
icon=
"icons/custom.png"
>
<description>
Navicat
</description>
</wizard>
<wizard
category=
"org.jkiss.dbeaver.import_config.third-party"
class=
"org.jkiss.dbeaver.ext.import_config.wizards.custom.ConfigImportWizardCustom"
...
...
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardNavicat.java
0 → 100644
浏览文件 @
4d4140d2
/*
* 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.ext.import_config.wizards.navicat
;
import
java.io.File
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ConfigImportWizard
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ConfigImportWizardPage
;
import
org.jkiss.dbeaver.ext.import_config.wizards.custom.ConfigImportWizardPageCustomConnections
;
import
org.jkiss.dbeaver.ext.import_config.wizards.custom.ConfigImportWizardPageCustomDriver
;
import
org.jkiss.dbeaver.ext.import_config.wizards.custom.ConfigImportWizardPageCustomSettings
;
import
org.jkiss.dbeaver.model.connection.DBPDriver
;
public
class
ConfigImportWizardNavicat
extends
ConfigImportWizard
{
private
ConfigImportWizardPageNavicatDriver
pageDriver
;
private
ConfigImportWizardPageNavicatSettings
pageSettings
;
@Override
protected
ConfigImportWizardPageNavicatConnections
createMainPage
()
{
return
new
ConfigImportWizardPageNavicatConnections
();
}
@Override
public
void
addPages
()
{
pageDriver
=
new
ConfigImportWizardPageNavicatDriver
();
pageSettings
=
new
ConfigImportWizardPageNavicatSettings
();
addPage
(
pageDriver
);
addPage
(
pageSettings
);
super
.
addPages
();
}
public
ConfigImportWizardPageNavicatSettings
getPageSettings
()
{
return
pageSettings
;
}
public
ConfigImportWizardPageNavicatDriver
getPageDriver
()
{
return
pageDriver
;
}
public
DBPDriver
getDriver
()
{
return
pageDriver
.
getSelectedDriver
();
}
public
File
getInputFile
()
{
return
pageSettings
.
getInputFile
();
}
public
String
getInputFileEncoding
()
{
return
pageSettings
.
getInputFileEncoding
();
}
}
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardPageNavicatConnections.java
0 → 100644
浏览文件 @
4d4140d2
/*
* 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.ext.import_config.wizards.navicat
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ConfigImportWizardPage
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportConnectionInfo
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportData
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportDriverInfo
;
import
org.jkiss.dbeaver.ext.import_config.wizards.custom.ConfigImportWizardCustom
;
import
org.jkiss.dbeaver.model.connection.DBPDriver
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.xml.XMLException
;
import
org.jkiss.utils.xml.XMLUtils
;
import
org.w3c.dom.Attr
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.w3c.dom.NamedNodeMap
;
import
au.com.bytecode.opencsv.CSVReader
;
public
class
ConfigImportWizardPageNavicatConnections
extends
ConfigImportWizardPage
{
protected
ConfigImportWizardPageNavicatConnections
()
{
super
(
"Navicat"
);
setTitle
(
"Navicat"
);
setDescription
(
"Import Navicat connections"
);
}
@Override
protected
void
loadConnections
(
ImportData
importData
)
throws
DBException
{
setErrorMessage
(
null
);
ConfigImportWizardNavicat
wizard
=
(
ConfigImportWizardNavicat
)
getWizard
();
final
DBPDriver
driver
=
wizard
.
getDriver
();
ImportDriverInfo
driverInfo
=
new
ImportDriverInfo
(
driver
.
getId
(),
driver
.
getName
(),
driver
.
getSampleURL
(),
driver
.
getDriverClassName
());
importData
.
addDriver
(
driverInfo
);
File
inputFile
=
wizard
.
getInputFile
();
try
(
InputStream
is
=
new
FileInputStream
(
inputFile
))
{
try
(
Reader
reader
=
new
InputStreamReader
(
is
,
wizard
.
getInputFileEncoding
()))
{
importNCX
(
importData
,
driverInfo
,
reader
);
}
}
catch
(
Exception
e
)
{
setErrorMessage
(
e
.
getMessage
());
}
}
private
void
importNCX
(
ImportData
importData
,
ImportDriverInfo
driver
,
Reader
reader
)
throws
XMLException
{
Document
document
=
XMLUtils
.
parseDocument
(
reader
);
for
(
Element
conElement
:
XMLUtils
.
getChildElementList
(
document
.
getDocumentElement
()))
{
Map
<
String
,
String
>
conProps
=
new
HashMap
<>();
NamedNodeMap
attrs
=
conElement
.
getAttributes
();
for
(
int
i
=
0
;
i
<
attrs
.
getLength
();
i
++)
{
Attr
attr
=
(
Attr
)
attrs
.
item
(
i
);
conProps
.
put
(
attr
.
getName
(),
attr
.
getValue
());
}
makeConnectionFromProps
(
importData
,
driver
,
conProps
);
}
}
private
void
makeConnectionFromProps
(
ImportData
importData
,
ImportDriverInfo
driver
,
Map
<
String
,
String
>
conProps
)
{
String
name
=
conProps
.
get
(
"ConnectionName"
);
if
(
CommonUtils
.
isEmpty
(
name
))
{
return
;
}
importData
.
addConnection
(
new
ImportConnectionInfo
(
driver
,
conProps
.
get
(
"ConnectionName"
),
name
,
""
,
conProps
.
get
(
"Host"
),
conProps
.
get
(
"Port"
),
conProps
.
get
(
"Database"
),
conProps
.
get
(
"UserName"
),
""
));
}
}
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardPageNavicatDriver.java
0 → 100644
浏览文件 @
4d4140d2
/*
* 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.ext.import_config.wizards.navicat
;
import
org.eclipse.jface.viewers.*
;
import
org.eclipse.jface.wizard.WizardPage
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.jkiss.dbeaver.model.connection.DBPDriver
;
import
org.jkiss.dbeaver.registry.DataSourceProviderRegistry
;
import
org.jkiss.dbeaver.registry.driver.DriverDescriptor
;
import
org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeControl
;
public
class
ConfigImportWizardPageNavicatDriver
extends
WizardPage
implements
ISelectionChangedListener
,
IDoubleClickListener
{
private
DriverDescriptor
selectedDriver
;
protected
ConfigImportWizardPageNavicatDriver
()
{
super
(
"Driver"
);
setTitle
(
"Driver selection"
);
setDescription
(
"Select the driver to use for imported connections"
);
}
@Override
public
void
createControl
(
Composite
parent
)
{
Composite
placeholder
=
new
Composite
(
parent
,
SWT
.
NONE
);
placeholder
.
setLayout
(
new
GridLayout
(
1
,
true
));
DriverTreeControl
driverTreeControl
=
new
DriverTreeControl
(
placeholder
,
this
,
DataSourceProviderRegistry
.
getInstance
().
getEnabledDataSourceProviders
(),
true
);
GridData
gd
=
new
GridData
(
GridData
.
FILL_BOTH
);
gd
.
heightHint
=
200
;
driverTreeControl
.
setLayoutData
(
gd
);
setControl
(
placeholder
);
}
@Override
public
boolean
isPageComplete
()
{
return
selectedDriver
!=
null
;
}
@Override
public
void
selectionChanged
(
SelectionChangedEvent
event
)
{
this
.
selectedDriver
=
null
;
this
.
setMessage
(
""
);
ISelection
selection
=
event
.
getSelection
();
if
(
selection
instanceof
IStructuredSelection
)
{
Object
selectedObject
=
((
IStructuredSelection
)
selection
).
getFirstElement
();
if
(
selectedObject
instanceof
DBPDriver
)
{
selectedDriver
=
(
DriverDescriptor
)
selectedObject
;
this
.
setMessage
(
selectedDriver
.
getDescription
());
}
}
getWizard
().
getContainer
().
updateButtons
();
getWizard
().
getContainer
().
updateMessage
();
}
@Override
public
void
doubleClick
(
DoubleClickEvent
event
)
{
if
(
selectedDriver
!=
null
)
{
getWizard
().
getContainer
().
showPage
(
getWizard
().
getNextPage
(
this
));
}
}
public
DBPDriver
getSelectedDriver
()
{
return
selectedDriver
;
}
}
plugins/org.jkiss.dbeaver.ext.import-config/src/org/jkiss/dbeaver/ext/import_config/wizards/navicat/ConfigImportWizardPageNavicatSettings.java
0 → 100644
浏览文件 @
4d4140d2
/*
* 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.ext.import_config.wizards.navicat
;
import
java.io.File
;
import
org.eclipse.jface.wizard.WizardPage
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.ModifyEvent
;
import
org.eclipse.swt.events.ModifyListener
;
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.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.TextWithOpenFile
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
public
class
ConfigImportWizardPageNavicatSettings
extends
WizardPage
{
private
TextWithOpenFile
filePathText
;
private
File
inputFile
;
private
Combo
encodingCombo
;
protected
ConfigImportWizardPageNavicatSettings
()
{
super
(
"Navicat"
);
setTitle
(
"Navicat"
);
setDescription
(
"Import Navicat connections"
);
}
@Override
public
void
createControl
(
Composite
parent
)
{
Composite
placeholder
=
new
Composite
(
parent
,
SWT
.
NONE
);
placeholder
.
setLayout
(
new
GridLayout
(
1
,
true
));
UIUtils
.
createControlLabel
(
placeholder
,
"Navicat Connection Export (NCX) file"
);
filePathText
=
new
TextWithOpenFile
(
placeholder
,
"Navicat Connection Export (NCX) file"
,
new
String
[]
{
"*.ncx"
});
filePathText
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
filePathText
.
getTextControl
().
addModifyListener
(
new
ModifyListener
()
{
@Override
public
void
modifyText
(
ModifyEvent
e
)
{
inputFile
=
new
File
(
filePathText
.
getText
());
if
(!
inputFile
.
exists
())
{
setErrorMessage
(
"File '"
+
inputFile
.
getAbsolutePath
()
+
"' doesn't exist"
);
}
else
{
setErrorMessage
(
null
);
}
getWizard
().
getContainer
().
updateButtons
();
}
});
UIUtils
.
createControlLabel
(
placeholder
,
"File encoding"
);
encodingCombo
=
UIUtils
.
createEncodingCombo
(
placeholder
,
GeneralUtils
.
DEFAULT_ENCODING
);
setControl
(
placeholder
);
}
@Override
public
boolean
isPageComplete
()
{
return
inputFile
!=
null
&&
inputFile
.
exists
();
}
public
String
getInputFileEncoding
()
{
return
encodingCombo
.
getText
();
}
public
File
getInputFile
()
{
return
inputFile
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录