Skip to content
Snippets Groups Projects
Commit 1a321a72 authored by Sudeep Kanav's avatar Sudeep Kanav
Browse files

reverted code to the old state of 15742

refs 2572
parent 022d37ab
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,6 @@ import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.introspection.items.ElementCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
......@@ -44,7 +43,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 40A8C2F33D7EA00AD729B89098BB8911
* @ConQAT.Rating YELLOW Hash: A3C3DACAD6D38C54CBD29735646CB874
*/
public final class ElementCompositorService extends
EObjectAwareServiceBase<IElementCompositor<EObject>> implements IElementCompositorService,
......@@ -100,12 +99,9 @@ public final class ElementCompositorService extends
// Add element to the model (might instantiate annotations for IModelElements)
boolean rval = compositor.compose(container, element, context);
if(rval) {
makeNameDistinct(container, element);
// Generate IDs (including potentially instantiated annotations)
IPersistencyService.INSTANCE.getTopLevelElementFor(container).prepareIDs(element);
}
// Generate IDs (including potentially instantiated annotations)
IPersistencyService.INSTANCE.getTopLevelElementFor(container).prepareIDs(element);
return rval;
}
......@@ -203,26 +199,4 @@ public final class ElementCompositorService extends
public IIntrospectionDetailsItem getDetailsItem() {
return new ElementCompositorServiceIntrospectionDetailsItem(handlerMap);
}
/**
* This function checks if the name of any element of same type and name as "contained" exists
* in the container, and modifies the name in case if required.
* */
private void makeNameDistinct(EObject container, EObject contained) {
if(!(contained instanceof INamedElement) || ((INamedElement)contained).getName() == null)
return;
INamedElement neNew = (INamedElement)contained;
int index = 0;
for(EObject o : container.eContents()) {
if(o.getClass().isInstance(contained) && o instanceof INamedElement) {
INamedElement e = (INamedElement)o;
if(e.getName().equals(neNew.getName()) ||
e.getName().equals(neNew.getName() + index)) {
index++;
}
}
}
if(index > 0)
neNew.setName(neNew.getName() + index);
}
}
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