Lines 37-43
Link Here
|
37 |
* @since 3.1 |
37 |
* @since 3.1 |
38 |
*/ |
38 |
*/ |
39 |
public final class TriggeredOperations extends AbstractOperation implements |
39 |
public final class TriggeredOperations extends AbstractOperation implements |
40 |
ICompositeOperation, IAdvancedUndoableOperation { |
40 |
ICompositeOperation, IAdvancedUndoableOperation, IContextReplacingOperation { |
41 |
|
41 |
|
42 |
private IUndoableOperation triggeringOperation; |
42 |
private IUndoableOperation triggeringOperation; |
43 |
|
43 |
|
Lines 374-378
Link Here
|
374 |
return Status.OK_STATUS; |
374 |
return Status.OK_STATUS; |
375 |
|
375 |
|
376 |
} |
376 |
} |
|
|
377 |
|
378 |
/** |
379 |
* Replace the undo context of the receiver with the provided replacement |
380 |
* undo context. In the case of triggered operations, all contained operations |
381 |
* are checked and any occurrence of the original context is replaced with the |
382 |
* new undo context. |
383 |
* <p> |
384 |
* This message has no effect if the original undo context is not present in |
385 |
* the receiver. |
386 |
* |
387 |
* @param original the undo context which is to be replaced |
388 |
* @param replacement the undo context which is replacing the original |
389 |
* |
390 |
*/ |
391 |
public void replaceContext(IUndoContext original, IUndoContext replacement) { |
392 |
|
393 |
// first check the triggering operation |
394 |
if (triggeringOperation != null && triggeringOperation.hasContext(original)) { |
395 |
if (triggeringOperation instanceof IContextReplacingOperation) { |
396 |
((IContextReplacingOperation)triggeringOperation).replaceContext(original, replacement); |
397 |
} else { |
398 |
triggeringOperation.removeContext(original); |
399 |
triggeringOperation.addContext(replacement); |
400 |
} |
401 |
} |
402 |
// Now check all the children |
403 |
for (int i = 0; i < children.size(); i++) { |
404 |
IUndoableOperation child = (IUndoableOperation) children.get(i); |
405 |
if (child.hasContext(original)) { |
406 |
if (child instanceof IContextReplacingOperation) { |
407 |
((IContextReplacingOperation)child).replaceContext(original, replacement); |
408 |
} else { |
409 |
child.removeContext(original); |
410 |
child.addContext(replacement); |
411 |
} |
412 |
} |
413 |
} |
414 |
recomputeContexts(); |
415 |
} |
377 |
|
416 |
|
378 |
} |
417 |
} |