[518793] Do not refresh all diagrams with Force refresh tool.

If automatic refresh Sirius preference is disabled, the use of Force
Refresh tool refreshes only the current diagram instead of all opened
diagrams. 

Bug: 518793
Cherry-picked-from: 517956
Change-Id: I71b06e3b90e360d5bd58559f416a1d15020b6554
Signed-off-by: jmallet <jessy.mallet@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index f77fc4d..1bf2805 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -19,6 +19,9 @@
 								<a href="#UserVisibleChanges">User-Visible Changes</a>
 							</li>
 							<li>
+								<a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a>
+							</li>
+							<li>
 								<a href="#DeveloperVisibleChanges">Developer-Visible Changes</a>
 							</li>
 						</ol>
@@ -82,7 +85,7 @@
 								<a href="#UserVisibleChanges6">User-Visible Changes</a>
 							</li>
 							<li>
-								<a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a>
+								<a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a>
 							</li>
 							<li>
 								<a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a>
@@ -96,7 +99,7 @@
 								<a href="#UserVisibleChanges7">User-Visible Changes</a>
 							</li>
 							<li>
-								<a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a>
+								<a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a>
 							</li>
 							<li>
 								<a href="#DeveloperVisibleChanges8">Developer-Visible Changes</a>
@@ -110,7 +113,7 @@
 								<a href="#UserVisibleChanges8">User-Visible Changes</a>
 							</li>
 							<li>
-								<a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a>
+								<a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a>
 							</li>
 							<li>
 								<a href="#DeveloperVisibleChanges9">Developer-Visible Changes</a>
@@ -124,7 +127,7 @@
 								<a href="#UserVisibleChanges9">User-Visible Changes</a>
 							</li>
 							<li>
-								<a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a>
+								<a href="#SpecifierVisibleChanges5">Specifier-Visible Changes</a>
 							</li>
 							<li>
 								<a href="#DeveloperVisibleChanges10">Developer-Visible Changes</a>
@@ -152,6 +155,13 @@
 				</ul>
 			</li>
 		</ul>
+		<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
+		<ul>
+			<li><span class="label label-info">Modified</span> Since this version, in manual refresh mode (
+				<em>Automatic Refresh</em> Sirius preference disabled), when the 
+				<em>Force Refresh</em> option of a tool is enabled in your VSM, only the current representation is refreshed when the tool is applied. Before this version, all open representations were refreshed.
+			</li>
+		</ul>
 		<h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
 		<h4 id="Migrations">Migrations</h4>
 		<ul>
@@ -364,7 +374,7 @@
 				<em>Ctrl+HOME</em>.
 			</li>
 		</ul>
-		<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
+		<h3 id="SpecifierVisibleChanges2">Specifier-Visible Changes</h3>
 		<ul>
 			<li><span class="label label-success">Added</span> It is now possible to inline a copy of the default Properties Views model inside the VSM. This is a copy of the model Sirius would use if no 
 				<em>Properties View Description</em> was specified. It can be used as a starting point for manual customization, or as a complement for elements for which you do not provide any custom rules. 
@@ -838,7 +848,7 @@
 				<code>Apply Appearance Properties</code> action has been modified to use the last selected element as base style instead of the first one.
 			</li>
 		</ul>
-		<h3 id="SpecifierVisibleChanges2">Specifier-Visible Changes</h3>
+		<h3 id="SpecifierVisibleChanges3">Specifier-Visible Changes</h3>
 		<ul>
 			<li><span class="label label-success">Added</span> Sirius 4.0 introduces 
 				<strong>experimental</strong>  support for specifying the properties views of your modelers directly from inside the VSM. This feature uses the same dynamic approach as for specifying  diagrams, tables and trees, with a very flexible configuration language and no code generation involved (including live preview of any change). As of Sirius 4.0, this feature should be considered in an experimental  state with details subject to changes until Sirius 4.1, and is not installed by default. To install it, make sure either 
