From 6cc1220056398ba53532332406eefb48a63adc5b Mon Sep 17 00:00:00 2001 From: Klaus Becker <becker@fortiss.org> Date: Tue, 17 Jan 2012 14:29:44 +0000 Subject: [PATCH] refs 216 --- .../tooling/kernel/utils/UniqueIDUtils.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 77ef138fe..7051d7350 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. * -- GitLab