diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/UniqueIDUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/UniqueIDUtils.java index 77ef138fe77f9e0db5540eb226641405703dfc1b..7051d73509034b23551cfbfb1cc4f437ee2285af 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/UniqueIDUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/UniqueIDUtils.java @@ -33,7 +33,7 @@ import org.fortiss.tooling.kernel.model.IIdLabeled; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: 8A4299022B07F32CEED5A061DC03FBD2 + * @ConQAT.Rating YELLOW Hash: 20798F4B379821E393B1CC36691662EA */ public class UniqueIDUtils { @@ -58,6 +58,23 @@ public class UniqueIDUtils { return currentMaxId; } + /** + * Generates all IDs of the given model. Already existing IDs are + * overwritten. + * + * @param existingModel + * the model to be updated + */ + public static void generateAllIDs(EObject existingModel) { + int currentId = 0; + for (Iterator<EObject> i = existingModel.eAllContents(); i.hasNext();) { + EObject eo = i.next(); + if (eo instanceof IIdLabeled) { + ((IIdLabeled) eo).setId((++currentId)); + } + } + } + /** * Assigns unique IDs to the given object and its content. *