@Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { InstallableUnitBuilder iu = ((InstallableUnitEditor) m_formPage.getEditor()).getInstallableUnit(); if (m_add) iu.removeArtifactKey(m_artifact); else iu.addArtifactKey(m_artifact, m_index); updatePageState(!m_add); if (monitor != null) monitor.done(); return Status.OK_STATUS; }
/** * Method common to both add and remove. Operation can be undone. * * @param artifact what to add or remove * @param add true if required should be added, false to remove */ private void addRemove(ArtifactKeyBuilder artifact, boolean add) { FormToolkit toolkit = m_formPage.getManagedForm().getToolkit(); if (toolkit instanceof IUndoOperationSupport) { AddRemoveOperation op = new AddRemoveOperation(artifact, add); op.addContext(((IUndoOperationSupport) toolkit).getUndoContext()); try { ((IUndoOperationSupport) toolkit).getOperationHistory().execute(op, null, null); } catch (ExecutionException e) { // TODO Proper logging e.printStackTrace(); } } else { // without undo support - just add it... (should not happen) InstallableUnitBuilder iu = ((InstallableUnitEditor) m_formPage.getEditor()).getInstallableUnit(); iu.addArtifactKey(artifact); } }