Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Delete Element - also delete Table in MySQL
Delete Element - also delete Table in MySQL [message #671965] Thu, 19 May 2011 13:28 Go to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
Hi there,

my elemetents represent tables in a MySQL-database. So when I delete an element (via [DEL] or Menu->Delete From Model) the tabel should also be dropped in the databse. So that the table also is dropped is working. But I wrote the code in the DeleteElementAction in the package diagram.part. But now the table is always dropped when I select the node. So where do I have to write the code, that it is only deleted when it's supposed to?

Thanks in advance.
Re: Delete Element - also delete Table in MySQL [message #672187 is a reply to message #671965] Fri, 20 May 2011 09:04 Go to previous messageGo to next message
AlexejS Mising name is currently offline AlexejS Mising name
Messages: 25
Registered: May 2010
Junior Member
Hi,

you can add an Command which extends an AbstractTransactionalCommand in XXXItemSemanticEditPolicy

for example AfterElementDeleteCommand extends AbstractTransactionalCommand {
...
	@Override
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
			IAdaptable info) throws ExecutionException {
                  //add here your mysql code
        }


and then add this command to


protected Command getDestroyElementCommand(DestroyElementRequest req) {

		View view = (View) getHost().getModel();
		CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
				getEditingDomain(), null);
		cmd.setTransactionNestingEnabled(false);

cmd.add(new AfterElementDeleteCommand(getEditingDomain(), "delte", null, (IGraphicalEditPart) getHost()));



[Updated on: Fri, 20 May 2011 09:06]

Report message to a moderator

Re: Delete Element - also delete Table in MySQL [message #673682 is a reply to message #672187] Tue, 24 May 2011 13:11 Go to previous message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
Thanks for your reply. But that leads me to another question. How do I pass the editPart throught the XXXSemanticEditPolicy to my XXXDeleteCommand?

Thanks in advance.
Previous Topic:Redundant space in compartments
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Sep 19 21:57:14 GMT 2014

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

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