Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2019-07-09 08:13:39 -0400
committerMaxime Porhel2019-07-19 08:55:48 -0400
commit1e758a7f17d77548675702feabb574ba0e301225 (patch)
treee691c3f46c8a354c957627ffcb819f0e8c4d3575
parent7130a6e214c3d5c5a23c6a3d8b6e978867f56639 (diff)
downloadorg.eclipse.sirius-1e758a7f17d77548675702feabb574ba0e301225.tar.gz
org.eclipse.sirius-1e758a7f17d77548675702feabb574ba0e301225.tar.xz
org.eclipse.sirius-1e758a7f17d77548675702feabb574ba0e301225.zip
[549054] Avoid duplicated calls to EditPart.getRoot() and
MapModeUtil.getMapMode() Bug: 549054 Change-Id: I94f2160df2817bd3a8399dcf14a00ece7507e8ac Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decoration/AbstractSiriusDecorationDescriptorProvider.java16
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/decoration/SiriusGenericDecorator.java10
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarArrangeMenuManager.java27
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/ArrangeSelectionLayoutProvider.java48
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java22
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java29
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java8
-rw-r--r--plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java11
-rw-r--r--plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/AlphaDropShadowBorder.java16
-rw-r--r--plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/RoundedCornerMarginBorder.java11
10 files changed, 108 insertions, 90 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decoration/AbstractSiriusDecorationDescriptorProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decoration/AbstractSiriusDecorationDescriptorProvider.java
index 5cca56586e..9bb99582db 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decoration/AbstractSiriusDecorationDescriptorProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decoration/AbstractSiriusDecorationDescriptorProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017 THALES GLOBAL SERVICES.
+ * Copyright (c) 2019 THALES GLOBAL SERVICES.
* 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
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator;
import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
import org.eclipse.gmf.runtime.notation.View;
@@ -94,7 +95,7 @@ public abstract class AbstractSiriusDecorationDescriptorProvider implements Siri
*/
protected boolean shouldBeDecorated(final EditPart editPart) {
boolean shouldBeDecorated = true;
- if (editPart == null || editPart.getParent() == null || editPart.getRoot() == null || editPart.getViewer() == null) {
+ if (isUnsafeEditPart(editPart)) {
shouldBeDecorated = false;
} else if (editPart instanceof AbstractDiagramNameEditPart && !(editPart instanceof DNodeListElementEditPart)) {
/*
@@ -106,6 +107,17 @@ public abstract class AbstractSiriusDecorationDescriptorProvider implements Siri
return shouldBeDecorated;
}
+ private boolean isUnsafeEditPart(final EditPart editPart) {
+ boolean unsafe = false;
+ if (editPart == null || editPart.getParent() == null) {
+ unsafe = true;
+ } else {
+ RootEditPart root = editPart.getRoot();
+ unsafe = root == null || root.getViewer() == null;
+ }
+ return unsafe;
+ }
+
/**
* Indicates if the given editPart should contain decorations according to its type. For example,
* {@link DNodeListNameEditPart}s should not be decorated.
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/decoration/SiriusGenericDecorator.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/decoration/SiriusGenericDecorator.java
index 8c584ed977..f24719172a 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/decoration/SiriusGenericDecorator.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/decoration/SiriusGenericDecorator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017, 2018 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2017, 2019 THALES GLOBAL SERVICES and others.
* 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
@@ -38,6 +38,7 @@ import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderedShapeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.services.decorator.AbstractDecorator;
@@ -855,8 +856,11 @@ public class SiriusGenericDecorator extends AbstractDecorator {
}
final GraphicalEditPart ownerEditPart = (GraphicalEditPart) getDecoratorTarget().getAdapter(GraphicalEditPart.class);
- if (ownerEditPart != null && ownerEditPart.getRoot() != null && ownerEditPart.getViewer() != null) {
- ownerEditPart.getViewer().getVisualPartMap().remove(decoration);
+ if (ownerEditPart != null) {
+ RootEditPart root = ownerEditPart.getRoot();
+ if (root != null && root.getViewer() != null) {
+ root.getViewer().getVisualPartMap().remove(decoration);
+ }
}
}
decorations = new ArrayList<IDecoration>();
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarArrangeMenuManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarArrangeMenuManager.java
index 1122c2e55a..e2ee1f668d 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarArrangeMenuManager.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarArrangeMenuManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010-2015 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010-2019 THALES GLOBAL SERVICES.
* 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
@@ -40,8 +40,7 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
/**
- * An arrange menu manager which handle cleanly {@link IDisposableAction} and
- * set correctly handler for tabbar.
+ * An arrange menu manager which handle cleanly {@link IDisposableAction} and set correctly handler for tabbar.
*
* @author mchauvin
*/
@@ -215,8 +214,7 @@ public class TabbarArrangeMenuManager extends ArrangeMenuManager implements ISel
}
/**
- * Remove all "Arrange" actions: - Arrange Selection - Arrange All - Arrange
- * Linked Border Nodes
+ * Remove all "Arrange" actions: - Arrange Selection - Arrange All - Arrange Linked Border Nodes
*/
private void removeArrangeActions() {
remove(ActionIds.ACTION_TOOLBAR_ARRANGE_SELECTION);
@@ -234,11 +232,9 @@ public class TabbarArrangeMenuManager extends ArrangeMenuManager implements ISel
}
/**
- * Check that there are only two arrange actions when the diagram is
- * selected.
+ * Check that there are only two arrange actions when the diagram is selected.
*
- * @return true id there are only two arrange actions when the diagram is
- * selected
+ * @return true id there are only two arrange actions when the diagram is selected
*/
private boolean isArrangeAllAndBorderNodes() {
return find(ActionIds.ACTION_TOOLBAR_ARRANGE_ALL) != null && find(org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds.ARRANGE_BORDER_NODES_TOOLBAR) != null;
@@ -246,13 +242,12 @@ public class TabbarArrangeMenuManager extends ArrangeMenuManager implements ISel
/**
* <p>
- * Disables the given action if the diagram containing the selected elements
- * doesn't support arrange selection Action.
+ * Disables the given action if the diagram containing the selected elements doesn't support arrange selection
+ * Action.
* </p>
* <p>
- * <b>Note</b> : any diagram associated to a LayoutNodeProvider which
- * implements ArrangeAllOnlyLayoutProvider does not support ArrangeSelection
- * Action.
+ * <b>Note</b> : any diagram associated to a LayoutNodeProvider which implements ArrangeAllOnlyLayoutProvider does
+ * not support ArrangeSelection Action.
*
* @param toolbarArrangeSelectionAction
* the action
@@ -273,9 +268,9 @@ public class TabbarArrangeMenuManager extends ArrangeMenuManager implements ISel
}
}
- if (graphicalElement != null && graphicalElement.isActive() && graphicalElement.getRoot() != null) {
+ if (graphicalElement != null && graphicalElement.isActive()) {
RootEditPart root = graphicalElement.getRoot();
- if (!root.getChildren().isEmpty() && root.getChildren().iterator().next() instanceof IGraphicalEditPart) {
+ if (root != null && !root.getChildren().isEmpty() && root.getChildren().iterator().next() instanceof IGraphicalEditPart) {
IGraphicalEditPart diagramEditPart = (IGraphicalEditPart) root.getChildren().iterator().next();
// Step 2 : we get the LayoutNodeProvider associated to this
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/ArrangeSelectionLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/ArrangeSelectionLayoutProvider.java
index e28952c7bf..98072da3b2 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/ArrangeSelectionLayoutProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/ArrangeSelectionLayoutProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2010 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2019 THALES GLOBAL SERVICES.
* 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
@@ -20,6 +20,7 @@ import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.commands.UnexecutableCommand;
@@ -37,10 +38,9 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
/**
- * Layout provider that add a list of diagram elements to keep fixed in the
- * LayoutHint, during arrange selection action. This information will be used
- * later in the PinnedElementHandler and PinnedElementLayoutProvider. It is
- * executed before the generic arrange operation.
+ * Layout provider that add a list of diagram elements to keep fixed in the LayoutHint, during arrange selection action.
+ * This information will be used later in the PinnedElementHandler and PinnedElementLayoutProvider. It is executed
+ * before the generic arrange operation.
*
* @author smonnier
*
@@ -48,15 +48,13 @@ import com.google.common.collect.Lists;
public class ArrangeSelectionLayoutProvider extends AbstractLayoutProvider {
/**
- * The initial layout provider that arrange the nodes (launch before the
- * arrange of bordered nodes and before updating the list of diagram element
- * to keep fixed on arrange).
+ * The initial layout provider that arrange the nodes (launch before the arrange of bordered nodes and before
+ * updating the list of diagram element to keep fixed on arrange).
*/
private AbstractLayoutProvider initialLayoutProvider;
/**
- * List of IDiagramElementEditPart not selected and unpinned on the current
- * diagram.
+ * List of IDiagramElementEditPart not selected and unpinned on the current diagram.
*/
private ArrayList<IDiagramElementEditPart> notSelectedShapeNodeEditPartAndUnpinned;
@@ -90,8 +88,7 @@ public class ArrangeSelectionLayoutProvider extends AbstractLayoutProvider {
* The default constructor.
*
* @param clp
- * The layout provider to call after finding diagram element to
- * keep fixed on arrange all.
+ * The layout provider to call after finding diagram element to keep fixed on arrange all.
*/
public ArrangeSelectionLayoutProvider(AbstractLayoutProvider clp) {
initialLayoutProvider = clp;
@@ -100,8 +97,8 @@ public class ArrangeSelectionLayoutProvider extends AbstractLayoutProvider {
/**
* {@inheritDoc}
*
- * This method is overridden to have the arrange selection acting as an
- * arrange all where non selected elements are pinned.
+ * This method is overridden to have the arrange selection acting as an arrange all where non selected elements are
+ * pinned.
*
* @see org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractLayoutEditPartProvider#layoutEditParts(java.util.List,
* org.eclipse.core.runtime.IAdaptable)
@@ -139,8 +136,9 @@ public class ArrangeSelectionLayoutProvider extends AbstractLayoutProvider {
addChildrenToNotSelectedUnpinnedList(notSelectedShapeNodeEditPart);
// Add all edges that connect two unpinned elements in the
// unpinned list
- if (igep.getRoot().getChildren().size() == 1 && igep.getRoot().getChildren().get(0) instanceof DiagramEditPart) {
- addEdgesToNotSelectedUnpinnedList((DiagramEditPart) igep.getRoot().getChildren().get(0));
+ RootEditPart root = igep.getRoot();
+ if (root.getChildren().size() == 1 && root.getChildren().get(0) instanceof DiagramEditPart) {
+ addEdgesToNotSelectedUnpinnedList((DiagramEditPart) root.getChildren().get(0));
}
// Update Layout Hint to find later (in
@@ -182,8 +180,8 @@ public class ArrangeSelectionLayoutProvider extends AbstractLayoutProvider {
* Add, if needed, children that are also unpinned.
*
* @param notSelectedParent
- * list of parents which are not selected for which you want to
- * browse the children to possibly add to the unpinned list
+ * list of parents which are not selected for which you want to browse the children to possibly add to
+ * the unpinned list
*/
private void addChildrenToNotSelectedUnpinnedList(Collection<? extends EditPart> notSelectedParent) {
for (EditPart editPart : notSelectedParent) {
@@ -197,10 +195,9 @@ public class ArrangeSelectionLayoutProvider extends AbstractLayoutProvider {
}
/**
- * Adds all the edges that connect two pinned nodes (or considered as such)
- * in the list of <code>notSelectedShapeNodeEditPartAndUnpinned</code>. This
- * list of edges is used in {@link AbstractCompositeLayoutProvider} to avoid
- * the call of method routeThrough.
+ * Adds all the edges that connect two pinned nodes (or considered as such) in the list of
+ * <code>notSelectedShapeNodeEditPartAndUnpinned</code>. This list of edges is used in
+ * {@link AbstractCompositeLayoutProvider} to avoid the call of method routeThrough.
*/
private void addEdgesToNotSelectedUnpinnedList(DiagramEditPart diagramEditPart) {
for (Object connection : diagramEditPart.getConnections()) {
@@ -215,15 +212,14 @@ public class ArrangeSelectionLayoutProvider extends AbstractLayoutProvider {
}
/**
- * Tests whether an edit part is pinned or should be considered as pinned
- * (fixed size and location) during the layout.
+ * Tests whether an edit part is pinned or should be considered as pinned (fixed size and location) during the
+ * layout.
*
* @param editPart
* the edit part.
* @param editPartsConsiderAsPinned
* list of editParts that have to be consider as pinned
- * @return <code>true</code> if the edit part is pinned or should be
- * considered as pinned.
+ * @return <code>true</code> if the edit part is pinned or should be considered as pinned.
*/
protected boolean isPinnedOrConsiderAs(EditPart editPart, List<IDiagramElementEditPart> editPartsConsiderAsPinned) {
return editPart instanceof IGraphicalEditPart && (isPinned((IGraphicalEditPart) editPart) || editPartsConsiderAsPinned.contains(editPart));
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java
index 89688245d6..aee71320cc 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2019 THALES GLOBAL SERVICES and others.
* 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
@@ -44,6 +44,7 @@ import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.commands.UnexecutableCommand;
@@ -898,8 +899,10 @@ public class BorderItemAwareLayoutProvider extends AbstractLayoutProvider {
// Get the zoom level
double scale = 1.0;
- if (castedEditPart.getRoot() instanceof DiagramRootEditPart) {
- final ZoomManager zoomManager = ((DiagramRootEditPart) castedEditPart.getRoot()).getZoomManager();
+ RootEditPart root = castedEditPart.getRoot();
+ if (root instanceof DiagramRootEditPart) {
+ DiagramRootEditPart diagramRootEditPart = (DiagramRootEditPart) root;
+ final ZoomManager zoomManager = ((DiagramRootEditPart) root).getZoomManager();
scale = zoomManager.getZoom();
}
@@ -986,11 +989,14 @@ public class BorderItemAwareLayoutProvider extends AbstractLayoutProvider {
* the border nodes to apply snap command on.
*/
private void addSnapCommand(CompoundCommand resCommand, List<IBorderItemEditPart> allBorderNodes) {
- if (!allBorderNodes.isEmpty() && allBorderNodes.get(0).getViewer() instanceof DiagramGraphicalViewer) {
- IPreferenceStore preferenceStore = ((DiagramGraphicalViewer) allBorderNodes.get(0).getViewer()).getWorkspaceViewerPreferenceStore();
- if (preferenceStore != null && preferenceStore.getBoolean(WorkspaceViewerProperties.SNAPTOGRID)) {
- for (IBorderItemEditPart editPart : allBorderNodes) {
- resCommand.add(new ICommandProxy(new SnapCommand(editPart.getEditingDomain(), Collections.singletonList(editPart))));
+ if (!allBorderNodes.isEmpty()) {
+ EditPartViewer viewer = allBorderNodes.get(0).getViewer();
+ if (viewer instanceof DiagramGraphicalViewer) {
+ IPreferenceStore preferenceStore = ((DiagramGraphicalViewer) viewer).getWorkspaceViewerPreferenceStore();
+ if (preferenceStore != null && preferenceStore.getBoolean(WorkspaceViewerProperties.SNAPTOGRID)) {
+ for (IBorderItemEditPart editPart : allBorderNodes) {
+ resCommand.add(new ICommandProxy(new SnapCommand(editPart.getEditingDomain(), Collections.singletonList(editPart))));
+ }
}
}
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java
index 1b49f6faaf..be081df7f4 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2019 THALES GLOBAL SERVICES.
* 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
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.editparts.ZoomManager;
@@ -59,24 +60,20 @@ import com.google.common.collect.Maps;
public class PinnedElementsLayoutProvider extends DefaultLayoutProvider {
/**
- * Key to store that the move request is sent from this specific layout
- * provider to reset bounds of edit part to its origin location and size.
- * <BR>
- * The move request sets only the location but has, as side effect, to also
- * use the same {@link org.eclipse.gmf.runtime.notation.Size} as the origin.
- * <BR>
+ * Key to store that the move request is sent from this specific layout provider to reset bounds of edit part to its
+ * origin location and size. <BR>
+ * The move request sets only the location but has, as side effect, to also use the same
+ * {@link org.eclipse.gmf.runtime.notation.Size} as the origin. <BR>
* For example, the move of a region is forbidden (see
* {@link org.eclipse.sirius.diagram.ui.graphical.edit.policies.RegionResizableEditPolicy#getMoveCommand(ChangeBoundsRequest)}
- * ). The user has not the authorization to move a region of a container.
- * But if this flag exists in the extended data of the request, the move is
- * "forced".
+ * ). The user has not the authorization to move a region of a container. But if this flag exists in the extended
+ * data of the request, the move is "forced".
*
*/
public static final String PINNED_ELEMENTS_MOVE = "sirius.pinned.elements.move.request"; //$NON-NLS-1$
/**
- * The layout provider which was executed before us. Needed to obtain the
- * new
+ * The layout provider which was executed before us. Needed to obtain the new
*/
private final ExtendableLayoutProvider baseProvider;
@@ -172,8 +169,7 @@ public class PinnedElementsLayoutProvider extends DefaultLayoutProvider {
}
/**
- * Finds the "real" children of the specified edit part that needs to be
- * laid out.
+ * Finds the "real" children of the specified edit part that needs to be laid out.
*/
private Collection<IGraphicalEditPart> getChildrenOfInterest(final IGraphicalEditPart gep) {
final Iterable<IGraphicalEditPart> rawChildren = Iterables.filter(gep.getChildren(), IGraphicalEditPart.class);
@@ -211,8 +207,9 @@ public class PinnedElementsLayoutProvider extends DefaultLayoutProvider {
final Object existingRequest = this.findRequest(editPart, org.eclipse.gef.RequestConstants.REQ_MOVE);
ChangeBoundsRequest request = null;
double scale = 1.0;
- if (editPart.getRoot() instanceof DiagramRootEditPart) {
- final ZoomManager zoomManager = ((DiagramRootEditPart) editPart.getRoot()).getZoomManager();
+ RootEditPart root = editPart.getRoot();
+ if (root instanceof DiagramRootEditPart) {
+ final ZoomManager zoomManager = ((DiagramRootEditPart) root).getZoomManager();
scale = zoomManager.getZoom();
}
if (existingRequest instanceof ChangeBoundsRequest) {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java
index 84863b361a..fc752cf05a 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2018 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2008, 2019 THALES GLOBAL SERVICES and others.
* 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
@@ -35,6 +35,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gef.EditDomain;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener;
@@ -268,9 +269,10 @@ public class PopupMenuContribution implements IContributionItemProvider {
*/
protected Point getCurrentLocation(EditPart primarySelection) {
org.eclipse.swt.graphics.Point cursorLocation = PlatformUI.getWorkbench().getDisplay().getCursorLocation();
- final FigureCanvas control = (FigureCanvas) primarySelection.getRoot().getViewer().getControl();
+ EditPartViewer viewer = primarySelection.getRoot().getViewer();
+ final FigureCanvas control = (FigureCanvas) viewer.getControl();
final org.eclipse.swt.graphics.Point screenRelativeSWTPoint = control.toControl(cursorLocation);
- EditPart editPartUnderMouse = primarySelection.getRoot().getViewer().findObjectAtExcluding(new Point(screenRelativeSWTPoint.x, screenRelativeSWTPoint.y), Collections.EMPTY_LIST);
+ EditPart editPartUnderMouse = viewer.findObjectAtExcluding(new Point(screenRelativeSWTPoint.x, screenRelativeSWTPoint.y), Collections.EMPTY_LIST);
Point currentLocation = new Point(screenRelativeSWTPoint.x, screenRelativeSWTPoint.y);
if (editPartUnderMouse instanceof GraphicalEditPart) {
diff --git a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java
index aaaae221e3..6431fb49c4 100644
--- a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java
+++ b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java
@@ -28,6 +28,7 @@ import org.eclipse.draw2d.geometry.PrecisionRectangle;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.SnapToGrid;
import org.eclipse.gef.handles.HandleBounds;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart;
@@ -60,8 +61,9 @@ public final class GraphicalHelper {
public static double getZoom(EditPart part) {
Objects.requireNonNull(part);
double scale = 1.0;
- if (part.getRoot() instanceof DiagramRootEditPart) {
- DiagramRootEditPart rootEditPart = (DiagramRootEditPart) part.getRoot();
+ RootEditPart root = part.getRoot();
+ if (root instanceof DiagramRootEditPart) {
+ DiagramRootEditPart rootEditPart = (DiagramRootEditPart) root;
scale = rootEditPart.getZoomManager().getZoom();
}
return scale;
@@ -158,8 +160,9 @@ public final class GraphicalHelper {
*/
public static void setZoom(IGraphicalEditPart part, double scale) {
Objects.requireNonNull(part);
- if (part.getRoot() instanceof DiagramRootEditPart) {
- DiagramRootEditPart rootEditPart = (DiagramRootEditPart) part.getRoot();
+ RootEditPart root = part.getRoot();
+ if (root instanceof DiagramRootEditPart) {
+ DiagramRootEditPart rootEditPart = (DiagramRootEditPart) root;
rootEditPart.getZoomManager().setZoom(scale);
}
}
diff --git a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/AlphaDropShadowBorder.java b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/AlphaDropShadowBorder.java
index ae0ed220e1..9eb7c62a9c 100644
--- a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/AlphaDropShadowBorder.java
+++ b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/AlphaDropShadowBorder.java
@@ -1,5 +1,5 @@
/***********************************************************************
- * Copyright (c) 2008, 2018 Anyware Technologies and others.
+ * Copyright (c) 2008, 2019 Anyware Technologies and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -25,6 +25,7 @@ import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.diagram.ui.figures.DiagramColorConstants;
import org.eclipse.gmf.runtime.draw2d.ui.figures.DropShadowBorder;
import org.eclipse.gmf.runtime.draw2d.ui.figures.IPolygonAnchorableFigure;
+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
import org.eclipse.sirius.ext.draw2d.figure.IRoundedCorner;
import org.eclipse.swt.graphics.Color;
@@ -33,8 +34,7 @@ import org.eclipse.swt.graphics.Color;
* A border using a shadow<br>
* creation : 17 mai. 08
*
- * @author <a href="mailto:simon.bernard@anyware-tech.com">Simon Bernard</a>
- * CHECKSTYLE:OFF
+ * @author <a href="mailto:simon.bernard@anyware-tech.com">Simon Bernard</a> CHECKSTYLE:OFF
*/
public class AlphaDropShadowBorder extends AbstractBackground implements DropShadowBorder {
@@ -90,8 +90,9 @@ public class AlphaDropShadowBorder extends AbstractBackground implements DropSha
Insets insetsNew = new Insets();
insetsNew.top = 0;
insetsNew.left = 0;
- insetsNew.bottom = MapModeUtil.getMapMode(figure).DPtoLP(shift * 2);
- insetsNew.right = MapModeUtil.getMapMode(figure).DPtoLP(shift * 2);
+ IMapMode mapMode = MapModeUtil.getMapMode(figure);
+ insetsNew.bottom = mapMode.DPtoLP(shift * 2);
+ insetsNew.right = mapMode.DPtoLP(shift * 2);
return insetsNew;
}
@@ -100,8 +101,9 @@ public class AlphaDropShadowBorder extends AbstractBackground implements DropSha
Insets insetsNew = new Insets();
insetsNew.top = 0;
insetsNew.left = 0;
- insetsNew.bottom = MapModeUtil.getMapMode(figure).DPtoLP(shift * 2);
- insetsNew.right = MapModeUtil.getMapMode(figure).DPtoLP(shift * 2);
+ IMapMode mapMode = MapModeUtil.getMapMode(figure);
+ insetsNew.bottom = mapMode.DPtoLP(shift * 2);
+ insetsNew.right = mapMode.DPtoLP(shift * 2);
return insetsNew;
}
diff --git a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/RoundedCornerMarginBorder.java b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/RoundedCornerMarginBorder.java
index 2334f7c930..7ce786a205 100644
--- a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/RoundedCornerMarginBorder.java
+++ b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/gef/ui/figures/RoundedCornerMarginBorder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2018 Obeo.
+ * Copyright (c) 2015, 2019 Obeo.
* 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
@@ -17,6 +17,7 @@ import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
/**
@@ -67,9 +68,10 @@ public class RoundedCornerMarginBorder extends OneLineMarginBorder {
}
super.paint(figure, graphics, cornerAwareInsets);
- int one = MapModeUtil.getMapMode(figure).DPtoLP(1);
+ IMapMode mapMode = MapModeUtil.getMapMode(figure);
+ int one = mapMode.DPtoLP(1);
int widthInDP = getWidth() / one;
- int halfWidthInLP = MapModeUtil.getMapMode(figure).DPtoLP(widthInDP / 2);
+ int halfWidthInLP = mapMode.DPtoLP(widthInDP / 2);
if (!corner.isEmpty()) {
switch (getPosition()) {
@@ -104,8 +106,7 @@ public class RoundedCornerMarginBorder extends OneLineMarginBorder {
}
/**
- * Sets the dimensions of each corner. This will form the radii of the arcs
- * which form the corners.
+ * Sets the dimensions of each corner. This will form the radii of the arcs which form the corners.
*
* @param d
* the dimensions of the corner

Back to the top