@@ -1339,7 +1349,7 @@
 				<em>Arrange Linked Border Nodes</em> as it is border nodes which are layouted and not bordered nodes.
 			</li>
 		</ul>
-		<h3 id="SpecifierVisibleChanges3">Specifier-Visible Changes</h3>
+		<h3 id="SpecifierVisibleChanges4">Specifier-Visible Changes</h3>
 		<ul>
 			<li><span class="label label-info">Modified</span> The 
 				<em>Acceleo Query Language</em> (AQL) interpreter  has been improved. AQL, and its support in Sirius, is no longer considered experimental, and instead is now the recommended query language to use for new VSMs. Improvements mostly concern better completion and validation, and more precise error reporting. In particular AQL expressions will now be able to display warnings and errors in the Interpreter view. The message displayed in the Interpreter view after an evaluation has also been improved to display the qualified name of the type of the value computed (
@@ -1869,7 +1879,7 @@
 				<em>Viewpoint Selection</em> dialog and wizard page, the &#8220;plug-in&#8221; decorator for viewpoints loaded from plug-ins is removed, and a &#8220;Folder&#8221; decorator for viewpoints loaded from the current workspace has been added. This makes the icons more visible in the most common where viewpoints come from installed plug-ins.
 			</li>
 		</ul>
-		<h3 id="SpecifierVisibleChanges4">Specifier-Visible Changes</h3>
+		<h3 id="SpecifierVisibleChanges5">Specifier-Visible Changes</h3>
 		<ul>
 			<li><span class="label label-success">Added</span> <span class="label label-info">Experimental</span> Optional support for the experimental 
 				<em>Acceleo Query Language</em> (AQL) has been added to write interpreted expressions.  It is provided by the 
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 694ae9d..51ce4b6 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -13,6 +13,10 @@
 ** If the label is more than 1000 pixels away from the reference point on its corresponding edge, the label is considered as distant.
 ** Between these 2 limits, the label is considered as distant if the distance between the center of the label and the edge is higher than "four times the size of the nearest segment".
 
+h3. Specifier-Visible Changes
+
+* <span class="label label-info">Modified</span> Since this version, in manual refresh mode (_Automatic Refresh_ Sirius preference disabled), when the _Force Refresh_ option of a tool is enabled in your VSM, only the current representation is refreshed when the tool is applied. Before this version, all open representations were refreshed.
+
 h3. Developer-Visible Changes
 
 h4. Migrations
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html
index 024645d..bc453af 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html
@@ -30,7 +30,7 @@
 		<p>
 			<strong>Force Refresh.</strong> Tools have a 
 			<em>Force Refresh</em> flag. As most tools only perform a local change in the underlying model, by default Sirius will try to optimize its refresh operation (which synchronizes the graphical view with the state of the underlying semantic model) by only refreshing elements of the mappings explicitly associated with the tool. If you know your tool will have side-effects which can change other parts of the diagram, set the 
-			<em>Force Refresh</em> flag to force Sirius to perform a complete refresh of the whole diagram after the tool is executed. This ensures a perfect synchronization of the graphical representation with the state of the underlying model, possibly at the cost of performance and reactivity on big diagrams.
+			<em>Force Refresh</em> flag to force Sirius to perform a complete refresh of the whole diagram after the tool is executed. This ensures a perfect synchronization of the graphical representation with the state of the underlying model, possibly at the cost of performance and reactivity on big diagrams. The refresh will be effective only on the current diagram and not on all opened diagrams.
 		</p>
 		<p>
 			<strong>Selection after tool execution.</strong> The 
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile
index bf90d23..692ee3d 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile
@@ -8,7 +8,7 @@
 
 The _Precondition_ of a tool definition can be used to restrict its applicability to only some instances of the _Mappings_ (and _Extra Mappings_) associated with the tool. When the user tries to invoke the tool on an element, the expression will be evaluated in the context of that element' semantic target, and the tool will be applicable only if the expression returns true. Otherwise the user will have a feedback (typically a change in the mouse cursor's shape) to indicate the tool can not be applied on this element.
 
