Commit 008a8636 authored by Simon Barner's avatar Simon Barner
Browse files

- Assign IDs individually for each newly created annotation.

- I.e., do this for each specification instead of the "contained" model element. Since
"contained" might already have an any, this would trigger an expensive algorithm to
check if there are duplicated IDs.
refs 2759
parent d47b247d
......@@ -31,6 +31,7 @@ import org.fortiss.tooling.base.model.element.IModelElementReference;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.kernel.extension.IElementCompositor;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
......@@ -42,7 +43,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 14EC7CB721E223C172B6D534820C8FC2
* @ConQAT.Rating YELLOW Hash: D0431D84DF7559E6C1D2C46B0796E8DE
*/
public abstract class ModelElementCompositorBase<C extends EObject> extends Observable implements
IElementCompositor<C> {
......@@ -55,12 +56,25 @@ public abstract class ModelElementCompositorBase<C extends EObject> extends Obse
*/
@Override
public boolean compose(C container, EObject contained, IElementCompositionContext context) {
// Instantiate annotations for new model element. Derived compositors must call this method
// (see #2228 and #2208)
if(contained instanceof IModelElement) {
// Instantiate annotations for new model element. Derived compositors must call this
// method
// (see #2228 and #2208)
IAnnotationValueService.getInstance().instantiateAnnotations((IModelElement)contained);
IPersistencyService.getInstance().getTopLevelElementFor(container)
.prepareIDs(contained);
// Assign IDs for newly created annotations. Notes:
// - Do this for each specification instead of the "contained" model element. Since
// "contained" might already have an any, this would trigger an expensive algorithm to
// check if there are duplicated IDs.
// - The assignment of IDs cannot be performed in instantiateAnnotations() above since
// "contained" is not hooked to the model yet. Instead, the "container" is used as a
// reference to assign the annotations' IDs.
final ITopLevelElement topLevelElement =
IPersistencyService.getInstance().getTopLevelElementFor(container);
for(IModelElementSpecification specification : ((IModelElement)contained)
.getSpecifications()) {
topLevelElement.prepareIDs(specification);
}
}
makeNameDistinct(container, contained);
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment