[570355] Update SiriusPreferenceKeys.PREF_AUTO_REFRESH usage

Use session.getSiriusPreferences().isAutoRefresh() instead of getting
its value directly from the Instance scope.

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570355
Change-Id: I7b693e9f8c2ead7004bf13d57a0bbf0e46fe519f
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/part/SequenceDiagramEditPart.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/part/SequenceDiagramEditPart.java
index a4b9075..51d1d4b 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/part/SequenceDiagramEditPart.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/part/SequenceDiagramEditPart.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2020 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2021 THALES GLOBAL SERVICES and others.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -32,6 +32,7 @@
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.sirius.business.api.query.DRepresentationQuery;
 import org.eclipse.sirius.business.api.session.ModelChangeTrigger;
 import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.business.api.session.SessionEventBroker;
@@ -55,16 +56,15 @@
 import org.eclipse.sirius.diagram.sequence.ui.tool.internal.layout.SequenceZOrderingRefresher;
 import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactory;
 import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactoryProvider;
+import org.eclipse.sirius.diagram.ui.business.api.query.EditPartQuery;
 import org.eclipse.sirius.diagram.ui.graphical.edit.policies.ContainerCreationEditPolicy;
 import org.eclipse.sirius.diagram.ui.graphical.figures.OverlayLabel;
 import org.eclipse.sirius.diagram.ui.graphical.figures.OverlayLabelsDrawerFigure;
 import org.eclipse.sirius.diagram.ui.internal.edit.parts.DDiagramEditPart;
 import org.eclipse.sirius.diagram.ui.tools.api.editor.DDiagramEditor;
-import org.eclipse.sirius.diagram.ui.tools.api.properties.PropertiesService;
 import org.eclipse.sirius.diagram.ui.tools.internal.graphical.edit.part.DDiagramRootEditPart;
 import org.eclipse.sirius.ext.base.Option;
 import org.eclipse.sirius.ext.base.Options;
-import org.eclipse.sirius.tools.api.ui.property.IPropertiesProvider;
 import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
 
 import com.google.common.base.Predicate;
@@ -231,9 +231,9 @@
          * Once the diagram (and all its children) is active, refresh the various ordering. This is especially needed
          * when creating/opening a diagram as some commands need a properly initialized graphically ordering to work.
          */
-        boolean autoRefresh = PropertiesService.getInstance().getPropertiesProvider().getProperty(IPropertiesProvider.KEY_AUTO_REFRESH);
         boolean refreshOnOpen = DialectUIManager.INSTANCE.isRefreshActivatedOnRepresentationOpening();
         Diagram diagramView = getDiagramView();
+        boolean autoRefresh = new DRepresentationQuery(new EditPartQuery(this).getDDiagram().get()).isAutoRefresh();
         getEditingDomain().getCommandStack().execute(new RefreshLayoutCommand(getEditingDomain(), diagramView, autoRefresh || refreshOnOpen));
         getEditingDomain().addResourceSetListener(semanticOrderingSynchronizer);
         getEditingDomain().addResourceSetListener(refreshZorder);
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java
index 566376b..393d8b3 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2019 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2013, 2021 THALES GLOBAL SERVICES and others.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -40,6 +40,7 @@
 import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
 import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
 import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.sirius.business.api.query.DRepresentationQuery;
 import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.business.api.session.SessionManager;
 import org.eclipse.sirius.diagram.DDiagram;
@@ -59,7 +60,6 @@
 import org.eclipse.sirius.ext.base.Option;
 import org.eclipse.sirius.ext.base.Options;
 import org.eclipse.sirius.ext.gmf.runtime.gef.ui.figures.IContainerLabelOffsets;
-import org.eclipse.sirius.tools.api.ui.RefreshHelper;
 import org.eclipse.sirius.viewpoint.LabelAlignment;
 import org.eclipse.sirius.viewpoint.LabelStyle;
 import org.eclipse.sirius.viewpoint.Style;
