Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF Command(Transaction is already closed problem)
GMF Command [message #1186904] Thu, 14 November 2013 23:21 Go to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Hi all,

When my model changed i want to delete its childs from diagram and emf so i write;

	/**
	 * @not generated
	 */
	@Override
	public void handleNotificationEvent(Notification notification) {
		if (notification.getNotifier() instanceof Grid)
			switch (notification.getFeatureID(Grid.class)) {
			case FormPackage.GRID__CONTENT_FIELD:
				Grid grid = (Grid) notification.getNotifier();

				if (grid.getColumns() != null && !grid.getColumns().isEmpty()) {
					CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
							getEditingDomain(), null);
					cmd.setTransactionNestingEnabled(false);
					for (int i = 0; i < grid.getColumns().size(); i++) {				
						GridColumn column = (GridColumn) grid.getColumns().get(
								i);	
						
						DestroyElementRequest request = new DestroyElementRequest 
								(column, false);
					
						cmd.add(new DestroyElementCommand(request));
					}
					getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(cmd));	
				}
				refreshVisuals();
				break;
			}
		super.handleNotificationEvent(notification);
	}


this handleNotificationEvent but i always get error but dont understand why this code don't work. Anyone can help me ?

Caused by: java.lang.IllegalStateException: Transaction is already closed
	at org.eclipse.emf.transaction.impl.TransactionImpl.rollback(TransactionImpl.java:533)
	at org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory$DiagramEditingDomain.postcommit(DiagramEditingDomainFactory.java:223)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
	at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
	at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:155)
	at org.eclipse.core.commands.operations.TriggeredOperations.execute(TriggeredOperations.java:166)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513) ...


Regards

[Updated on: Thu, 14 November 2013 23:51]

Report message to a moderator

Re: GMF Command [message #1200447 is a reply to message #1186904] Thu, 21 November 2013 08:45 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

did you try using a EMF Delete or Remove Command? (http://download.eclipse.org/modeling/emf/emf/javadoc/2.4.2/org/eclipse/emf/edit/command/DeleteCommand.html)

Ralph
Previous Topic:How to implement something like gantt chart using GMF?
Next Topic:Reducing 2 Palette Tools to 1 Tool
Goto Forum:
  


Current Time: Thu Jun 04 08:53:29 GMT 2020

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

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

Back to the top