| /******************************************************************************* |
| * Copyright (c) 2010, 2011 Obeo. |
| |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Obeo - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.mylyn.docs.intent.client.ui.editor.quickfix; |
| |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.jface.text.source.Annotation; |
| import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument; |
| import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter; |
| import org.eclipse.mylyn.docs.intent.core.modelingunit.InstanciationInstruction; |
| import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnit; |
| import org.eclipse.mylyn.docs.intent.modelingunit.update.ModelingUnitUpdater; |
| |
| /** |
| * Proposal used to fix a Synchronization issue by opening the compare Editor. |
| * |
| * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a> |
| * @author <a href="mailto:william.piers@obeo.fr">William Piers</a> |
| */ |
| public class UpdateModelingUnitFix extends AbstractIntentFix { |
| |
| /** |
| * Default constructor. |
| * |
| * @param annotation |
| * the annotation describing the synchronization issue. |
| */ |
| public UpdateModelingUnitFix(Annotation annotation) { |
| super(annotation); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.mylyn.docs.intent.client.ui.editor.quickfix.AbstractIntentFix#applyFix(org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter, |
| * org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument) |
| */ |
| @Override |
| protected void applyFix(final RepositoryAdapter repositoryAdapter, IntentEditorDocument document) { |
| EObject intentTarget = syncAnnotation.getCompilationStatus().getTarget(); |
| if (intentTarget instanceof InstanciationInstruction) { |
| while (intentTarget != null && !(intentTarget instanceof ModelingUnit)) { |
| intentTarget = intentTarget.eContainer(); |
| } |
| if (intentTarget != null) { |
| ModelingUnitUpdater updater = new ModelingUnitUpdater(repositoryAdapter); |
| updater.fixSynchronizationStatus((ModelingUnit)intentTarget, |
| syncAnnotation.getCompilationStatus()); |
| ((IntentEditorDocument)document).reloadFromAST(); |
| } |
| } |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() |
| */ |
| public String getDisplayString() { |
| return "Update modeling unit"; |
| } |
| |
| } |