diff options
| author | Laurent Redor | 2017-01-24 16:23:50 +0000 |
|---|---|---|
| committer | Laurent Redor | 2017-02-01 11:05:44 +0000 |
| commit | 5223e74e6f0575dcc5b171f10eb54227d9f74593 (patch) | |
| tree | 48f79c5ffb059180a2f6069108cb96bb3431529d | |
| parent | dabed5af630e30f8c7eedd246643131eee76b6b2 (diff) | |
| download | org.eclipse.sirius-5223e74e6f0575dcc5b171f10eb54227d9f74593.tar.gz org.eclipse.sirius-5223e74e6f0575dcc5b171f10eb54227d9f74593.tar.xz org.eclipse.sirius-5223e74e6f0575dcc5b171f10eb54227d9f74593.zip | |
[510969] 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: 510969
Cherry-picked-from: 510582
Change-Id: I02ed099f654af6c4d03b08bd9e575327af6ed469
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
10 files changed, 226 insertions, 24 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index ce988edc8a..6e058728f1 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -13,7 +13,7 @@ <a href="#ReleaseNotesforSirius">Release Notes for Sirius</a> <ol style="list-style: disc;"> <li> - <a href="#sirius4.1.3">Changes in Sirius 4.1.3</a> + <a href="#sirius4.1.4">Changes in Sirius 4.1.4</a> <ol style="list-style: disc;"> <li> <a href="#DeveloperVisibleChanges">Developer-Visible Changes</a> @@ -21,13 +21,21 @@ </ol> </li> <li> + <a href="#sirius4.1.3">Changes in Sirius 4.1.3</a> + <ol style="list-style: disc;"> + <li> + <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a> + </li> + </ol> + </li> + <li> <a href="#sirius4.1.2">Changes in Sirius 4.1.2</a> <ol style="list-style: disc;"> <li> <a href="#UserVisibleChanges">User-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a> </li> </ol> </li> @@ -38,7 +46,7 @@ <a href="#UserVisibleChanges2">User-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges4">Developer-Visible Changes</a> </li> </ol> </li> @@ -52,7 +60,7 @@ <a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges4">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a> </li> </ol> </li> @@ -66,7 +74,7 @@ <a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a> </li> </ol> </li> @@ -80,7 +88,7 @@ <a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a> </li> </ol> </li> @@ -94,7 +102,7 @@ <a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges8">Developer-Visible Changes</a> </li> </ol> </li> @@ -104,8 +112,15 @@ <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="sirius4.1.3">Changes in Sirius 4.1.3</h2> + <h2 id="sirius4.1.4">Changes in Sirius 4.1.4</h2> <h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3> + <ul> + <li><span class="label label-success">Added</span> 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="sirius4.1.3">Changes in Sirius 4.1.3</h2> + <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3> <h4 id="Changesinorg.eclipse.sirius.tests.junit.support">Changes in <code>org.eclipse.sirius.tests.junit.support</code> </h4> @@ -124,7 +139,7 @@ <br/> <img border="0" src="./images/PreferencePageMaxTabName.png"/> </p> - <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> <code>org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManagerWithMapping</code> class has been added to handle copy/paste format with mapping information when an element target of a format pasting has many source diagram format corresponding to its key. In this case, we use the mapping information to get the more precise data format. And if no result matched, then we return the first found by using the key. @@ -159,7 +174,7 @@ <ul> <li><span class="label label-info">Modified</span>The “straighten to” actions were previously disabled when an edge is connected to border nodes that have several edges. It is now allowed.</li> </ul> - <h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> <code>org.eclipse.sirius.table.business.api.helper.TableHelper.getEStructuralFeature(DLine, DColumn)</code> method has been added to retrieve the EStructuralFeature associated to a table column. @@ -282,7 +297,7 @@ <code>org.eclipse.sirius.diagram.ui.formatDataManager</code>. The deprecated extension point will be removed in the next 5.0 Sirius major release. Several classes associated with this deprecated extension point are also deprecated (see Developer-Visible Changes for details). </li> </ul> - <h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges5">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> As the first step to save the DRepresentation in its own resource, <code>org.eclipse.sirius.viewpoint.DView.getOwnedRepresentationDescriptors()</code> has been added as a wrapper of the @@ -770,7 +785,7 @@ </li> <li><span class="label label-info">Modified</span> The variable under VariableFilter, previously named “Variable”, is renamed to “Select Model Element Variable”. It is functionally equivalent.</li> </ul> - <h3 id="DeveloperVisibleChanges5">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges6">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> It is now possible to provide a full customized tab-bar by implementing the <code>ITabbarContributor</code> through the @@ -1252,7 +1267,7 @@ <code>IPermissionAuthority</code>) of the potential to delete objects. This is the reverse order of what was done before, and can have performance impacts if the precondition is slow. The specifier will to take care to ensure a good performance for the precondition expression of the delete tool. </li> </ul> - <h3 id="DeveloperVisibleChanges6">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges7">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 “language packs” as OSGi fragments. Note that this does not concern the VSM editor’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> @@ -1809,7 +1824,7 @@ <em>EStructuralFeature</em> (inherited or with same name). </li> </ul> - <h3 id="DeveloperVisibleChanges7">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges8">Developer-Visible Changes</h3> <p>The most important and impacting changes in this release are (details below in plug-in specific sections):</p> <ul> <li><span class="label label-success">Added</span> The new extension point diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index 78af8ad6b8..8cb6fa2bf9 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(#sirius4.1.4). Changes in Sirius 4.1.4 + +h3. Developer-Visible Changes + +* <span class="label label-success">Added</span> 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(#sirius4.1.3). Changes in Sirius 4.1.3 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 daecc1ee14..6ec6465c1f 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, 2016 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 @@ -99,4 +99,11 @@ id="sampleDataProviderDeprecatedExtensionPoint"> </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 0d61aaac19..c333f7d7a4 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, 2016 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 @@ -193,6 +193,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()); @@ -327,7 +395,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); @@ -347,6 +415,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 16d2651b22..ee79b05142 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, 2016 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 @@ -529,6 +529,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 f9df3d454e..3fb53ca6a4 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, 2016 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 @@ -193,4 +193,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 cc559b1105..9ffc61988b 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, 2016 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 @@ -53,6 +53,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.SiriusPlugin; @@ -456,11 +458,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()) { |
