Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
5f137439
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,发现更多精彩内容 >>
提交
5f137439
编写于
10月 26, 2012
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Objects compare
Former-commit-id:
0a9084e0
上级
c5488ffe
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
113 addition
and
30 deletion
+113
-30
plugins/org.jkiss.dbeaver.core/icons/file/compare.png
plugins/org.jkiss.dbeaver.core/icons/file/compare.png
+0
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/compare/CompareObjectsPageSettings.java
...iss/dbeaver/tools/compare/CompareObjectsPageSettings.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/compare/CompareObjectsWizard.java
...org/jkiss/dbeaver/tools/compare/CompareObjectsWizard.java
+109
-29
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBIcon.java
...g.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBIcon.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/SQLParser.java
...rc/org/jkiss/dbeaver/ui/editors/sql/format/SQLParser.java
+2
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/icons/file/compare.png
0 → 100644
浏览文件 @
5f137439
356 字节
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/compare/CompareObjectsPageSettings.java
浏览文件 @
5f137439
...
...
@@ -82,7 +82,7 @@ class CompareObjectsPageSettings extends ActiveWizardPage<CompareObjectsWizard>
compareSettings
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
compareSettings
.
setLayout
(
new
GridLayout
(
1
,
false
));
skipSystemObjects
=
UIUtils
.
createCheckbox
(
compareSettings
,
"Skip system object"
,
settings
.
isSkipSystemObjects
());
skipSystemObjects
=
UIUtils
.
createCheckbox
(
compareSettings
,
"Skip system object
s
"
,
settings
.
isSkipSystemObjects
());
skipSystemObjects
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/compare/CompareObjectsWizard.java
浏览文件 @
5f137439
...
...
@@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.IFilter;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.jface.wizard.Wizard
;
import
org.eclipse.jface.wizard.WizardPage
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.ui.IExportWizard
;
import
org.eclipse.ui.IWorkbench
;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
...
...
@@ -41,24 +42,28 @@ import org.jkiss.dbeaver.ui.properties.ILazyPropertyLoadListener;
import
org.jkiss.dbeaver.ui.properties.ObjectPropertyDescriptor
;
import
org.jkiss.dbeaver.ui.properties.PropertyCollector
;
import
org.jkiss.dbeaver.ui.properties.tabbed.PropertiesContributor
;
import
org.jkiss.utils.CommonUtils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.IdentityHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
public
class
CompareObjectsWizard
extends
Wizard
implements
IExportWizard
{
private
static
final
String
RS_COMPARE_WIZARD_DIALOG_SETTINGS
=
"CompareWizard"
;
//$NON-NLS-1$
private
final
Object
PROPS_LOCK
=
new
Object
();
private
final
static
Object
LAZY_VALUE
=
new
Object
();
private
CompareObjectsSettings
settings
;
private
Map
<
DBPDataSource
,
IFilter
>
dataSourceFilters
=
new
IdentityHashMap
<
DBPDataSource
,
IFilter
>();
private
DBRProcessListener
initializeFinisher
;
private
final
DBRProcessListener
initializeFinisher
;
private
final
ILazyPropertyLoadListener
lazyPropertyLoadListener
;
private
volatile
int
initializedCount
=
0
;
private
volatile
IStatus
initializeError
;
private
final
Object
PROPS_LOCK
=
new
Object
();
private
final
static
Object
LAZY_VALUE
=
new
Object
();
private
final
Map
<
Object
,
Map
<
IPropertyDescriptor
,
Object
>>
propertyValues
=
new
IdentityHashMap
<
Object
,
Map
<
IPropertyDescriptor
,
Object
>>();
private
final
List
<
ObjectPropertyDescriptor
>
differentProps
=
new
ArrayList
<
ObjectPropertyDescriptor
>();
public
CompareObjectsWizard
(
List
<
DBNDatabaseNode
>
nodes
)
{
...
...
@@ -78,6 +83,26 @@ public class CompareObjectsWizard extends Wizard implements IExportWizard {
}
}
};
lazyPropertyLoadListener
=
new
ILazyPropertyLoadListener
()
{
@Override
public
void
handlePropertyLoad
(
Object
object
,
IPropertyDescriptor
property
,
Object
propertyValue
,
boolean
completed
)
{
synchronized
(
propertyValues
)
{
Map
<
IPropertyDescriptor
,
Object
>
objectProps
=
propertyValues
.
get
(
object
);
if
(
objectProps
!=
null
)
{
objectProps
.
put
(
property
,
propertyValue
);
}
}
}
};
PropertiesContributor
.
getInstance
().
addLazyListener
(
lazyPropertyLoadListener
);
}
@Override
public
void
dispose
()
{
PropertiesContributor
.
getInstance
().
removeLazyListener
(
lazyPropertyLoadListener
);
super
.
dispose
();
}
public
CompareObjectsSettings
getSettings
()
...
...
@@ -127,6 +152,7 @@ public class CompareObjectsWizard extends Wizard implements IExportWizard {
}
}
});
UIUtils
.
showMessageBox
(
getShell
(),
"Objects compare"
,
"Objects compare finished"
,
SWT
.
ICON_INFORMATION
);
}
catch
(
InvocationTargetException
e
)
{
if
(
initializeError
!=
null
)
{
showError
(
initializeError
.
getMessage
());
...
...
@@ -135,6 +161,7 @@ public class CompareObjectsWizard extends Wizard implements IExportWizard {
}
return
false
;
}
catch
(
InterruptedException
e
)
{
showError
(
"Compare interrupted"
);
return
false
;
}
...
...
@@ -145,15 +172,19 @@ public class CompareObjectsWizard extends Wizard implements IExportWizard {
private
void
compareNodes
(
DBRProgressMonitor
monitor
,
List
<
DBNDatabaseNode
>
nodes
)
throws
DBException
,
InterruptedException
{
// Clear compare singletons
this
.
initializedCount
=
0
;
this
.
initializeError
=
null
;
this
.
propertyValues
.
clear
();
this
.
differentProps
.
clear
();
StringBuilder
title
=
new
StringBuilder
();
// Initialize nodes
{
monitor
.
subTask
(
"Initialize nodes"
);
this
.
initializedCount
=
0
;
this
.
initializeError
=
null
;
for
(
DBNDatabaseNode
node
:
nodes
)
{
if
(
title
.
length
()
>
0
)
title
.
append
(
", "
);
title
.
append
(
node
.
getNodeName
());
title
.
append
(
node
.
getNode
Full
Name
());
node
.
initializeNode
(
null
,
initializeFinisher
);
monitor
.
worked
(
1
);
}
...
...
@@ -181,24 +212,7 @@ public class CompareObjectsWizard extends Wizard implements IExportWizard {
}
compareLazyProperties
=
compareLazyProperties
&&
getSettings
().
isCompareLazyProperties
();
final
Map
<
Object
,
Map
<
IPropertyDescriptor
,
Object
>>
propertyValues
=
new
IdentityHashMap
<
Object
,
Map
<
IPropertyDescriptor
,
Object
>>();
// Check should we read lazy properties
ILazyPropertyLoadListener
lazyPropertyLoadListener
=
null
;
if
(
compareLazyProperties
)
{
lazyPropertyLoadListener
=
new
ILazyPropertyLoadListener
()
{
@Override
public
void
handlePropertyLoad
(
Object
object
,
IPropertyDescriptor
property
,
Object
propertyValue
,
boolean
completed
)
{
synchronized
(
propertyValues
)
{
Map
<
IPropertyDescriptor
,
Object
>
objectProps
=
propertyValues
.
get
(
object
);
if
(
objectProps
!=
null
)
{
objectProps
.
put
(
property
,
propertyValue
);
}
}
}
};
PropertiesContributor
.
getInstance
().
addLazyListener
(
lazyPropertyLoadListener
);
}
try
{
boolean
hasLazy
=
false
;
// Load all properties
...
...
@@ -253,10 +267,24 @@ public class CompareObjectsWizard extends Wizard implements IExportWizard {
// Compare properties
for
(
ObjectPropertyDescriptor
prop
:
properties
)
{
Object
firstValue
=
null
;
for
(
DBNDatabaseNode
node
:
nodes
)
{
DBSObject
object
=
node
.
getObject
();
Object
value
=
propertyValues
.
get
(
object
).
get
(
prop
);
if
(
firstValue
==
null
)
{
firstValue
=
value
;
}
else
if
(!
CommonUtils
.
equalObjects
(
value
,
firstValue
))
{
differentProps
.
add
(
prop
);
break
;
}
}
}
if
(!
differentProps
.
isEmpty
())
{
// Add difference in report
}
// Compare children
compareChildren
(
monitor
,
nodes
);
}
finally
{
if
(
lazyPropertyLoadListener
!=
null
)
{
...
...
@@ -265,6 +293,58 @@ public class CompareObjectsWizard extends Wizard implements IExportWizard {
}
}
private
void
compareChildren
(
DBRProgressMonitor
monitor
,
List
<
DBNDatabaseNode
>
nodes
)
throws
DBException
,
InterruptedException
{
// Compare children
int
nodeCount
=
nodes
.
size
();
List
<
List
<
DBNDatabaseNode
>>
allChildren
=
new
ArrayList
<
List
<
DBNDatabaseNode
>>(
nodeCount
);
for
(
int
i
=
0
;
i
<
nodeCount
;
i
++)
{
DBNDatabaseNode
node
=
nodes
.
get
(
i
);
allChildren
.
add
(
node
.
getChildren
(
monitor
));
}
Set
<
String
>
allChildNames
=
new
LinkedHashSet
<
String
>();
for
(
List
<
DBNDatabaseNode
>
childList
:
allChildren
)
{
for
(
DBNDatabaseNode
child
:
childList
)
{
allChildNames
.
add
(
child
.
getNodeName
());
}
}
for
(
String
childName
:
allChildNames
)
{
int
[]
childIndexes
=
new
int
[
nodeCount
];
for
(
int
i
=
0
;
i
<
nodeCount
;
i
++)
{
childIndexes
[
i
]
=
-
1
;
List
<
DBNDatabaseNode
>
childList
=
allChildren
.
get
(
i
);
for
(
int
k
=
0
;
k
<
childList
.
size
();
k
++)
{
DBNDatabaseNode
child
=
childList
.
get
(
k
);
if
(
child
.
getNodeName
().
equals
(
childName
))
{
childIndexes
[
i
]
=
k
;
break
;
}
}
}
List
<
DBNDatabaseNode
>
nodesToCompare
=
new
ArrayList
<
DBNDatabaseNode
>(
nodeCount
);
for
(
int
i
=
0
;
i
<
nodeCount
;
i
++)
{
if
(
childIndexes
[
i
]
==
-
1
)
{
// Missing
}
else
{
for
(
int
k
=
0
;
k
<
nodeCount
;
k
++)
{
if
(
k
!=
i
&&
childIndexes
[
k
]
!=
childIndexes
[
i
])
{
// Wrong index - add to report
break
;
}
}
nodesToCompare
.
add
(
allChildren
.
get
(
i
).
get
(
childIndexes
[
i
]));
}
}
if
(
nodesToCompare
.
size
()
>
1
)
{
// Compare children recursively
compareNodes
(
monitor
,
nodesToCompare
);
}
}
}
private
IFilter
getDataSourceFilter
(
DBNDatabaseNode
node
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBIcon.java
浏览文件 @
5f137439
...
...
@@ -159,6 +159,7 @@ public enum DBIcon
SAVE_AS
(
"save_as"
,
"/icons/file/save_as.png"
),
//$NON-NLS-1$ //$NON-NLS-2$
LOAD
(
"load"
,
"/icons/file/load.png"
),
//$NON-NLS-1$ //$NON-NLS-2$
RESET
(
"reset"
,
"/icons/file/reset.png"
),
//$NON-NLS-1$ //$NON-NLS-2$
COMPARE
(
"compare"
,
"/icons/file/compare.png"
),
//$NON-NLS-1$ //$NON-NLS-2$
ACCEPT
(
"accept"
,
"/icons/sql/accept.png"
),
//$NON-NLS-1$ //$NON-NLS-2$
REJECT
(
"reject"
,
"/icons/sql/cancel.png"
),
//$NON-NLS-1$ //$NON-NLS-2$
REVERT
(
"revert"
,
"/icons/sql/revert.png"
),
//$NON-NLS-1$ //$NON-NLS-2$
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/format/SQLParser.java
浏览文件 @
5f137439
...
...
@@ -72,6 +72,8 @@ public class SQLParser {
case
'<'
:
// less than operator
case
'='
:
// equals operator
case
'>'
:
// greater than operator
case
'!'
:
// greater than operator
case
'~'
:
// greater than operator
return
true
;
default
:
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录