[543930] Fix repair not working
All layout information were lost when doing a repair because the views
were removed by the DDiagramCanonicalSynchronizer that is now active
when opening the session and not only when opening diagram editor.
Bug: 543930
Change-Id: I864031a0e3b0dcc808aab2e399e8017e47ce5c61
Cherry-picked-from: 543651
Signed-off-by: Pierre Guilet <pierre.guilet@obeo.fr>
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/refresh/SiriusDiagramSessionEventBroker.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/refresh/SiriusDiagramSessionEventBroker.java
index 84a2764..c0092f2 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/refresh/SiriusDiagramSessionEventBroker.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/refresh/SiriusDiagramSessionEventBroker.java
@@ -25,6 +25,7 @@
import org.eclipse.sirius.business.internal.session.SessionEventBrokerImpl;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.base.Options;
+import org.eclipse.sirius.viewpoint.SiriusPlugin;
import com.google.common.base.Predicate;
@@ -78,14 +79,15 @@
return reference;
}
- /**
- * {@inheritDoc}
- */
@Override
public Option<Command> localChangesAboutToCommit(Collection<Notification> notifications) {
- TransactionalEditingDomain domain = getSession().getTransactionalEditingDomain();
- Option<Command> triggerCommand = Options.newSome(viewpointGMFSynchronizerDispatcher.getGMFNotationModelSynchronizationCmd(domain, notifications));
- return triggerCommand;
+ if (!SiriusPlugin.getDefault().isRepairInProgress()) {
+ TransactionalEditingDomain domain = getSession().getTransactionalEditingDomain();
+ Option<Command> triggerCommand = Options.newSome(viewpointGMFSynchronizerDispatcher.getGMFNotationModelSynchronizationCmd(domain, notifications));
+ return triggerCommand;
+ } else {
+ return Options.newNone();
+ }
}
private Session getSession() {
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/repair/SiriusRepairProcess.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/repair/SiriusRepairProcess.java
index f93b9a9..978c7f4 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/repair/SiriusRepairProcess.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/repair/SiriusRepairProcess.java
@@ -139,11 +139,13 @@
final URI resourceURI = URI.createPlatformResourceURI(this.file.getFullPath().toOSString(), true);
try {
monitor.beginTask(Messages.SiriusRepairProcess_inProgressMsg, 1);
+ SiriusPlugin.getDefault().setRepairInProgress(true);
repair(resourceURI, new SubProgressMonitor(monitor, 1));
} catch (CoreException e) {
SiriusPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, SiriusPlugin.ID, ERROR_MSG, e));
} finally {
monitor.done();
+ SiriusPlugin.getDefault().setRepairInProgress(false);
}
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/SiriusPlugin.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/SiriusPlugin.java
index ef3e7e6..3c801d3 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/SiriusPlugin.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/SiriusPlugin.java
@@ -14,6 +14,7 @@
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -109,12 +110,12 @@
* The actual implementation of the Eclipse <b>Plugin</b>.
*/
public static class Implementation extends EclipsePlugin {
-
+
/**
* Handler for migration.
*/
private IMigrationHandler migrationHandler;
-
+
/**
* Registry of all supported interpreters.
*/
@@ -164,11 +165,36 @@
private UICallBack uiCallback;
/**
+ * True if the repair of an aird is currently happening. False otherwise.
+ */
+ private AtomicBoolean repairInProgress;
+
+ /**
* Creates an instance.
*/
public Implementation() {
super();
plugin = this;
+ repairInProgress = new AtomicBoolean(false);
+ }
+
+ /**
+ * Returns true if the repair of an aird is currently happening. False otherwise.
+ *
+ * @return true if the repair of an aird is currently happening. False otherwise.
+ */
+ public boolean isRepairInProgress() {
+ return this.repairInProgress.get();
+ }
+
+ /**
+ * Set the repair in progress status.
+ *
+ * @param repairInProgress
+ * true if the repair of an aird is currently happening. False otherwise.
+ */
+ public void setRepairInProgress(boolean repairInProgress) {
+ this.repairInProgress.set(repairInProgress);
}
@Override
@@ -195,7 +221,7 @@
modelOperationManagerRegistryListener.init();
expressionQueryProviderRegistry = new InterpretedExpressionQueryProviderRegistry(Platform.getExtensionRegistry(), this);
expressionQueryProviderRegistry.init();
-
+
List<IMigrationHandler> migrationHandlers = EclipseUtil.getExtensionPlugins(IMigrationHandler.class, IMigrationHandler.ID, IMigrationHandler.CLASS_ATTRIBUTE);
if (migrationHandlers.size() > 0) {
migrationHandler = migrationHandlers.get(0);
@@ -254,7 +280,7 @@
public InterpreterRegistry getInterpreterRegistry() {
return interRegistry;
}
-
+
/**
* Get the migration handler used for Description resource creation.
*