-*Force Refresh.* Tools have a _Force Refresh_ flag. As most tools only perform a local change in the underlying model, by default Sirius will try to optimize its refresh operation (which synchronizes the graphical view with the state of the underlying semantic model) by only refreshing elements of the mappings explicitly associated with the tool. If you know your tool will have side-effects which can change other parts of the diagram, set the _Force Refresh_ flag to force Sirius to perform a complete refresh of the whole diagram after the tool is executed. This ensures a perfect synchronization of the graphical representation with the state of the underlying model, possibly at the cost of performance and reactivity on big diagrams.
+*Force Refresh.* Tools have a _Force Refresh_ flag. As most tools only perform a local change in the underlying model, by default Sirius will try to optimize its refresh operation (which synchronizes the graphical view with the state of the underlying semantic model) by only refreshing elements of the mappings explicitly associated with the tool. If you know your tool will have side-effects which can change other parts of the diagram, set the _Force Refresh_ flag to force Sirius to perform a complete refresh of the whole diagram after the tool is executed. This ensures a perfect synchronization of the graphical representation with the state of the underlying model, possibly at the cost of performance and reactivity on big diagrams. The refresh will be effective only on the current diagram and not on all opened diagrams.
 
 *Selection after tool execution.* The _Elements to select_ and _Inverse Selection Order_ flags can be used to defined what is selected in the active editor after tool execution. 
 By default, only the top level created elements are selected.
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/Vp3616.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/Vp3616.ecore
new file mode 100644
index 0000000..fba9595
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/Vp3616.ecore
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"

+    name="P1" nsPrefix=""/>

diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/Vp3616.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/Vp3616.odesign
new file mode 100644
index 0000000..2517475
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/Vp3616.odesign
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="Vp3616" version="11.1.1.201610211630">

+  <ownedViewpoints name="MyVp3616Viewpoint">

+    <ownedRepresentations xsi:type="description_1:DiagramDescription" name="PackageDiag" domainClass="EPackage" enablePopupBars="true">

+      <defaultLayer name="Default">

+        <containerMappings name="mainPackage" semanticCandidatesExpression="aql:self.eContents()" domainClass="EPackage">

+          <style xsi:type="style:FlatContainerStyleDescription" borderSizeComputationExpression="1">

+            <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>

+            <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>

+            <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>

+            <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>

+          </style>

+        </containerMappings>

+        <toolSections name="tools">

+          <ownedTools xsi:type="tool:ContainerCreationDescription" name="createPackageWithRefresh" forceRefresh="true" containerMappings="//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']/@defaultLayer/@containerMappings[name='mainPackage']">

+            <variable name="container"/>

+            <viewVariable name="containerView"/>

+            <initialOperation>

+              <firstModelOperations xsi:type="tool_1:CreateInstance" typeName="EPackage" referenceName="eSubpackages">

+                <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:'NewPackage'"/>

+              </firstModelOperations>

+            </initialOperation>

+          </ownedTools>

+          <ownedTools xsi:type="tool:ContainerCreationDescription" name="createPackageNotRefresh" containerMappings="//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']/@defaultLayer/@containerMappings[name='mainPackage']">

+            <variable name="container"/>

+            <viewVariable name="containerView"/>

+            <initialOperation>

+              <firstModelOperations xsi:type="tool_1:CreateInstance" typeName="EPackage" referenceName="eSubpackages">

+                <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:'NewPackageWithoutForceRefresh'"/>

+              </firstModelOperations>

+            </initialOperation>

+          </ownedTools>

+        </toolSections>

+      </defaultLayer>

+    </ownedRepresentations>

+  </ownedViewpoints>

+</description:Group>

diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/representations.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/representations.aird
new file mode 100644
index 0000000..18dfe8e
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/refresh/forceRefreshTool/representations.aird
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description">

