Getting Undone proposal applications (from quick fix) using IOperationHistoryListener [message #769007] |
Wed, 21 December 2011 08:33 |
Kivanc Muslu Messages: 153 Registered: November 2010 |
Senior Member |
|
|
Hi all,
I am using IOperationHistoryListener as follows:
public class ObservationOperationHistoryListener implements IOperationHistoryListener
{
public void historyNotification(OperationHistoryEvent event)
{
IUndoableOperation op = event.getOperation();
if (op instanceof TriggeredOperations)
op = ((TriggeredOperations) op).getTriggeringOperation();
UndoableOperation2ChangeAdapter changeOperation = null;
if (op instanceof UndoableOperation2ChangeAdapter)
changeOperation = (UndoableOperation2ChangeAdapter) op;
if (changeOperation == null)
return;
Change change = changeOperation.getChange();
if (change == null)
return;
String changeName = change.getName();
switch (event.getEventType())
{
case OperationHistoryEvent.ABOUT_TO_EXECUTE:
break;
case OperationHistoryEvent.ABOUT_TO_UNDO:
break;
case OperationHistoryEvent.ABOUT_TO_REDO:
break;
case OperationHistoryEvent.DONE:
break;
case OperationHistoryEvent.UNDONE:
//Proposal undone detected. Do something with the change.
break;
case OperationHistoryEvent.REDONE:
break;
case OperationHistoryEvent.OPERATION_NOT_OK:
break;
case OperationHistoryEvent.OPERATION_ADDED:
break;
case OperationHistoryEvent.OPERATION_REMOVED:
break;
}
}
}
I have a problem with the following:
Consider the following two scenarios:
1-) The user invokes quick fix, selects a proposal, invokes another quick fix, selects a proposal, undoes (ctrl+z), undoes.
In this case, I can successfully get all undo events as proposal undo events (with the above code)
2-) The user invokes a quick fix, selects a proposal, invokes another quick fix, select a proposal, puts a whitespace somewhere, undoes (white space), undoes (second proposal application), undoes (first proposal application).
In this case, all undo events are degraded down to basic typing events and I cannot detect the last two undoes (with the above code). Basically the whitespace at the end breaks everything!
My question: Why does the event type for the first two proposal applications change when the user adds a whitespace at the end? am I getting something wrong?
Second question: Is there a better (or easier) way to detect undone proposal applications. Note that I don't need to detect anything else but only proposal applications?
Third question: (If the answer to the second one is no) Is there a way to detect all undos as textual diffs? If this is possible, I guess I could also compare this diff with the latest proposal application diff to see if they are equal (and maybe write my own undo detector).
Thanks in advance, best regards,
|
|
|
Powered by
FUDForum. Page generated in 0.02462 seconds