diff options
author | Ansgar Radermacher | 2014-06-03 14:40:51 +0000 |
---|---|---|
committer | Ansgar Radermacher | 2014-06-03 14:40:51 +0000 |
commit | 7f8625fb2e9ca13b351011c506c32470b607cb3f (patch) | |
tree | 784a1a79a9f63c6330e682e541c01847a3bdc02b | |
parent | abf5a7c7209b1fb9732e97fe4e7201caf2317e04 (diff) | |
download | org.eclipse.papyrus-7f8625fb2e9ca13b351011c506c32470b607cb3f.tar.gz org.eclipse.papyrus-7f8625fb2e9ca13b351011c506c32470b607cb3f.tar.xz org.eclipse.papyrus-7f8625fb2e9ca13b351011c506c32470b607cb3f.zip |
435765 - [QDesigner] isCompatible function in PortUtils file doesn't work correctly in case of required Interface of one port is null
5 files changed, 72 insertions, 13 deletions
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/PortUtils.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/PortUtils.java index e6ff1cb5bd8..9490fbe0859 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/PortUtils.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/PortUtils.java @@ -268,13 +268,32 @@ public class PortUtils { return true; } // no match found, try weaker condition: find 1st match for provided ... - // TODO: check not only for identical interfaces but allow a superclass on the required interface if(isAssembly) { - return (PortUtils.getProvided(portA) == PortUtils.getRequired(portB)) && - (PortUtils.getProvided(portB) == PortUtils.getRequired(portA)); - } else { + Interface reqA = PortUtils.getRequired(portA); + Interface reqB = PortUtils.getRequired(portB); + Interface prodA = PortUtils.getProvided(portA); + Interface prodB = PortUtils.getProvided(portB); + return ( + ((reqA == null) && isSubInterface(prodA, reqB)) + || ((reqB == null) && isSubInterface(prodB, reqA)) + || (isSubInterface(prodA, reqB) && isSubInterface(prodB, reqA)) + ); + } + else { return (PortUtils.getProvided(portA) == PortUtils.getProvided(portB)) && (PortUtils.getRequired(portB) == PortUtils.getRequired(portA)); } } + + /** + * return true, if intfA is a sub-interface of intfB, i.e. either both interfaces are identical or one of the + * superclasses (generalizations of intfA) is identical to B. + * more general than interfaceB. + * @param intfA + * @param intfB + * @return + */ + public static boolean isSubInterface(Interface intfA, Interface intfB) { + return (intfA == intfB) || (intfA.getGeneralizations().contains(intfB)); + } } diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java index 3335a7b25cb..4ce64498146 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java @@ -29,8 +29,10 @@ public interface IInstanceConfigurator { * the property that represents the component within the enclosing composite. May be null, if the instance * that should be configured is the main instance. * @param parentInstance - * additional information, if the element that should be configured is part of a container, e.g. an interceptor - * or an extension within the container. + * the instance specification of the parent, i.e. the enclosing composite. If the instance that should be + * configured has a container, the parent instance corresponds to the instance specification of this + * container. This instance specification provides thus access to additional infromation available on the + * container level. */ public void configureInstance(InstanceSpecification instance, Property componentPart, InstanceSpecification parentInstance); } diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/ConnectorBinding.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/ConnectorBinding.java index 9e1fceb0f57..1c0a2739369 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/ConnectorBinding.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/ConnectorBinding.java @@ -85,8 +85,8 @@ public class ConnectorBinding { // with whom this port is connected, i.e. examine all connectorEnds // The type of the connected port determines the binding. Log.log(Status.INFO, Log.TEMPLATE_BINDING, String.format( - "", port.getName())); //$NON-NLS-1$ - + "", port.getName())); //$NON-NLS-1$ + boolean found = false; for(ConnectorEnd connEnd : connector.getEnds()) { // the connector end targets a port of a part or the composite (in case of delegation) ConnectableElement connElem = connEnd.getRole(); @@ -105,21 +105,26 @@ public class ConnectorBinding { } Log.log(Status.INFO, Log.TEMPLATE_BINDING, String.format(Messages.ConnectorBinding_ConnectorsPort, otherInterface)); if(otherInterface != null) { - if(actual == null) { + if(actual == null || actual == otherInterface) { actual = otherInterface; Log.log(Status.INFO, Log.TEMPLATE_BINDING, String.format( Messages.ConnectorBinding_InfoActualReturnIntfIs, actual.getQualifiedName())); + found = true; } else if(actual != otherInterface) { - throw new TransformationException(String.format( - Messages.ConnectorBinding_CannotFindConsistentBinding, - port.getName(), connector.getName(), connector.getNamespace().getName(), actual.getName())); + continue; } } } } - return actual; + if (!found) { + throw new TransformationException(String.format( + Messages.ConnectorBinding_CannotFindConsistentBinding, + port.getName(), connector.getName(), connector.getNamespace().getName(), actual.getName())); + } + return actual; } + private static Type matchOtherEnd(Port port, Property partConnector, Type actual, boolean isProvided) throws TransformationException { // the template provides the formal parameter at one of its ports. Now examine diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/ContainerTrafo.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/ContainerTrafo.java index a7faefb946f..b2e366261ce 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/ContainerTrafo.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/ContainerTrafo.java @@ -704,6 +704,20 @@ public class ContainerTrafo extends AbstractContainerTrafo { } /** + * Utility function to retrieve the executor slot, when given the container instance. + * Needs to be called, after a container instance has been created. + * @param containerInstance the instance of a container specification + * @return the associated executor slot, or null, if it cannot be found + */ + public static Slot getExecutorSlot(InstanceSpecification containerInstance) { + for (Slot slot : containerInstance.getSlots()) { + if (slot.getDefiningFeature().getName().equals(ContainerTrafo.executorPartName)) { + return slot; + } + } + return null; + } + /** * Return the port that is intercepted when given a part * @param containerPart a part that participates in a port interception * @return intercepted port diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java index d12ffca85ee..f4d28c0d966 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java @@ -1,3 +1,17 @@ +/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * 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: + * Ansgar Radermacher ansgar.radermacher@cea.fr + * + *****************************************************************************/ + package org.eclipse.papyrus.qompass.modellibs.core.bindinghelpers; import org.eclipse.emf.common.util.BasicEList; @@ -21,6 +35,11 @@ import org.eclipse.uml2.uml.Operation; import org.eclipse.uml2.uml.TemplateBinding; import org.eclipse.uml2.uml.Type; +/** + * This binding helper loops over all operations of the actual template parameter + * (typically an interface) + * + */ public class LoopOperations implements IBindingHelper, PreCopyListener { private TemplateBinding binding; |