+  <viewpoint:DAnalysis xmi:id="_Ms_J0FtMEeebnrt9BUfJZA" selectedViews="_GrHRgFtNEeebnrt9BUfJZA" version="11.1.6.201706261600">

+    <semanticResources>Vp3616.ecore</semanticResources>

+    <ownedViews xmi:type="viewpoint:DView" xmi:id="_GrHRgFtNEeebnrt9BUfJZA">

+      <viewpoint xmi:type="description:Viewpoint" href="Vp3616.odesign#//@ownedViewpoints[name='MyVp3616Viewpoint']"/>

+      <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_JGqt8FtNEeebnrt9BUfJZA" name="firstDiag" representation="_JGrVAFtNEeebnrt9BUfJZA">

+        <description xmi:type="description_1:DiagramDescription" href="Vp3616.odesign#//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']"/>

+        <target xmi:type="ecore:EPackage" href="Vp3616.ecore#/"/>

+      </ownedRepresentationDescriptors>

+      <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_K6rCMFtNEeebnrt9BUfJZA" name="secondDiag" representation="_K6tecFtNEeebnrt9BUfJZA">

+        <description xmi:type="description_1:DiagramDescription" href="Vp3616.odesign#//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']"/>

+        <target xmi:type="ecore:EPackage" href="Vp3616.ecore#/"/>

+      </ownedRepresentationDescriptors>

+    </ownedViews>

+  </viewpoint:DAnalysis>

+  <diagram:DSemanticDiagram xmi:id="_JGrVAFtNEeebnrt9BUfJZA" name="firstDiag">

+    <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_JGrVAVtNEeebnrt9BUfJZA" source="DANNOTATION_CUSTOMIZATION_KEY">

+      <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_JGrVAltNEeebnrt9BUfJZA"/>

+    </ownedAnnotationEntries>

+    <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_JHLEQFtNEeebnrt9BUfJZA" source="GMF_DIAGRAMS">

+      <data xmi:type="notation:Diagram" xmi:id="_JHLEQVtNEeebnrt9BUfJZA" type="Sirius" element="_JGrVAFtNEeebnrt9BUfJZA" measurementUnit="Pixel">

+        <styles xmi:type="notation:DiagramStyle" xmi:id="_JHLEQltNEeebnrt9BUfJZA"/>

+      </data>

+    </ownedAnnotationEntries>

+    <description xmi:type="description_1:DiagramDescription" href="Vp3616.odesign#//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']"/>

+    <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_JGrVA1tNEeebnrt9BUfJZA"/>

+    <activatedLayers xmi:type="description_1:Layer" href="Vp3616.odesign#//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']/@defaultLayer"/>

+    <target xmi:type="ecore:EPackage" href="Vp3616.ecore#/"/>

+  </diagram:DSemanticDiagram>

+  <diagram:DSemanticDiagram xmi:id="_K6tecFtNEeebnrt9BUfJZA" name="secondDiag">

+    <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_K6tecVtNEeebnrt9BUfJZA" source="DANNOTATION_CUSTOMIZATION_KEY">

+      <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_K6tecltNEeebnrt9BUfJZA"/>

+    </ownedAnnotationEntries>

+    <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_K6uFgFtNEeebnrt9BUfJZA" source="GMF_DIAGRAMS">

+      <data xmi:type="notation:Diagram" xmi:id="_K6uFgVtNEeebnrt9BUfJZA" type="Sirius" element="_K6tecFtNEeebnrt9BUfJZA" measurementUnit="Pixel">

+        <styles xmi:type="notation:DiagramStyle" xmi:id="_K6uFgltNEeebnrt9BUfJZA"/>

+      </data>

+    </ownedAnnotationEntries>

+    <description xmi:type="description_1:DiagramDescription" href="Vp3616.odesign#//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']"/>

+    <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_K6tec1tNEeebnrt9BUfJZA"/>

+    <activatedLayers xmi:type="description_1:Layer" href="Vp3616.odesign#//@ownedViewpoints[name='MyVp3616Viewpoint']/@ownedRepresentations[name='PackageDiag']/@defaultLayer"/>

