Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
3540d968
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,发现更多精彩内容 >>
未验证
提交
3540d968
编写于
7月 02, 2021
作者:
S
ShadelessFox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#12001 Allow changing order of table columns in columns mapping dialog
上级
20380815
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
149 addition
and
173 deletion
+149
-173
plugins/org.jkiss.dbeaver.data.transfer.ui/src/org/jkiss/dbeaver/tools/transfer/ui/pages/database/ColumnsMappingDialog.java
...ools/transfer/ui/pages/database/ColumnsMappingDialog.java
+149
-173
未找到文件。
plugins/org.jkiss.dbeaver.data.transfer.ui/src/org/jkiss/dbeaver/tools/transfer/ui/pages/database/ColumnsMappingDialog.java
浏览文件 @
3540d968
...
...
@@ -47,6 +47,7 @@ import org.jkiss.dbeaver.ui.SharedTextColors;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.CustomComboBoxCellEditor
;
import
org.jkiss.dbeaver.ui.controls.ListContentProvider
;
import
org.jkiss.dbeaver.ui.controls.ViewerColumnController
;
import
org.jkiss.dbeaver.ui.dialogs.BaseDialog
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -135,199 +136,174 @@ class ColumnsMappingDialog extends BaseDialog {
}
});
{
TableViewerColumn
columnSource
=
new
TableViewerColumn
(
mappingViewer
,
SWT
.
LEFT
);
columnSource
.
setLabelProvider
(
new
CellLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
cell
.
getElement
();
cell
.
setText
(
DBUtils
.
getObjectFullName
(
attrMapping
.
getSource
(),
DBPEvaluationContext
.
UI
));
if
(
attrMapping
.
getIcon
()
!=
null
)
{
cell
.
setImage
(
DBeaverIcons
.
getImage
(
attrMapping
.
getIcon
()));
}
}
});
columnSource
.
getColumn
().
setText
(
DTUIMessages
.
columns_mapping_dialog_column_source_text
);
columnSource
.
getColumn
().
setWidth
(
170
);
}
{
TableViewerColumn
columnSourceType
=
new
TableViewerColumn
(
mappingViewer
,
SWT
.
LEFT
);
columnSourceType
.
setLabelProvider
(
new
CellLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
cell
.
setText
(((
DatabaseMappingAttribute
)
cell
.
getElement
()).
getSourceType
());
final
ViewerColumnController
<?,
?>
columnController
=
new
ViewerColumnController
<>(
getClass
().
getName
(),
mappingViewer
);
columnController
.
addColumn
(
DTUIMessages
.
columns_mapping_dialog_column_source_text
,
null
,
SWT
.
LEFT
,
true
,
false
,
new
ColumnLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
DatabaseMappingAttribute
mapping
=
(
DatabaseMappingAttribute
)
cell
.
getElement
();
cell
.
setText
(
DBUtils
.
getObjectFullName
(
mapping
.
getSource
(),
DBPEvaluationContext
.
UI
));
if
(
mapping
.
getIcon
()
!=
null
)
{
cell
.
setImage
(
DBeaverIcons
.
getImage
(
mapping
.
getIcon
()));
}
});
columnSourceType
.
getColumn
().
setText
(
DTUIMessages
.
columns_mapping_dialog_column_source_type_text
);
columnSourceType
.
getColumn
().
setWidth
(
100
);
}
}
});
{
TableViewerColumn
columnTarget
=
new
TableViewerColumn
(
mappingViewer
,
SWT
.
LEFT
);
columnTarget
.
setLabelProvider
(
new
CellLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
DatabaseMappingAttribute
mapping
=
(
DatabaseMappingAttribute
)
cell
.
getElement
();
cell
.
setText
(
mapping
.
getTargetName
());
if
(
mapping
.
getMappingType
()
==
DatabaseMappingType
.
unspecified
)
{
cell
.
setBackground
(
UIUtils
.
getSharedTextColors
().
getColor
(
SharedTextColors
.
COLOR_WARNING
));
}
else
{
cell
.
setBackground
(
null
);
}
cell
.
setFont
(
boldFont
);
columnController
.
addColumn
(
DTUIMessages
.
columns_mapping_dialog_column_source_type_text
,
null
,
SWT
.
LEFT
,
true
,
false
,
new
ColumnLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
cell
.
setText
(((
DatabaseMappingAttribute
)
cell
.
getElement
()).
getSourceType
());
}
});
columnController
.
addColumn
(
DTUIMessages
.
columns_mapping_dialog_column_target_text
,
null
,
SWT
.
LEFT
,
true
,
false
,
false
,
null
,
new
ColumnLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
DatabaseMappingAttribute
mapping
=
(
DatabaseMappingAttribute
)
cell
.
getElement
();
cell
.
setText
(
mapping
.
getTargetName
());
if
(
mapping
.
getMappingType
()
==
DatabaseMappingType
.
unspecified
)
{
cell
.
setBackground
(
UIUtils
.
getSharedTextColors
().
getColor
(
SharedTextColors
.
COLOR_WARNING
));
}
else
{
cell
.
setBackground
(
null
);
}
});
columnTarget
.
getColumn
().
setText
(
DTUIMessages
.
columns_mapping_dialog_column_target_text
);
columnTarget
.
getColumn
().
setWidth
(
170
);
columnTarget
.
setEditingSupport
(
new
EditingSupport
(
mappingViewer
)
{
@Override
protected
CellEditor
getCellEditor
(
Object
element
)
{
try
{
java
.
util
.
List
<
String
>
items
=
new
ArrayList
<>();
DatabaseMappingAttribute
mapping
=
(
DatabaseMappingAttribute
)
element
;
if
(
mapping
.
getParent
().
getMappingType
()
==
DatabaseMappingType
.
existing
&&
mapping
.
getParent
().
getTarget
()
instanceof
DBSEntity
)
{
DBSEntity
parentEntity
=
(
DBSEntity
)
mapping
.
getParent
().
getTarget
();
for
(
DBSEntityAttribute
attr
:
CommonUtils
.
safeCollection
(
parentEntity
.
getAttributes
(
new
VoidProgressMonitor
())))
{
items
.
add
(
attr
.
getName
());
}
cell
.
setFont
(
boldFont
);
}
},
new
EditingSupport
(
mappingViewer
)
{
@Override
protected
CellEditor
getCellEditor
(
Object
element
)
{
try
{
java
.
util
.
List
<
String
>
items
=
new
ArrayList
<>();
DatabaseMappingAttribute
mapping
=
(
DatabaseMappingAttribute
)
element
;
if
(
mapping
.
getParent
().
getMappingType
()
==
DatabaseMappingType
.
existing
&&
mapping
.
getParent
().
getTarget
()
instanceof
DBSEntity
)
{
DBSEntity
parentEntity
=
(
DBSEntity
)
mapping
.
getParent
().
getTarget
();
for
(
DBSEntityAttribute
attr
:
CommonUtils
.
safeCollection
(
parentEntity
.
getAttributes
(
new
VoidProgressMonitor
())))
{
items
.
add
(
attr
.
getName
());
}
items
.
add
(
DatabaseMappingAttribute
.
TARGET_NAME_SKIP
);
return
new
CustomComboBoxCellEditor
(
mappingViewer
,
mappingViewer
.
getTable
(),
items
.
toArray
(
new
String
[
0
]),
SWT
.
DROP_DOWN
);
}
catch
(
DBException
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Bad value"
,
"Wrong target column"
,
e
);
return
null
;
}
}
@Override
protected
boolean
canEdit
(
Object
element
)
{
return
true
;
items
.
add
(
DatabaseMappingAttribute
.
TARGET_NAME_SKIP
);
return
new
CustomComboBoxCellEditor
(
mappingViewer
,
mappingViewer
.
getTable
(),
items
.
toArray
(
new
String
[
0
]),
SWT
.
DROP_DOWN
);
}
catch
(
DBException
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Bad value"
,
"Wrong target column"
,
e
);
return
null
;
}
}
@Override
protected
Object
getValue
(
Object
element
)
{
return
((
DatabaseMappingAttribute
)
element
).
getTargetName
()
;
}
@Override
protected
boolean
canEdit
(
Object
element
)
{
return
true
;
}
@Override
protected
void
setValue
(
Object
element
,
Object
value
)
{
try
{
String
name
=
CommonUtils
.
toString
(
value
);
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
if
(
DatabaseMappingAttribute
.
TARGET_NAME_SKIP
.
equals
(
name
))
{
attrMapping
.
setMappingType
(
DatabaseMappingType
.
skip
);
}
else
{
if
(
attrMapping
.
getParent
().
getMappingType
()
==
DatabaseMappingType
.
existing
&&
attrMapping
.
getParent
().
getTarget
()
instanceof
DBSEntity
)
{
DBSEntity
parentEntity
=
(
DBSEntity
)
attrMapping
.
getParent
().
getTarget
();
for
(
DBSEntityAttribute
attr
:
CommonUtils
.
safeCollection
(
parentEntity
.
getAttributes
(
new
VoidProgressMonitor
())))
{
if
(
name
.
equalsIgnoreCase
(
attr
.
getName
()))
{
attrMapping
.
setTarget
(
attr
);
attrMapping
.
setMappingType
(
DatabaseMappingType
.
existing
);
attrMapping
.
setTargetName
(
name
);
return
;
}
@Override
protected
Object
getValue
(
Object
element
)
{
return
((
DatabaseMappingAttribute
)
element
).
getTargetName
();
}
@Override
protected
void
setValue
(
Object
element
,
Object
value
)
{
try
{
String
name
=
CommonUtils
.
toString
(
value
);
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
if
(
DatabaseMappingAttribute
.
TARGET_NAME_SKIP
.
equals
(
name
))
{
attrMapping
.
setMappingType
(
DatabaseMappingType
.
skip
);
}
else
{
if
(
attrMapping
.
getParent
().
getMappingType
()
==
DatabaseMappingType
.
existing
&&
attrMapping
.
getParent
().
getTarget
()
instanceof
DBSEntity
)
{
DBSEntity
parentEntity
=
(
DBSEntity
)
attrMapping
.
getParent
().
getTarget
();
for
(
DBSEntityAttribute
attr
:
CommonUtils
.
safeCollection
(
parentEntity
.
getAttributes
(
new
VoidProgressMonitor
())))
{
if
(
name
.
equalsIgnoreCase
(
attr
.
getName
()))
{
attrMapping
.
setTarget
(
attr
);
attrMapping
.
setMappingType
(
DatabaseMappingType
.
existing
);
attrMapping
.
setTargetName
(
name
);
return
;
}
}
attrMapping
.
setMappingType
(
DatabaseMappingType
.
create
);
attrMapping
.
setTargetName
(
name
);
}
}
catch
(
DBException
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Bad value"
,
"Wrong target"
,
e
);
}
finally
{
mappingViewer
.
refresh
();
attrMapping
.
setMappingType
(
DatabaseMappingType
.
create
);
attrMapping
.
setTargetName
(
name
);
}
}
catch
(
DBException
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Bad value"
,
"Wrong target"
,
e
);
}
finally
{
mappingViewer
.
refresh
();
}
}
);
}
}
}
);
{
TableViewerColumn
columnTargetType
=
new
TableViewerColumn
(
mappingViewer
,
SWT
.
LEFT
);
columnTargetType
.
setLabelProvider
(
new
CellLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
cell
.
getElement
();
DBPDataSource
dataSource
=
settings
.
getTargetDataSource
(
attrMapping
);
cell
.
setText
(
attrMapping
.
getTargetType
(
dataSource
,
true
));
cell
.
setFont
(
boldFont
);
}
});
columnTargetType
.
getColumn
().
setText
(
DTUIMessages
.
columns_mapping_dialog_column_target_type_text
);
columnTargetType
.
getColumn
().
setWidth
(
100
);
columnTargetType
.
setEditingSupport
(
new
EditingSupport
(
mappingViewer
)
{
@Override
protected
CellEditor
getCellEditor
(
Object
element
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
columnController
.
addColumn
(
DTUIMessages
.
columns_mapping_dialog_column_target_type_text
,
null
,
SWT
.
LEFT
,
true
,
false
,
false
,
null
,
new
ColumnLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
cell
.
getElement
();
DBPDataSource
dataSource
=
settings
.
getTargetDataSource
(
attrMapping
);
cell
.
setText
(
attrMapping
.
getTargetType
(
dataSource
,
true
));
cell
.
setFont
(
boldFont
);
}
},
new
EditingSupport
(
mappingViewer
)
{
@Override
protected
CellEditor
getCellEditor
(
Object
element
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
Set
<
String
>
types
=
new
TreeSet
<>();
DBPDataTypeProvider
dataTypeProvider
=
DBUtils
.
getParentOfType
(
DBPDataTypeProvider
.
class
,
settings
.
getContainer
());
if
(
dataTypeProvider
!=
null
)
{
for
(
DBSDataType
type
:
dataTypeProvider
.
getLocalDataTypes
())
{
types
.
add
(
type
.
getName
());
}
Set
<
String
>
types
=
new
TreeSet
<>();
DBPDataTypeProvider
dataTypeProvider
=
DBUtils
.
getParentOfType
(
DBPDataTypeProvider
.
class
,
settings
.
getContainer
());
if
(
dataTypeProvider
!=
null
)
{
for
(
DBSDataType
type
:
dataTypeProvider
.
getLocalDataTypes
())
{
types
.
add
(
type
.
getName
());
}
types
.
add
(
attrMapping
.
getTargetType
(
settings
.
getTargetDataSource
(
attrMapping
),
true
));
return
new
CustomComboBoxCellEditor
(
mappingViewer
,
mappingViewer
.
getTable
(),
types
.
toArray
(
new
String
[
0
]),
SWT
.
BORDER
);
}
@Override
protected
boolean
canEdit
(
Object
element
)
{
return
true
;
}
@Override
protected
Object
getValue
(
Object
element
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
return
attrMapping
.
getTargetType
(
settings
.
getTargetDataSource
(
attrMapping
),
true
);
}
@Override
protected
void
setValue
(
Object
element
,
Object
value
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
attrMapping
.
setTargetType
(
CommonUtils
.
toString
(
value
));
mappingViewer
.
refresh
(
element
);
}
});
}
types
.
add
(
attrMapping
.
getTargetType
(
settings
.
getTargetDataSource
(
attrMapping
),
true
));
{
TableViewerColumn
columnType
=
new
TableViewerColumn
(
mappingViewer
,
SWT
.
LEFT
);
columnType
.
setLabelProvider
(
new
CellLabelProvider
()
{
@Override
public
void
update
(
ViewerCell
cell
)
{
DatabaseMappingAttribute
mapping
=
(
DatabaseMappingAttribute
)
cell
.
getElement
();
String
text
=
""
;
switch
(
mapping
.
getMappingType
())
{
case
unspecified:
text
=
"?"
;
break
;
case
existing:
text
=
DTUIMessages
.
columns_mapping_dialog_cell_text_existing
;
break
;
case
create:
text
=
DTUIMessages
.
columns_mapping_dialog_cell_text_new
;
break
;
case
skip:
text
=
DTUIMessages
.
columns_mapping_dialog_cell_text_skip
;
break
;
}
cell
.
setText
(
text
);
return
new
CustomComboBoxCellEditor
(
mappingViewer
,
mappingViewer
.
getTable
(),
types
.
toArray
(
new
String
[
0
]),
SWT
.
BORDER
);
}
@Override
protected
boolean
canEdit
(
Object
element
)
{
return
true
;
}
@Override
protected
Object
getValue
(
Object
element
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
return
attrMapping
.
getTargetType
(
settings
.
getTargetDataSource
(
attrMapping
),
true
);
}
@Override
protected
void
setValue
(
Object
element
,
Object
value
)
{
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
attrMapping
.
setTargetType
(
CommonUtils
.
toString
(
value
));
mappingViewer
.
refresh
(
element
);
}
});
columnController
.
addColumn
(
DTUIMessages
.
columns_mapping_dialog_column_type_text_mapping
,
null
,
SWT
.
LEFT
,
true
,
false
,
new
ColumnLabelProvider
()
{
@Override
public
String
getText
(
Object
element
)
{
DatabaseMappingAttribute
mapping
=
(
DatabaseMappingAttribute
)
element
;
switch
(
mapping
.
getMappingType
())
{
case
existing:
return
DTUIMessages
.
columns_mapping_dialog_cell_text_existing
;
case
create:
return
DTUIMessages
.
columns_mapping_dialog_cell_text_new
;
case
skip:
return
DTUIMessages
.
columns_mapping_dialog_cell_text_skip
;
default
:
return
"?"
;
}
}
);
columnType
.
getColumn
().
setText
(
DTUIMessages
.
columns_mapping_dialog_column_type_text_mapping
);
columnType
.
getColumn
().
setWidth
(
60
);
}
}
}
);
columnController
.
createColumns
();
mappingViewer
.
setInput
(
attributeMappings
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录