Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to make an element undeletable
how to make an element undeletable [message #538534] Mon, 07 June 2010 21:38 Go to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
For some reasons I want to make one element non deletable once created,
Is there a way to do that ?
Re: how to make an element undeletable [message #538545 is a reply to message #538534] Mon, 07 June 2010 22:17 Go to previous messageGo to next message
Axel Guckelsberger is currently offline Axel GuckelsbergerFriend
Messages: 354
Registered: July 2009
Senior Member
Hi,

you can try to override the getDestroyElementCommand() method of the
ItemSemanticEditPolicy of the corresponding node edit parts.

protected Command getDestroyElementCommand(DestroyElementRequest req) {
return UnexecutableCommand.INSTANCE;
}

For links use getDestroyReferenceCommand() accordingly. Note that this
includes that the parent edit part can not be deleted, too.

Maybe you need to additionally install another policy to prevent deletion by
the del key also:
installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() {
protected Command getDeleteCommand(GroupRequest request) {
return null;
}
});


HTH
Axel


bachra04 wrote:

> For some reasons I want to make one element non deletable once created,
> Is there a way to do that ?
Re: how to make an element undeletable [message #538856 is a reply to message #538545] Tue, 08 June 2010 19:44 Go to previous messageGo to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
I tried but I had the following compile error:

Type mismatch: cannot convert from UnexecutableCommand to Command
even casting does not work.

Any idea ?
Re: how to make an element undeletable [message #539109 is a reply to message #538534] Wed, 09 June 2010 16:04 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

be careful with command: some are emf, other gef or gmf. So check carefully the right type of the UnexecutableCommand

Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: how to make an element undeletable [message #539162 is a reply to message #538534] Wed, 09 June 2010 19:40 Go to previous messageGo to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
Thanks Aurelien,
I tried it and works perfectly.
Re: how to make an element undeletable [message #539450 is a reply to message #539162] Thu, 10 June 2010 18:32 Go to previous messageGo to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
I have one problem when deleting using the key:
THE element itself is not deleted but its children were deleted.
Re: how to make an element undeletable [message #539997 is a reply to message #539450] Mon, 14 June 2010 14:26 Go to previous messageGo to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
Now it works fine.
But I need to make the Delete from Model popup menu disabled for this element. Any idea on how to do that ?

Thanks
Re: how to make an element undeletable [message #540025 is a reply to message #538534] Mon, 14 June 2010 15:54 Go to previous message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
I have found the answer through this good link:
http://www.jlab.net/Jboard11/JBoard.jsp?action=read&inde x=610&page=2&tale=0&tablename=eclipsedev&way =0&maxrow=18&searchtype=&keyword=&category=
Previous Topic:Migration to GMF 2.3: issue with Editpolicy and move/reparent
Next Topic:Exceptions with Palette since 3.6 RC3
Goto Forum:
  


Current Time: Sat Jul 27 14:56:12 GMT 2024

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

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

Back to the top