Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
33f18e93
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,发现更多精彩内容 >>
提交
33f18e93
编写于
7月 17, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Utilities model
Former-commit-id:
e9e8bc1c
上级
562ec363
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
662 addition
and
2 deletion
+662
-2
plugins/org.jkiss.dbeaver.model/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.model/META-INF/MANIFEST.MF
+1
-0
plugins/org.jkiss.dbeaver.model/OSGI-INF/l10n/bundle.properties
...s/org.jkiss.dbeaver.model/OSGI-INF/l10n/bundle.properties
+1
-0
plugins/org.jkiss.dbeaver.model/plugin.xml
plugins/org.jkiss.dbeaver.model/plugin.xml
+1
-0
plugins/org.jkiss.dbeaver.model/schema/org.jkiss.dbeaver.utils.exsd
...g.jkiss.dbeaver.model/schema/org.jkiss.dbeaver.utils.exsd
+213
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/encode/ContentEncrypter.java
...rc/org/jkiss/dbeaver/runtime/encode/ContentEncrypter.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/DBUActionUtility.java
...src/org/jkiss/dbeaver/runtime/utils/DBUActionUtility.java
+30
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/DBUScriptUtility.java
...src/org/jkiss/dbeaver/runtime/utils/DBUScriptUtility.java
+34
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/DBUUtility.java
...model/src/org/jkiss/dbeaver/runtime/utils/DBUUtility.java
+39
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/UtilityTaskDescriptor.java
...rg/jkiss/dbeaver/runtime/utils/UtilityTaskDescriptor.java
+88
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/UtilityTaskRegistry.java
.../org/jkiss/dbeaver/runtime/utils/UtilityTaskRegistry.java
+253
-0
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
...rg/jkiss/dbeaver/registry/DataSourceSerializerModern.java
+1
-1
未找到文件。
plugins/org.jkiss.dbeaver.model/META-INF/MANIFEST.MF
浏览文件 @
33f18e93
...
...
@@ -74,6 +74,7 @@ Export-Package: org.jkiss.dbeaver,
org.jkiss.dbeaver.runtime.resource.links,
org.jkiss.dbeaver.runtime.ui,
org.jkiss.dbeaver.runtime.ui.console,
org.jkiss.dbeaver.runtime.utils,
org.jkiss.dbeaver.utils
Bundle-ClassPath: .
Require-Bundle: org.eclipse.equinox.security,
...
...
plugins/org.jkiss.dbeaver.model/OSGI-INF/l10n/bundle.properties
浏览文件 @
33f18e93
...
...
@@ -8,6 +8,7 @@ extension-point.org.jkiss.dbeaver.pluginService.name = Plugin service
extension-point.org.jkiss.dbeaver.dataFormatter.name
=
Data value formatters
extension-point.org.jkiss.dbeaver.aggregateFunction.name
=
Aggregate Functions
extension-point.org.jkiss.dbeaver.dataTypeProvider.name
=
DataType provider
extension-point.org.jkiss.dbeaver.utils.name
=
Database utilities
extension.org.jkiss.dbeaver.DBeaverNature.name
=
DBeaver Nature
...
...
plugins/org.jkiss.dbeaver.model/plugin.xml
浏览文件 @
33f18e93
...
...
@@ -23,6 +23,7 @@
<extension-point
id=
"org.jkiss.dbeaver.application"
name=
"%extension-point.org.jkiss.dbeaver.application.name"
schema=
"schema/org.jkiss.dbeaver.application.exsd"
/>
<extension-point
id=
"org.jkiss.dbeaver.dataFormatter"
name=
"%extension-point.org.jkiss.dbeaver.dataFormatter.name"
schema=
"schema/org.jkiss.dbeaver.dataFormatter.exsd"
/>
<extension-point
id=
"org.jkiss.dbeaver.dataTypeProvider"
name=
"%extension-point.org.jkiss.dbeaver.dataTypeProvider.name"
schema=
"schema/org.jkiss.dbeaver.dataTypeProvider.exsd"
/>
<extension-point
id=
"org.jkiss.dbeaver.utils"
name=
"%extension-point.org.jkiss.dbeaver.utils.name"
schema=
"schema/org.jkiss.dbeaver.utils.exsd"
/>
<extension
point=
"org.eclipse.core.resources.natures"
id=
"org.jkiss.dbeaver.DBeaverNature"
name=
"%extension.org.jkiss.dbeaver.DBeaverNature.name"
>
<runtime>
...
...
plugins/org.jkiss.dbeaver.model/schema/org.jkiss.dbeaver.utils.exsd
0 → 100644
浏览文件 @
33f18e93
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema
targetNamespace=
"org.jkiss.dbeaver.core"
xmlns=
"http://www.w3.org/2001/XMLSchema"
>
<annotation>
<appInfo>
<meta.schema
plugin=
"org.jkiss.dbeaver.core"
id=
"org.jkiss.dbeaver.utils"
name=
"Database utilities"
/>
</appInfo>
<documentation>
Headless database utilities
</documentation>
</annotation>
<element
name=
"extension"
>
<annotation>
<appInfo>
<meta.element
/>
</appInfo>
</annotation>
<complexType>
<sequence>
<element
ref=
"utility"
minOccurs=
"0"
maxOccurs=
"unbounded"
/>
</sequence>
<attribute
name=
"point"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute
name=
"id"
type=
"string"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute
name=
"name"
type=
"string"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
translatable=
"true"
/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element
name=
"utility"
>
<complexType>
<sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
<element
ref=
"propertyGroup"
minOccurs=
"0"
maxOccurs=
"unbounded"
/>
</sequence>
<attribute
name=
"id"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
kind=
"identifier"
/>
</appInfo>
</annotation>
</attribute>
<attribute
name=
"class"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
kind=
"java"
basedOn=
":org.jkiss.dbeaver.model.data.DBDDataFormatter"
/>
</appInfo>
</annotation>
</attribute>
<attribute
name=
"label"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
translatable=
"true"
/>
</appInfo>
</annotation>
</attribute>
<attribute
name=
"description"
type=
"string"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
translatable=
"true"
/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element
name=
"property"
>
<complexType>
<attribute
name=
"id"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute
name=
"label"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
translatable=
"true"
/>
</appInfo>
</annotation>
</attribute>
<attribute
name=
"description"
type=
"string"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
translatable=
"true"
/>
</appInfo>
</annotation>
</attribute>
<attribute
name=
"type"
type=
"string"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute
name=
"required"
type=
"boolean"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute
name=
"defaultValue"
type=
"string"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute
name=
"validValues"
type=
"string"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element
name=
"propertyGroup"
>
<complexType>
<sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
<element
ref=
"property"
/>
</sequence>
<attribute
name=
"label"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
translatable=
"true"
/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section
type=
"since"
/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section
type=
"examples"
/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section
type=
"apiinfo"
/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section
type=
"implementation"
/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/
model/impl/app
/ContentEncrypter.java
→
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/
runtime/encode
/ContentEncrypter.java
浏览文件 @
33f18e93
...
...
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.
model.impl.app
;
package
org.jkiss.dbeaver.
runtime.encode
;
import
org.jkiss.utils.IOUtils
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/DBUActionUtility.java
0 → 100644
浏览文件 @
33f18e93
/*
* 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.runtime.utils
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
/**
* Action utility.
*/
public
interface
DBUActionUtility
extends
DBUUtility
{
void
runUtility
(
DBRProgressMonitor
monitor
)
throws
DBException
;
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/DBUScriptUtility.java
0 → 100644
浏览文件 @
33f18e93
/*
* 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.runtime.utils
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
/**
* Script utility.
* Generates target database script as a result of utility work
*/
public
interface
DBUScriptUtility
extends
DBUUtility
{
String
generateScript
(
DBRProgressMonitor
monitor
)
throws
DBException
;
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/DBUUtility.java
0 → 100644
浏览文件 @
33f18e93
/*
* 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.runtime.utils
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
java.util.Collection
;
import
java.util.Locale
;
import
java.util.Map
;
/**
* Database utility.
*/
public
interface
DBUUtility
{
void
initTool
(
DBPProject
project
,
Collection
<
DBSObject
>
objects
)
throws
DBException
;
void
updateToolSettings
(
Locale
locale
,
Map
<
Object
,
Object
>
properties
)
throws
DBException
;
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/UtilityTaskDescriptor.java
0 → 100644
浏览文件 @
33f18e93
/*
* 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.runtime.utils
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatter
;
import
org.jkiss.dbeaver.model.impl.AbstractContextDescriptor
;
import
org.jkiss.dbeaver.model.impl.PropertyDescriptor
;
import
org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* DataFormatterDescriptor
*/
public
class
UtilityTaskDescriptor
extends
AbstractContextDescriptor
{
private
static
final
Log
log
=
Log
.
getLog
(
UtilityTaskDescriptor
.
class
);
public
static
final
String
EXTENSION_ID
=
"org.jkiss.dbeaver.utils"
;
//$NON-NLS-1$
private
String
id
;
private
String
name
;
private
String
description
;
private
List
<
DBPPropertyDescriptor
>
properties
=
new
ArrayList
<>();
private
ObjectType
utilityType
;
UtilityTaskDescriptor
(
IConfigurationElement
config
)
{
super
(
config
);
this
.
id
=
config
.
getAttribute
(
"id"
);
this
.
utilityType
=
new
ObjectType
(
config
.
getAttribute
(
"class"
));
this
.
name
=
config
.
getAttribute
(
"label"
);
this
.
description
=
config
.
getAttribute
(
"description"
);
IConfigurationElement
[]
propElements
=
config
.
getChildren
(
PropertyDescriptor
.
TAG_PROPERTY_GROUP
);
for
(
IConfigurationElement
prop
:
propElements
)
{
properties
.
addAll
(
PropertyDescriptor
.
extractProperties
(
prop
));
}
}
public
String
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
List
<
DBPPropertyDescriptor
>
getProperties
()
{
return
properties
;
}
public
DBDDataFormatter
createFormatter
()
throws
IllegalAccessException
,
InstantiationException
{
Class
<?
extends
DBDDataFormatter
>
clazz
=
utilityType
.
getObjectClass
(
DBDDataFormatter
.
class
);
if
(
clazz
==
null
)
{
return
null
;
}
return
clazz
.
newInstance
();
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/utils/UtilityTaskRegistry.java
0 → 100644
浏览文件 @
33f18e93
/*
* 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.runtime.utils
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.core.runtime.IExtensionRegistry
;
import
org.eclipse.core.runtime.Platform
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatterProfile
;
import
org.jkiss.dbeaver.model.impl.preferences.SimplePreferenceStore
;
import
org.jkiss.dbeaver.registry.formatter.DataFormatterProfile
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.xml.SAXListener
;
import
org.jkiss.utils.xml.SAXReader
;
import
org.jkiss.utils.xml.XMLBuilder
;
import
org.jkiss.utils.xml.XMLException
;
import
org.xml.sax.Attributes
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
UtilityTaskRegistry
implements
DBPDataFormatterRegistry
{
private
static
final
Log
log
=
Log
.
getLog
(
UtilityTaskRegistry
.
class
);
public
static
final
String
CONFIG_FILE_NAME
=
"dataformat-profiles.xml"
;
//$NON-NLS-1$
private
static
UtilityTaskRegistry
instance
=
null
;
public
synchronized
static
UtilityTaskRegistry
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
UtilityTaskRegistry
(
Platform
.
getExtensionRegistry
());
}
return
instance
;
}
private
final
List
<
UtilityTaskDescriptor
>
dataFormatterList
=
new
ArrayList
<>();
private
final
Map
<
String
,
UtilityTaskDescriptor
>
dataFormatterMap
=
new
HashMap
<>();
private
DBDDataFormatterProfile
globalProfile
;
private
List
<
DBDDataFormatterProfile
>
customProfiles
=
null
;
private
UtilityTaskRegistry
(
IExtensionRegistry
registry
)
{
// Load data formatters from external plugins
{
IConfigurationElement
[]
extElements
=
registry
.
getConfigurationElementsFor
(
UtilityTaskDescriptor
.
EXTENSION_ID
);
for
(
IConfigurationElement
ext
:
extElements
)
{
UtilityTaskDescriptor
formatterDescriptor
=
new
UtilityTaskDescriptor
(
ext
);
dataFormatterList
.
add
(
formatterDescriptor
);
dataFormatterMap
.
put
(
formatterDescriptor
.
getId
(),
formatterDescriptor
);
}
}
}
public
void
dispose
()
{
this
.
dataFormatterList
.
clear
();
this
.
dataFormatterMap
.
clear
();
this
.
globalProfile
=
null
;
}
////////////////////////////////////////////////////
// Data formatters
public
List
<
UtilityTaskDescriptor
>
getDataFormatters
()
{
return
dataFormatterList
;
}
public
UtilityTaskDescriptor
getDataFormatter
(
String
typeId
)
{
return
dataFormatterMap
.
get
(
typeId
);
}
@Override
public
synchronized
DBDDataFormatterProfile
getGlobalProfile
()
{
if
(
globalProfile
==
null
)
{
globalProfile
=
new
DataFormatterProfile
(
"Global"
,
DBWorkbench
.
getPlatform
().
getPreferenceStore
());
}
return
globalProfile
;
}
@Override
@Nullable
public
DBDDataFormatterProfile
getCustomProfile
(
String
name
)
{
for
(
DBDDataFormatterProfile
profile
:
getCustomProfiles
())
{
if
(
profile
.
getProfileName
().
equals
(
name
))
{
return
profile
;
}
}
return
null
;
}
@Override
public
synchronized
List
<
DBDDataFormatterProfile
>
getCustomProfiles
()
{
if
(
customProfiles
==
null
)
{
loadProfiles
();
}
return
customProfiles
;
}
private
void
loadProfiles
()
{
customProfiles
=
new
ArrayList
<>();
File
storeFile
=
DBWorkbench
.
getPlatform
().
getConfigurationFile
(
CONFIG_FILE_NAME
);
if
(!
storeFile
.
exists
())
{
return
;
}
try
{
try
(
InputStream
is
=
new
FileInputStream
(
storeFile
))
{
SAXReader
parser
=
new
SAXReader
(
is
);
try
{
parser
.
parse
(
new
FormattersParser
());
}
catch
(
XMLException
ex
)
{
throw
new
DBException
(
"Datasource config parse error"
,
ex
);
}
}
catch
(
DBException
ex
)
{
log
.
warn
(
"Can't load profiles config from "
+
storeFile
.
getPath
(),
ex
);
}
}
catch
(
IOException
ex
)
{
log
.
warn
(
"IO error"
,
ex
);
}
}
private
void
saveProfiles
()
{
if
(
customProfiles
==
null
)
{
return
;
}
File
storeFile
=
DBWorkbench
.
getPlatform
().
getConfigurationFile
(
CONFIG_FILE_NAME
);
try
(
OutputStream
os
=
new
FileOutputStream
(
storeFile
))
{
XMLBuilder
xml
=
new
XMLBuilder
(
os
,
GeneralUtils
.
UTF8_ENCODING
);
xml
.
setButify
(
true
);
xml
.
startElement
(
"profiles"
);
for
(
DBDDataFormatterProfile
profile
:
customProfiles
)
{
xml
.
startElement
(
"profile"
);
xml
.
addAttribute
(
"name"
,
profile
.
getProfileName
());
SimplePreferenceStore
store
=
(
SimplePreferenceStore
)
profile
.
getPreferenceStore
();
Map
<
String
,
String
>
props
=
store
.
getProperties
();
if
(
props
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
props
.
entrySet
())
{
xml
.
startElement
(
"property"
);
xml
.
addAttribute
(
"name"
,
entry
.
getKey
());
xml
.
addAttribute
(
"value"
,
entry
.
getValue
());
xml
.
endElement
();
}
}
xml
.
endElement
();
}
xml
.
endElement
();
xml
.
flush
();
}
catch
(
IOException
ex
)
{
log
.
warn
(
"IO error"
,
ex
);
}
}
public
DBDDataFormatterProfile
createCustomProfile
(
String
profileName
)
{
getCustomProfiles
();
DBDDataFormatterProfile
profile
=
new
DataFormatterProfile
(
profileName
,
new
CustomProfileStore
());
customProfiles
.
add
(
profile
);
saveProfiles
();
return
profile
;
}
public
void
deleteCustomProfile
(
DBDDataFormatterProfile
profile
)
{
getCustomProfiles
();
if
(
customProfiles
.
remove
(
profile
))
{
saveProfiles
();
}
}
private
class
CustomProfileStore
extends
SimplePreferenceStore
{
private
CustomProfileStore
()
{
super
(
DBWorkbench
.
getPlatform
().
getPreferenceStore
());
}
@Override
public
void
save
()
throws
IOException
{
saveProfiles
();
}
}
private
class
FormattersParser
extends
SAXListener
.
BaseListener
{
private
String
profileName
;
private
SimplePreferenceStore
curStore
;
@Override
public
void
saxStartElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
,
Attributes
atts
)
throws
XMLException
{
if
(
localName
.
equals
(
"profile"
))
{
curStore
=
new
CustomProfileStore
();
profileName
=
atts
.
getValue
(
"name"
);
}
else
if
(
localName
.
equals
(
"property"
))
{
if
(
curStore
!=
null
)
{
curStore
.
setValue
(
atts
.
getValue
(
"name"
),
atts
.
getValue
(
"value"
));
}
}
}
@Override
public
void
saxEndElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
)
throws
XMLException
{
if
(
localName
.
equals
(
"profile"
))
{
if
(!
CommonUtils
.
isEmpty
(
profileName
))
{
DataFormatterProfile
profile
=
new
DataFormatterProfile
(
profileName
,
curStore
);
customProfiles
.
add
(
profile
);
}
}
}
}
}
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
浏览文件 @
33f18e93
...
...
@@ -33,7 +33,7 @@ import org.jkiss.dbeaver.model.app.DBASecureStorage;
import
org.jkiss.dbeaver.model.app.DBPDataSourceRegistry
;
import
org.jkiss.dbeaver.model.connection.*
;
import
org.jkiss.dbeaver.model.data.json.JSONUtils
;
import
org.jkiss.dbeaver.
model.impl.app
.ContentEncrypter
;
import
org.jkiss.dbeaver.
runtime.encode
.ContentEncrypter
;
import
org.jkiss.dbeaver.model.impl.preferences.SimplePreferenceStore
;
import
org.jkiss.dbeaver.model.net.DBWHandlerConfiguration
;
import
org.jkiss.dbeaver.model.net.DBWNetworkProfile
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录