@@ -617,32 +617,31 @@
         @SuppressWarnings("restriction")
         @Override
         protected DragTracker createDragTracker() {
-            return new CompartmentCollapseTracker(
-                    (IResizableCompartmentEditPart) getOwner()) {
+            return new CompartmentCollapseTracker((IResizableCompartmentEditPart) getOwner()) {
                 @Override
                 protected Command getCommand(Boolean expand) {
                     Command command = super.getCommand(expand);
                     CompoundCommand commandPlusForceRefresh = new CompoundCommand(command.getLabel());
                     // If we are in manual refresh, add a new command to force the refresh of the current diagram.
-                    if (!RefreshHelper.isAutoRefresh()) {
-                        commandPlusForceRefresh.add(new Command() {
-                            @Override
-                            public void execute() {
-                                Optional<DDiagram> optionalDDiagram = new org.eclipse.sirius.diagram.ui.business.api.query.EditPartQuery(regionPart).getDDiagram();
-                                if (optionalDDiagram.isPresent()) {
+                    Optional<DDiagram> optionalDDiagram = new org.eclipse.sirius.diagram.ui.business.api.query.EditPartQuery(regionPart).getDDiagram();
+                    if (optionalDDiagram.isPresent()) {
+                        if (!new DRepresentationQuery(optionalDDiagram.get()).isAutoRefresh()) {
+                            commandPlusForceRefresh.add(new Command() {
+                                @Override
+                                public void execute() {
                                     Session session = SessionManager.INSTANCE.getSession(optionalDDiagram.get());
                                     if (session != null) {
                                         // Set the RefreshEditorsListener in forceRefresh mode
                                         session.getRefreshEditorsListener().setForceRefresh(true);
                                     }
                                 }
-                            }
 
-                            @Override
-                            public void undo() {
-                                execute();
-                            }
-                        });
+                                @Override
+                                public void undo() {
+                                    execute();
+                                }
+                            });
+                        }
                     }
                     commandPlusForceRefresh.add(command);
                     return commandPlusForceRefresh;
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/VisibilityUpdater.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/VisibilityUpdater.java
index b45d95f..4732243 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/VisibilityUpdater.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/VisibilityUpdater.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2021 THALES GLOBAL SERVICES and others.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -25,6 +25,7 @@
 import org.eclipse.emf.transaction.ResourceSetListenerImpl;
 import org.eclipse.emf.transaction.RollbackException;
 import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.sirius.business.api.query.DRepresentationQuery;
 import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.business.api.session.SessionManager;
 import org.eclipse.sirius.common.tools.DslCommonPlugin;
@@ -37,19 +38,15 @@
 import org.eclipse.sirius.diagram.DDiagramElement;
 import org.eclipse.sirius.diagram.DSemanticDiagram;
 import org.eclipse.sirius.diagram.DiagramPackage;
-import org.eclipse.sirius.diagram.DiagramPlugin;
 import org.eclipse.sirius.diagram.GraphicalFilter;
 import org.eclipse.sirius.diagram.business.api.componentization.DiagramMappingsManager;
 import org.eclipse.sirius.diagram.business.api.componentization.DiagramMappingsManagerRegistry;
 import org.eclipse.sirius.diagram.business.api.helper.display.DisplayServiceManager;
 import org.eclipse.sirius.diagram.ui.provider.Messages;
-import org.eclipse.sirius.diagram.ui.tools.api.properties.PropertiesService;
 import org.eclipse.sirius.tools.api.profiler.SiriusTasksKey;
-import org.eclipse.sirius.tools.api.ui.property.IPropertiesProvider;
 
 /**
- * A ResourceSet listener to refresh visibility when graphical filters are
- * updated.
+ * A ResourceSet listener to refresh visibility when graphical filters are updated.
  * 
  * @author mporhel
  */
@@ -139,13 +136,7 @@
     }
 
     private boolean isAutoRefresh() {
-        boolean autoRefresh = false;
-        try {
-            autoRefresh = PropertiesService.getInstance().getPropertiesProvider().getProperty(IPropertiesProvider.KEY_AUTO_REFRESH);
-        } catch (final IllegalArgumentException e) {
-            DiagramPlugin.getDefault().logError(e.getMessage());
-        }
-        return autoRefresh;
+        return new DRepresentationQuery(dDiagram).isAutoRefresh();
     }
 
     /**
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/properties/PropertiesService.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/properties/PropertiesService.java
deleted file mode 100644
index 20fc091..0000000
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/properties/PropertiesService.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 THALES GLOBAL SERVICES.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.diagram.ui.tools.api.properties;
-
-import org.eclipse.sirius.diagram.ui.tools.internal.properties.SiriusDiagramEditorPropertiesProvider;
-import org.eclipse.sirius.tools.api.ui.property.IPropertiesProvider;
-
-/**
- * Service to get the Designer UI properties.
- * 
- * @author mchauvin
- */
-public final class PropertiesService {
-
-    private static final PropertiesService INSTANCE = new PropertiesService();
-
-    private IPropertiesProvider provider = new SiriusDiagramEditorPropertiesProvider();
-
-    /**
-     * Avoid instantiation
-     */
-    private PropertiesService() {
-    }
-
-    /**
-     * Get the properties provider.
-     * 
-     * @return the properties provider
-     */
-    public IPropertiesProvider getPropertiesProvider() {
-        return provider;
-    }
-
-    /**
-     * Get the service instance.
-     * 
-     * @return the service instance.
-     */
-    public static PropertiesService getInstance() {
-        return INSTANCE;
-    }
-}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java
index 0fdbf74..5641361 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2020 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2009, 2021 THALES GLOBAL SERVICES and others.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -106,6 +106,7 @@
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.sirius.business.api.dialect.command.RefreshRepresentationsCommand;
+import org.eclipse.sirius.business.api.query.DRepresentationQuery;
 import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.business.api.session.SessionListener;
 import org.eclipse.sirius.business.api.session.SessionManager;
@@ -158,7 +159,6 @@
 import org.eclipse.sirius.diagram.ui.tools.api.editor.DDiagramEditor;
 import org.eclipse.sirius.diagram.ui.tools.api.graphical.edit.palette.PaletteManager;
 import org.eclipse.sirius.diagram.ui.tools.api.preferences.SiriusDiagramUiPreferencesKeys;
-import org.eclipse.sirius.diagram.ui.tools.api.properties.PropertiesService;
 import org.eclipse.sirius.diagram.ui.tools.internal.actions.delete.DeleteFromModelWithHookAction;
 import org.eclipse.sirius.diagram.ui.tools.internal.actions.delete.DeleteWithHookAction;
 import org.eclipse.sirius.diagram.ui.tools.internal.actions.visibility.HideDDiagramElementAction;
@@ -196,7 +196,6 @@
 import org.eclipse.sirius.tools.api.interpreter.InterpreterRegistry;
 import org.eclipse.sirius.tools.api.permission.DRepresentationPermissionStatusListener;
 import org.eclipse.sirius.tools.api.permission.DRepresentationPermissionStatusQuery;
-import org.eclipse.sirius.tools.api.ui.property.IPropertiesProvider;
 import org.eclipse.sirius.ui.business.api.dialect.DialectEditor;
 import org.eclipse.sirius.ui.business.api.dialect.DialectEditorDialogFactory;
 import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
@@ -1435,13 +1434,7 @@
     }
 
     private boolean isAutoRefresh() {
-        boolean autoRefresh = false;
-        try {
-            autoRefresh = PropertiesService.getInstance().getPropertiesProvider().getProperty(IPropertiesProvider.KEY_AUTO_REFRESH);
-        } catch (final IllegalArgumentException e) {
-            DiagramPlugin.getDefault().logError(e.getMessage());
-        }
-        return autoRefresh;
+        return new DRepresentationQuery(getRepresentation()).isAutoRefresh();
     }
 
     /**
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/SiriusDiagramEditorPropertiesProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/SiriusDiagramEditorPropertiesProvider.java
deleted file mode 100644
index e160e39..0000000
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/SiriusDiagramEditorPropertiesProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 THALES GLOBAL SERVICES.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.diagram.ui.tools.internal.properties;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
-import org.eclipse.sirius.tools.api.ui.property.IPropertiesProvider;
-import org.eclipse.sirius.viewpoint.SiriusPlugin;
-
-/**
- * Implementation ...
- * 
- * @author mchauvin
- */
-public class SiriusDiagramEditorPropertiesProvider implements IPropertiesProvider {
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.sirius.tools.api.ui.property.IPropertiesProvider#getProperty(int)
-     */
-    public boolean getProperty(final int key) throws IllegalArgumentException {
-
-        if (IPropertiesProvider.KEY_AUTO_REFRESH == key) {
-            return Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
-        }
-        throw IPropertiesProvider.EXCEPTION_PROPERTY_NOT_FOUND;
-    }
-
-}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/editors/EntitiesSpecificEditorTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/editors/EntitiesSpecificEditorTests.java
index 8178698..68dc93f 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/editors/EntitiesSpecificEditorTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/editors/EntitiesSpecificEditorTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2019 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2021 THALES GLOBAL SERVICES.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -27,13 +27,11 @@
 import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentEditor;
 import org.eclipse.sirius.business.api.query.DRepresentationQuery;
 import org.eclipse.sirius.business.api.session.SessionManager;
-import org.eclipse.sirius.diagram.ui.tools.api.properties.PropertiesService;
 import org.eclipse.sirius.tests.SiriusTestsPlugin;
 import org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper;
 import org.eclipse.sirius.tests.support.api.SiriusDiagramTestCase;
 import org.eclipse.sirius.tests.support.api.TestsUtil;
 import org.eclipse.sirius.tests.unit.diagram.modeler.ecore.EcoreModeler;
-import org.eclipse.sirius.tools.api.ui.property.IPropertiesProvider;
 import org.eclipse.sirius.ui.business.api.dialect.DialectEditor;
 import org.eclipse.sirius.viewpoint.DRepresentation;
 import org.eclipse.sirius.viewpoint.ViewpointPackage;
@@ -76,15 +74,15 @@
     public void testSessionisCreated() throws Exception {
         if (TestsUtil.shouldSkipUnreliableTests()) {
             /*
-            junit.framework.AssertionFailedError: expected:<0> but was:<1>
-            at junit.framework.Assert.fail(Assert.java:57)
-            at junit.framework.Assert.failNotEquals(Assert.java:329)
-            at junit.framework.Assert.assertEquals(Assert.java:78)
-            at junit.framework.Assert.assertEquals(Assert.java:234)
-            at junit.framework.Assert.assertEquals(Assert.java:241)
-            at junit.framework.TestCase.assertEquals(TestCase.java:409)
-            at org.eclipse.sirius.tests.unit.api.editors.EntitiesSpecificEditorTests.testSessionisCreated(EntitiesSpecificEditorTests.java:75)
-            */
+             * junit.framework.AssertionFailedError: expected:<0> but was:<1> at
+             * junit.framework.Assert.fail(Assert.java:57) at junit.framework.Assert.failNotEquals(Assert.java:329) at
+             * junit.framework.Assert.assertEquals(Assert.java:78) at
+             * junit.framework.Assert.assertEquals(Assert.java:234) at
+             * junit.framework.Assert.assertEquals(Assert.java:241) at
+             * junit.framework.TestCase.assertEquals(TestCase.java:409) at
+             * org.eclipse.sirius.tests.unit.api.editors.EntitiesSpecificEditorTests.testSessionisCreated(
+             * EntitiesSpecificEditorTests.java:75)
+             */
             return;
         }
         assertEquals(0, SessionManager.INSTANCE.getSessions().size());
@@ -101,7 +99,6 @@
         openEditor();
         try {
             DRepresentation representation = ((DialectEditor) editor).getRepresentation();
-            PropertiesService.getInstance().getPropertiesProvider().getProperty(IPropertiesProvider.KEY_AUTO_REFRESH);
             assertEquals(5, representation.getOwnedRepresentationElements().size());
         } finally {
             closeEditor();
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/RefreshEditorsPrecommitListenerTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/RefreshEditorsPrecommitListenerTests.java
index 4603c06..8ac7a65 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/RefreshEditorsPrecommitListenerTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/RefreshEditorsPrecommitListenerTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2021 THALES GLOBAL SERVICES.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@
 import java.util.Collection;
 import java.util.Collections;
 
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.preferences.InstanceScope;
 import org.eclipse.emf.common.command.Command;
@@ -33,6 +34,8 @@
 import org.eclipse.gmf.runtime.notation.Bounds;
 import org.eclipse.gmf.runtime.notation.NotationPackage;
 import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.business.api.session.SessionManager;
 import org.eclipse.sirius.diagram.DNodeList;
 import org.eclipse.sirius.diagram.DiagramPackage;
 import org.eclipse.sirius.ext.base.Option;
@@ -47,8 +50,8 @@
 import junit.framework.TestCase;
 
 /**
- * Test that {@link RefreshEditorsPrecommitListener} return a {@link Command} to
- * refresh a {@link DRepresentation} only on semantic change notification.
+ * Test that {@link RefreshEditorsPrecommitListener} return a {@link Command} to refresh a {@link DRepresentation} only
+ * on semantic change notification.
  * 
  * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
  */
@@ -76,15 +79,17 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
-        refreshEditorsPrecommitListener = new RefreshEditorsPrecommitListener(domain);
-
-        resourceSet = domain.getResourceSet();
         sessionResourceURI = URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.aird", true);
         semanticResourceURI = URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.ecore", true);
+        Session session = SessionManager.INSTANCE.getSession(sessionResourceURI, new NullProgressMonitor());
+        domain = session.getTransactionalEditingDomain();
+
+        resourceSet = domain.getResourceSet();
 
         sessionResource = resourceSet.getResource(sessionResourceURI, true);
 
+        refreshEditorsPrecommitListener = new RefreshEditorsPrecommitListener(session);
+
         final DRepresentation firstDRepresentation = getFirstElement(sessionResource, DRepresentation.class);
         refreshFilterStub = new RefreshFilterStub(firstDRepresentation);
         RefreshFilterManager.INSTANCE.addRefreshFilter(refreshFilterStub);
@@ -94,8 +99,7 @@
     }
 
     /**
-     * Test that no refresh command is returned by the
-     * {@link RefreshEditorsPrecommitListener} when it receives a
+     * Test that no refresh command is returned by the {@link RefreshEditorsPrecommitListener} when it receives a
      * {@link DRepresentationElement} change notification.
      */
     public void testNoRefreshOnDRepresentationElementChangeNotification() {
@@ -112,9 +116,8 @@
     }
 
     /**
-     * Test that no refresh command is returned by the
-     * {@link RefreshEditorsPrecommitListener} when it receives a GMF notation
-     * model change notification.
+     * Test that no refresh command is returned by the {@link RefreshEditorsPrecommitListener} when it receives a GMF
+     * notation model change notification.
      */
     public void testNoRefreshOnGMFNodeChangeNotification() {
         // 1. Create a Notification for theRefreshEditorsPrecommitListener
@@ -129,9 +132,8 @@
     }
 
     /**
-     * Test that a refresh command is returned by the
-     * {@link RefreshEditorsPrecommitListener} when it receives a semantic
-     * change notification.
+     * Test that a refresh command is returned by the {@link RefreshEditorsPrecommitListener} when it receives a
+     * semantic change notification.
      */
     public void testRefreshOnSemanticChangeNotification() {
         // 1. Create a Notification for theRefreshEditorsPrecommitListener
@@ -166,10 +168,12 @@
             this.dRepresentation = dRepresentation;
         }
 
+        @Override
         public boolean shouldRefresh(DRepresentation representation) {
             return true;
         }
 
+        @Override
         public Collection<DRepresentation> getOpenedRepresantationsToRefresh() {
             return Collections.singletonList(dRepresentation);
         }
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/listeners/ExpandDTreeItemRunnableWithProgress.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/listeners/ExpandDTreeItemRunnableWithProgress.java
index 61177d5..1771a47 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/listeners/ExpandDTreeItemRunnableWithProgress.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/listeners/ExpandDTreeItemRunnableWithProgress.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2021 Obeo.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -16,13 +16,11 @@
 import java.text.MessageFormat;
 
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.emf.common.command.Command;
 import org.eclipse.emf.common.command.CommandStack;
 import org.eclipse.emf.common.command.CompoundCommand;
 import org.eclipse.emf.transaction.TransactionalEditingDomain;
 import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
 import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.tools.api.command.SiriusCommand;
 import org.eclipse.sirius.tree.DTreeItem;
@@ -31,7 +29,6 @@
 import org.eclipse.sirius.tree.business.internal.dialect.common.viewpoint.GlobalContext;
 import org.eclipse.sirius.tree.business.internal.helper.RefreshTreeElementTask;
 import org.eclipse.sirius.tree.ui.provider.Messages;
-import org.eclipse.sirius.viewpoint.SiriusPlugin;
 
 /**
  * Refresh tree elements when a SWT TreeItem is expanded.
@@ -82,7 +79,7 @@
                 monitor.beginTask(Messages.ExpandDTreeItemRunnableWithProgress_treeItemExpanding, 1);
                 CompoundCommand expandDTreeItemCmd = new CompoundCommand(MessageFormat.format(Messages.ExpandDTreeItemRunnableWithProgress_expandTreeItem, dTreeItem.getName()));
                 expandDTreeItemCmd.append(new DTreeItemExpansionChangeCommand(globalContext, domain, dTreeItem, monitor, true));
-                if (!Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null)) {
+                if (!session.getSiriusPreferences().isAutoRefresh()) {
                     SiriusCommand result = new SiriusCommand(domain);
                     result.getTasks().add(new RefreshTreeElementTask(dTreeItem));
                     expandDTreeItemCmd.append(result);
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java
index ff19918..d95c186 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2020 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2008, 2021 THALES GLOBAL SERVICES and others.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -19,7 +19,6 @@
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.emf.common.notify.AdapterFactory;
@@ -35,7 +34,6 @@
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.sirius.business.api.dialect.command.RefreshRepresentationsCommand;
-import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
 import org.eclipse.sirius.business.api.query.DRepresentationQuery;
 import org.eclipse.sirius.business.api.query.URIQuery;
 import org.eclipse.sirius.business.api.session.Session;
@@ -562,7 +560,7 @@
     public boolean needsRefresh(int propId) {
         boolean result = false;
         if (propId == DialectEditor.PROP_REFRESH) {
-            if (isAutoRefresh()) {
+            if (session.getSiriusPreferences().isAutoRefresh()) {
                 result = true;
             }
         } else if (propId == DialectEditor.PROP_FORCE_REFRESH) {
@@ -771,21 +769,6 @@
         return isDirty();
     }
 
-    /**
-     * .
-     * 
-     * @return if is auto refresh
-     */
-    protected boolean isAutoRefresh() {
-        boolean autoRefresh = false;
-        try {
-            autoRefresh = Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), autoRefresh, null);
-        } catch (final IllegalArgumentException e) {
-            SiriusTransPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SiriusTransPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e));
-        }
-        return autoRefresh;
-    }
-
     @Override
     public void setDialogFactory(DialectEditorDialogFactory dialogFactory) {
         myDialogFactory = dialogFactory;
@@ -902,7 +885,7 @@
      * @see org.eclipse.sirius.business.api.componentization.ViewpointRegistryListener2#modelerDesciptionFilesLoaded()
      */
     protected void modelerDescriptionFilesLoaded() {
-        if (isAutoRefresh()) {
+        if (session.getSiriusPreferences().isAutoRefresh()) {
             Job refreshJob = new Job(Messages.AbstractDTreeEditor_modelerDescriptionFilesLoadedJob) {
                 @Override
                 protected IStatus run(IProgressMonitor monitor) {
diff --git a/plugins/org.eclipse.sirius/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius/META-INF/MANIFEST.MF
index 0c8a86b..795c8b8 100644
--- a/plugins/org.eclipse.sirius/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.sirius/META-INF/MANIFEST.MF
@@ -82,7 +82,6 @@
  org.eclipse.sirius.tools.api.profiler;version="2.0.5",
  org.eclipse.sirius.tools.api.ui;version="2.1.0",
  org.eclipse.sirius.tools.api.ui.color;version="2.0.4",
- org.eclipse.sirius.tools.api.ui.property;version="2.0.4",
  org.eclipse.sirius.tools.api.ui.resource;version="2.0.5",
  org.eclipse.sirius.tools.api.validation.constraint;version="2.0.4",
  org.eclipse.sirius.tools.internal;version="6.1.2";x-internal:=true,
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DeleteDRepresentationElementsTask.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DeleteDRepresentationElementsTask.java
index 69048ad..3fa2ecc 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DeleteDRepresentationElementsTask.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DeleteDRepresentationElementsTask.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2021 THALES GLOBAL SERVICES.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -17,19 +17,18 @@
 import java.util.List;
 import java.util.Set;
 
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.sirius.business.api.helper.task.DeleteEObjectTask;
 import org.eclipse.sirius.business.api.helper.task.ICommandTask;
 import org.eclipse.sirius.business.api.helper.task.TaskHelper;
-import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+import org.eclipse.sirius.business.api.query.DRepresentationElementQuery;
+import org.eclipse.sirius.business.api.query.DRepresentationQuery;
 import org.eclipse.sirius.business.api.query.EObjectQuery;
 import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
 import org.eclipse.sirius.tools.api.command.DCommand;
 import org.eclipse.sirius.viewpoint.DRepresentationElement;
 import org.eclipse.sirius.viewpoint.DSemanticDecorator;
 import org.eclipse.sirius.viewpoint.Messages;
-import org.eclipse.sirius.viewpoint.SiriusPlugin;
 
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Sets;
@@ -78,12 +77,11 @@
     @Override
     protected List<ICommandTask> prepareSubTasks() {
         /*
-         * Now delete all the DSemanticDecorators corresponding to the semantic
-         * elements
+         * Now delete all the DSemanticDecorators corresponding to the semantic elements
          */
         final List<ICommandTask> tasks = new ArrayList<ICommandTask>();
         EObject root = null;
-        final boolean automaticRefresh = Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
+        final boolean automaticRefresh = new DRepresentationQuery(new DRepresentationElementQuery(repElt).getParentRepresentation()).isAutoRefresh();
         if (automaticRefresh) {
             root = new EObjectQuery(this.repElt).getDAnalysis();
         } else {
@@ -109,9 +107,8 @@
     }
 
     /**
-     * This method can be overridden to add Dialect specific additional delete
-     * tasks. A DeleteEObjectTask for the given decorator has already been added
-     * to subtasks.
+     * This method can be overridden to add Dialect specific additional delete tasks. A DeleteEObjectTask for the given
+     * decorator has already been added to subtasks.
      * 
      * @param decorator
      *            the current decorator to delete
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
index 7b77301..a60c058 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
@@ -1291,7 +1291,7 @@
      */
     protected void addRefreshEditorsListener() {
         if (refreshEditorsListeners == null) {
-            refreshEditorsListeners = new RefreshEditorsPrecommitListener(transactionalEditingDomain);
+            refreshEditorsListeners = new RefreshEditorsPrecommitListener(this);
             getEventBroker().addLocalTrigger(RefreshEditorsPrecommitListener.IS_IMPACTING, refreshEditorsListeners);
             this.addListener(refreshEditorsListeners);
         }
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshEditorsPrecommitListener.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshEditorsPrecommitListener.java
index 5713173..c04b625 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshEditorsPrecommitListener.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshEditorsPrecommitListener.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2019 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2011, 2021 THALES GLOBAL SERVICES and others.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -17,7 +17,6 @@
 import java.util.LinkedHashSet;
 
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.emf.common.command.Command;
 import org.eclipse.emf.common.command.CompoundCommand;
 import org.eclipse.emf.common.notify.Notification;
@@ -26,8 +25,8 @@
 import org.eclipse.emf.transaction.TransactionalEditingDomain;
 import org.eclipse.emf.transaction.util.TransactionUtil;
 import org.eclipse.sirius.business.api.dialect.command.RefreshRepresentationsCommand;
-import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
 import org.eclipse.sirius.business.api.session.ModelChangeTrigger;
+import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.business.api.session.SessionListener;
 import org.eclipse.sirius.business.internal.dialect.command.RefreshImpactedElementsCommand;
 import org.eclipse.sirius.business.internal.session.danalysis.DanglingRefRemovalTrigger;
@@ -36,16 +35,14 @@
 import org.eclipse.sirius.tools.api.command.ui.RefreshFilterManager;
 import org.eclipse.sirius.viewpoint.DRepresentation;
 import org.eclipse.sirius.viewpoint.DSemanticDecorator;
-import org.eclipse.sirius.viewpoint.SiriusPlugin;
 
 /**
  * A listener to refresh all Sirius opened editors. It is used as :
  * <UL>
  * <LI>precommit listener (a model change trigger of the
- * {@link org.eclipse.sirius.business.api.session.SessionEventBroker}) : on
- * semantic modifications (with localChangesAboutToCommit())</LI>
- * <LI>session listener : on reloading of resources detecting by the session
- * itself (with notify())</LI>
+ * {@link org.eclipse.sirius.business.api.session.SessionEventBroker}) : on semantic modifications (with
+ * localChangesAboutToCommit())</LI>
+ * <LI>session listener : on reloading of resources detecting by the session itself (with notify())</LI>
  * </UL>
  * 
  * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
@@ -58,11 +55,9 @@
     public static final int REFRESH_EDITOR_PRIORITY = DanglingRefRemovalTrigger.DANGLING_REFERENCE_REMOVAL_PRIORITY + 1;
 
     /**
-     * Filter {@link Notification}s which are not touch. More filtering work is
-     * done later in localChangesAboutToCommit, see
-     * isImpactingNotification(Collection<Notification>) which return true as
-     * soon as an impacting notification is found. This is not done here for
-     * performance reason: we need the container resource of the notifier.
+     * Filter {@link Notification}s which are not touch. More filtering work is done later in localChangesAboutToCommit,
+     * see isImpactingNotification(Collection<Notification>) which return true as soon as an impacting notification is
+     * found. This is not done here for performance reason: we need the container resource of the notifier.
      */
     public static final NotificationFilter IS_IMPACTING = new NotificationFilter.Custom() {
         @Override
@@ -77,8 +72,12 @@
     TransactionalEditingDomain transactionalEditingDomain;
 
     /**
-     * True if this listener must launch a refresh even if the autoRefresh is
-     * off.
+     * The session.
+     */
+    Session session;
+
+    /**
+     * True if this listener must launch a refresh even if the autoRefresh is off.
      */
     private boolean forceRefresh;
 
@@ -88,9 +87,8 @@
     private final Collection<DRepresentation> representationsToForceRefresh = new ArrayList<DRepresentation>();
 
     /**
-     * A list of {@link PostRefreshCommandFactory} that is called to complete
-     * the refresh command. The commands provided by the factory is added after
-     * the refresh command if it can be executed.
+     * A list of {@link PostRefreshCommandFactory} that is called to complete the refresh command. The commands provided
+     * by the factory is added after the refresh command if it can be executed.
      */
     private final Collection<PostRefreshCommandFactory> postRefreshCommandFactories = new ArrayList<PostRefreshCommandFactory>();
 
@@ -99,11 +97,14 @@
     /**
      * Default constructor.
      * 
-     * @param transactionalEditingDomain
-     *            The editing domain used to create the refresh command.
+     * The editing domain used to create the refresh command.
+     * 
+     * @param session
+     *            the session
      */
-    public RefreshEditorsPrecommitListener(TransactionalEditingDomain transactionalEditingDomain) {
-        this.transactionalEditingDomain = transactionalEditingDomain;
+    public RefreshEditorsPrecommitListener(Session session) {
+        this.transactionalEditingDomain = session.getTransactionalEditingDomain();
+        this.session = session;
     }
 
     @Override
@@ -114,8 +115,7 @@
     /**
      * {@inheritDoc}
      * 
-     * Do a refresh only if there is at least one notification that concern
-     * another thing that an aird Resource.
+     * Do a refresh only if there is at least one notification that concern another thing that an aird Resource.
      */
     @Override
     public Option<Command> localChangesAboutToCommit(Collection<Notification> notifications) {
@@ -149,8 +149,7 @@
      * Compute the refresh command or null if no refresh is needed.
      * 
      * @param isChanged
-     *            True if there is some semantic changes or a reloading of the
-     *            session, false otherwise
+     *            True if there is some semantic changes or a reloading of the session, false otherwise
      * @return An optional command if at least one refresh is needed.
      */
     private Option<? extends Command> getRefreshOpenedRepresentationsCommand(boolean isChanged) {
@@ -221,8 +220,7 @@
     }
 
     /**
-     * Force this PrecommitListener to launch a refresh the next time it is
-     * called.
+     * Force this PrecommitListener to launch a refresh the next time it is called.
      * 
      * @param forceRefresh
      *            the forceRefresh to set
@@ -236,13 +234,12 @@
     }
 
     /**
-     * Check if someone notify me for a force refresh or if the preference
-     * AutoRefresh is on.
+     * Check if someone notify me for a force refresh or if the preference AutoRefresh is on.
      * 
      * @return true if a refresh must be launch.
      */
     private boolean isAutoRefresh() {
-        return Platform.isRunning() && Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
+        return session.getSiriusPreferences().isAutoRefresh();
     }
 
     @Override
@@ -277,9 +274,8 @@
     }
 
     /**
-     * Add a new PostRefreshCommandFactory to the
-     * RefreshEditorsPrecommitListener. The commands provided by the factory is
-     * added after the refresh command if it can be executed.
+     * Add a new PostRefreshCommandFactory to the RefreshEditorsPrecommitListener. The commands provided by the factory
+     * is added after the refresh command if it can be executed.
      * 
      * The factory is removed after the first refresh.
      * 
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshHelper.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshHelper.java
index e9a9c8c..f9daf12 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshHelper.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/RefreshHelper.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2016, 2019 THALES GLOBAL SERVICES.
+ * Copyright (c) 2016, 2021 THALES GLOBAL SERVICES.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -21,19 +21,17 @@
 import java.util.Set;
 import java.util.function.Predicate;
 
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
 import org.eclipse.sirius.business.api.query.EObjectQuery;
 import org.eclipse.sirius.business.api.query.ResourceQuery;
 import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.business.api.session.SessionManager;
 import org.eclipse.sirius.ext.base.Option;
+import org.eclipse.sirius.ext.base.Options;
 import org.eclipse.sirius.viewpoint.DRepresentation;
 import org.eclipse.sirius.viewpoint.Messages;
-import org.eclipse.sirius.viewpoint.SiriusPlugin;
 
 import com.google.common.base.Preconditions;
 
@@ -69,7 +67,8 @@
             Object notifier = notification.getNotifier();
             if (notifier instanceof EObject) {
                 EObject eObjectNotifier = (EObject) notifier;
-                if (!alreadyDoneNotifiers.contains(eObjectNotifier) && isImpactingNotification(notification, eObjectNotifier, alreadyDoneNotifiers, notifierWithResource, notifierIsInAirdOrSrmResource)) {
+                if (!alreadyDoneNotifiers.contains(eObjectNotifier)
+                        && isImpactingNotification(notification, eObjectNotifier, alreadyDoneNotifiers, notifierWithResource, notifierIsInAirdOrSrmResource)) {
                     return true;
                 }
             }
@@ -117,18 +116,22 @@
         if (notifierResource != null && !isImpactingNotification && isSpecificImpactingNotification(notification)) {
             // The impacting notification is a graphical one, so if we are in manual refresh, we must add
             // the corresponding representation to the force refresh list
-            if (!isAutoRefresh()) {
-                Option<DRepresentation> optionalDRepresentation = new EObjectQuery(notifier).getRepresentation();
+            Option<DRepresentation> optionalDRepresentation = Options.newNone();
+            Session session = SessionManager.INSTANCE.getExistingSession(notifierResource.getURI());
+            if (session == null) {
+                // Maybe the notifier resource is not the session resource (for example a SRM resource in
+                // Collab), in this case, use a more global session search.
+                optionalDRepresentation = new EObjectQuery(notifier).getRepresentation();
                 if (optionalDRepresentation.some()) {
-                    Session session = SessionManager.INSTANCE.getExistingSession(notifierResource.getURI());
-                    if (session == null) {
-                        // Maybe the notifier resource is not the session resource (for example a SRM resource in
-                        // Collab), in this case, use a more global session search.
-                        session = new EObjectQuery(optionalDRepresentation.get()).getSession();
-                    }
-                    if (session != null) {
-                        session.getRefreshEditorsListener().addRepresentationToForceRefresh(optionalDRepresentation.get());
-                    }
+                    session = new EObjectQuery(optionalDRepresentation.get()).getSession();
+                }
+            }
+            if (session != null && session.getSiriusPreferences().isAutoRefresh()) {
+                if (!optionalDRepresentation.some()) {
+                    optionalDRepresentation = new EObjectQuery(notifier).getRepresentation();
+                }
+                if (optionalDRepresentation.some()) {
+                    session.getRefreshEditorsListener().addRepresentationToForceRefresh(optionalDRepresentation.get());
                 }
             }
             isImpactingNotification = true;
@@ -137,15 +140,6 @@
     }
 
     /**
-     * Return true if the automatic refresh mode is activated, false otherwise.
-     * 
-     * @return true if the automatic refresh mode is activated, false otherwise.
-     */
-    public static boolean isAutoRefresh() {
-        return Platform.isRunning() && Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
-    }
-
-    /**
      * Check this notification with all registered predicates.
      * 
      * @param notification
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/property/IPropertiesProvider.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/property/IPropertiesProvider.java
deleted file mode 100644
index c46088e..0000000
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/ui/property/IPropertiesProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.tools.api.ui.property;
-
-import org.eclipse.sirius.viewpoint.Messages;
-
-/**
- * Properties provider.
- * 
- * @author Mariot Chauvin (mchauvin)
- */
-public interface IPropertiesProvider {
-    /**
-     * Key for auto_refresh.
-     */
-    int KEY_AUTO_REFRESH = 1;
-
-    /**
-     * Exception when no property is found.
-     */
-    IllegalArgumentException EXCEPTION_PROPERTY_NOT_FOUND = new IllegalArgumentException(Messages.IPropertiesProvider_unfoundPropertyErrorMsg);
-
-    /**
-     * get the enablement of a property.
-     * 
-     * @param key
-     *            a property key in the following list :
-     * 
-     *            {@link IPropertiesProvider#KEY_AUTO_REFRESH}
-     * 
-     * @return true if the property is enabled, false otherwise
-     * @throws IllegalArgumentException
-     *             if the property is not available or not supported
-     */
-    boolean getProperty(int key) throws IllegalArgumentException;
-}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/command/builders/AbstractCommandBuilder.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/command/builders/AbstractCommandBuilder.java
index ede2eae..6aa6dd1 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/command/builders/AbstractCommandBuilder.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/command/builders/AbstractCommandBuilder.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2021 THALES GLOBAL SERVICES.
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
@@ -12,11 +12,13 @@
  *******************************************************************************/
 package org.eclipse.sirius.tools.internal.command.builders;
 
-import org.eclipse.core.runtime.Platform;
+import java.util.Optional;
+
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.transaction.TransactionalEditingDomain;
 import org.eclipse.sirius.business.api.helper.task.TaskHelper;
-import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.business.api.session.SessionManager;
 import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException;
 import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
 import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
@@ -24,7 +26,6 @@
 import org.eclipse.sirius.tools.api.command.DCommand;
 import org.eclipse.sirius.tools.api.command.SiriusCommand;
 import org.eclipse.sirius.tools.api.command.ui.UICallBack;
-import org.eclipse.sirius.viewpoint.SiriusPlugin;
 
 /**
  * Default implementation for {@link CommandBuilder}.
@@ -58,22 +59,24 @@
      *      org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor,
      *      org.eclipse.emf.transaction.TransactionalEditingDomain)
      */
+    @Override
     public void init(final ModelAccessor accessor, final TransactionalEditingDomain domain, final UICallBack ui) {
         this.modelAccessor = accessor;
         this.editingDomain = domain;
         this.uiCallback = ui;
         this.permissionAuthority = accessor.getPermissionAuthority();
         this.taskHelper = new TaskHelper(modelAccessor, uiCallback);
-        this.autoRefresh = Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
+        Optional<Session> session = SessionManager.INSTANCE.getSessions().stream().filter(s -> s.getTransactionalEditingDomain().equals(editingDomain)).findAny();
+        if (session.isPresent()) {
+            this.autoRefresh = session.get().getSiriusPreferences().isAutoRefresh();
+        }
     }
 
     /**
-     * Evaluates the precondition on the current tool. Must only be overridden
-     * to add specific variables.
+     * Evaluates the precondition on the current tool. Must only be overridden to add specific variables.
      * 
      * @param interpreter
-     *            the interpreter capable to interpret the precondition
-     *            expression
+     *            the interpreter capable to interpret the precondition expression
      * @param semanticContainer
      *            the semantic element on which evaluates the expression
      * @param precondition