How to implement the undo&redo functions? [message #1014598] |
Tue, 26 February 2013 06:04 |
sakop qq Messages: 29 Registered: January 2013 |
Junior Member |
|
|
Hi,I am a newbie to Graphiti.
Last week,I finished the tutorial part by follwing the contents attached to the eclipse "help" menu.
However, there are still a big problem that is still haunting me,as the tutorial says nothing about this topic
How to implement "undo" and "redo" functions?
I tried to wrap several modifications into one RecordingCommand and invoked
command.execute(),the shape was drawn on the panel without any exception.
However,when I pressed "Ctrl+Z", an exception was thrown:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:348)
Below is the code of assertWriting,the first time tx is a valid object,however,it becomes null the second time this code is executed.
protected void assertWriting() {
InternalTransaction tx = domain.getActiveTransaction();
if ((tx == null) || tx.isReadOnly() || (tx.getOwner() != Thread.currentThread())) {
synchronized (domain) {
tx = domain.getActiveTransaction();
// the transaction could be null now if it completed before we
// synchronized on the domain
if (tx != null) {
tx.abort(new Status(
IStatus.ERROR,
EMFTransactionPlugin.getPluginId(),
EMFTransactionStatusCodes.CONCURRENT_WRITE,
Messages.concurrentWrite,
null));
}
}
IllegalStateException ise = new IllegalStateException(
Messages.noWriteTx);
Tracing.throwing(TransactionChangeRecorder.class, "assertWriting", ise); //$NON-NLS-1$
throw ise;
}
}
Can sb tell me how to do it(any simple examples will be fully appreciated!) or give a link to a more detailed tutorial.
Thanks!
[Updated on: Tue, 26 February 2013 07:41] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.12018 seconds