diff options
6 files changed, 71 insertions, 9 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF index 3a5765238fb..138bef12448 100755 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF @@ -99,7 +99,7 @@ Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.common.Activator Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-ClassPath: . -Bundle-Version: 4.2.0.qualifier +Bundle-Version: 4.3.0.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-ManifestVersion: 2 diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml index 5a748174bbb..76eff12ab77 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml @@ -9,6 +9,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.infra.gmfdiag.common</artifactId> - <version>4.2.0-SNAPSHOT</version> + <version>4.3.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java index c7dadd06b19..a9d2887378f 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2018 EclipseSource and others. + * Copyright (c) 2018, 2022 EclipseSource and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,16 +10,18 @@ * * Contributors: * EclipseSource - Initial API and implementation (Bug 533701) - * + * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - Bug 577845 *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.common.service; import org.eclipse.gef.EditPart; import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider; import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; +import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart; /** @@ -32,6 +34,46 @@ import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart; public class ProviderServiceUtil { /** + * this method allows to identify if the editpart is associated to a Papyrus GMF Diagram (diagram.eContainer()==null) + * + * @param editPart + * an edit part + * @return + * <code>true</code> if the editPart probably concerns the Papyrus GMF Diagram + * <code>false</code> otherwise (editPart is <code>null</code> or diagram.eContainer()!=null in case of a Papyrus Sirius Diagram) + * + */ + private static final boolean isPapyrusGMFPart(final EditPart editPart) { + if (editPart != null) { + final Object model = editPart.getModel(); + if (model instanceof View) { + return isPapyrusGMFView((View) model); + } + } + return false; + } + + /** + * this method allows to identify if the view is associated to a Papyrus GMF Diagram (diagram.eContainer()==null) + * + * @param view + * a view + * @return + * <code>true</code> if the view probably concerns the Papyrus GMF Diagram + * <code>false</code> otherwise (view is <code>null</code> or diagram.eContainer()!=null in case of a Papyrus Sirius Diagram) + * + */ + private static final boolean isPapyrusGMFView(final View view) { + if (view != null) { + final Diagram d = view.getDiagram(); + if (d != null) { + return DiagramUtils.isPapyrusGMFDiagram(d); + } + } + return false; + } + + /** * <p> * Tests if the given edit part is a Papyrus Edit Part, by testing if a Papyrus {@link ServicesRegistry} * is present. @@ -43,6 +85,9 @@ public class ProviderServiceUtil { * <code>true</code> if this edit part is part of a Papyrus environment (Using a Papyrus {@link ServicesRegistry}), <code>false</code> otherwise */ public static boolean isPapyrusPart(EditPart editPart) { + if (!isPapyrusGMFPart(editPart)) { + return false; + } try { return ServiceUtilsForEditPart.getInstance().getServiceRegistry(editPart) != null; } catch (Exception ex) { @@ -63,6 +108,9 @@ public class ProviderServiceUtil { * <code>true</code> if this view is part of a Papyrus environment (Using a Papyrus {@link ServicesRegistry}), <code>false</code> otherwise */ public static boolean isPapyrusView(View view) { + if (!isPapyrusGMFView(view)) { + return false; + } try { return ServiceUtilsForEObject.getInstance().getServiceRegistry(view) != null; } catch (Exception ex) { diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramUtils.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramUtils.java index 2c7fed7f86b..5ab212de21a 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramUtils.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramUtils.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2013, 2017, 2019, 2020 CEA LIST and others. + * Copyright (c) 2013, 2017, 2019, 2020, 2022 CEA LIST and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,8 +15,7 @@ * Christian W. Damus - bug 527580 * Ansgar Radermacher - bug 539754 * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550568 - * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 560644 - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 560644, 577845 *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.common.utils; @@ -412,4 +411,17 @@ public class DiagramUtils { return null; } + /** + * + * @param diagram + * a diagram, can't be <code>null</code> + * @return + * <code>true</code> if the view probably concerns the Papyrus GMF Diagram (diagram.eContainer()==null) + * <code>false</code> the view probably concerns a Papyrus Sirius Diagram (diagram.eContainer()!=null) + * @since 4.3 + */ + public static final boolean isPapyrusGMFDiagram(final Diagram diagram) { + return diagram.eContainer() == null; // diagram.eContainer()!=null for papyrus sirius diagram + } + } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java index 1b61d1a5b69..522b0210ea3 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java @@ -28,6 +28,7 @@ import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; /** Get the collection of all contained diagrams */ public class GetContainedDiagrams implements IJavaQuery2<EObject, Collection<org.eclipse.gmf.runtime.notation.Diagram>> { @@ -41,7 +42,7 @@ public class GetContainedDiagrams implements IJavaQuery2<EObject, Collection<org if (settings != null) { for (Setting setting : settings) { Diagram diagram = NotationUtils.getOwnedDiagram(setting.getEObject(), source); - if (diagram != null && diagram.eContainer() == null) {// diagram.eContainer()!=null for Sirius Diagram + if (diagram != null && DiagramUtils.isPapyrusGMFDiagram(diagram)) { result.add(diagram); } } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java index 0ff666c07c7..9a4e8e66d97 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java @@ -26,6 +26,7 @@ import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; public class IsDiagramContainer implements IJavaQuery2<EObject, Boolean> { @@ -38,7 +39,7 @@ public class IsDiagramContainer implements IJavaQuery2<EObject, Boolean> { if (settings != null) { for (Setting setting : settings) { Diagram diagram = NotationUtils.getOwnedDiagram(setting.getEObject(), source); - if (diagram != null && diagram.eContainer() == null) {// diagram.eContainer()!=null for Sirius Diagram + if (diagram != null && DiagramUtils.isPapyrusGMFDiagram(diagram)) { return true; } } |