From 82be79eb7277f335d3a707e5f242a4cdf8012654 Mon Sep 17 00:00:00 2001 From: Nicolas PERANSIN Date: Mon, 29 Jul 2024 09:27:27 +0200 Subject: [PATCH] [cleanup] Remove dead or redundant code for LayoutData Code has leftovers after some refactoring. --- .../internal/view/DiagramLayoutData.java | 130 ------------------ .../ui/business/internal/view/LayoutData.java | 4 +- .../internal/view/RootLayoutData.java | 29 ++-- 3 files changed, 12 insertions(+), 151 deletions(-) delete mode 100644 plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/DiagramLayoutData.java diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/DiagramLayoutData.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/DiagramLayoutData.java deleted file mode 100644 index 073ae5f255..0000000000 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/DiagramLayoutData.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2009 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 - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.eclipse.sirius.diagram.ui.business.internal.view; - -import java.util.ArrayList; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.notation.LayoutConstraint; -import org.eclipse.gmf.runtime.notation.Location; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.gmf.runtime.notation.Size; -import org.eclipse.sirius.diagram.AbstractDNode; -import org.eclipse.sirius.diagram.DDiagram; - -/** - * A DiagramLayoutData is the root of an LayoutDataHint. - * - * @author Laurent Redor - * - */ -public class DiagramLayoutData extends RootLayoutData { - - // /** - // * This constructor is used when you want to store the layout data of the - // * DDiagram of editPart and all its children. - // * - // * @param editPart . - // * @param location . - // */ - // public DiagramLayoutData(final ShapeEditPart editPart, final Point - // location) { - // super(editPart, location); - // } - - /** - * This constructor is used when you want to store the layout data of only - * one element which the parent is the DDiagram of editPart. - * - * @param editPart - * . - * @param location - * . - * @param size - * the future size - */ - public DiagramLayoutData(final EditPart editPart, final Point location, final Dimension size) { - super(editPart, location, size); - } - - /** - * Initialize this object (with a new location) and all its children. - * - * @param nodeTarget - * The node to deal with - * @param gmfNode - * the corresponding GMF node - * @param futureLocation - * The future location of the node (or null if the editPart - * location is OK) - */ - @Override - protected void init(final AbstractDNode nodeTarget, final Node gmfNode, final Point futureLocation) { - super.init(nodeTarget, gmfNode); - if (futureLocation != null) { - // Override the location of the nodeTarget - setLocation(futureLocation); - } - } - - /** - * Initialize this object (with a new location and size). The children of - * this object is not added because the - * - * @param parentNodeTarget - * The parent of the node to deal with - * @param parentGmfNode - * the corresponding GMF node - * @param futureLocation - * The future location of the node (or null if the editPart - * location is OK) - * @param futureSize - * The future size of the node (or null if the editPart size is - * OK) - */ - protected void init(final AbstractDNode parentNodeTarget, final Node parentGmfNode, final Point futureLocation, final Dimension futureSize) { - setTarget(parentNodeTarget); - final LayoutConstraint constaint = parentGmfNode.getLayoutConstraint(); - if (futureSize != null) { - setSize(futureSize); - } else if (constaint instanceof Size) { - setSize(new Dimension(((Size) constaint).getWidth(), ((Size) constaint).getHeight())); - } - if (futureLocation != null) { - // Take this location as a priority value if it's not null - setLocation(futureLocation); - } else if (constaint instanceof Location) { - setLocation(new Point(((Location) constaint).getX(), ((Location) constaint).getY())); - } - setChildren(new ArrayList()); - } - - /** - * Search recursively in in all the DiagramLayoutData is there is one which - * have the diagram for target. - * - * @param diagram - * The search diagram - * @param ignoreConsumeState - * true to ignore the consume state and to authorize to consume - * an already consumed data, false otherwise - * @return the corresponding LayoutData or null if not found. - */ - @Override - public LayoutData getData(final DDiagram diagram, boolean ignoreConsumeState) { - final LayoutData result = (ignoreConsumeState || !isConsume()) && getTarget().equals(diagram) ? this : null; - return result; - } -} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/LayoutData.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/LayoutData.java index acf17fd6b8..7d8d7bfa7f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/LayoutData.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/LayoutData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2021 THALES GLOBAL SERVICES and others. + * Copyright (c) 2009, 2024 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 @@ -215,7 +215,7 @@ public List getChildren() { } /** - * Search recursively in in all the LayoutData is there is one which have + * Search recursively in in all the LayoutData if there is one which have * the element for target. * * @param node diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/RootLayoutData.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/RootLayoutData.java index 77fc5305df..082b179e2f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/RootLayoutData.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/RootLayoutData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2021 THALES GLOBAL SERVICES and others. + * Copyright (c) 2009, 2024 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 @@ -57,16 +57,7 @@ public class RootLayoutData extends LayoutData { * the future size */ public RootLayoutData(final EditPart editPart, final Point location, final Dimension size) { - final Object adaptObject = EditPartTools.getParentOfType(editPart, IGraphicalEditPart.class).resolveSemanticElement(); - if (adaptObject instanceof AbstractDNode) { - init((AbstractDNode) adaptObject, location, size); - } else if (adaptObject instanceof DDiagram) { - init((DDiagram) adaptObject, location, size); - } else if (adaptObject instanceof DEdge) { - init((DEdge) adaptObject, location, size); - } else { - AbstractSiriusFormatDataManager.logUnhandledDiagramElementKindMessage(adaptObject); - } + this(EditPartTools.getParentOfType(editPart, IGraphicalEditPart.class).resolveSemanticElement(), location, size); } /** @@ -107,12 +98,10 @@ public RootLayoutData(final AbstractDNode target, final ShapeEditPart editPart, */ public RootLayoutData(final Object adaptObject, final Point location, final Dimension size) { super(); - if (adaptObject instanceof AbstractDNode) { - init((AbstractDNode) adaptObject, location, size); - } else if (adaptObject instanceof DDiagram) { - init((DDiagram) adaptObject, location, size); - } else if (adaptObject instanceof DEdge) { - init((DEdge) adaptObject, location, size); + if (adaptObject instanceof DDiagram // for root + || adaptObject instanceof AbstractDNode // container or simple node + || adaptObject instanceof DEdge) { + init((EObject) adaptObject, location, size); } else { AbstractSiriusFormatDataManager.logUnhandledDiagramElementKindMessage(adaptObject); } @@ -170,8 +159,10 @@ public RootLayoutData getRoot() { } /** - * Search recursively in in all the DiagramLayoutData is there is one which - * have the diagram for target. + * Search if there is data which have the diagram for target. + *

+ * Default implementation does not perform a recursive search. + *

* * @param diagram * The search diagram