diff options
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common')
20 files changed, 374 insertions, 62 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath index e801ebfb468..81fe078c20c 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/.api_filters b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/.api_filters deleted file mode 100644 index fbd75a89482..00000000000 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/.api_filters +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<component id="org.eclipse.papyrus.infra.gmfdiag.common" version="2"> - <resource path="src/org/eclipse/papyrus/infra/gmfdiag/common/sync/UISyncUtils.java" type="org.eclipse.papyrus.infra.gmfdiag.common.sync.UISyncUtils"> - <filter id="338792546"> - <message_arguments> - <message_argument value="org.eclipse.papyrus.infra.gmfdiag.common.sync.UISyncUtils"/> - <message_argument value="asyncExec(ISyncObject, SyncServiceRunnable<V,X>)"/> - </message_arguments> - </filter> - </resource> -</component> diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs index f09f5504dea..fcf1425718d 100755 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -12,7 +12,7 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false 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 ebb9c24d826..ff876f501ca 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 @@ -1,9 +1,11 @@ Manifest-Version: 1.0 Require-Bundle: com.ibm.icu, - org.apache.batik.dom;bundle-version="[1.6.0,1.7.0)", - org.apache.batik.dom.svg;bundle-version="[1.6.0,1.7.0)", - org.apache.batik.util;bundle-version="[1.6.0,1.7.0)", - org.apache.batik.xml;bundle-version="[1.6.0,1.7.0)", + org.apache.batik.dom;bundle-version="[1.17.0,1.18.0)", + org.apache.batik.dom.svg;bundle-version="[1.17.0,1.18.0)", + org.apache.batik.util;bundle-version="[1.17.0,1.18.0)", + org.apache.batik.xml;bundle-version="[1.17.0,1.18.0)", + org.apache.batik.anim;bundle-version="[1.17.0,1.18.0)", + org.apache.batik.constants;bundle-version="[1.17.0,1.18.0)", org.eclipse.core.databinding.property;bundle-version="[1.8.0,2.0.0)", org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)", org.eclipse.emf.databinding;bundle-version="[1.5.0,2.0.0)", @@ -47,9 +49,9 @@ Require-Bundle: com.ibm.icu, org.eclipse.papyrus.infra.widgets;bundle-version="[4.0.0,5.0.0)", org.eclipse.ui.ide;bundle-version="[3.17.0,4.0.0)", org.eclipse.uml2.types;bundle-version="[2.5.0,3.0.0)", - org.w3c.dom.svg;bundle-version="[1.1.0,2.0.0)", org.eclipse.gmf.runtime.diagram.ui.providers;bundle-version="[1.7.0,2.0.0)", - org.eclipse.papyrus.infra.guava;bundle-version="[1.0.0,2.0.0)" + org.eclipse.papyrus.infra.guava;bundle-version="[1.0.0,2.0.0)", + org.eclipse.orbit.xml-apis-ext;bundle-version="[1.0.0,2.0.0)" Export-Package: org.eclipse.papyrus.infra.gmfdiag.common, org.eclipse.papyrus.infra.gmfdiag.common.adapter, org.eclipse.papyrus.infra.gmfdiag.common.advice, @@ -94,20 +96,20 @@ Export-Package: org.eclipse.papyrus.infra.gmfdiag.common, org.eclipse.papyrus.infra.gmfdiag.common.utils, org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions;x-internal:=true, org.eclipse.papyrus.infra.gmfdiag.internal.common.model;x-internal:=true -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.common.Activator Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-ClassPath: . -Bundle-Version: 4.1.0.qualifier +Bundle-Version: 4.3.200.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.common;singleton:=true -Import-Package: com.google.common.base;version="[30.1.0, 31.0.0)", - com.google.common.collect;version="[30.1.0, 31.0.0)", - com.google.common.util.concurrent;version="[30.1.0, 31.0.0)", +Import-Package: com.google.common.base;version="[32.0.0,33.0.0)", + com.google.common.collect;version="[32.0.0,33.0.0)", + com.google.common.util.concurrent;version="[32.0.0,33.0.0)", org.osgi.service.component.annotations;version="1.3.0";resolution:=optional Automatic-Module-Name: org.eclipse.papyrus.infra.gmfdiag.common -Service-Component: OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl.xml, - OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl.xml +Service-Component: OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl.xml, + OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl.xml diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml index fd848859279..84919191723 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml @@ -43,14 +43,17 @@ label="Refresh" style="push" tooltip="Refresh the current diagram"> - <visibleWhen - checkEnabled="false"> - <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + <visibleWhen> + <and> + <with + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> + </and> </visibleWhen> </command> </menuContribution> @@ -220,6 +223,13 @@ properties="canDelete,isSemanticDeletion" type="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart"> </propertyTester> + <propertyTester + class="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester" + id="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester" + namespace="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester" + properties="isPapyrusGMFDiagramActive" + type="org.eclipse.jface.viewers.IStructuredSelection"> + </propertyTester> </extension> <extension point="org.eclipse.ui.menus"> 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 55516b17229..c2ba82bb608 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.1.0-SNAPSHOT</version> + <version>4.3.200-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/editpart/AbstractResizableCompartmentEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/AbstractResizableCompartmentEditPart.java new file mode 100644 index 00000000000..b54d76586fd --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/AbstractResizableCompartmentEditPart.java @@ -0,0 +1,91 @@ +/***************************************************************************** +* Copyright (c) 2021 CEA LIST, ARTAL +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License 2.0 +* which accompanies this distribution, and is available at +* https://www.eclipse.org/legal/epl-2.0/ +* +* SPDX-License-Identifier: EPL-2.0 +* +* Contributors: +* Etienne ALLOGO (ARTAL) - Initial API and implementation +* Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : generate less dead or duplicate code +*****************************************************************************/ + +package org.eclipse.papyrus.infra.gmfdiag.common.editpart; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; +import org.eclipse.gmf.runtime.notation.NotationPackage; + +/** + * An intermediate class with the common methods used by resizeable list compartments (inherit from ResizeableListCompartmentEditPart). + * + * @author allogo + * @since 4.2 + */ +public abstract class AbstractResizableCompartmentEditPart extends ResizeableListCompartmentEditPart { + + /** + * Constructor. + * + * @param model + * the model + */ + public AbstractResizableCompartmentEditPart(EObject model) { + super(model); + } + + @Override + public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); + } + + @Override + protected void handleNotificationEvent(Notification notification) { + Object feature = notification.getFeature(); + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + refreshBounds(); + } + super.handleNotificationEvent(notification); + } + + @Override + protected void refreshBounds() { + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + Dimension size = new Dimension(width, height); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + Point loc = new Point(x, y); + ((GraphicalEditPart) getParent()).setLayoutConstraint( + this, + getFigure(), + new Rectangle(loc, size)); + } + + @Override + protected void refreshVisuals() { + super.refreshVisuals(); + refreshBounds(); + } + + @Override + protected void setRatio(Double ratio) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + super.setRatio(ratio); + } + } + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NavigableShapeCompartmentEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NavigableShapeCompartmentEditPart.java new file mode 100644 index 00000000000..940557d0b16 --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NavigableShapeCompartmentEditPart.java @@ -0,0 +1,89 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : Pull up refreshVisuals/setRatio for shape compartments + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.editpart; + +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.requests.SelectionRequest; +import org.eclipse.gef.tools.DeselectAllTracker; +import org.eclipse.gmf.runtime.diagram.ui.internal.tools.RubberbandDragTracker; +import org.eclipse.gmf.runtime.notation.View; + +/** + * this is an abstract editpart used to allow double click on XY layout compartment + * + * @since 4.2 + * + */ +@SuppressWarnings("restriction") +public abstract class NavigableShapeCompartmentEditPart extends XYLayoutShapeCompartmentEditPart { + + public NavigableShapeCompartmentEditPart(View view) { + super(view); + } + + /** + * + * @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart#getDragTracker(org.eclipse.gef.Request) + * + */ + @Override + public DragTracker getDragTracker(Request req) { + if (!supportsDragSelection()) { + return super.getDragTracker(req); + } + if (req instanceof SelectionRequest && ((SelectionRequest) req).getLastButtonPressed() == 3) { + return new DeselectAllTracker(this) { + + @Override + protected boolean handleButtonDown(int button) { + getCurrentViewer().select(NavigableShapeCompartmentEditPart.this); + return true; + } + }; + } + return new RubberbandDragTracker() { + + /* + * this method has been respecified in order to allow double click + * on the compartment. + * hence it allows the navigation by double click + */ + @Override + protected boolean handleDoubleClick(int button) { + SelectionRequest request = new SelectionRequest(); + request.setLocation(getLocation()); + request.setType(RequestConstants.REQ_OPEN); + NavigableShapeCompartmentEditPart.this.performRequest(request); + return true; + } + + @Override + protected void handleFinished() { + if (getViewer().getSelectedEditParts().isEmpty()) { + getViewer().select(NavigableShapeCompartmentEditPart.this); + } + } + }; + } + + @Override + public boolean isSelectable() { + return false; + } + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusResizableShapeEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusResizableShapeEditPolicy.java index ef91f12970c..8ae47a3019a 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusResizableShapeEditPolicy.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusResizableShapeEditPolicy.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2013 CEA LIST. + * Copyright (c) 2013, 2023 CEA LIST. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -9,8 +9,8 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Pauline DEVILLE (CEA LIST) <pauline.deville@cea.fr> - Bug 582075 * *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.common.editpolicies; @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Set; import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.ChangeBoundsRequest; import org.eclipse.gef.tools.ResizeTracker; @@ -132,7 +131,7 @@ public class PapyrusResizableShapeEditPolicy extends ResizableShapeEditPolicy { */ @Override protected ResizeTracker getResizeTracker(int direction) { - return new ResizeTrackerWithPreferences((GraphicalEditPart) getHost(), direction); + return new ResizeTrackerWithPreferences(getHost(), direction); } protected static enum MovedNodeKind { @@ -147,7 +146,7 @@ public class PapyrusResizableShapeEditPolicy extends ResizableShapeEditPolicy { private final Set<EditPart> myKnownIndirectlyNo; - public CachedEditPartsSet(List<EditPart> directlyMoved) { + public CachedEditPartsSet(List<? extends EditPart> directlyMoved) { myDirectlyMoved = new HashSet<>(directlyMoved); myKnownIndirectlyNo = new HashSet<>(directlyMoved.size() * 5 + 1); myKnownIndirectlyYes = new HashSet<>(directlyMoved.size() * 5 + 1); diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java index 6f69ce0f689..d319824483d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010, 2014, 2018 CEA LIST and others. + * Copyright (c) 2010, 2014, 2018, 2023 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 @@ -13,6 +13,7 @@ * Laurent Wouters (CEA LIST) laurent.wouters@cea.fr - Refactoring, cleanup, added support for PapyrusLabel element * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Add IRoundedRectangleFigure use case(436547) * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - NPE if SVG unit is not in pixels (521232) + * Pascal Bannerot (CEA LIST) pascal.bannerot@cea.fr - Bug 582007 * *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.common.figure.node; @@ -173,6 +174,8 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure { element = svgDocument.getElementById("PapyrusLabel"); if (element != null) { labelBounds = toDraw2DRectangle((SVGRectElement) element); + // Bug 582007: force labelBounds value to null to prevent freeze (infinite refresh loop) + labelBounds = null; } } else { this.svgDimension = null; @@ -395,7 +398,7 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure { */ private Rectangle getDraw2DAnchor() { if (this.getChildren().size() > 0 && this.getChildren().get(0) instanceof IFigure) { - IFigure primaryShape = (IFigure) this.getChildren().get(0); + IFigure primaryShape = this.getChildren().get(0); for (Object subFigure : primaryShape.getChildren()) { if (subFigure instanceof ScalableCompartmentFigure) { return ((IFigure) subFigure).getBounds(); diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/PopupBarEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/PopupBarEditPolicyProvider.java index 3a0a1273a62..1d8f0ccdbe2 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/PopupBarEditPolicyProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/PopupBarEditPolicyProvider.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2012, 2014 CEA LIST, Christian W. Damus, and others. + * Copyright (c) 2012, 2014, 2023 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -12,7 +12,7 @@ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Christian W. Damus - bug 451230 * Shuai Li - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - bug 577845 *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.common.providers; @@ -27,6 +27,7 @@ import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvide import org.eclipse.papyrus.infra.core.services.ServiceException; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusPopupBarEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil; import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart; /** @@ -47,6 +48,9 @@ public class PopupBarEditPolicyProvider extends AbstractProvider implements IEdi if (operation instanceof CreateEditPoliciesOperation) { CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation; EditPart editPart = epOperation.getEditPart(); + if (!ProviderServiceUtil.isPapyrusPart(editPart)) { + return false; + } try { ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(editPart); if (registry == null) { diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/selection/PapyrusRubberbandSelectionTool.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/selection/PapyrusRubberbandSelectionTool.java index 63c10b3b6a8..2eb7bab9516 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/selection/PapyrusRubberbandSelectionTool.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/selection/PapyrusRubberbandSelectionTool.java @@ -455,7 +455,7 @@ public class PapyrusRubberbandSelectionTool extends AbstractTool { private HashSet<EditPart> getAllChildren(EditPart editPart, HashSet<EditPart> currentSelection) { // List all the editPart children - List<EditPart> children = editPart.getChildren(); + List<? extends EditPart> children = editPart.getChildren(); // for each child, add the child and all its connections to the currentSelection for (int i = 0; i < children.size(); i++) { 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/service/shape/AbstractShapeProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java index c2f15ec90db..29593dc9533 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; -import org.apache.batik.dom.svg.SAXSVGDocumentFactory; +import org.apache.batik.anim.dom.SAXSVGDocumentFactory; import org.apache.batik.dom.util.DOMUtilities; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.draw2d.PositionConstants; diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/sync/ContainerChildrenSyncFeature.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/sync/ContainerChildrenSyncFeature.java index 567c615d400..da5f07b88f3 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/sync/ContainerChildrenSyncFeature.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/sync/ContainerChildrenSyncFeature.java @@ -73,6 +73,6 @@ public abstract class ContainerChildrenSyncFeature<M extends EObject, N extends @SuppressWarnings("unchecked") @Override Iterable<? extends T> basicGetContents(T backend) { - return getEffectiveEditPart(backend).getChildren(); + return (Iterable<? extends T>) getEffectiveEditPart(backend).getChildren(); } } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramEditPartsUtil.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramEditPartsUtil.java index a3da4d4cfb5..8040ffbd293 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramEditPartsUtil.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramEditPartsUtil.java @@ -570,7 +570,7 @@ public class DiagramEditPartsUtil { return; } - List<EditPart> children = editPart.getChildren(); + List<? extends EditPart> children = editPart.getChildren(); for (EditPart ep : children) { if (ep instanceof IGraphicalEditPart) { 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.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/EditPartUtils.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/EditPartUtils.java index 29973c9bf12..9ca64b3bde7 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/EditPartUtils.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/EditPartUtils.java @@ -52,8 +52,7 @@ public class EditPartUtils { } } } - @SuppressWarnings("unchecked") - final List<EditPart> children = editPart.getChildren(); + final List<? extends EditPart> children = editPart.getChildren(); for (final EditPart child : children) { internalFindChildEditPartsWithId(child, visualId, result); } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/FigureUtils.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/FigureUtils.java index ccd530091c6..e64f90674ab 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/FigureUtils.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/FigureUtils.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2012 CEA LIST. + * Copyright (c) 2012, 2023 CEA LIST. * * * All rights reserved. This program and the accompanying materials @@ -8,7 +8,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 581898 *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.common.utils; @@ -41,7 +41,7 @@ public final class FigureUtils { */ @SuppressWarnings("unchecked") public static <T extends IFigure> T findChildFigureInstance(final IFigure parent, final Class<T> childFigureClass) { - final List<IFigure> children = parent.getChildren(); + final List<? extends IFigure> children = parent.getChildren(); for (final IFigure child : children) { if (childFigureClass.isAssignableFrom(child.getClass())) { return (T) child; @@ -67,7 +67,7 @@ public final class FigureUtils { if (parent == null) { return; } - final List<IFigure> children = parent.getChildren(); + final List<? extends IFigure> children = parent.getChildren(); for (final IFigure child : children) { if (childFigureClass.isAssignableFrom(child.getClass())) { result.add((T) child); diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/internal/common/expressions/PapyrusGMFDiagramTester.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/internal/common/expressions/PapyrusGMFDiagramTester.java new file mode 100644 index 00000000000..776ba74e5b6 --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/internal/common/expressions/PapyrusGMFDiagramTester.java @@ -0,0 +1,66 @@ +/***************************************************************************** + * Copyright (c) 2021 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.gmfdiag.common.SynchronizableGmfDiagramEditor; +import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.ui.util.EditorHelper; +import org.eclipse.ui.IEditorPart; + +/** + * This tester is used to check if the current Editor is a Papyrus GMF diagram (and not a papyrus Sirius Diagram) (see bug 577822) + */ +public class PapyrusGMFDiagramTester extends PropertyTester { + + /** + * this property is used to know is the current Editor is a Papyrus GMF diagram (and not a papyrus Sirius Diagram) + */ + private static final String IS_PAPYRUS_GMF_DIAGRAM_ACTIVE = "isPapyrusGMFDiagramActive";//$NON-NLS-1$ + + + /** + * + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + * + * @param receiver + * @param property + * @param args + * @param expectedValue + * @return + */ + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (IS_PAPYRUS_GMF_DIAGRAM_ACTIVE.equals(property) && receiver instanceof IStructuredSelection && expectedValue instanceof Boolean) { + return expectedValue.equals(isPapyrusGMFDiagramActive()); + } + return false; + } + + + /** + * + * @return + * <code>true</code> if the current active editor represents a Papyrus GMF Editor + */ + private final boolean isPapyrusGMFDiagramActive() { + IEditorPart editorPart = EditorHelper.getCurrentEditor(); + // this code also should work when the SynchronizableGmfDiagramEditor is not embedded in the IMultiDiagramEditor + if (editorPart instanceof IMultiDiagramEditor) { + editorPart = ((IMultiDiagramEditor) editorPart).getActiveEditor(); + } + return editorPart instanceof SynchronizableGmfDiagramEditor; + } +} |