Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » ContextMenu
ContextMenu [message #1778081] Sat, 09 December 2017 10:44 Go to next message
xi yahui is currently offline xi yahuiFriend
Messages: 32
Registered: October 2017
Member
How to remove the "remove" and "update" menu in the contextmenu?
Re: ContextMenu [message #1778140 is a reply to message #1778081] Mon, 11 December 2017 08:41 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
These entries are added automatically by the framework in DiagramEditorContextMenuProvider.addDefaultMenuGroupRest if an action for them is available in the tool.

So one option would be to remove the actions in DiagramEditorActionBarContributor, the other to provide your own context menu provider (as subclass of DiagramEditorContextMenuProvider) in DiagramBehavior.createContextMenuProvider.

Michael
Re: ContextMenu [message #1778219 is a reply to message #1778140] Tue, 12 December 2017 06:07 Go to previous messageGo to next message
xi yahui is currently offline xi yahuiFriend
Messages: 32
Registered: October 2017
Member
I hope to create mine context menu provider. I must modify the createContextMenuProvider in DiagramBehavior. But I don't want to modify the DiagramBehavior.java. Can i create a new DiagramBehavior as subclass of DiagramBehavior? Where should I put the new DiagramBehavior ?
Re: ContextMenu [message #1778248 is a reply to message #1778219] Tue, 12 December 2017 10:16 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Yes, you will need to create a subclass of DiagramBehavior and just override createContextMenuProvider. The creation of that class needs to happen in your own subclass of DiagramEditor (method createDiagramBehavior).

HTH,
Michael
Re: ContextMenu [message #1778255 is a reply to message #1778248] Tue, 12 December 2017 11:18 Go to previous messageGo to next message
xi yahui is currently offline xi yahuiFriend
Messages: 32
Registered: October 2017
Member
Does the DiagramEditor use the extension point org.eclipse.ui.editors in plugin.xml?
Can I override the isAvailable method in updatefeature and RemoveFeature?
@Override
public IRemoveFeature getRemoveFeature(IRemoveContext context) {
return new DefaultRemoveFeature(this) {
@Override
public boolean isAvailable(IContext context) {
return false;
}

};
}
Another one:
How can I remove or disable the align top, align middle in edit menu?

[Updated on: Tue, 12 December 2017 12:34]

Report message to a moderator

Re: ContextMenu [message #1778322 is a reply to message #1778255] Wed, 13 December 2017 07:38 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Not sure what exactly you mean with "use", but the DiagramEditor class (or its subclass) needs to be registered for your file extension in plugin.xml.

Surely you can override the isAvailable method. Not sure what you intend to do, in case it is for trying to remove the feature from the context menu, I do not think that will help.

In general you can remove menu entries by removing their actions in DiagramEditorActionBarContributor (or rather your subclass of it, remember to register it together with your DiagramEditor in plugin.xml).

HTH,
Michael
Re: ContextMenu [message #1778409 is a reply to message #1778322] Thu, 14 December 2017 01:50 Go to previous message
xi yahui is currently offline xi yahuiFriend
Messages: 32
Registered: October 2017
Member
Thanks Michael
Previous Topic:Internationalization of Graphiti Components
Next Topic:How to prevent the selection of Shape
Goto Forum:
  


Current Time: Fri Apr 19 00:03:54 GMT 2024

Powered by FUDForum. Page generated in 0.02282 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top