Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Forbid users from creating and deleting EClasses
Forbid users from creating and deleting EClasses [message #1860659] Thu, 24 August 2023 09:13 Go to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi,

Is it possible to forbid users in an EMF tree based editor to create and to delete a particular EClass? Would I have to customise the ClassItemProvider.java to do that? Do you have any tutorial or tips on how to do that?

Thanks!
Re: Forbid users from creating and deleting EClasses [message #1860668 is a reply to message #1860659] Thu, 24 August 2023 14:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
When you talk about create/delete an EClass I assume you mean create/delete an instance of some EClass, not something you're trying to restrict in the Ecore editor itself.

Yes, generally you're going to have to specialize something. Creation is generally supported anywhere there is a containment reference that supports the given EClass as an instance so you could specialize the container's item provider, in their collectNewChildDescriptors(Collection<Object>, Object) method. Also, in the container item providers, you could specialize ItemProviderAdapter.createRemoveCommand(EditingDomain, EObject, EStructuralFeature, Collection<?>)to refuse to remove certain types of object. In general, you can track down such places using the debugger how the actions are created and what they do when invoked...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Forbid users from creating and deleting EClasses [message #1860806 is a reply to message #1860668] Mon, 04 September 2023 07:51 Go to previous messageGo to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi Ed,

Thanks for that. All worked perfectly. However, this is something I need to do for multiple editors. Is there a way to access the code that generates the editor itself? So that I can customise that code instead and generate the editor according to my requirements?

Thanks!
Re: Forbid users from creating and deleting EClasses [message #1860812 is a reply to message #1860806] Mon, 04 September 2023 12:30 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
You changes the editor rather than the item providers? In general you can use dynamic templates (specialized templates), but then you have to maintain that too/instead:

https://wiki.eclipse.org/EMF/FAQ#What_are_Dynamic_Templates.3F


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to use tycho plugin
Next Topic:Relation doesn't exists when executing CDOServerUtil.addRepository()
Goto Forum:
  


Current Time: Thu May 02 03:55:25 GMT 2024

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

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

Back to the top