+    <target xmi:type="ecore:EPackage" href="Vp3616.ecore#/"/>

+  </diagram:DSemanticDiagram>

+</xmi:XMI>

diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
index eff01d8..475b80e 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
@@ -186,6 +186,7 @@
 import org.eclipse.sirius.tests.unit.diagram.refresh.DanglingReferencesTest;
 import org.eclipse.sirius.tests.unit.diagram.refresh.DiagramElementMappingHelperTest;
 import org.eclipse.sirius.tests.unit.diagram.refresh.DiagramSynchronizerTest;
+import org.eclipse.sirius.tests.unit.diagram.refresh.ForceRefreshToolTest;
 import org.eclipse.sirius.tests.unit.diagram.refresh.LabelExpressionOnEdgeCreationTest;
 import org.eclipse.sirius.tests.unit.diagram.refresh.MultiMappingImportChainsWithSameSemanticTest;
 import org.eclipse.sirius.tests.unit.diagram.refresh.RefreshToolTipTest;
@@ -385,6 +386,7 @@
         suite.addTestSuite(DiagramSynchronizerTest.class);
         suite.addTestSuite(DiagramElementMappingHelperTest.class);
         suite.addTestSuite(DNodeListChildrenReoderingOnChildDirectEditTests.class);
+        suite.addTestSuite(ForceRefreshToolTest.class);
         suite.addTestSuite(LabelExpressionOnEdgeCreationTest.class);
         suite.addTestSuite(RefreshToolTipTest.class);
         suite.addTestSuite(DAnalysisModelsUpdateTests.class);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/ForceRefreshToolTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/ForceRefreshToolTest.java
