Skip to content
Snippets Groups Projects
Commit 7f669e13 authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

resolving this issue

refs 1179
parent a2acfa17
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ import java.util.List;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IModelElement;
......@@ -44,7 +45,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 6AABB1E76AD510EFBA64B6315EA5137A
* @ConQAT.Rating YELLOW Hash: 394D006ABBE472DF4310F5F594B8A36A
*/
public class ModelElementLibraryService implements ILibraryService {
......@@ -125,18 +126,56 @@ public class ModelElementLibraryService implements ILibraryService {
IHierarchicElement container = (IHierarchicElement)elementRef.eContainer();
container.getContainedElementsList().remove(elementRef);
EList<IConnector> connectorsList = new BasicEList<IConnector>();
connectorsList.addAll(((IHierarchicElement)elementRef).getConnectorsList());
for(IConnector connector : connectorsList) {
wrapped.getConnectorsList().add(connector);
// copy all connectors of the reference to the wrapped component
EList<IConnector> wrappedConnectorsList = new BasicEList<IConnector>();
wrappedConnectorsList.addAll(wrapped.getConnectorsList());
wrapped.getConnectorsList().clear();
EList<IConnector> elementRefConnectorsList = new BasicEList<IConnector>();
elementRefConnectorsList.addAll(((IHierarchicElement)elementRef)
.getConnectorsList());
for(IConnector elemRefConnector : elementRefConnectorsList) {
wrapped.getConnectorsList().add(elemRefConnector);
String elementRefConnectorName = ((INamedElement)elemRefConnector).getName();
// for each connector of the element reference add the inner connections from
// the wrapped connector
for(IConnector wrappedConnector : wrappedConnectorsList) {
String currentWrappedConnectorName =
((INamedElement)wrappedConnector).getName();
if(currentWrappedConnectorName.equals(elementRefConnectorName)) {
// copy incoming connections
EList<IConnection> wrappedIncomingConnectionsList =
new BasicEList<IConnection>();
wrappedIncomingConnectionsList.addAll(wrappedConnector
.getIncomingList());
for(IConnection connection : wrappedIncomingConnectionsList) {
elemRefConnector.getIncomingList().add(connection);
}
// copy outgoing connections
EList<IConnection> wrappedOutgoingConnectionsList =
new BasicEList<IConnection>();
wrappedOutgoingConnectionsList.addAll(wrappedConnector
.getOutgoingList());
for(IConnection connection : wrappedOutgoingConnectionsList) {
elemRefConnector.getOutgoingList().add(connection);
}
}
}
}
((ILayoutedModelElement)wrapped).setLayoutData(copyAll(
((ILayoutedModelElement)elementRef).getLayoutDataList()).toArray(
new ILayoutData[2]));
copyAllLayoutData((ILayoutedModelElement)wrapped, (ILayoutedModelElement)elementRef);
container.getContainedElementsList().add(wrapped);
}
});
}
/** Copies the layout data from source to target. */
private static void
copyAllLayoutData(ILayoutedModelElement source, ILayoutedModelElement target) {
target.setLayoutData(copyAll(source.getLayoutDataList()).toArray(new ILayoutData[2]));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment