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

fixing the model checking of libraries

refs 1529
parent d75dbe6d
Branches
Tags
No related merge requests found
...@@ -111,16 +111,27 @@ public class ModelElementLibraryService implements ILibraryService { ...@@ -111,16 +111,27 @@ public class ModelElementLibraryService implements ILibraryService {
ILibraryService.INSTANCE.addElementToLibrary(pack, obj); ILibraryService.INSTANCE.addElementToLibrary(pack, obj);
} }
/** Converts a {@link ILibraryElementReference} into a {@link IHierarchicElement}. */ /**
* Converts a {@link ILibraryElementReference} into a {@link IHierarchicElement} inside command
* stack.
*/
public void convertLibraryElementRefToHierarchicalElement( public void convertLibraryElementRefToHierarchicalElement(
final ILibraryElementReference elementRef) { final ILibraryElementReference elementRef) {
final IHierarchicElement wrapped = (IHierarchicElement)elementRef.getLibraryElementShadow();
final ITopLevelElement topLevel = final ITopLevelElement topLevel =
IPersistencyService.INSTANCE.getTopLevelElementFor(elementRef); IPersistencyService.INSTANCE.getTopLevelElementFor(elementRef);
topLevel.runAsCommand(new Runnable() { topLevel.runAsCommand(new Runnable() {
@Override @Override
public void run() { public void run() {
doConvertLibraryElementRefToHierarchicalElement(elementRef);
}
});
}
/** Converts a {@link ILibraryElementReference} into a {@link IHierarchicElement}. */
public void doConvertLibraryElementRefToHierarchicalElement(
final ILibraryElementReference elementRef) {
IHierarchicElement wrapped = (IHierarchicElement)elementRef.getLibraryElementShadow();
IHierarchicElement container = (IHierarchicElement)elementRef.eContainer(); IHierarchicElement container = (IHierarchicElement)elementRef.eContainer();
container.getContainedElementsList().remove(elementRef); container.getContainedElementsList().remove(elementRef);
...@@ -129,8 +140,7 @@ public class ModelElementLibraryService implements ILibraryService { ...@@ -129,8 +140,7 @@ public class ModelElementLibraryService implements ILibraryService {
wrappedConnectorsList.addAll(wrapped.getConnectorsList()); wrappedConnectorsList.addAll(wrapped.getConnectorsList());
wrapped.getConnectorsList().clear(); wrapped.getConnectorsList().clear();
EList<IConnector> elementRefConnectorsList = new BasicEList<IConnector>(); EList<IConnector> elementRefConnectorsList = new BasicEList<IConnector>();
elementRefConnectorsList.addAll(((IHierarchicElement)elementRef) elementRefConnectorsList.addAll(((IHierarchicElement)elementRef).getConnectorsList());
.getConnectorsList());
for(IConnector elemRefConnector : elementRefConnectorsList) { for(IConnector elemRefConnector : elementRefConnectorsList) {
wrapped.getConnectorsList().add(elemRefConnector); wrapped.getConnectorsList().add(elemRefConnector);
String elementRefConnectorName = ((INamedElement)elemRefConnector).getName(); String elementRefConnectorName = ((INamedElement)elemRefConnector).getName();
...@@ -138,16 +148,14 @@ public class ModelElementLibraryService implements ILibraryService { ...@@ -138,16 +148,14 @@ public class ModelElementLibraryService implements ILibraryService {
// for each connector of the element reference add the inner connections from // for each connector of the element reference add the inner connections from
// the wrapped connector // the wrapped connector
for(IConnector wrappedConnector : wrappedConnectorsList) { for(IConnector wrappedConnector : wrappedConnectorsList) {
String currentWrappedConnectorName = String currentWrappedConnectorName = ((INamedElement)wrappedConnector).getName();
((INamedElement)wrappedConnector).getName();
if(currentWrappedConnectorName.equals(elementRefConnectorName)) { if(currentWrappedConnectorName.equals(elementRefConnectorName)) {
// copy incoming connections // copy incoming connections
EList<IConnection> wrappedIncomingConnectionsList = EList<IConnection> wrappedIncomingConnectionsList =
new BasicEList<IConnection>(); new BasicEList<IConnection>();
wrappedIncomingConnectionsList.addAll(wrappedConnector wrappedIncomingConnectionsList.addAll(wrappedConnector.getIncomingList());
.getIncomingList());
for(IConnection connection : wrappedIncomingConnectionsList) { for(IConnection connection : wrappedIncomingConnectionsList) {
elemRefConnector.getIncomingList().add(connection); elemRefConnector.getIncomingList().add(connection);
} }
...@@ -155,8 +163,7 @@ public class ModelElementLibraryService implements ILibraryService { ...@@ -155,8 +163,7 @@ public class ModelElementLibraryService implements ILibraryService {
// copy outgoing connections // copy outgoing connections
EList<IConnection> wrappedOutgoingConnectionsList = EList<IConnection> wrappedOutgoingConnectionsList =
new BasicEList<IConnection>(); new BasicEList<IConnection>();
wrappedOutgoingConnectionsList.addAll(wrappedConnector wrappedOutgoingConnectionsList.addAll(wrappedConnector.getOutgoingList());
.getOutgoingList());
for(IConnection connection : wrappedOutgoingConnectionsList) { for(IConnection connection : wrappedOutgoingConnectionsList) {
elemRefConnector.getOutgoingList().add(connection); elemRefConnector.getOutgoingList().add(connection);
} }
...@@ -168,8 +175,6 @@ public class ModelElementLibraryService implements ILibraryService { ...@@ -168,8 +175,6 @@ public class ModelElementLibraryService implements ILibraryService {
container.getContainedElementsList().add(wrapped); container.getContainedElementsList().add(wrapped);
} }
});
}
/** Copies the layout data from source to target. */ /** Copies the layout data from source to target. */
private static void private static void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment