Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
76e0c1ab
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,发现更多精彩内容 >>
提交
76e0c1ab
编写于
8月 24, 2019
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#6529 Virtual structure editor tab. Virt model events
上级
52e49e12
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
215 addition
and
82 deletion
+215
-82
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
....model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
+20
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModelSerializerLegacy.java
...jkiss/dbeaver/model/virtual/DBVModelSerializerLegacy.java
+2
-2
plugins/org.jkiss.dbeaver.ui.editors.data/plugin.xml
plugins/org.jkiss.dbeaver.ui.editors.data/plugin.xml
+1
-1
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetContainer.java
...ss/dbeaver/ui/controls/resultset/IResultSetContainer.java
+8
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
.../jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
+49
-27
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingResultsContainer.java
...ls/resultset/panel/grouping/GroupingResultsContainer.java
+9
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/references/ReferencesResultsContainer.java
...esultset/panel/references/ReferencesResultsContainer.java
+9
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/dialogs/CursorViewDialog.java
...c/org/jkiss/dbeaver/ui/data/dialogs/CursorViewDialog.java
+7
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/AbstractDataEditor.java
...org/jkiss/dbeaver/ui/editors/data/AbstractDataEditor.java
+7
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/VirtualStructureEditor.java
...jkiss/dbeaver/ui/editors/data/VirtualStructureEditor.java
+89
-51
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
...s.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
+6
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLResultsView.java
.../src/org/jkiss/dbeaver/ui/editors/sql/SQLResultsView.java
+8
-0
未找到文件。
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
浏览文件 @
76e0c1ab
...
@@ -294,14 +294,22 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -294,14 +294,22 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
}
}
void
addVirtualAttribute
(
DBVEntityAttribute
attribute
)
{
void
addVirtualAttribute
(
DBVEntityAttribute
attribute
)
{
addVirtualAttribute
(
attribute
,
true
);
}
void
addVirtualAttribute
(
DBVEntityAttribute
attribute
,
boolean
reflect
)
{
if
(
entityAttributes
==
null
)
{
if
(
entityAttributes
==
null
)
{
entityAttributes
=
new
ArrayList
<>();
entityAttributes
=
new
ArrayList
<>();
}
}
entityAttributes
.
add
(
attribute
);
entityAttributes
.
add
(
attribute
);
if
(
reflect
)
{
DBUtils
.
fireObjectUpdate
(
this
);
}
}
}
void
re
set
VirtualAttribute
(
DBVEntityAttribute
attribute
)
{
void
re
move
VirtualAttribute
(
DBVEntityAttribute
attribute
)
{
entityAttributes
.
remove
(
attribute
);
entityAttributes
.
remove
(
attribute
);
DBUtils
.
fireObjectUpdate
(
this
,
attribute
);
}
}
@Nullable
@Nullable
...
@@ -331,15 +339,24 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -331,15 +339,24 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
}
}
public
void
addConstraint
(
DBVEntityConstraint
constraint
)
{
public
void
addConstraint
(
DBVEntityConstraint
constraint
)
{
addConstraint
(
constraint
,
true
);
}
public
void
addConstraint
(
DBVEntityConstraint
constraint
,
boolean
reflect
)
{
if
(
entityConstraints
==
null
)
{
if
(
entityConstraints
==
null
)
{
entityConstraints
=
new
ArrayList
<>();
entityConstraints
=
new
ArrayList
<>();
}
}
entityConstraints
.
add
(
constraint
);
entityConstraints
.
add
(
constraint
);
if
(
reflect
)
{
DBUtils
.
fireObjectUpdate
(
this
,
constraint
);
}
}
}
public
void
removeConstraint
(
DBVEntityConstraint
constraint
)
{
public
void
removeConstraint
(
DBVEntityConstraint
constraint
)
{
if
(
entityConstraints
!=
null
)
{
if
(
entityConstraints
!=
null
)
{
entityConstraints
.
remove
(
constraint
);
entityConstraints
.
remove
(
constraint
);
DBUtils
.
fireObjectUpdate
(
this
,
constraint
);
}
}
}
}
...
@@ -365,11 +382,13 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
...
@@ -365,11 +382,13 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
entityForeignKeys
=
new
ArrayList
<>();
entityForeignKeys
=
new
ArrayList
<>();
}
}
entityForeignKeys
.
add
(
foreignKey
);
entityForeignKeys
.
add
(
foreignKey
);
DBUtils
.
fireObjectUpdate
(
this
,
foreignKey
);
}
}
public
synchronized
void
removeForeignKey
(
@NotNull
DBVEntityForeignKey
foreignKey
)
{
public
synchronized
void
removeForeignKey
(
@NotNull
DBVEntityForeignKey
foreignKey
)
{
if
(
entityForeignKeys
!=
null
)
{
if
(
entityForeignKeys
!=
null
)
{
entityForeignKeys
.
remove
(
foreignKey
);
entityForeignKeys
.
remove
(
foreignKey
);
DBUtils
.
fireObjectUpdate
(
this
,
foreignKey
);
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModelSerializerLegacy.java
浏览文件 @
76e0c1ab
...
@@ -255,7 +255,7 @@ class DBVModelSerializerLegacy implements DBVModelSerializer
...
@@ -255,7 +255,7 @@ class DBVModelSerializerLegacy implements DBVModelSerializer
curEntity
,
curEntity
,
DBSEntityConstraintType
.
VIRTUAL_KEY
,
DBSEntityConstraintType
.
VIRTUAL_KEY
,
atts
.
getValue
(
ATTR_NAME
));
atts
.
getValue
(
ATTR_NAME
));
curEntity
.
addConstraint
(
curConstraint
);
curEntity
.
addConstraint
(
curConstraint
,
false
);
}
}
break
;
break
;
case
TAG_ATTRIBUTE:
case
TAG_ATTRIBUTE:
...
@@ -267,7 +267,7 @@ class DBVModelSerializerLegacy implements DBVModelSerializer
...
@@ -267,7 +267,7 @@ class DBVModelSerializerLegacy implements DBVModelSerializer
curAttribute
=
childAttribute
;
curAttribute
=
childAttribute
;
}
else
if
(
curEntity
!=
null
)
{
}
else
if
(
curEntity
!=
null
)
{
curAttribute
=
new
DBVEntityAttribute
(
curEntity
,
null
,
atts
.
getValue
(
ATTR_NAME
));
curAttribute
=
new
DBVEntityAttribute
(
curEntity
,
null
,
atts
.
getValue
(
ATTR_NAME
));
curEntity
.
addVirtualAttribute
(
curAttribute
);
curEntity
.
addVirtualAttribute
(
curAttribute
,
false
);
}
}
break
;
break
;
case
TAG_TRANSFORM:
case
TAG_TRANSFORM:
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/plugin.xml
浏览文件 @
76e0c1ab
...
@@ -167,7 +167,7 @@
...
@@ -167,7 +167,7 @@
</editor>
</editor>
<editor
<editor
id=
"
org.jkiss.dbeaver.ui.editors.data.VirtualStructureEditor
"
id=
"
db-logical-structure
"
class=
"org.jkiss.dbeaver.ui.editors.data.VirtualStructureEditor"
class=
"org.jkiss.dbeaver.ui.editors.data.VirtualStructureEditor"
objectType=
"org.jkiss.dbeaver.model.struct.DBSEntity"
objectType=
"org.jkiss.dbeaver.model.struct.DBSEntity"
main=
"false"
main=
"false"
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetContainer.java
浏览文件 @
76e0c1ab
...
@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ui.controls.resultset;
...
@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ui.controls.resultset;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
...
@@ -30,6 +31,13 @@ import org.jkiss.dbeaver.model.struct.DBSDataContainer;
...
@@ -30,6 +31,13 @@ import org.jkiss.dbeaver.model.struct.DBSDataContainer;
*/
*/
public
interface
IResultSetContainer
{
public
interface
IResultSetContainer
{
/**
* Owner project.
* May be null if results container is hosted by some external file editor.
*/
@Nullable
DBPProject
getProject
();
/**
/**
* Execution context which will be used by Results viewer to read data
* Execution context which will be used by Results viewer to read data
* @return execution context. Maybe null is container is not connected
* @return execution context. Maybe null is container is not connected
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
浏览文件 @
76e0c1ab
...
@@ -55,6 +55,7 @@ import org.jkiss.dbeaver.DBException;
...
@@ -55,6 +55,7 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ModelPreferences
;
import
org.jkiss.dbeaver.ModelPreferences
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.data.*
;
import
org.jkiss.dbeaver.model.data.*
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.model.exec.*
;
...
@@ -73,10 +74,7 @@ import org.jkiss.dbeaver.model.sql.SQLQueryContainer;
...
@@ -73,10 +74,7 @@ import org.jkiss.dbeaver.model.sql.SQLQueryContainer;
import
org.jkiss.dbeaver.model.sql.SQLScriptElement
;
import
org.jkiss.dbeaver.model.sql.SQLScriptElement
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.dbeaver.model.virtual.DBVEntity
;
import
org.jkiss.dbeaver.model.virtual.*
;
import
org.jkiss.dbeaver.model.virtual.DBVEntityConstraint
;
import
org.jkiss.dbeaver.model.virtual.DBVTransformSettings
;
import
org.jkiss.dbeaver.model.virtual.DBVUtils
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.runtime.DBeaverNotifications
;
import
org.jkiss.dbeaver.runtime.DBeaverNotifications
;
import
org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor
;
import
org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor
;
...
@@ -126,7 +124,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
...
@@ -126,7 +124,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*
*
*/
*/
public
class
ResultSetViewer
extends
Viewer
public
class
ResultSetViewer
extends
Viewer
implements
DBPContextProvider
,
IResultSetController
,
ISaveablePart2
,
IAdaptable
implements
DBPContextProvider
,
IResultSetController
,
ISaveablePart2
,
IAdaptable
,
DBPEventListener
{
{
private
static
final
Log
log
=
Log
.
getLog
(
ResultSetViewer
.
class
);
private
static
final
Log
log
=
Log
.
getLog
(
ResultSetViewer
.
class
);
...
@@ -355,6 +353,11 @@ public class ResultSetViewer extends Viewer
...
@@ -355,6 +353,11 @@ public class ResultSetViewer extends Viewer
}
}
updateFiltersText
();
updateFiltersText
();
DBPProject
project
=
container
.
getProject
();
if
(
project
!=
null
)
{
project
.
getDataSourceRegistry
().
addDataSourceListener
(
this
);
}
}
}
@Override
@Override
...
@@ -417,13 +420,18 @@ public class ResultSetViewer extends Viewer
...
@@ -417,13 +420,18 @@ public class ResultSetViewer extends Viewer
}
}
DataFilterRegistry
.
getInstance
().
saveDataFilter
(
getDataContainer
(),
model
.
getDataFilter
());
DataFilterRegistry
.
getInstance
().
saveDataFilter
(
getDataContainer
(),
model
.
getDataFilter
());
DBeaverNotifications
.
showNotification
(
DBeaverNotifications
.
NT_GENERAL
,
if
(
filtersPanel
!=
null
)
{
"Data filter was saved"
,
DBeaverNotifications
.
showNotification
(
DBeaverNotifications
.
NT_GENERAL
,
filtersPanel
.
getFilterText
(),
"Data filter was saved"
,
DBPMessageType
.
INFORMATION
,
null
);
filtersPanel
.
getFilterText
(),
DBPMessageType
.
INFORMATION
,
null
);
}
}
}
void
switchFilterFocus
()
{
void
switchFilterFocus
()
{
if
(
filtersPanel
==
null
)
{
return
;
}
boolean
filterFocused
=
filtersPanel
.
getEditControl
().
isFocusControl
();
boolean
filterFocused
=
filtersPanel
.
getEditControl
().
isFocusControl
();
if
(
filterFocused
)
{
if
(
filterFocused
)
{
if
(
activePresentation
!=
null
)
{
if
(
activePresentation
!=
null
)
{
...
@@ -772,7 +780,9 @@ public class ResultSetViewer extends Viewer
...
@@ -772,7 +780,9 @@ public class ResultSetViewer extends Viewer
}
}
panelButton
.
setChecked
(!
isPanelVisible
);
panelButton
.
setChecked
(!
isPanelVisible
);
panelsButton
.
setChecked
(
isPanelsVisible
());
panelsButton
.
setChecked
(
isPanelsVisible
());
panelSwitchFolder
.
redraw
();
if
(
panelSwitchFolder
!=
null
)
{
panelSwitchFolder
.
redraw
();
}
}
}
});
});
panelButton
.
setChecked
(
panelsVisible
&&
isPanelVisible
(
panel
.
getId
()));
panelButton
.
setChecked
(
panelsVisible
&&
isPanelVisible
(
panel
.
getId
()));
...
@@ -1673,6 +1683,11 @@ public class ResultSetViewer extends Viewer
...
@@ -1673,6 +1683,11 @@ public class ResultSetViewer extends Viewer
private
void
dispose
()
private
void
dispose
()
{
{
DBPProject
project
=
container
.
getProject
();
if
(
project
!=
null
)
{
project
.
getDataSourceRegistry
().
removeDataSourceListener
(
this
);
}
savePresentationSettings
();
savePresentationSettings
();
clearData
();
clearData
();
...
@@ -2495,6 +2510,14 @@ public class ResultSetViewer extends Viewer
...
@@ -2495,6 +2510,14 @@ public class ResultSetViewer extends Viewer
return
refTablesMenu
;
return
refTablesMenu
;
}
}
@Override
public
void
handleDataSourceEvent
(
DBPEvent
event
)
{
if
(
event
.
getObject
()
instanceof
DBVEntity
&&
event
.
getData
()
instanceof
DBVEntityForeignKey
&&
event
.
getObject
()
==
getVirtualEntity
())
{
// Virtual foreign key change - let's refresh
refreshData
(
null
);
}
}
private
class
TransformerAction
extends
Action
{
private
class
TransformerAction
extends
Action
{
private
final
DBDAttributeBinding
attribute
;
private
final
DBDAttributeBinding
attribute
;
...
@@ -2739,9 +2762,6 @@ public class ResultSetViewer extends Viewer
...
@@ -2739,9 +2762,6 @@ public class ResultSetViewer extends Viewer
throw
new
DBException
(
"Referenced constraint ["
+
refConstraint
+
"] is not a referrer"
);
throw
new
DBException
(
"Referenced constraint ["
+
refConstraint
+
"] is not a referrer"
);
}
}
DBSEntity
targetEntity
=
refConstraint
.
getParentObject
();
DBSEntity
targetEntity
=
refConstraint
.
getParentObject
();
if
(
targetEntity
==
null
)
{
throw
new
DBException
(
"Null constraint parent"
);
}
targetEntity
=
DBVUtils
.
getRealEntity
(
monitor
,
targetEntity
);
targetEntity
=
DBVUtils
.
getRealEntity
(
monitor
,
targetEntity
);
if
(!(
targetEntity
instanceof
DBSDataContainer
))
{
if
(!(
targetEntity
instanceof
DBSDataContainer
))
{
throw
new
DBException
(
"Entity ["
+
DBUtils
.
getObjectFullName
(
targetEntity
,
DBPEvaluationContext
.
UI
)
+
"] is not a data container"
);
throw
new
DBException
(
"Entity ["
+
DBUtils
.
getObjectFullName
(
targetEntity
,
DBPEvaluationContext
.
UI
)
+
"] is not a data container"
);
...
@@ -2768,11 +2788,14 @@ public class ResultSetViewer extends Viewer
...
@@ -2768,11 +2788,14 @@ public class ResultSetViewer extends Viewer
return
;
return
;
}
}
DBDAttributeConstraint
constraint
=
new
DBDAttributeConstraint
(
refAttr
.
getAttribute
(),
DBDAttributeConstraint
.
NULL_VISUAL_POSITION
);
DBSEntityAttribute
attribute
=
refAttr
.
getAttribute
();
constraint
.
setVisible
(
true
);
if
(
attribute
!=
null
)
{
constraints
.
add
(
constraint
);
DBDAttributeConstraint
constraint
=
new
DBDAttributeConstraint
(
attribute
,
DBDAttributeConstraint
.
NULL_VISUAL_POSITION
);
constraint
.
setVisible
(
true
);
constraints
.
add
(
constraint
);
createFilterConstraint
(
rows
,
ownBinding
,
constraint
);
}
createFilterConstraint
(
rows
,
ownBinding
,
constraint
);
}
}
// Save cur data filter in state
// Save cur data filter in state
if
(
curState
==
null
)
{
if
(
curState
==
null
)
{
...
@@ -2799,9 +2822,6 @@ public class ResultSetViewer extends Viewer
...
@@ -2799,9 +2822,6 @@ public class ResultSetViewer extends Viewer
}
}
DBSEntity
targetEntity
=
association
.
getParentObject
();
DBSEntity
targetEntity
=
association
.
getParentObject
();
if
(
targetEntity
==
null
)
{
throw
new
DBException
(
"Null constraint parent"
);
}
//DBSDataContainer dataContainer = DBUtils.getAdapter(DBSDataContainer.class, targetEntity);
//DBSDataContainer dataContainer = DBUtils.getAdapter(DBSDataContainer.class, targetEntity);
targetEntity
=
DBVUtils
.
getRealEntity
(
monitor
,
targetEntity
);
targetEntity
=
DBVUtils
.
getRealEntity
(
monitor
,
targetEntity
);
if
(!(
targetEntity
instanceof
DBSDataContainer
))
{
if
(!(
targetEntity
instanceof
DBSDataContainer
))
{
...
@@ -2893,9 +2913,7 @@ public class ResultSetViewer extends Viewer
...
@@ -2893,9 +2913,7 @@ public class ResultSetViewer extends Viewer
viewerPanel
.
getShell
(),
viewerPanel
.
getShell
(),
ResultSetPreferences
.
CONFIRM_RS_PANEL_RESET
,
ResultSetPreferences
.
CONFIRM_RS_PANEL_RESET
,
ConfirmationDialog
.
CONFIRM
);
ConfirmationDialog
.
CONFIRM
);
if
(
result
==
IDialogConstants
.
CANCEL_ID
)
{
return
result
!=
IDialogConstants
.
CANCEL_ID
;
return
false
;
}
}
}
return
true
;
return
true
;
}
}
...
@@ -3454,7 +3472,6 @@ public class ResultSetViewer extends Viewer
...
@@ -3454,7 +3472,6 @@ public class ResultSetViewer extends Viewer
* In some cases there may be many frequent data read requests (e.g. when user works
* In some cases there may be many frequent data read requests (e.g. when user works
* with references panel). We need to execute only current one and the last one. All
* with references panel). We need to execute only current one and the last one. All
* intrmediate data read requests must be ignored.
* intrmediate data read requests must be ignored.
* @param dataPumpJob
*/
*/
private
void
queueDataPump
(
ResultSetJobDataRead
dataPumpJob
)
{
private
void
queueDataPump
(
ResultSetJobDataRead
dataPumpJob
)
{
synchronized
(
dataPumpJobQueue
)
{
synchronized
(
dataPumpJobQueue
)
{
...
@@ -3764,9 +3781,14 @@ public class ResultSetViewer extends Viewer
...
@@ -3764,9 +3781,14 @@ public class ResultSetViewer extends Viewer
}
}
private
DBVEntity
getVirtualEntity
(
DBSEntity
entity
)
{
private
DBVEntity
getVirtualEntity
(
DBSEntity
entity
)
{
return
entity
!=
null
?
if
(
entity
!=
null
)
{
DBVUtils
.
getVirtualEntity
(
entity
,
true
)
:
return
DBVUtils
.
getVirtualEntity
(
entity
,
true
);
DBVUtils
.
getVirtualEntity
(
getDataContainer
(),
true
);
}
DBSDataContainer
dataContainer
=
getDataContainer
();
if
(
dataContainer
!=
null
)
{
return
DBVUtils
.
getVirtualEntity
(
dataContainer
,
true
);
}
return
null
;
}
}
private
void
checkEntityIdentifiers
(
ResultSetPersister
persister
)
throws
DBException
private
void
checkEntityIdentifiers
(
ResultSetPersister
persister
)
throws
DBException
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingResultsContainer.java
浏览文件 @
76e0c1ab
...
@@ -18,9 +18,11 @@ package org.jkiss.dbeaver.ui.controls.resultset.panel.grouping;
...
@@ -18,9 +18,11 @@ package org.jkiss.dbeaver.ui.controls.resultset.panel.grouping;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Composite
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCStatistics
;
import
org.jkiss.dbeaver.model.exec.DBCStatistics
;
...
@@ -76,6 +78,13 @@ public class GroupingResultsContainer implements IResultSetContainer {
...
@@ -76,6 +78,13 @@ public class GroupingResultsContainer implements IResultSetContainer {
return
groupFunctions
;
return
groupFunctions
;
}
}
@Nullable
@Override
public
DBPProject
getProject
()
{
DBSDataContainer
dataContainer
=
getDataContainer
();
return
dataContainer
==
null
||
dataContainer
.
getDataSource
()
==
null
?
null
:
dataContainer
.
getDataSource
().
getContainer
().
getProject
();
}
@Override
@Override
public
DBCExecutionContext
getExecutionContext
()
{
public
DBCExecutionContext
getExecutionContext
()
{
return
presentation
.
getController
().
getExecutionContext
();
return
presentation
.
getController
().
getExecutionContext
();
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/references/ReferencesResultsContainer.java
浏览文件 @
76e0c1ab
...
@@ -27,11 +27,13 @@ import org.eclipse.swt.layout.FillLayout;
...
@@ -27,11 +27,13 @@ import org.eclipse.swt.layout.FillLayout;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Composite
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
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.DBIcon
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
...
@@ -107,6 +109,13 @@ class ReferencesResultsContainer implements IResultSetContainer {
...
@@ -107,6 +109,13 @@ class ReferencesResultsContainer implements IResultSetContainer {
return
parentController
.
getActivePresentation
();
return
parentController
.
getActivePresentation
();
}
}
@Nullable
@Override
public
DBPProject
getProject
()
{
DBSDataContainer
dataContainer
=
getDataContainer
();
return
dataContainer
==
null
||
dataContainer
.
getDataSource
()
==
null
?
null
:
dataContainer
.
getDataSource
().
getContainer
().
getProject
();
}
@Override
@Override
public
DBCExecutionContext
getExecutionContext
()
{
public
DBCExecutionContext
getExecutionContext
()
{
return
DBUtils
.
getDefaultContext
(
dataContainer
,
false
);
return
DBUtils
.
getDefaultContext
(
dataContainer
,
false
);
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/dialogs/CursorViewDialog.java
浏览文件 @
76e0c1ab
...
@@ -29,6 +29,7 @@ import org.jkiss.dbeaver.Log;
...
@@ -29,6 +29,7 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.data.DBDCursor
;
import
org.jkiss.dbeaver.model.data.DBDCursor
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.data.DBDDataReceiver
;
import
org.jkiss.dbeaver.model.data.DBDDataReceiver
;
...
@@ -142,6 +143,12 @@ public class CursorViewDialog extends ValueViewDialog implements IResultSetConta
...
@@ -142,6 +143,12 @@ public class CursorViewDialog extends ValueViewDialog implements IResultSetConta
}
}
@Nullable
@Override
public
DBPProject
getProject
()
{
return
getValueController
().
getExecutionContext
().
getDataSource
().
getContainer
().
getProject
();
}
@Override
@Override
public
DBCExecutionContext
getExecutionContext
()
{
public
DBCExecutionContext
getExecutionContext
()
{
return
getValueController
()
==
null
?
null
:
getValueController
().
getExecutionContext
();
return
getValueController
()
==
null
?
null
:
getValueController
().
getExecutionContext
();
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/AbstractDataEditor.java
浏览文件 @
76e0c1ab
...
@@ -28,6 +28,7 @@ import org.jkiss.code.Nullable;
...
@@ -28,6 +28,7 @@ import org.jkiss.code.Nullable;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
...
@@ -115,6 +116,12 @@ public abstract class AbstractDataEditor<OBJECT_TYPE extends DBSObject> extends
...
@@ -115,6 +116,12 @@ public abstract class AbstractDataEditor<OBJECT_TYPE extends DBSObject> extends
super
.
dispose
();
super
.
dispose
();
}
}
@NotNull
@Override
public
DBPProject
getProject
()
{
return
getDatabaseObject
().
getDataSource
().
getContainer
().
getProject
();
}
@Nullable
@Nullable
@Override
@Override
public
ResultSetViewer
getResultSetController
()
public
ResultSetViewer
getResultSetController
()
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/VirtualStructureEditor.java
浏览文件 @
76e0c1ab
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
*/
*/
package
org.jkiss.dbeaver.ui.editors.data
;
package
org.jkiss.dbeaver.ui.editors.data
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.events.SelectionEvent
;
...
@@ -24,12 +26,13 @@ import org.eclipse.swt.layout.GridLayout;
...
@@ -24,12 +26,13 @@ import org.eclipse.swt.layout.GridLayout;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.swt.widgets.*
;
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.*
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
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.runtime.AbstractJob
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntityConstraint
;
import
org.jkiss.dbeaver.model.struct.DBSEntityConstraintType
;
import
org.jkiss.dbeaver.model.struct.DBSEntityConstraintType
;
import
org.jkiss.dbeaver.model.virtual.*
;
import
org.jkiss.dbeaver.model.virtual.*
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
...
@@ -49,8 +52,7 @@ import java.util.stream.Collectors;
...
@@ -49,8 +52,7 @@ import java.util.stream.Collectors;
/**
/**
* VirtualStructureEditor
* VirtualStructureEditor
*/
*/
public
class
VirtualStructureEditor
extends
AbstractDatabaseObjectEditor
<
DBSEntity
>
public
class
VirtualStructureEditor
extends
AbstractDatabaseObjectEditor
<
DBSEntity
>
implements
DBPEventListener
{
{
private
static
final
Log
log
=
Log
.
getLog
(
VirtualStructureEditor
.
class
);
private
static
final
Log
log
=
Log
.
getLog
(
VirtualStructureEditor
.
class
);
private
boolean
activated
;
private
boolean
activated
;
...
@@ -58,9 +60,9 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -58,9 +60,9 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
private
DBSEntity
entity
;
private
DBSEntity
entity
;
private
DBVEntity
vEntity
;
private
DBVEntity
vEntity
;
private
EditDictionaryPage
editDictionaryPage
;
private
EditDictionaryPage
editDictionaryPage
;
private
EditConstraintPage
editUniqueKeyPage
;
private
DBVEntityConstraint
uniqueConstraint
;
private
DBVEntityConstraint
uniqueConstraint
;
private
boolean
fkChanged
=
false
;
private
Table
ukTable
;
private
Table
fkTable
;
@Override
@Override
public
void
createPartControl
(
Composite
parent
)
{
public
void
createPartControl
(
Composite
parent
)
{
...
@@ -72,52 +74,96 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -72,52 +74,96 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
@Override
@Override
public
void
setFocus
()
{
public
void
setFocus
()
{
this
.
parent
.
setFocus
();
}
}
@Override
@Override
public
void
refreshPart
(
Object
source
,
boolean
force
)
{
public
void
refreshPart
(
Object
source
,
boolean
force
)
{
new
AbstractJob
(
"Load logical entity references"
)
{
@Override
protected
IStatus
run
(
DBRProgressMonitor
monitor
)
{
for
(
DBVEntityForeignKey
fk
:
vEntity
.
getForeignKeys
())
{
try
{
fk
.
getRealReferenceConatraint
(
monitor
);
fk
.
getAssociatedEntity
(
monitor
);
}
catch
(
DBException
e
)
{
log
.
debug
(
e
);
}
}
UIUtils
.
asyncExec
(()
->
refreshVisuals
());
return
Status
.
OK_STATUS
;
}
}.
schedule
();
}
private
void
refreshVisuals
()
{
ukTable
.
removeAll
();
try
{
for
(
DBVEntityConstraint
uk
:
vEntity
.
getConstraints
())
{
if
(!
CommonUtils
.
isEmpty
(
uk
.
getAttributes
()))
{
createUniqueKeyItem
(
ukTable
,
uk
);
}
}
}
catch
(
Exception
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Foreign keys"
,
"Error loading virtual unique keys"
,
e
);
}
UIUtils
.
packColumns
(
ukTable
,
true
);
fkTable
.
removeAll
();
try
{
for
(
DBVEntityForeignKey
fk
:
vEntity
.
getForeignKeys
())
{
createForeignKeyItem
(
fkTable
,
fk
);
}
}
catch
(
Exception
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"Foreign keys"
,
"Error loading virtual foreign keys"
,
e
);
}
UIUtils
.
packColumns
(
fkTable
,
true
);
}
}
@Override
@Override
public
void
activatePart
()
{
public
void
activatePart
()
{
if
(!
activated
)
{
if
(!
activated
)
{
createEditorUI
();
createEditorUI
();
refreshPart
(
this
,
true
);
activated
=
true
;
activated
=
true
;
}
}
}
}
private
void
createEditorUI
()
{
@Override
try
{
public
void
dispose
()
{
UIUtils
.
runInProgressService
(
monitor
->
{
if
(
activated
)
{
for
(
DBVEntityForeignKey
fk
:
vEntity
.
getForeignKeys
())
{
DBSEntity
dbObject
=
getDatabaseObject
();
try
{
if
(
dbObject
!=
null
)
{
fk
.
getRealReferenceConatraint
(
monitor
);
DBUtils
.
getObjectRegistry
(
dbObject
).
removeDataSourceListener
(
this
);
fk
.
getAssociatedEntity
(
monitor
);
}
}
catch
(
DBException
e
)
{
log
.
debug
(
e
);
}
}
});
}
catch
(
InvocationTargetException
e
)
{
log
.
error
(
e
.
getTargetException
());
}
catch
(
InterruptedException
e
)
{
// ignore
}
}
super
.
dispose
();
}
Composite
composite
=
UIUtils
.
createComposite
(
parent
,
1
);
private
void
createEditorUI
()
{
Composite
composite
=
UIUtils
.
createComposite
(
parent
,
2
);
((
GridLayout
)
composite
.
getLayout
()).
makeColumnsEqualWidth
=
true
;
((
GridLayout
)
composite
.
getLayout
()).
makeColumnsEqualWidth
=
true
;
Composite
keysComposite
=
UIUtils
.
createComposite
(
composite
,
1
);
keysComposite
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
//createColumnsPage(tabFolder);
//createColumnsPage(tabFolder);
createUniqueKeysPage
(
c
omposite
);
createUniqueKeysPage
(
keysC
omposite
);
createForeignKeysPage
(
c
omposite
);
createForeignKeysPage
(
keysC
omposite
);
//createDictionaryPage(composite);
//createDictionaryPage(composite);
UIUtils
.
createInfoLabel
(
composite
,
"Entity logical structure is defined on client-side."
+
Composite
attrsComposite
=
UIUtils
.
createComposite
(
composite
,
1
);
attrsComposite
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
UIUtils
.
createInfoLabel
(
composite
,
"Entity logical structure exists only on the client-side, not in a real database."
+
"\nYou can define virtual unique/foreign keys even if physical database "
+
"\nYou can define virtual unique/foreign keys even if physical database "
+
"doesn't have or doesn't support them."
,
GridData
.
FILL_HORIZONTAL
,
2
);
"doesn't have or doesn't support them."
,
GridData
.
FILL_HORIZONTAL
,
2
);
parent
.
layout
(
true
,
true
);
parent
.
layout
(
true
,
true
);
DBSEntity
dbObject
=
getDatabaseObject
();
if
(
dbObject
!=
null
)
{
DBUtils
.
getObjectRegistry
(
dbObject
).
addDataSourceListener
(
this
);
}
}
}
private
void
createDictionaryPage
(
TabFolder
tabFolder
)
{
private
void
createDictionaryPage
(
TabFolder
tabFolder
)
{
...
@@ -138,20 +184,13 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -138,20 +184,13 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
}
}
Group
group
=
UIUtils
.
createControlGroup
(
parent
,
"Virtual Unique Keys"
,
1
,
GridData
.
FILL_BOTH
,
SWT
.
DEFAULT
);
Group
group
=
UIUtils
.
createControlGroup
(
parent
,
"Virtual Unique Keys"
,
1
,
GridData
.
FILL_BOTH
,
SWT
.
DEFAULT
);
Table
ukTable
=
new
Table
(
group
,
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
);
ukTable
=
new
Table
(
group
,
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
);
ukTable
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
ukTable
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
ukTable
.
setHeaderVisible
(
true
);
ukTable
.
setHeaderVisible
(
true
);
UIUtils
.
executeOnResize
(
ukTable
,
()
->
UIUtils
.
packColumns
(
ukTable
,
true
));
UIUtils
.
createTableColumn
(
ukTable
,
SWT
.
LEFT
,
"Ref Table"
);
UIUtils
.
createTableColumn
(
ukTable
,
SWT
.
LEFT
,
"Ref Table"
);
UIUtils
.
createTableColumn
(
ukTable
,
SWT
.
LEFT
,
"Columns"
);
UIUtils
.
createTableColumn
(
ukTable
,
SWT
.
LEFT
,
"Columns"
);
for
(
DBVEntityConstraint
uk
:
vEntity
.
getConstraints
())
{
if
(!
CommonUtils
.
isEmpty
(
uk
.
getAttributes
()))
{
createUniqueKeyItem
(
ukTable
,
uk
);
}
}
{
{
Composite
buttonsPanel
=
UIUtils
.
createComposite
(
group
,
3
);
Composite
buttonsPanel
=
UIUtils
.
createComposite
(
group
,
3
);
buttonsPanel
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
buttonsPanel
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
...
@@ -239,30 +278,24 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -239,30 +278,24 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
private
void
createForeignKeysPage
(
Composite
parent
)
{
private
void
createForeignKeysPage
(
Composite
parent
)
{
Group
group
=
UIUtils
.
createControlGroup
(
parent
,
"Virtual Foreign Keys"
,
1
,
GridData
.
FILL_BOTH
,
SWT
.
DEFAULT
);
Group
group
=
UIUtils
.
createControlGroup
(
parent
,
"Virtual Foreign Keys"
,
1
,
GridData
.
FILL_BOTH
,
SWT
.
DEFAULT
);
Table
fkTable
=
new
Table
(
group
,
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
);
fkTable
=
new
Table
(
group
,
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
);
fkTable
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
fkTable
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
fkTable
.
setHeaderVisible
(
true
);
fkTable
.
setHeaderVisible
(
true
);
UIUtils
.
executeOnResize
(
fkTable
,
()
->
UIUtils
.
packColumns
(
fkTable
,
true
));
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"
);
UIUtils
.
createTableColumn
(
fkTable
,
SWT
.
LEFT
,
"Ref Datasource"
);
UIUtils
.
createTableColumn
(
fkTable
,
SWT
.
LEFT
,
"Ref Datasource"
);
for
(
DBVEntityForeignKey
fk
:
vEntity
.
getForeignKeys
())
{
createForeignKeyItem
(
fkTable
,
fk
);
}
{
{
Composite
buttonsPanel
=
UIUtils
.
createComposite
(
group
,
2
);
Composite
buttonsPanel
=
UIUtils
.
createComposite
(
group
,
2
);
buttonsPanel
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
buttonsPanel
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
Button
btnAdd
=
UIUtils
.
createDialogButton
(
buttonsPanel
,
"Add"
,
new
SelectionAdapter
()
{
UIUtils
.
createDialogButton
(
buttonsPanel
,
"Add"
,
new
SelectionAdapter
()
{
@Override
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
public
void
widgetSelected
(
SelectionEvent
e
)
{
DBVEntityForeignKey
virtualFK
=
EditForeignKeyPage
.
createVirtualForeignKey
(
vEntity
);
DBVEntityForeignKey
virtualFK
=
EditForeignKeyPage
.
createVirtualForeignKey
(
vEntity
);
if
(
virtualFK
!=
null
)
{
if
(
virtualFK
!=
null
)
{
createForeignKeyItem
(
fkTable
,
virtualFK
);
createForeignKeyItem
(
fkTable
,
virtualFK
);
fkChanged
=
true
;
}
}
}
}
});
});
...
@@ -278,7 +311,7 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -278,7 +311,7 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
}
}
vEntity
.
removeForeignKey
(
virtualFK
);
vEntity
.
removeForeignKey
(
virtualFK
);
fkTable
.
remove
(
fkTable
.
getSelectionIndices
());
fkTable
.
remove
(
fkTable
.
getSelectionIndices
());
fkChanged
=
true
;
((
Button
)
e
.
widget
).
setEnabled
(
false
)
;
}
}
});
});
btnRemove
.
setEnabled
(
false
);
btnRemove
.
setEnabled
(
false
);
...
@@ -286,8 +319,7 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -286,8 +319,7 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
fkTable
.
addSelectionListener
(
new
SelectionAdapter
()
{
fkTable
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
public
void
widgetSelected
(
SelectionEvent
e
)
{
boolean
hasSelection
=
fkTable
.
getSelectionIndex
()
>=
0
;
btnRemove
.
setEnabled
(
fkTable
.
getSelectionIndex
()
>=
0
);
btnRemove
.
setEnabled
(
hasSelection
);
}
}
});
});
}
}
...
@@ -296,12 +328,12 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -296,12 +328,12 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
private
void
createForeignKeyItem
(
Table
fkTable
,
DBVEntityForeignKey
fk
)
{
private
void
createForeignKeyItem
(
Table
fkTable
,
DBVEntityForeignKey
fk
)
{
TableItem
item
=
new
TableItem
(
fkTable
,
SWT
.
NONE
);
TableItem
item
=
new
TableItem
(
fkTable
,
SWT
.
NONE
);
//item.setImage(0, DBeaverIcons.getImage(DBIcon.TREE_FOREIGN_KEY));
//item.setImage(0, DBeaverIcons.getImage(DBIcon.TREE_FOREIGN_KEY));
DBSEntity
refEntity
=
fk
.
getReferencedConstraint
().
getParentObject
();
DBSEntityConstraint
refConstraint
=
fk
.
getReferencedConstraint
();
DBSEntity
refEntity
=
refConstraint
.
getParentObject
();
item
.
setImage
(
0
,
DBeaverIcons
.
getImage
(
DBIcon
.
TREE_FOREIGN_KEY
));
item
.
setImage
(
0
,
DBeaverIcons
.
getImage
(
DBIcon
.
TREE_FOREIGN_KEY
));
if
(
fk
.
getReferencedConstraint
()
!=
null
)
{
item
.
setText
(
0
,
DBUtils
.
getObjectFullName
(
refEntity
,
DBPEvaluationContext
.
UI
));
item
.
setText
(
0
,
DBUtils
.
getObjectFullName
(
refEntity
,
DBPEvaluationContext
.
UI
));
}
String
ownAttrNames
=
fk
.
getAttributes
().
stream
().
map
(
DBVEntityForeignKeyColumn:
:
getAttributeName
)
String
ownAttrNames
=
fk
.
getAttributes
().
stream
().
map
(
DBVEntityForeignKeyColumn:
:
getAttributeName
)
.
collect
(
Collectors
.
joining
(
","
));
.
collect
(
Collectors
.
joining
(
","
));
String
refAttrNames
=
fk
.
getAttributes
().
stream
().
map
(
DBVEntityForeignKeyColumn:
:
getRefAttributeName
)
String
refAttrNames
=
fk
.
getAttributes
().
stream
().
map
(
DBVEntityForeignKeyColumn:
:
getRefAttributeName
)
...
@@ -352,4 +384,10 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
...
@@ -352,4 +384,10 @@ public class VirtualStructureEditor extends AbstractDatabaseObjectEditor<DBSEnti
attrItem
.
setText
(
2
,
colorSettings
);
attrItem
.
setText
(
2
,
colorSettings
);
}
}
@Override
public
void
handleDataSourceEvent
(
DBPEvent
event
)
{
if
(
event
.
getObject
()
==
vEntity
)
{
UIUtils
.
asyncExec
(()
->
refreshPart
(
event
,
true
));
}
}
}
}
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
浏览文件 @
76e0c1ab
...
@@ -2722,6 +2722,12 @@ public class SQLEditor extends SQLEditorBase implements
...
@@ -2722,6 +2722,12 @@ public class SQLEditor extends SQLEditorBase implements
tabItem
.
setData
(
DATA_PINNED
,
pinned
);
tabItem
.
setData
(
DATA_PINNED
,
pinned
);
}
}
@NotNull
@Override
public
DBPProject
getProject
()
{
return
SQLEditor
.
this
.
getProject
();
}
@Override
@Override
public
DBCExecutionContext
getExecutionContext
()
{
public
DBCExecutionContext
getExecutionContext
()
{
return
SQLEditor
.
this
.
getExecutionContext
();
return
SQLEditor
.
this
.
getExecutionContext
();
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLResultsView.java
浏览文件 @
76e0c1ab
...
@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Composite;
...
@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Composite;
import
org.eclipse.ui.part.ViewPart
;
import
org.eclipse.ui.part.ViewPart
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.app.DBPProject
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
...
@@ -68,6 +69,13 @@ public class SQLResultsView extends ViewPart
...
@@ -68,6 +69,13 @@ public class SQLResultsView extends ViewPart
private
class
DetachedContainer
implements
IResultSetContainer
{
private
class
DetachedContainer
implements
IResultSetContainer
{
private
IResultSetContainer
currentContainer
;
private
IResultSetContainer
currentContainer
;
@Nullable
@Override
public
DBPProject
getProject
()
{
return
currentContainer
==
null
?
null
:
currentContainer
.
getProject
();
}
@Nullable
@Nullable
@Override
@Override
public
DBCExecutionContext
getExecutionContext
()
{
public
DBCExecutionContext
getExecutionContext
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录