Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
d8938f20
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,发现更多精彩内容 >>
提交
d8938f20
编写于
7月 18, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#5384 FK create editor (add/remove)
上级
b91eca6b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
105 addition
and
67 deletion
+105
-67
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
....model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
+36
-49
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntityForeignKey.java
.../org/jkiss/dbeaver/model/virtual/DBVEntityForeignKey.java
+4
-0
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/editors/object/struct/EditForeignKeyPage.java
.../dbeaver/ui/editors/object/struct/EditForeignKeyPage.java
+4
-1
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/EditVirtualEntityDialog.java
...beaver/ui/controls/resultset/EditVirtualEntityDialog.java
+61
-17
未找到文件。
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
浏览文件 @
d8938f20
...
@@ -165,8 +165,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -165,8 +165,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
}
}
@Nullable
@Nullable
public
DBSEntity
getRealEntity
(
DBRProgressMonitor
monitor
)
throws
DBException
public
DBSEntity
getRealEntity
(
DBRProgressMonitor
monitor
)
throws
DBException
{
{
DBSObjectContainer
realContainer
=
container
.
getRealContainer
(
monitor
);
DBSObjectContainer
realContainer
=
container
.
getRealContainer
(
monitor
);
if
(
realContainer
==
null
)
{
if
(
realContainer
==
null
)
{
return
null
;
return
null
;
...
@@ -187,50 +186,42 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -187,50 +186,42 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@Nullable
@Nullable
@Override
@Override
public
String
getDescription
()
public
String
getDescription
()
{
{
return
description
;
return
description
;
}
}
@Override
@Override
public
DBVContainer
getParentObject
()
public
DBVContainer
getParentObject
()
{
{
return
container
;
return
container
;
}
}
@NotNull
@NotNull
@Override
@Override
public
DBPDataSource
getDataSource
()
public
DBPDataSource
getDataSource
()
{
{
return
container
==
null
?
null
:
container
.
getDataSource
();
return
container
==
null
?
null
:
container
.
getDataSource
();
}
}
public
void
setDescription
(
String
description
)
public
void
setDescription
(
String
description
)
{
{
this
.
description
=
description
;
this
.
description
=
description
;
}
}
@Override
@Override
public
boolean
isPersisted
()
public
boolean
isPersisted
()
{
{
return
true
;
return
true
;
}
}
@NotNull
@NotNull
@Override
@Override
public
DBSEntityType
getEntityType
()
public
DBSEntityType
getEntityType
()
{
{
return
DBSEntityType
.
VIRTUAL_ENTITY
;
return
DBSEntityType
.
VIRTUAL_ENTITY
;
}
}
@Nullable
@Nullable
public
String
getProperty
(
String
name
)
public
String
getProperty
(
String
name
)
{
{
return
CommonUtils
.
isEmpty
(
properties
)
?
null
:
properties
.
get
(
name
);
return
CommonUtils
.
isEmpty
(
properties
)
?
null
:
properties
.
get
(
name
);
}
}
public
void
setProperty
(
String
name
,
@Nullable
String
value
)
public
void
setProperty
(
String
name
,
@Nullable
String
value
)
{
{
if
(
properties
==
null
)
{
if
(
properties
==
null
)
{
properties
=
new
LinkedHashMap
<>();
properties
=
new
LinkedHashMap
<>();
}
}
...
@@ -243,8 +234,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -243,8 +234,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@NotNull
@NotNull
@Override
@Override
public
Collection
<?
extends
DBSEntityAttribute
>
getAttributes
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
public
Collection
<?
extends
DBSEntityAttribute
>
getAttributes
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
{
DBSEntity
realEntity
=
getRealEntity
(
monitor
);
DBSEntity
realEntity
=
getRealEntity
(
monitor
);
if
(
realEntity
!=
null
)
{
if
(
realEntity
!=
null
)
{
final
Collection
<?
extends
DBSEntityAttribute
>
realAttributes
=
realEntity
.
getAttributes
(
monitor
);
final
Collection
<?
extends
DBSEntityAttribute
>
realAttributes
=
realEntity
.
getAttributes
(
monitor
);
...
@@ -257,8 +247,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -257,8 +247,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@Nullable
@Nullable
@Override
@Override
public
DBSEntityAttribute
getAttribute
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
String
attributeName
)
public
DBSEntityAttribute
getAttribute
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
String
attributeName
)
{
{
try
{
try
{
return
DBUtils
.
findObject
(
getAttributes
(
monitor
),
attributeName
);
return
DBUtils
.
findObject
(
getAttributes
(
monitor
),
attributeName
);
}
catch
(
DBException
e
)
{
}
catch
(
DBException
e
)
{
...
@@ -268,8 +257,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -268,8 +257,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
}
}
@Nullable
@Nullable
public
DBVEntityAttribute
getVirtualAttribute
(
DBDAttributeBinding
binding
,
boolean
create
)
public
DBVEntityAttribute
getVirtualAttribute
(
DBDAttributeBinding
binding
,
boolean
create
)
{
{
if
(
entityAttributes
!=
null
||
create
)
{
if
(
entityAttributes
!=
null
||
create
)
{
if
(
entityAttributes
==
null
)
{
if
(
entityAttributes
==
null
)
{
entityAttributes
=
new
ArrayList
<>();
entityAttributes
=
new
ArrayList
<>();
...
@@ -313,13 +301,11 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -313,13 +301,11 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@Nullable
@Nullable
@Override
@Override
public
Collection
<?
extends
DBVEntityConstraint
>
getConstraints
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
public
Collection
<?
extends
DBVEntityConstraint
>
getConstraints
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
{
return
entityConstraints
;
return
entityConstraints
;
}
}
public
DBVEntityConstraint
getBestIdentifier
()
public
DBVEntityConstraint
getBestIdentifier
()
{
{
if
(
entityConstraints
==
null
)
{
if
(
entityConstraints
==
null
)
{
entityConstraints
=
new
ArrayList
<>();
entityConstraints
=
new
ArrayList
<>();
}
}
...
@@ -334,8 +320,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -334,8 +320,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
return
entityConstraints
.
get
(
0
);
return
entityConstraints
.
get
(
0
);
}
}
void
addConstraint
(
DBVEntityConstraint
constraint
)
void
addConstraint
(
DBVEntityConstraint
constraint
)
{
{
if
(
entityConstraints
==
null
)
{
if
(
entityConstraints
==
null
)
{
entityConstraints
=
new
ArrayList
<>();
entityConstraints
=
new
ArrayList
<>();
}
}
...
@@ -344,23 +329,31 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -344,23 +329,31 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@Nullable
@Nullable
@Override
@Override
public
Collection
<
DBVEntityForeignKey
>
getAssociations
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
public
synchronized
List
<
DBVEntityForeignKey
>
getAssociations
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
{
return
entityForeignKeys
;
return
entityForeignKeys
;
}
}
void
addForeignKey
(
DBVEntityForeignKey
foreignKey
)
@NotNull
{
public
synchronized
List
<
DBVEntityForeignKey
>
getForeignKeys
()
{
return
entityForeignKeys
!=
null
?
entityForeignKeys
:
Collections
.
emptyList
();
}
public
synchronized
void
addForeignKey
(
@NotNull
DBVEntityForeignKey
foreignKey
)
{
if
(
entityForeignKeys
==
null
)
{
if
(
entityForeignKeys
==
null
)
{
entityForeignKeys
=
new
ArrayList
<>();
entityForeignKeys
=
new
ArrayList
<>();
}
}
entityForeignKeys
.
add
(
foreignKey
);
entityForeignKeys
.
add
(
foreignKey
);
}
}
public
synchronized
void
removeForeignKey
(
@NotNull
DBVEntityForeignKey
foreignKey
)
{
if
(
entityForeignKeys
!=
null
)
{
entityForeignKeys
.
remove
(
foreignKey
);
}
}
@Nullable
@Nullable
@Override
@Override
public
Collection
<?
extends
DBSEntityAssociation
>
getReferences
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
public
Collection
<?
extends
DBSEntityAssociation
>
getReferences
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
{
return
null
;
return
null
;
}
}
...
@@ -368,20 +361,17 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -368,20 +361,17 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
return
descriptionColumnNames
;
return
descriptionColumnNames
;
}
}
public
void
setDescriptionColumnNames
(
String
descriptionColumnNames
)
public
void
setDescriptionColumnNames
(
String
descriptionColumnNames
)
{
{
this
.
descriptionColumnNames
=
descriptionColumnNames
;
this
.
descriptionColumnNames
=
descriptionColumnNames
;
}
}
public
Collection
<
DBSEntityAttribute
>
getDescriptionColumns
(
DBRProgressMonitor
monitor
,
DBSEntity
entity
)
public
Collection
<
DBSEntityAttribute
>
getDescriptionColumns
(
DBRProgressMonitor
monitor
,
DBSEntity
entity
)
throws
DBException
throws
DBException
{
{
return
getDescriptionColumns
(
monitor
,
entity
,
descriptionColumnNames
);
return
getDescriptionColumns
(
monitor
,
entity
,
descriptionColumnNames
);
}
}
public
static
Collection
<
DBSEntityAttribute
>
getDescriptionColumns
(
DBRProgressMonitor
monitor
,
DBSEntity
entity
,
String
descColumns
)
public
static
Collection
<
DBSEntityAttribute
>
getDescriptionColumns
(
DBRProgressMonitor
monitor
,
DBSEntity
entity
,
String
descColumns
)
throws
DBException
throws
DBException
{
{
if
(
CommonUtils
.
isEmpty
(
descColumns
))
{
if
(
CommonUtils
.
isEmpty
(
descColumns
))
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
...
@@ -402,8 +392,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -402,8 +392,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
}
}
public
static
String
getDefaultDescriptionColumn
(
DBRProgressMonitor
monitor
,
DBSEntityAttribute
keyColumn
)
public
static
String
getDefaultDescriptionColumn
(
DBRProgressMonitor
monitor
,
DBSEntityAttribute
keyColumn
)
throws
DBException
throws
DBException
{
{
assert
keyColumn
.
getParentObject
()
!=
null
;
assert
keyColumn
.
getParentObject
()
!=
null
;
Collection
<?
extends
DBSEntityAttribute
>
allColumns
=
keyColumn
.
getParentObject
().
getAttributes
(
monitor
);
Collection
<?
extends
DBSEntityAttribute
>
allColumns
=
keyColumn
.
getParentObject
().
getAttributes
(
monitor
);
...
@@ -419,8 +408,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -419,8 +408,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
if
(
column
!=
keyColumn
&&
if
(
column
!=
keyColumn
&&
column
.
getDataKind
()
==
DBPDataKind
.
STRING
&&
column
.
getDataKind
()
==
DBPDataKind
.
STRING
&&
column
.
getMaxLength
()
<
MAX_DESC_COLUMN_LENGTH
&&
column
.
getMaxLength
()
<
MAX_DESC_COLUMN_LENGTH
&&
column
.
getMaxLength
()
>=
MIN_DESC_COLUMN_LENGTH
)
column
.
getMaxLength
()
>=
MIN_DESC_COLUMN_LENGTH
)
{
{
stringColumns
.
put
(
column
.
getName
(),
column
);
stringColumns
.
put
(
column
.
getName
(),
column
);
}
}
}
}
...
@@ -466,7 +454,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -466,7 +454,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
final
DBVColorOverride
co
=
new
DBVColorOverride
(
final
DBVColorOverride
co
=
new
DBVColorOverride
(
attrName
,
attrName
,
DBCLogicalOperator
.
EQUALS
,
DBCLogicalOperator
.
EQUALS
,
new
Object
[]
{
value
},
new
Object
[]
{
value
},
foreground
,
foreground
,
background
);
background
);
...
@@ -539,8 +527,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -539,8 +527,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@NotNull
@NotNull
@Override
@Override
public
String
getFullyQualifiedName
(
DBPEvaluationContext
context
)
public
String
getFullyQualifiedName
(
DBPEvaluationContext
context
)
{
{
return
DBUtils
.
getFullQualifiedName
(
getDataSource
(),
return
DBUtils
.
getFullQualifiedName
(
getDataSource
(),
container
,
container
,
this
);
this
);
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntityForeignKey.java
浏览文件 @
d8938f20
...
@@ -71,6 +71,10 @@ public class DBVEntityForeignKey implements DBSEntityConstraint, DBSEntityReferr
...
@@ -71,6 +71,10 @@ public class DBVEntityForeignKey implements DBSEntityConstraint, DBSEntityReferr
return
attributes
;
return
attributes
;
}
}
public
List
<
DBVEntityForeignKeyColumn
>
getAttributes
()
{
return
attributes
;
}
public
synchronized
void
setAttributes
(
List
<
DBVEntityForeignKeyColumn
>
attrs
)
{
public
synchronized
void
setAttributes
(
List
<
DBVEntityForeignKeyColumn
>
attrs
)
{
attributes
.
clear
();
attributes
.
clear
();
attributes
.
addAll
(
attrs
);
attributes
.
addAll
(
attrs
);
...
...
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/editors/object/struct/EditForeignKeyPage.java
浏览文件 @
d8938f20
...
@@ -373,7 +373,10 @@ public class EditForeignKeyPage extends BaseObjectEditPage {
...
@@ -373,7 +373,10 @@ public class EditForeignKeyPage extends BaseObjectEditPage {
break
;
break
;
}
}
if
(
childNode
instanceof
DBNDatabaseFolder
)
{
if
(
childNode
instanceof
DBNDatabaseFolder
)
{
loadEntities
(
monitor
,
entities
,
(
DBNDatabaseFolder
)
childNode
);
Class
<?>
childrenClass
=
((
DBNDatabaseFolder
)
childNode
).
getChildrenClass
(((
DBNDatabaseFolder
)
childNode
).
getItemsMeta
());
if
(
DBSEntity
.
class
.
isAssignableFrom
(
childrenClass
))
{
loadEntities
(
monitor
,
entities
,
(
DBNDatabaseFolder
)
childNode
);
}
}
else
{
}
else
{
if
(
childNode
instanceof
DBNDatabaseNode
)
{
if
(
childNode
instanceof
DBNDatabaseNode
)
{
DBSObject
object
=
((
DBNDatabaseNode
)
childNode
).
getObject
();
DBSObject
object
=
((
DBNDatabaseNode
)
childNode
).
getObject
();
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/EditVirtualEntityDialog.java
浏览文件 @
d8938f20
...
@@ -28,13 +28,13 @@ import org.jkiss.code.NotNull;
...
@@ -28,13 +28,13 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBValueFormatting
;
import
org.jkiss.dbeaver.model.DBValueFormatting
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor
;
import
org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor
;
import
org.jkiss.dbeaver.model.data.DBDRowIdentifier
;
import
org.jkiss.dbeaver.model.data.DBDRowIdentifier
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAssociation
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSForeignKeyModifyRule
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSForeignKeyModifyRule
;
import
org.jkiss.dbeaver.model.virtual.*
;
import
org.jkiss.dbeaver.model.virtual.*
;
...
@@ -49,6 +49,8 @@ import org.jkiss.utils.CommonUtils;
...
@@ -49,6 +49,8 @@ import org.jkiss.utils.CommonUtils;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.stream.Collectors
;
class
EditVirtualEntityDialog
extends
BaseDialog
{
class
EditVirtualEntityDialog
extends
BaseDialog
{
...
@@ -170,24 +172,54 @@ class EditVirtualEntityDialog extends BaseDialog {
...
@@ -170,24 +172,54 @@ class EditVirtualEntityDialog extends BaseDialog {
UIUtils
.
createTableColumn
(
fkTable
,
SWT
.
LEFT
,
"Ref Table"
);
UIUtils
.
createTableColumn
(
fkTable
,
SWT
.
LEFT
,
"Ref Table"
);
UIUtils
.
createTableColumn
(
fkTable
,
SWT
.
LEFT
,
"Columns"
);
UIUtils
.
createTableColumn
(
fkTable
,
SWT
.
LEFT
,
"Columns"
);
Composite
buttonsPanel
=
UIUtils
.
createComposite
(
panel
,
2
);
for
(
DBVEntityForeignKey
fk
:
vEntity
.
getForeignKeys
())
{
buttonsPanel
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
createForeignKeyItem
(
fkTable
,
fk
);
Button
btnAdd
=
createButton
(
buttonsPanel
,
ID_CREATE_FOREIGN_KEY
,
"Add"
,
false
);
}
btnAdd
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
DBSEntityAssociation
virtualFK
=
new
DBVEntityForeignKey
(
vEntity
);
{
EditForeignKeyPage
editDialog
=
new
EditForeignKeyPage
(
Composite
buttonsPanel
=
UIUtils
.
createComposite
(
panel
,
2
);
"Define virtual foreign keys"
,
virtualFK
,
new
DBSForeignKeyModifyRule
[]
{
DBSForeignKeyModifyRule
.
NO_ACTION
});
buttonsPanel
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
if
(!
editDialog
.
edit
())
{
return
;
Button
btnAdd
=
createButton
(
buttonsPanel
,
ID_CREATE_FOREIGN_KEY
,
"Add"
,
false
);
btnAdd
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
DBVEntityForeignKey
virtualFK
=
new
DBVEntityForeignKey
(
vEntity
);
EditForeignKeyPage
editDialog
=
new
EditForeignKeyPage
(
"Define virtual foreign keys"
,
virtualFK
,
new
DBSForeignKeyModifyRule
[]{
DBSForeignKeyModifyRule
.
NO_ACTION
});
if
(!
editDialog
.
edit
())
{
return
;
}
// Save
virtualFK
.
setReferencedConstraint
(
editDialog
.
getUniqueConstraint
());
List
<
DBVEntityForeignKeyColumn
>
columns
=
new
ArrayList
<>();
for
(
EditForeignKeyPage
.
FKColumnInfo
tableColumn
:
editDialog
.
getColumns
())
{
columns
.
add
(
new
DBVEntityForeignKeyColumn
(
virtualFK
,
tableColumn
.
getOwnColumn
().
getName
(),
tableColumn
.
getRefColumn
().
getName
()));
}
virtualFK
.
setAttributes
(
columns
);
vEntity
.
addForeignKey
(
virtualFK
);
createForeignKeyItem
(
fkTable
,
virtualFK
);
}
}
// Save
});
}
});
Button
btnRemove
=
createButton
(
buttonsPanel
,
ID_REMOVE_FOREIGN_KEY
,
"Remove"
,
false
);
Button
btnRemove
=
createButton
(
buttonsPanel
,
ID_REMOVE_FOREIGN_KEY
,
"Remove"
,
false
);
btnRemove
.
setEnabled
(
false
);
btnRemove
.
setEnabled
(
false
);
btnRemove
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
DBVEntityForeignKey
virtualFK
=
(
DBVEntityForeignKey
)
fkTable
.
getSelection
()[
0
].
getData
();
if
(!
UIUtils
.
confirmAction
(
getShell
(),
"Delete virtual FK"
,
"Are you sure you want to delete virtual foreign key '"
+
virtualFK
.
getName
()
+
"'?"
))
{
return
;
}
vEntity
.
removeForeignKey
(
virtualFK
);
fkTable
.
remove
(
fkTable
.
getSelectionIndices
());
}
});
}
fkTable
.
addSelectionListener
(
new
SelectionAdapter
()
{
fkTable
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
@Override
...
@@ -198,6 +230,18 @@ class EditVirtualEntityDialog extends BaseDialog {
...
@@ -198,6 +230,18 @@ class EditVirtualEntityDialog extends BaseDialog {
});
});
}
}
private
void
createForeignKeyItem
(
Table
fkTable
,
DBVEntityForeignKey
fk
)
{
TableItem
item
=
new
TableItem
(
fkTable
,
SWT
.
NONE
);
item
.
setImage
(
0
,
DBeaverIcons
.
getImage
(
DBIcon
.
TREE_FOREIGN_KEY
));
if
(
fk
.
getReferencedConstraint
()
!=
null
)
{
item
.
setText
(
0
,
fk
.
getReferencedConstraint
().
getParentObject
().
getName
());
}
String
attrNames
=
fk
.
getAttributes
().
stream
().
map
(
DBVEntityForeignKeyColumn:
:
getAttributeName
)
.
collect
(
Collectors
.
joining
(
","
));
item
.
setText
(
1
,
attrNames
);
item
.
setData
(
fk
);
}
private
void
createColumnsPage
(
TabFolder
tabFolder
)
{
private
void
createColumnsPage
(
TabFolder
tabFolder
)
{
TabItem
colItem
=
new
TabItem
(
tabFolder
,
SWT
.
NONE
);
TabItem
colItem
=
new
TabItem
(
tabFolder
,
SWT
.
NONE
);
colItem
.
setText
(
"Columns view"
);
colItem
.
setText
(
"Columns view"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录