/* * (non-Javadoc) * @see org.eclipse.emf.henshin.interpreter.UnitApplication#execute(org.eclipse.emf.henshin.interpreter.ApplicationMonitor) */ @Override public boolean execute(ApplicationMonitor monitor) { if (unit == null) { throw new NullPointerException("No transformation unit set"); } // Already executed? if (isExecuted) { if (isCompleteMatchDerived) { completeMatch = null; // reset the complete match if it was derived isCompleteMatchDerived = false; } isExecuted = false; isUndone = false; change = null; resultMatch = null; } // Do we need to derive a complete match? if (completeMatch == null) { completeMatch = engine.findMatches((Rule) unit, graph, partialMatch).iterator().next(); isCompleteMatchDerived = true; } if (completeMatch == null) { if (monitor != null) { monitor.notifyExecute(this, false); } return false; } resultMatch = new MatchImpl((Rule) unit, true); change = engine.createChange((Rule) unit, graph, completeMatch, resultMatch); if (change == null) { if (monitor != null) { monitor.notifyExecute(this, false); } return false; } change.applyAndReverse(); isExecuted = true; if (monitor != null) { monitor.notifyExecute(this, true); } return true; }
/* * (non-Javadoc) * @see org.eclipse.emf.henshin.interpreter.UnitApplication#redo(org.eclipse.emf.henshin.interpreter.ApplicationMonitor) */ public boolean redo(ApplicationMonitor monitor) { boolean success = false; if (isExecuted && isUndone) { change.applyAndReverse(); isUndone = false; success = true; } if (monitor != null) { monitor.notifyUndo(this, success); } return success; }