diff options
| author | Florian Barbin | 2016-03-25 10:02:26 +0000 |
|---|---|---|
| committer | Steve Monnier | 2016-11-09 13:55:36 +0000 |
| commit | 0c5c182f6b57900ccf80ac2f8999f0a28708ecee (patch) | |
| tree | 7dbc50e996677e48237b6247adb50a8601b678ce | |
| parent | ad951e6401025631c12f48c111a4bb3dc34c589c (diff) | |
| download | org.eclipse.sirius-0c5c182f6b57900ccf80ac2f8999f0a28708ecee.tar.gz org.eclipse.sirius-0c5c182f6b57900ccf80ac2f8999f0a28708ecee.tar.xz org.eclipse.sirius-0c5c182f6b57900ccf80ac2f8999f0a28708ecee.zip | |
[506420] make figures under lock decorator selectable
A specific DecoratorTarget is now used in order to have no behavior when
selecting a decorator and instead delegate the selection behavior of the
element below the decorator, which can be different that the decorator
parents in case of overlappings (like a border node beneath the
decorator of the parent node).
Bug: 506420
Change-Id: I66e4acf52fc1869872e599fe4b99931dbe254b98
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
6 files changed, 186 insertions, 12 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractBorderedDiagramElementEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractBorderedDiagramElementEditPart.java index 2fa9d6b834..dcd110bf7b 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractBorderedDiagramElementEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractBorderedDiagramElementEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2013, 2016 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 @@ -18,12 +18,14 @@ import org.eclipse.gef.SnapToHelper; import org.eclipse.gef.editparts.ZoomManager; import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.sirius.diagram.DDiagramElement; import org.eclipse.sirius.diagram.ui.edit.internal.part.AbstractDiagramNodeEditPartOperation; import org.eclipse.sirius.diagram.ui.edit.internal.part.DiagramElementEditPartOperation; import org.eclipse.sirius.diagram.ui.edit.internal.part.EditStatusUpdater; +import org.eclipse.sirius.diagram.ui.graphical.edit.policies.SiriusDecoratorEditPolicy; import org.eclipse.sirius.diagram.ui.tools.api.permission.EditPartAuthorityListener; import org.eclipse.sirius.diagram.ui.tools.internal.ruler.SiriusSnapToHelperUtil; import org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority; @@ -58,6 +60,13 @@ public abstract class AbstractBorderedDiagramElementEditPart extends AbstractBor super(view); } + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + removeEditPolicy(EditPolicyRoles.DECORATION_ROLE); + installEditPolicy(EditPolicyRoles.DECORATION_ROLE, new SiriusDecoratorEditPolicy()); + } + /** * {@inheritDoc} * diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusDecoratorEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusDecoratorEditPolicy.java new file mode 100644 index 0000000000..3a482326ab --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusDecoratorEditPolicy.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.graphical.edit.policies; + +import java.util.HashMap; +import java.util.Iterator; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Locator; +import org.eclipse.draw2d.TreeSearch; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DecorationEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.internal.services.decorator.DecoratorService; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.Decoration; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoration; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator; + +/** + * A specific {@link DecorationEditPolicy} that provides its own + * {@link DecoratorTarget} in order to ignore the decorator when selected and + * select the diagram element behind it instead. This way if a border node is + * under a decorator of the parent node, it is still selectable. + * + * @author <a href="mailto:florian.barbin@obeo.fr">Florian Barbin</a> + * + */ +@SuppressWarnings("restriction") +public class SiriusDecoratorEditPolicy extends DecorationEditPolicy { + + /** + * This method was overridden in order to create a + * {@link SiriusDecoratorTarget} instead of a default + * {@link DecoratorTarget}. + */ + @SuppressWarnings({ "rawtypes" }) + @Override + public void activate() { + if (decorators == null) { + decorators = new HashMap(); + DecoratorService.getInstance().createDecorators(new SiriusDecoratorTarget()); + } + if (decorators != null) { + for (Iterator iter = decorators.values().iterator(); iter.hasNext(); ) { + IDecorator decorator = (IDecorator) iter.next(); + decorator.activate(); + } + } + } + + /** + * This method was overridden in order to create a + * {@link SiriusDecoratorTarget} instead of a default + * {@link DecoratorTarget}. + */ + @SuppressWarnings({ "rawtypes" }) + @Override + public void refresh() { + if (decorators == null) { + decorators = new HashMap(); + DecoratorService.getInstance().createDecorators(new SiriusDecoratorTarget()); + } + for (Iterator iter = decorators.values().iterator(); iter.hasNext(); ) { + IDecorator decorator = (IDecorator) iter.next(); + decorator.refresh(); + } + } + + private final class SiriusDecoratorTarget extends DecoratorTarget { + + /** + * This method was overridden in order to create a decoration that on + * selection behave as if it did not exist (allowing to select the + * diagram element underneath). + */ + @SuppressWarnings("unchecked") + @Override + public IDecoration addDecoration(IFigure figure, Locator locator, boolean isVolatile) { + + Decoration decoration = new Decoration() { + @Override + public IFigure findFigureAt(int x, int y, TreeSearch search) { + return null; + } + }; + decoration.add(figure); + decoration.setSize(figure.getSize()); + + GraphicalEditPart ownerEditPart = (GraphicalEditPart) getAdapter(GraphicalEditPart.class); + decoration.setOwnerFigure(ownerEditPart.getFigure()); + decoration.setLocator(locator); + + // Register this figure with it's owner editpart so mouse events + // will be propagated to it's host. + ownerEditPart.getViewer().getVisualPartMap().put(decoration, ownerEditPart); + + IFigure pane = getLayer(isVolatile ? DiagramRootEditPart.DECORATION_UNPRINTABLE_LAYER : DiagramRootEditPart.DECORATION_PRINTABLE_LAYER); + + pane.add(decoration); + return decoration; + } + } +} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java index 6ee1cbc1a7..95695ef162 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java @@ -19,6 +19,7 @@ import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.LayeredPane; +import org.eclipse.draw2d.TreeSearch; import org.eclipse.draw2d.Viewport; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; @@ -237,7 +238,8 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse { final LayeredPane pane = (LayeredPane) rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS); List<IFigure> figuresToRemove = Lists.newArrayList(); // Collects notification figures that needs to be removed - for (DiagramSemanticElementLockedNotificationFigure diagramSemanticElementLockedNotificationFigure : Iterables.filter(pane.getChildren(), DiagramSemanticElementLockedNotificationFigure.class)) { + for (DiagramSemanticElementLockedNotificationFigure diagramSemanticElementLockedNotificationFigure : Iterables.filter(pane.getChildren(), + DiagramSemanticElementLockedNotificationFigure.class)) { figuresToRemove.add(diagramSemanticElementLockedNotificationFigure); } // Removes these notation figures from Layer @@ -309,4 +311,9 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse { g.setAlpha(255 - transparency * 255 / 100); } + @Override + public IFigure findFigureAt(int x, int y, TreeSearch search) { + return null; + } + } diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 99d65051f4..d3fb0f62e4 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -13,13 +13,21 @@ <a href="#ReleaseNotesforSirius">Release Notes for Sirius</a> <ol style="list-style: disc;"> <li> + <a href="#sirius4.1.2">Changes in Sirius 4.1.2</a> + <ol style="list-style: disc;"> + <li> + <a href="#DeveloperVisibleChanges">Developer-Visible Changes</a> + </li> + </ol> + </li> + <li> <a href="#sirius4.1.1">Changes in Sirius 4.1.1</a> <ol style="list-style: disc;"> <li> <a href="#UserVisibleChanges">User-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a> </li> </ol> </li> @@ -33,7 +41,7 @@ <a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a> </li> </ol> </li> @@ -47,7 +55,7 @@ <a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges4">Developer-Visible Changes</a> </li> </ol> </li> @@ -61,7 +69,7 @@ <a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges4">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a> </li> </ol> </li> @@ -75,7 +83,7 @@ <a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a> </li> </ol> </li> @@ -85,12 +93,19 @@ <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.2">Changes in Sirius 4.1.2</h2> + <h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3> + <ul> + <li><span class="label label-success">Added</span> + <code>org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor.dragCentered(String, Class<? extends EditPart>, int, int)</code> method has been added to provide the EditPart class of the element that should be dragged by the center. + </li> + </ul> <h2 id="sirius4.1.1">Changes in Sirius 4.1.1</h2> <h3 id="UserVisibleChanges">User-Visible Changes</h3> <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="DeveloperVisibleChanges">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges2">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. @@ -213,7 +228,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="DeveloperVisibleChanges2">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges3">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 @@ -701,7 +716,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="DeveloperVisibleChanges3">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges4">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 @@ -1183,7 +1198,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="DeveloperVisibleChanges4">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges5">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> @@ -1740,7 +1755,7 @@ <em>EStructuralFeature</em> (inherited or with same name). </li> </ul> - <h3 id="DeveloperVisibleChanges5">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges6">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 559967c913..bdc9f5480f 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.2). Changes in Sirius 4.1.2 + +h3. Developer-Visible Changes + +* <span class="label label-success">Added</span> @org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor.dragCentered(String, Class<? extends EditPart>, int, int)@ method has been added to provide the EditPart class of the element that should be dragged by the center. + h2(#sirius4.1.1). Changes in Sirius 4.1.1 h3. User-Visible Changes diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java index 3caf7c7709..8ea8a62855 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java +++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java @@ -364,6 +364,32 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor { } /** + * + * Uses the generic mouseDrag functionality to drag the item from its + * center. + * + * @param label + * the label + * @param editPartClass + * The type of the expected edit part + * @param toXPosition + * the relative x position within the graphical viewer to drag to + * @param toYPosition + * the relative y position within the graphical viewer to drag to + * + * @see org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor#drag(java.lang.String, + * int, int) + */ + public void dragCentered(final String label, final Class<? extends EditPart> editPartClass, final int toXPosition, final int toYPosition) { + final SWTBotGefEditPart selectedEP = getEditPart(label, editPartClass); + if (selectedEP == null) { + throw new WidgetNotFoundException(String.format(SWTBotSiriusDiagramEditor.EXPECTED_TO_FIND_WIDGET_S, label)); + } + final Rectangle bounds = ((GraphicalEditPart) selectedEP.part()).getFigure().getBounds(); + drag(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, toXPosition, toYPosition); + } + + /** * Get the EditPartBot representing the EditPart at this location. * * @param location |