new file mode 100644
index 0000000..051b3b4
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/ForceRefreshToolTest.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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.sirius.tests.unit.diagram.refresh;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.tests.SiriusTestsPlugin;
+import org.eclipse.sirius.tests.support.api.SiriusDiagramTestCase;
+import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
+import org.eclipse.sirius.viewpoint.DRepresentation;
+
+/**
+ * A test ensuring that the DDiagramElement synchronizer correctly forces refresh. In particular, :
+ * <ul>
+ * <li>ensures that only "force refresh" current diagram is refreshed when automatic refresh preference is disabled.</li>
+ * </ul>
+ * <p>
+ * Relevant tickets :
+ * <ul>
+ * <li>[517956] Do not refresh all diagrams with Force refresh tool</li>
+ * </ul>
+ * </p>
+ * 
+ * @author jmallet</a>
+ */
+public class ForceRefreshToolTest extends SiriusDiagramTestCase {
+
+    private static final String TEST_DATA_FOLDER = SiriusTestsPlugin.PLUGIN_ID + "/data/unit/refresh/forceRefreshTool/";
+
+    private static final String SEMANTIC_MODEL_PATH = TEST_DATA_FOLDER + "Vp3616.ecore";
+
+    private static final String MODELER_DESCRIPTION_PATH = TEST_DATA_FOLDER + "Vp3616.odesign";
+
+    private static final String SESSION_PATH = TEST_DATA_FOLDER + "representations.aird";
+
+    private DDiagram firstDiag;
+
+    private DDiagram secondDiag;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        genericSetUp(SEMANTIC_MODEL_PATH, MODELER_DESCRIPTION_PATH, SESSION_PATH);
+
+        Iterator<DRepresentation> iterator = getRepresentations("PackageDiag").iterator();
+        firstDiag = (DDiagram) iterator.next();
+        DiagramEditor diagramEditor = (DiagramEditor) DialectUIManager.INSTANCE.openEditor(session, firstDiag,
+                new NullProgressMonitor());
+
+        secondDiag = (DDiagram) iterator.next();
+        diagramEditor = (DiagramEditor) DialectUIManager.INSTANCE.openEditor(session, secondDiag,
+                new NullProgressMonitor());
+    }
+
+    /**
+     * Ensures that force refresh works only on current diagram when autoRefresh is disable.
+     * 
+     * @throws Exception
+     *             any exception
+     */
+    public void testForceRefreshWithoutAutoRefresh() throws Exception {
+        // disable autoRefresh Sirius preference
+        changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false);
+
+        // Step 1 : checking that both diagrams are empty
+        assertTrue("Diagram should be empty", firstDiag.getOwnedDiagramElements().isEmpty());
+        assertTrue("Diagram should be empty", secondDiag.getOwnedDiagramElements().isEmpty());
+
+        // Step 2 : applying a Creation tool whit Force Refresh
+        applyNodeCreationTool("createPackageWithRefresh", secondDiag, secondDiag);
+
+        // Step 3 : ensuring that the Creation works and refresh has been activated only on the second diagram
+        assertEquals("Force refresh diagram has not been refreshed. Bad diagram elements number in diagram "
+            + secondDiag.getName(), 1, secondDiag.getOwnedDiagramElements().size());
+        assertTrue("The non 'force refresh' diagram has been refreshed whereas 'automatic refresh' is false.",
+                firstDiag.getOwnedDiagramElements().isEmpty());
+    }
+
+    /**
+     * Ensures that autoRefresh,when it is enable, works when force refresh tool is applied.
+     * 
+     * @throws Exception
+     *             any exception
+     */
+    public void testForceRefreshWithAutoRefresh() throws Exception {
+        // enable autoRefresh Sirius preference
+        changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);
+
+        // Step 1 : checking that both diagrams are empty
+        assertTrue("Diagram should be empty", firstDiag.getOwnedDiagramElements().isEmpty());
+        assertTrue("Diagram should be empty", secondDiag.getOwnedDiagramElements().isEmpty());
+
+        // Step 2 : applying a Creation tool whit Force Refresh
+        applyNodeCreationTool("createPackageWithRefresh", secondDiag, secondDiag);
+
+        // Step 3 : ensuring that the Creation works and refresh has been activated on both diagram
+        assertEquals("Force refresh diagram has not been refreshed. Bad diagram elements number in diagram "
+            + secondDiag.getName(), 1, secondDiag.getOwnedDiagramElements().size());
+        assertEquals("Non 'Force refresh' diagram has not been refreshed. Bad diagram elements number in diagram "
+            + firstDiag.getName(), 1, firstDiag.getOwnedDiagramElements().size());
+    }
+
+    /**
+     * Ensures that autoRefresh,when it is enable, works when tool without force refresh is applied.
+     * 
+     * @throws Exception
+     *             any exception
+     */
+    public void testAutoRefreshWithoutForceRefresh() throws Exception {
+        // enable autoRefresh Sirius preference
+        changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);
+
+        // Step 1 : checking that both diagrams are empty
+        assertTrue("Diagram should be empty", firstDiag.getOwnedDiagramElements().isEmpty());
+        assertTrue("Diagram should be empty", secondDiag.getOwnedDiagramElements().isEmpty());
+
+        // Step 2 : applying a Creation tool without Force Refresh
+        applyNodeCreationTool("createPackageNotRefresh", secondDiag, secondDiag);
+
+        // Step 3 : ensuring that the Creation works and refresh has been activated on both diagram
+        assertEquals("Force refresh diagram has not been refreshed. Bad diagram elements number in diagram "
+            + secondDiag.getName(), 1, secondDiag.getOwnedDiagramElements().size());
+        assertEquals("Non 'Force refresh' diagram has not been refreshed. Bad diagram elements number in diagram "
+            + firstDiag.getName(), 1, firstDiag.getOwnedDiagramElements().size());
+    }
+}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/AbstractCommandFactory.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/AbstractCommandFactory.java
index 7fd71ce..e09e7e9 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/AbstractCommandFactory.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/AbstractCommandFactory.java
@@ -22,6 +22,7 @@
 import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
 import org.eclipse.sirius.ecore.extender.business.api.accessor.exception.FeatureNotFoundException;
 import org.eclipse.sirius.ecore.extender.business.api.accessor.exception.MetaClassNotFoundException;
+import org.eclipse.sirius.tools.api.command.ui.RefreshFilterManager;
 import org.eclipse.sirius.tools.api.command.ui.UICallBack;
 import org.eclipse.sirius.viewpoint.DRepresentation;
 import org.eclipse.sirius.viewpoint.DRepresentationElement;
@@ -65,8 +66,7 @@
      * {@inheritDoc}
      * 
      * @see org.eclipse.sirius.tools.api.command.ICommandFactory#buildCreateRepresentationFromDescription(org.eclipse.sirius.viewpoint.description.tool.RepresentationCreationDescription,
-     *      org.eclipse.sirius.viewpoint.DRepresentationElement,
-     *      java.lang.String)
+     *      org.eclipse.sirius.viewpoint.DRepresentationElement, java.lang.String)
      */
     @Override
     public CreateRepresentationCommand buildCreateRepresentationFromDescription(final RepresentationCreationDescription desc, final DRepresentationElement element, final String newDiagramName) {
@@ -98,13 +98,12 @@
     }
 
     /**
-     * Append the refresh representation task if necessary. The refresh task is
-     * appended if the <code>toolDescription.isForceRefresh()</code> is
-     * <code>true</code> or if {@link #autoRefreshView} is <code>true</code>.
+     * Append the refresh representation task if necessary. The refresh task is appended if the
+     * <code>toolDescription.isForceRefresh()</code> is <code>true</code> or if {@link #autoRefreshView} is
+     * <code>true</code>.
      * 
      * @param semanticDecorator
-     *            the semantic decorator whose parent representation should be
-     *            refreshed.
+     *            the semantic decorator whose parent representation should be refreshed.
      * @param result
      *            the command.
      * @param toolDescription
@@ -145,7 +144,13 @@
                         // - It could be possible that no editor is opened on it
                         // - The tool should probably made a modification only
                         // in the aird model (and this not launches a refresh)
-                        session.getRefreshEditorsListener().addRepresentationToForceRefresh(representationToRefresh);
+                        if (toolDescription == null) {
+                            for (DRepresentation dRepresentation : RefreshFilterManager.INSTANCE.getOpenedRepresantationsToRefresh()) {
+                                session.getRefreshEditorsListener().addRepresentationToForceRefresh(dRepresentation);
+                            }
+                        } else {
+                            session.getRefreshEditorsListener().addRepresentationToForceRefresh(representationToRefresh);
+                        }
                     }
                 });
             }
@@ -153,13 +158,12 @@
     }
 
     /**
-     * Append the refresh representation task if necessary. The refresh task is
-     * appended if the <code>toolDescription.isForceRefresh()</code> is
-     * <code>true</code> or if {@link #autoRefreshView} is <code>true</code>.
+     * Append the refresh representation task if necessary. The refresh task is appended if the
+     * <code>toolDescription.isForceRefresh()</code> is <code>true</code> or if {@link #autoRefreshView} is
+     * <code>true</code>.
      * 
      * @param semanticDecorator
-     *            the semantic decorator whose parent representation should be
-     *            refreshed.
+     *            the semantic decorator whose parent representation should be refreshed.
      * @param result
      *            the command.
      * @param toolDescription
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 3fad292..057ba24 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
@@ -158,7 +158,8 @@
         // DialectEditor interface) */
         Option<? extends Command> result = Options.newNone();
         Collection<DRepresentation> representationsToRefresh = new LinkedHashSet<DRepresentation>();
-        if (isChanged) {
+        // if ForceRefresh is activate and automaticRefresh is disable, only the current diagram is refreshed.
+        if (isChanged && isAutoRefresh()) {
             representationsToRefresh.addAll(RefreshFilterManager.INSTANCE.getOpenedRepresantationsToRefresh());
         }
         representationsToRefresh.addAll(representationsToForceRefresh);