Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
7f80f42e
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,发现更多精彩内容 >>
提交
7f80f42e
编写于
4月 25, 2021
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dbeaver/dbeaver-ee#587 ERD editor context menu improvements. Object create handlers refactoring.
上级
cd93dd0b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
49 addition
and
31 deletion
+49
-31
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+0
-6
plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/erd/ui/editor/ERDEditorContextMenuProvider.java
...s/dbeaver/erd/ui/editor/ERDEditorContextMenuProvider.java
+18
-16
plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/erd/ui/editor/ERDEditorPart.java
...ui/src/org/jkiss/dbeaver/erd/ui/editor/ERDEditorPart.java
+1
-1
plugins/org.jkiss.dbeaver.ui.navigator/plugin.xml
plugins/org.jkiss.dbeaver.ui.navigator/plugin.xml
+1
-1
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/actions/ObjectPropertyTester.java
...rc/org/jkiss/dbeaver/ui/actions/ObjectPropertyTester.java
+3
-2
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerCreateColumnObjectBase.java
...gator/actions/NavigatorHandlerCreateColumnObjectBase.java
+1
-2
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectCreateNew.java
...ui/navigator/actions/NavigatorHandlerObjectCreateNew.java
+25
-3
未找到文件。
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
7f80f42e
...
...
@@ -38,12 +38,6 @@
namespace=
"org.jkiss.dbeaver.core.global"
properties=
"standalone,hasActiveProject,hasMultipleProjects"
type=
"java.lang.Object"
/>
<propertyTester
class=
"org.jkiss.dbeaver.ui.actions.ObjectPropertyTester"
id=
"org.jkiss.dbeaver.ui.actions.ObjectPropertyTester"
namespace=
"org.jkiss.dbeaver.core.object"
properties=
"canOpen,canCreate,canPaste,canDelete,canRename,canMoveUp,canMoveDown,canFilter,canFilterObject,hasFilter"
type=
"org.jkiss.dbeaver.model.navigator.DBNNode"
/>
<propertyTester
class=
"org.jkiss.dbeaver.ui.actions.DataSourcePropertyTester"
id=
"org.jkiss.dbeaver.ui.actions.DataSourcePropertyTester"
...
...
plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/erd/ui/editor/ERDEditorContextMenuProvider.java
浏览文件 @
7f80f42e
...
...
@@ -19,11 +19,8 @@
*/
package
org.jkiss.dbeaver.erd.ui.editor
;
import
org.eclipse.gef.ContextMenuProvider
;
import
org.eclipse.gef.ui.actions.GEFActionConstants
;
import
org.eclipse.jface.action.GroupMarker
;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.jface.action.*
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.ui.IWorkbenchActionConstants
;
...
...
@@ -34,7 +31,7 @@ import org.jkiss.dbeaver.ui.navigator.NavigatorCommands;
/**
* Provides a context menu for the schema diagram editor. A virtual cut and paste from the flow example
*/
public
class
ERDEditorContextMenuProvider
extends
ContextMenuProvid
er
{
public
class
ERDEditorContextMenuProvider
extends
MenuManager
implements
IMenuListen
er
{
private
ERDEditorPart
editor
;
/**
...
...
@@ -44,16 +41,24 @@ public class ERDEditorContextMenuProvider extends ContextMenuProvider {
* @param editor the editor
*/
ERDEditorContextMenuProvider
(
ERDEditorPart
editor
)
{
super
(
editor
.
getViewer
()
);
super
(
"ERD Editor Context Menu"
,
"#ERDEditorContext"
);
this
.
editor
=
editor
;
this
.
addMenuListener
(
this
);
this
.
setRemoveAllWhenShown
(
true
);
editor
.
getEditorSite
().
registerContextMenu
(
"#ERDEditorContext"
,
this
,
editor
.
getEditorSite
().
getSelectionProvider
(),
false
);
}
/**
* @see ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
p
ublic
void
buildContextMenu
(
IMenuManager
menu
)
{
public
void
menuAboutToShow
(
IMenuManager
menu
)
{
this
.
buildContextMenu
(
menu
);
}
p
rivate
void
buildContextMenu
(
IMenuManager
menu
)
{
if
(
editor
.
isLoaded
())
{
menu
.
add
(
new
Separator
(
IWorkbenchActionConstants
.
M_EDIT
));
ISelection
selection
=
editor
.
getGraphicalViewer
().
getSelection
();
if
(!
selection
.
isEmpty
()
&&
selection
instanceof
IStructuredSelection
)
{
editor
.
fillPartContextMenu
(
menu
,
(
IStructuredSelection
)
selection
);
...
...
@@ -69,18 +74,15 @@ public class ERDEditorContextMenuProvider extends ContextMenuProvider {
menu
.
add
(
new
Separator
(
GEFActionConstants
.
GROUP_COPY
));
//menu.add(ActionUtils.makeCommandContribution(editor.getSite(), IWorkbenchCommandConstants.EDIT_COPY));
menu
.
add
(
new
Separator
(
GEFActionConstants
.
GROUP_PRINT
));
menu
.
add
(
new
Separator
(
GEFActionConstants
.
GROUP_EDIT
));
menu
.
add
(
new
Separator
(
GEFActionConstants
.
GROUP_VIEW
));
menu
.
add
(
new
Separator
(
GEFActionConstants
.
GROUP_FIND
));
menu
.
add
(
new
Separator
(
GEFActionConstants
.
GROUP_REST
));
menu
.
add
(
new
Separator
(
GEFActionConstants
.
GROUP_SAVE
));
menu
.
add
(
new
Separator
());
menu
.
add
(
new
GroupMarker
(
NavigatorCommands
.
GROUP_TOOLS
));
menu
.
add
(
new
GroupMarker
(
NavigatorCommands
.
GROUP_NAVIGATOR_ADDITIONS
));
menu
.
add
(
new
GroupMarker
(
NavigatorCommands
.
GROUP_NAVIGATOR_ADDITIONS_END
));
//
menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS));
//
menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS_END));
menu
.
add
(
new
GroupMarker
(
IWorkbenchActionConstants
.
MB_ADDITIONS
));
menu
.
add
(
new
GroupMarker
(
IActionConstants
.
MB_ADDITIONS_END
));
...
...
plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/erd/ui/editor/ERDEditorPart.java
浏览文件 @
7f80f42e
...
...
@@ -409,7 +409,7 @@ public abstract class ERDEditorPart extends GraphicalEditorWithFlyoutPalette
viewer
.
setContents
(
new
EntityDiagram
(
null
,
"empty"
,
getContentProvider
(),
getDecorator
()));
// Set context menu
ContextMenuProvider
provider
=
new
ERDEditorContextMenuProvider
(
this
);
ERDEditor
ContextMenuProvider
provider
=
new
ERDEditorContextMenuProvider
(
this
);
viewer
.
setContextMenu
(
provider
);
IWorkbenchPartSite
site
=
getSite
();
if
(
site
instanceof
IEditorSite
)
{
...
...
plugins/org.jkiss.dbeaver.ui.navigator/plugin.xml
浏览文件 @
7f80f42e
...
...
@@ -117,7 +117,7 @@
id=
"org.jkiss.dbeaver.ui.actions.ObjectPropertyTester"
namespace=
"org.jkiss.dbeaver.core.object"
properties=
"canOpen,canCreateSingle,canCreateMulti,canPaste,canDelete,canRename,canMoveUp,canMoveDown,canFilter,canFilterObject,hasFilter,supportsIndexCreate,supportsConstraintCreate"
type=
"org.jkiss.dbeaver.model.
navigator.DBNNode
"
/>
type=
"org.jkiss.dbeaver.model.
DBPNamedObject
"
/>
<propertyTester
class=
"org.jkiss.dbeaver.ui.navigator.ResourcePropertyTester"
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/actions/ObjectPropertyTester.java
浏览文件 @
7f80f42e
...
...
@@ -32,6 +32,7 @@ import org.jkiss.dbeaver.registry.ObjectManagerRegistry;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.ActionUtils
;
import
org.jkiss.dbeaver.ui.navigator.actions.NavigatorHandlerObjectCreateNew
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
java.util.List
;
...
...
@@ -66,14 +67,14 @@ public class ObjectPropertyTester extends PropertyTester
@Override
public
boolean
test
(
Object
receiver
,
String
property
,
Object
[]
args
,
Object
expectedValue
)
{
if
(!(
receiver
instanceof
DBNNode
))
{
DBNNode
node
=
RuntimeUtils
.
getObjectAdapter
(
receiver
,
DBNNode
.
class
);
if
(
node
==
null
)
{
return
false
;
}
Display
display
=
Display
.
getCurrent
();
if
(
display
==
null
)
{
return
false
;
}
DBNNode
node
=
(
DBNNode
)
receiver
;
//System.out.println("TEST " + property + " ON " + node.getName());
switch
(
property
)
{
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerCreateColumnObjectBase.java
浏览文件 @
7f80f42e
...
...
@@ -31,7 +31,6 @@ import org.jkiss.dbeaver.model.struct.DBSEntityAttribute;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.navigator.NavigatorUtils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Collections
;
...
...
@@ -40,7 +39,7 @@ public abstract class NavigatorHandlerCreateColumnObjectBase extends NavigatorHa
private
static
final
Log
log
=
Log
.
getLog
(
NavigatorHandlerCreateColumnObjectBase
.
class
);
static
Object
createColumnObject
(
@NotNull
ExecutionEvent
event
,
@NotNull
Class
<?>
columnObjectSuperType
)
{
DBNNode
node
=
Navigator
Utils
.
getSelectedNode
(
HandlerUtil
.
getCurrentSelection
(
event
));
DBNNode
node
=
Navigator
HandlerObjectCreateNew
.
getNodeFromSelection
(
HandlerUtil
.
getCurrentSelection
(
event
));
if
(!(
node
instanceof
DBNDatabaseItem
))
{
log
.
error
(
"Selected node is not a database item"
);
return
null
;
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectCreateNew.java
浏览文件 @
7f80f42e
...
...
@@ -25,6 +25,8 @@ import org.eclipse.core.resources.IResource;
import
org.eclipse.jface.action.IContributionItem
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.ISelectionProvider
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.osgi.util.NLS
;
import
org.eclipse.ui.*
;
import
org.eclipse.ui.actions.CompoundContributionItem
;
...
...
@@ -54,6 +56,7 @@ import org.jkiss.dbeaver.ui.UIUtils;
import
org.jkiss.dbeaver.ui.internal.UINavigatorMessages
;
import
org.jkiss.dbeaver.ui.navigator.NavigatorCommands
;
import
org.jkiss.dbeaver.ui.navigator.NavigatorUtils
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
...
...
@@ -78,7 +81,12 @@ public class NavigatorHandlerObjectCreateNew extends NavigatorHandlerObjectCreat
boolean
isFolder
=
CommonUtils
.
toBoolean
(
event
.
getParameter
(
NavigatorCommands
.
PARAM_OBJECT_TYPE_FOLDER
));
final
ISelection
selection
=
HandlerUtil
.
getCurrentSelection
(
event
);
DBNNode
node
=
NavigatorUtils
.
getSelectedNode
(
selection
);
if
(
selection
.
isEmpty
())
{
return
null
;
}
DBNNode
node
=
getNodeFromSelection
(
selection
);
if
(
node
!=
null
)
{
Class
<?>
newObjectType
=
null
;
if
(
objectType
!=
null
)
{
...
...
@@ -112,6 +120,16 @@ public class NavigatorHandlerObjectCreateNew extends NavigatorHandlerObjectCreat
return
null
;
}
@Nullable
static
DBNNode
getNodeFromSelection
(
ISelection
selection
)
{
DBNNode
node
=
null
;
if
(
selection
instanceof
IStructuredSelection
&&
!
selection
.
isEmpty
())
{
Object
selectedObject
=
((
IStructuredSelection
)
selection
).
getFirstElement
();
node
=
RuntimeUtils
.
getObjectAdapter
(
selectedObject
,
DBNNode
.
class
);
}
return
node
;
}
@Override
public
void
updateElement
(
UIElement
element
,
Map
parameters
)
{
...
...
@@ -127,7 +145,11 @@ public class NavigatorHandlerObjectCreateNew extends NavigatorHandlerObjectCreat
Object
objectIcon
=
parameters
.
get
(
NavigatorCommands
.
PARAM_OBJECT_TYPE_ICON
);
if
(
typeName
==
null
)
{
// Try to get type from active selection
DBNNode
node
=
NavigatorUtils
.
getSelectedNode
(
element
);
ISelectionProvider
selectionProvider
=
UIUtils
.
getSelectionProvider
(
element
.
getServiceLocator
());
if
(
selectionProvider
==
null
)
{
return
;
}
DBNNode
node
=
getNodeFromSelection
(
selectionProvider
.
getSelection
());
if
(
node
!=
null
&&
!
node
.
isDisposed
())
{
List
<
IContributionItem
>
actions
=
fillCreateMenuItems
(
workbenchWindow
.
getActivePage
().
getActivePart
().
getSite
(),
node
);
for
(
IContributionItem
item
:
actions
)
{
...
...
@@ -418,7 +440,7 @@ public class NavigatorHandlerObjectCreateNew extends NavigatorHandlerObjectCreat
return
EMPTY_MENU
;
}
IWorkbenchPartSite
site
=
activePart
.
getSite
();
DBNNode
node
=
NavigatorUtils
.
getSelectedNode
(
site
.
getSelectionProvider
());
DBNNode
node
=
getNodeFromSelection
(
site
.
getSelectionProvider
().
getSelection
());
List
<
IContributionItem
>
createActions
=
fillCreateMenuItems
(
site
,
node
);
return
createActions
.
toArray
(
new
IContributionItem
[
0
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录