Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2017-01-17 14:43:09 +0000
committerLaurent Redor2017-01-24 17:00:19 +0000
commit1731249f1d434249ac36a2c98035db272ad4abc0 (patch)
tree2227b63150529b8697f396c1d1517a0801f8dd93
parent33bddafbffcbb739c0937cfaaca7fbaa8cd05528 (diff)
downloadorg.eclipse.sirius-1731249f1d434249ac36a2c98035db272ad4abc0.tar.gz
org.eclipse.sirius-1731249f1d434249ac36a2c98035db272ad4abc0.tar.xz
org.eclipse.sirius-1731249f1d434249ac36a2c98035db272ad4abc0.zip
[510850] Fix pb of ignored file during conversion to modeling project
Some files can be ignored with the extension point "org.eclipse.sirius.ui.modelingprojectresourcelistener". But these files are only ignored when they are added to a Modeling Project. The conversion action (Convert to Modeling Project) does not ignore these kind of files. This difference of behavior appears like a bug. On maintenance branch, some deprecated "API" have been added to temporarily solved the problem. On Sirius 5.0.0 another approach will be done (probably with API breaks). Bug: 510850 Cherry-picked-from: 510582 Change-Id: I02ed099f654af6c4d03b08bd9e575327af6ed469 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html45
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile6
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.ecore3
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.genmodel7
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/plugin.xml9
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/ConvertProjectToModelingProjectTest.java77
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/TestModelingProjectResourceListener.java51
-rw-r--r--plugins/org.eclipse.sirius.ui/src-gen/org/eclipse/sirius/viewpoint/provider/SiriusEditPlugin.java16
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java20
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java25
10 files changed, 231 insertions, 28 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index e122737038..c9fc141c3d 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -13,6 +13,14 @@
<a href="#ReleaseNotesforSirius">Release Notes for Sirius</a>
<ol style="list-style: disc;">
<li>
+ <a href="#sirius3.1.8">Changes in Sirius 3.1.8</a>
+ <ol style="list-style: disc;">
+ <li>
+ <a href="#APIChanges">API Changes</a>
+ </li>
+ </ol>
+ </li>
+ <li>
<a href="#sirius3.1.7">Changes in Sirius 3.1.7</a>
<ol style="list-style: disc;">
<li>
@@ -102,7 +110,7 @@
<a href="#SpecifierVisibleChanges6">Specifier-Visible Changes</a>
</li>
<li>
- <a href="#APIChanges">API Changes</a>
+ <a href="#APIChanges2">API Changes</a>
</li>
</ol>
</li>
@@ -112,6 +120,13 @@
<p>This document contains the release notes for recent major releases of Sirius. See also
<a href="Release_Notes_Previous.html">the release notes from previous versions</a> for details about older releases.
</p>
+ <h2 id="sirius3.1.8">Changes in Sirius 3.1.8</h2>
+ <h3 id="APIChanges">API Changes</h3>
+ <ul>
+ <li>The method
+ <code>org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.DefaultModelingProjectResourceListener.isPotentialSemanticResource2(IFile)</code> has been added but directly in deprecated. Indeed, it is a part of a temporary fix, waiting for a more impacting fix made in Sirius 5.0.0. This method will be removed in Sirius 5.0.0. It is not intended to be used by clients.
+ </li>
+ </ul>
<h2 id="sirius3.1.7">Changes in Sirius 3.1.7</h2>
<h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
<ul>
@@ -289,7 +304,7 @@
</ul>
<h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3>
<h4 id="Partialsupportforinternationalization">Partial support for internationalization</h4>
- <p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate &#8220;language packs&#8221; as OSGi fragments. Note that this does not concern the VSM editor&#8217;s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p>
+ <p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate &#171;language packs&#187; as OSGi fragments. Note that this does not concern the VSM editor&#8217;s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p>
<p>Some API changes were required to enable this. While technically breaking changes if interpreting strictly the OSGi versioning rules, the major version number of the impacted bundles was not incremented as the changes only concern classes that should not impact the vast majority of users. Most breaking changes concern the plug-in/activator classes from each bundle. They are:</p>
<ul>
<li><span class="label label-success">Added</span>
@@ -758,7 +773,7 @@
</li>
<li><span class="label label-success">Added</span> On diagrams, it is now possible to set a custom background image on list containers.</li>
<li><span class="label label-info">Modified</span> In the
- <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.
+ <em>Viewpoint Selection</em> dialog and wizard page, the &#171;plug-in&#187; decorator for viewpoints loaded from plug-ins is removed, and a &#171;Folder&#187; 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="SpecifierVisibleChanges5">Specifier-Visible Changes</h3>
@@ -781,12 +796,12 @@
<li><span class="label label-success">Added</span> Compressed SVG images (
<code>*.svgz</code>) are now supported everywhere normal SVG images were supported.
</li>
- <li><span class="label label-success">Added</span> When developing a modeler in &#8220;live mode&#8221;, with the VSM in the same workspace as the sample session(s) which use it, VSM expressions which use
+ <li><span class="label label-success">Added</span> When developing a modeler in &#171;live mode&#187;, with the VSM in the same workspace as the sample session(s) which use it, VSM expressions which use
<code>service:</code> or
<code>aql:</code> can now invoke Java services which are defined in the workspace (with no need to launch a separate runtime).
</li>
<li><span class="label label-success">Added</span> A quick outline is now accessible in the VSM editor by using the shortcut <kbd>Ctrl+o</kbd>. It supports filtering on both an element&#8217;s name and properties for quick, keyboard-only navigation in complex VSMs.</li>
- <li><span class="label label-success">Added</span> The &#8220;hide label by default capability&#8221; has been added to the container styles.</li>
+ <li><span class="label label-success">Added</span> The &#171;hide label by default capability&#187; has been added to the container styles.</li>
<li><span class="label label-success">Added</span> In addition to
<em>Bold</em> and
<em>Italic</em>,
@@ -819,7 +834,7 @@
</li>
<li><span class="label label-success">Improved</span> The precision of the VSM validation, especially regarding the typing of computed expressions, has been greatly improved. Other validation rules like static image paths have also been added or improved.</li>
<li><span class="label label-info">Modified</span> In the VSM editor, the context menu entries (categories and items) have been reorganized to put most common actions/items first.</li>
- <li><span class="label label-info">Modified</span> In diagrams, the style previously named &#8220;Lozenge&#8221; is now called &#8220;Diamond&#8221;.</li>
+ <li><span class="label label-info">Modified</span> In diagrams, the style previously named &#171;Lozenge&#187; is now called &#171;Diamond&#187;.</li>
<li><span class="label label-info">Modified</span> In the
<em>Open</em> menu on a representation, the menu is computed from the navigation tool&#8217;s label instead of its name/id.
</li>
@@ -1702,13 +1717,13 @@
<img border="0" src="images/containerResize-changedBehavior.gif"/>
</p>
<ul>
- <li>The &#8220;snap to shapes&#8221; is now enabled by default (see
+ <li>The &#171;snap to shapes&#187; is now enabled by default (see
<em>Sirius &gt; Sirius Diagram &gt; Rulers and Grid</em> preference page). This is true only for new diagrams. The existing diagrams are not impacted.
</li>
- <li>The &#8220;Navigate&#8221; top-level contextual menu entry with mixed actions for creating new representations and opening existing ones has been changed by two top-level menus:
+ <li>The &#171;Navigate&#187; top-level contextual menu entry with mixed actions for creating new representations and opening existing ones has been changed by two top-level menus:
<ul>
- <li>One named &#8220;New&#8221;, which lists only the available actions to create new representations on the selected element.</li>
- <li>One named &#8220;Open&#8221;, which lists only the existing representations on the selected element. </li>
+ <li>One named &#171;New&#187;, which lists only the available actions to create new representations on the selected element.</li>
+ <li>One named &#171;Open&#187;, which lists only the existing representations on the selected element. </li>
</ul>
</li>
<li>When a shape is resized (no matter the direction), the edge(s) connection location (toward or from this one) is kept. Before that, edges connections moved according to the ratio of the resizing.</li>
@@ -1733,21 +1748,21 @@
<li>Distribute centers vertically</li>
</ul>
</li>
- <li>The end user can now remove all bend-points between the two edge ends. This action is available on edge context menu &#8220;Remove Bend-points&#8221; or by using the shortcut &#8220;Ctrl&#8221; + &#8220;Shift&#8221; + &#8220;-&#8221;.</li>
+ <li>The end user can now remove all bend-points between the two edge ends. This action is available on edge context menu &#171;Remove Bend-points&#187; or by using the shortcut &#171;Ctrl&#187; + &#171;Shift&#187; + &#171;-&#187;.</li>
<li>Reconnection of an edge will only now move the minimum necessary bendpoints instead of reseting it to default.</li>
<li>A new action has been added to reset the diagram (or container) origin: the diagram (or container) bounds (the rectangle formed by the highest, the leftmost, the lowest and the rightmost children elements) can have a negative origin or can be shifted toward the bottom-right with a blank zone at the top-left. This action aims to move all diagram (or container) elements so that the it retrieves its origin while keeping elements layout.</li>
</ul>
<h3 id="SpecifierVisibleChanges6">Specifier-Visible Changes</h3>
<ul>
- <li>The specifier can now choose to hold the edge ends toward the center of the source, target or both. New fields within the &#8220;advance&#8221; tab of EdgeStyle description have been added to choose for which source or target mappings an edge should be centered. See
+ <li>The specifier can now choose to hold the edge ends toward the center of the source, target or both. New fields within the &#171;advance&#187; tab of EdgeStyle description have been added to choose for which source or target mappings an edge should be centered. See
<a href="specifier/diagrams/Diagrams.html#edges_styles">Edges Styles &gt; Edge Centering</a> in the specifier manual for more details.
</li>
<li>When creating a new Viewpoint Specification Project using the supplied wizard:
- <em>New &gt; Viewpoint Specification Project</em>, the VSM name is now given according to the project name. If the project name is suffixed with &#8220;design&#8221;, the VSM name is provided by the last word before this suffix. Otherwise, the VSM name is given by the last word of the project name.
+ <em>New &gt; Viewpoint Specification Project</em>, the VSM name is now given according to the project name. If the project name is suffixed with &#171;design&#187;, the VSM name is provided by the last word before this suffix. Otherwise, the VSM name is given by the last word of the project name.
</li>
- <li>&#8220;Lozenge&#8221; is replaced by &#8220;Diamond&#8221; in diagram style.</li>
+ <li>&#171;Lozenge&#187; is replaced by &#171;Diamond&#187; in diagram style.</li>
</ul>
- <h3 id="APIChanges">API Changes</h3>
+ <h3 id="APIChanges2">API Changes</h3>
<h4 id="Changesinorg.eclipse.sirius4">Changes in
<code>org.eclipse.sirius</code>
</h4>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 91a867b6c0..1454748c2c 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -4,6 +4,12 @@ h1. Release Notes for Sirius
This document contains the release notes for recent major releases of Sirius. See also "the release notes from previous versions":Release_Notes_Previous.html for details about older releases.
+h2(#sirius3.1.8). Changes in Sirius 3.1.8
+
+h3. API Changes
+
+* The method @org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.DefaultModelingProjectResourceListener.isPotentialSemanticResource2(IFile)@ has been added but directly in deprecated. Indeed, it is a part of a temporary fix, waiting for a more impacting fix made in Sirius 5.0.0. This method will be removed in Sirius 5.0.0. It is not intended to be used by clients.
+
h2(#sirius3.1.7). Changes in Sirius 3.1.7
h3. Developer-Visible Changes
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.ecore
new file mode 100644
index 0000000000..876a15ed7b
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.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="testName" nsURI="testURI" nsPrefix="testPrefix"/>
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.genmodel b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.genmodel
new file mode 100644
index 0000000000..e1cea68f7e
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/modeling/My.genmodel
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel"
+ modelDirectory="/Aaaaaaa/src" modelPluginID="Aaaaaaa" modelName="My"
+ importerID="org.eclipse.emf.importer.ecore" complianceLevel="7.0" copyrightFields="false">
+ <foreignModel>My.ecore</foreignModel>
+ <genPackages prefix="TestName" disposableProviderFactory="true" ecorePackage="My.ecore#/"/>
+</genmodel:GenModel>
diff --git a/plugins/org.eclipse.sirius.tests.junit/plugin.xml b/plugins/org.eclipse.sirius.tests.junit/plugin.xml
index 7f724c4223..e3271a0715 100644
--- a/plugins/org.eclipse.sirius.tests.junit/plugin.xml
+++ b/plugins/org.eclipse.sirius.tests.junit/plugin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<!--
- Copyright (c) 2010, 2014 THALES GLOBAL SERVICES
+ Copyright (c) 2010, 2017 THALES GLOBAL SERVICES
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
@@ -78,4 +78,11 @@
id="sampleDataProvider">
</layoutDataManagerProvider>
</extension>
+ <extension
+ id="testModelingProjectResourceListener"
+ point="org.eclipse.sirius.ui.modelingprojectresourcelistener">
+ <resourcelistener
+ class="org.eclipse.sirius.tests.unit.api.convert.TestModelingProjectResourceListener">
+ </resourcelistener>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/ConvertProjectToModelingProjectTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/ConvertProjectToModelingProjectTest.java
index 41b1af51c8..37d5b6f0b1 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/ConvertProjectToModelingProjectTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/ConvertProjectToModelingProjectTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES.
* 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
@@ -63,7 +63,8 @@ public class ConvertProjectToModelingProjectTest extends SiriusTestCase {
private static final String MODELING_PROJECT_NATURE = "Modeling project";
private static final String[] NON_LOADABLE_FILES = { ".checkstyle", ".classpath", ".options", ".project", "about.ini", "build.xml", "classpath.xml", "generate.mtl", "Glossary.html", "image.svg",
- "MANIFEST.MF", "plugin.xml", "pom.xml", "project.xml", "resourcelocator.exsd", "test.docx", "unknownMM.ummfortest", "web.xml", "representations.aird.old", "vsm.odesign.old", "vsm.odesign" };
+ "MANIFEST.MF", "plugin.xml", "pom.xml", "project.xml", "resourcelocator.exsd", "test.docx", "unknownMM.ummfortest", "web.xml", "representations.aird.old", "vsm.odesign.old",
+ "vsm.odesign" };
@Override
protected void setUp() throws Exception {
@@ -188,6 +189,74 @@ public class ConvertProjectToModelingProjectTest extends SiriusTestCase {
checkModelingProject(project, representationFile, 0);
}
+ /**
+ * Launch the conversion on project with an ignored file. This file is
+ * ignored through the extension point
+ * org.eclipse.sirius.ui.modelingprojectresourcelistener. This extension
+ * point is, in theory used only for resources added or removed in an
+ * existing Modeling Project. But ignored files by this extension point were
+ * not ignored during a conversion. A fix has been done in maintenance
+ * branch to also ignore the file during conversion. A new extension point,
+ * more general, will be added in Sirius 5.0.0.
+ */
+ public void testConverProjectToModelingProjectWithIgnoredFiles() {
+ // Create a project with no Modeling project nature
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(TEMPORARY_PROJECT_NAME);
+ assertNotNull("The project should not be null", project);
+
+ // Copy an ecore file and its associated genModel
+ copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, DATA_UNIT_PROJECT_MODELING, "My.ecore", "My.genmodel");
+
+ // Convert the project to a Modeling Project
+ createAndExecuteConvertAction(project);
+
+ // check project is a Modeling project
+ checkProjectNatureIsModeling(project);
+
+ // check representation file is created
+ IFile representationFile = checkRepresentationFileExists(project);
+
+ // check modeling project is loaded with 2 semantic files ("My.ecore",
+ // "My.genmodel")
+ Session session = checkModelingProject(project, representationFile, 2);
+
+ // Convert the project to a "non Modeling Project"
+ createAndExecuteConvertAction(project);
+
+ // check project is not a Modeling project
+ checkProjectNatureIsNotModeling(project);
+
+ // Close the existing session (the "Remove Modeling Project Nature"
+ // action does not close the session)
+ session.close(new NullProgressMonitor());
+ // Delete the representations file
+ try {
+ representationFile.delete(true, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Impossible to delete representation file " + representationFile.getLocation().toOSString() + ": " + e.getMessage());
+ }
+
+ try {
+ // Register the extension that ignores genmodel files
+ TestModelingProjectResourceListener.enable();
+
+ // create convert action
+ createAndExecuteConvertAction(project);
+
+ // check project is a Modeling project
+ checkProjectNatureIsModeling(project);
+
+ // check representation file is created
+ checkRepresentationFileExists(project);
+
+ // check modeling project is loaded with 1 semantic file
+ // ("My.genmodel" must be ignored)
+ checkModelingProject(project, representationFile, 1);
+ } finally {
+ TestModelingProjectResourceListener.disable();
+ }
+ }
+
private IFile createRepresentationFile(IProject project) {
try {
ModelingProjectManager.INSTANCE.createLocalRepresentationsFile(project, new NullProgressMonitor());
@@ -322,7 +391,7 @@ public class ConvertProjectToModelingProjectTest extends SiriusTestCase {
checkModelingProject(project, representationFile, 3);
}
- private void checkModelingProject(IProject project, IFile representationFile, int expectedSemanticResources) {
+ private Session checkModelingProject(IProject project, IFile representationFile, int expectedSemanticResources) {
Option<ModelingProject> modelingProject = ModelingProject.asModelingProject(project);
assertTrue(modelingProject.some());
URI representationFileURI = URI.createPlatformResourceURI(representationFile.getFullPath().toOSString(), true);
@@ -342,6 +411,8 @@ public class ConvertProjectToModelingProjectTest extends SiriusTestCase {
// check there are 1 session resource
assertEquals("The session should contains one session resource.", 1, modelingSession.getAllSessionResources().size());
+
+ return modelingSession;
}
private IFile checkRepresentationFileExists(IProject project) {
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/TestModelingProjectResourceListener.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/TestModelingProjectResourceListener.java
new file mode 100644
index 0000000000..24ff05e55e
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/convert/TestModelingProjectResourceListener.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.api.convert;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.DefaultModelingProjectResourceListener;
+
+/**
+ * This class overrides DefaultModelingProjectResourceListener and also ignores
+ * genmodel files (if it is enabled).<BR>
+ * It is only really enabled when the static method {@link #enable()} is called.
+ * This avoids to have side effect on others tests.
+ *
+ * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
+ */
+public class TestModelingProjectResourceListener extends DefaultModelingProjectResourceListener {
+
+ private static boolean enabled;
+
+ /**
+ * Default constructor
+ */
+ public TestModelingProjectResourceListener() {
+ super();
+ }
+
+ public static void enable() {
+ enabled = true;
+ }
+
+ public static void disable() {
+ enabled = false;
+ }
+
+ @Override
+ protected boolean isPotentialSemanticResource(IFile file) {
+ boolean result = super.isPotentialSemanticResource(file);
+ if (enabled) {
+ result = result && !"genmodel".equals(file.getFileExtension());
+ }
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.sirius.ui/src-gen/org/eclipse/sirius/viewpoint/provider/SiriusEditPlugin.java b/plugins/org.eclipse.sirius.ui/src-gen/org/eclipse/sirius/viewpoint/provider/SiriusEditPlugin.java
index b69bccde59..59b88590a8 100644
--- a/plugins/org.eclipse.sirius.ui/src-gen/org/eclipse/sirius/viewpoint/provider/SiriusEditPlugin.java
+++ b/plugins/org.eclipse.sirius.ui/src-gen/org/eclipse/sirius/viewpoint/provider/SiriusEditPlugin.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2007, 2014 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2017 THALES GLOBAL SERVICES and others.
* 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
@@ -479,6 +479,20 @@ public final class SiriusEditPlugin extends EMFPlugin {
this.uiCallback = uiCallback;
}
+ /**
+ * Return the instantiated {@link IModelingProjectResourceListener}.
+ * This method has been added only in maintenance branch of Sirius,
+ * directly in deprecated as in will be removed in Sirius 5.0.0. It
+ * should not be used by clients. It has been added to avoid an API
+ * break.
+ *
+ * @return the instantiated {@link IModelingProjectResourceListener}.
+ * @deprecated
+ */
+ @Deprecated
+ public IModelingProjectResourceListener getModelingProjectListener() {
+ return modelingProjectListener;
+ }
}
/**
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java
index 8bc5287674..c5ec0adc2a 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2017 THALES GLOBAL SERVICES.
* 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
@@ -196,4 +196,22 @@ public class DefaultModelingProjectResourceListener implements IModelingProjectR
return file != null && new ModelingProjectFileQuery(file).isPotentialSemanticResource();
}
+ /**
+ * Check if the file must be considered as semantic resource during semantic
+ * resource detection. If it is, this listener will check if is it loadable.
+ * <BR>
+ * Added only in maintenance branch to avoid an API break by changing the
+ * visibility of {@link #isPotentialSemanticResource(IFile)}. This method
+ * will be removed in Sirius 5.0.0.<BR>
+ * This method is not intended to be used by clients.
+ *
+ * @param file
+ * an added file
+ * @return <code>false</code> if the file should be ignored.
+ * @deprecated
+ */
+ @Deprecated
+ public boolean isPotentialSemanticResource2(IFile file) {
+ return isPotentialSemanticResource(file);
+ }
}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
index 80a5acf1b8..d20b52c7cf 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2011, 2017 THALES GLOBAL SERVICES and others.
* 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
@@ -49,6 +49,8 @@ import org.eclipse.sirius.common.tools.api.resource.ResourceSetFactory;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.tools.api.command.semantic.AddSemanticResourceCommand;
import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
+import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.DefaultModelingProjectResourceListener;
+import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.IModelingProjectResourceListener;
import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.ModelingProjectFileQuery;
import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.OpenRepresentationsFileJob;
import org.eclipse.sirius.viewpoint.provider.Messages;
@@ -75,7 +77,7 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
public void notify(Session updated, int notification) {
if (notification == SessionListener.OPENING) {
// No need to at it again to the sessionFileLoading list because
- // we add it during the starting of the load
+ // we add it during the starting of the load
// ModelingProjectManager.loadAndOpenSession().
} else if (notification == SessionListener.OPENED) {
sessionFileLoading.remove(updated.getSessionResource().getURI());
@@ -244,7 +246,7 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
};
ResourcesPlugin.getWorkspace().run(create, monitor);
}
-
+
@Override
public void createLocalRepresentationsFile(IProject project, IProgressMonitor monitor) throws CoreException {
URI representationsURI = URI.createPlatformResourceURI(project.getFullPath().append(ModelingProject.DEFAULT_REPRESENTATIONS_FILE_NAME).toString(), true);
@@ -377,11 +379,20 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
private Command getSemanticResourcesAdditionCommand(IContainer container, Session session, IProgressMonitor monitor) throws CoreException {
CompoundCommand cc = new CompoundCommand();
if (container != null) {
+ IModelingProjectResourceListener modelingProjectResourceListener = SiriusEditPlugin.getPlugin().getModelingProjectListener();
for (IResource resource : container.members()) {
- if (resource instanceof IFile && new ModelingProjectFileQuery((IFile) resource).isPotentialSemanticResource() && isLoadableModel((IFile) resource, session)) {
- final URI uri = URI.createPlatformResourceURI(resource.getFullPath().toOSString(), true);
- AddSemanticResourceCommand cmd = new AddSemanticResourceCommand(session, uri, new SubProgressMonitor(monitor, 1));
- cc.append(cmd);
+ if (resource instanceof IFile) {
+ boolean isPotentialSemanticResource;
+ if (modelingProjectResourceListener instanceof DefaultModelingProjectResourceListener) {
+ isPotentialSemanticResource = ((DefaultModelingProjectResourceListener) modelingProjectResourceListener).isPotentialSemanticResource2((IFile) resource);
+ } else {
+ isPotentialSemanticResource = new ModelingProjectFileQuery((IFile) resource).isPotentialSemanticResource();
+ }
+ if (isPotentialSemanticResource && isLoadableModel((IFile) resource, session)) {
+ final URI uri = URI.createPlatformResourceURI(resource.getFullPath().toOSString(), true);
+ AddSemanticResourceCommand cmd = new AddSemanticResourceCommand(session, uri, new SubProgressMonitor(monitor, 1));
+ cc.append(cmd);
+ }
} else if (resource instanceof IContainer) {
Command subCc = getSemanticResourcesAdditionCommand((IContainer) resource, session, monitor);
if (subCc.canExecute()) {

Back to the top