Skip to main content



      Home
Home » Modeling » EMF » Forbid users from creating and deleting EClasses
Forbid users from creating and deleting EClasses [message #1860659] Thu, 24 August 2023 05:13 Go to next message
Eclipse UserFriend
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 10:19 Go to previous messageGo to next message
Eclipse UserFriend
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...
Re: Forbid users from creating and deleting EClasses [message #1860806 is a reply to message #1860668] Mon, 04 September 2023 03:51 Go to previous messageGo to next message
Eclipse UserFriend
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 08:30 Go to previous message
Eclipse UserFriend
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
Previous Topic:How to use tycho plugin
Next Topic:Create Ecore Modelling Project programmatically
Goto Forum:
  


Current Time: Sun Aug 31 10:45:09 EDT 2025

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

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

Back to the top