From 094acb9379dd4bdc68a071778abe991e7b2f21ea Mon Sep 17 00:00:00 2001 From: Daniel Ratiu <ratiu@fortiss.org> Date: Mon, 14 Jan 2013 09:48:02 +0000 Subject: [PATCH] resolving this issue refs 1151 --- .../internal/LibraryPrototypeProvider.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/LibraryPrototypeProvider.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/LibraryPrototypeProvider.java index 6e74ac9c8..f34cce145 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/LibraryPrototypeProvider.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/LibraryPrototypeProvider.java @@ -17,7 +17,9 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.internal; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.extension.ILibraryElementHandler; @@ -34,7 +36,7 @@ import org.fortiss.tooling.kernel.service.ILibraryService; * @author ratiu * @author $Author: hoelzl $ * @version $Rev: 18709 $ - * @ConQAT.Rating YELLOW Hash: C80FA91F50ADA9FFBC25CE927814BF6C + * @ConQAT.Rating YELLOW Hash: C6CEC15D2930553DD96080E74D1FFF14 */ public class LibraryPrototypeProvider extends PrototypeProviderBase { @@ -44,6 +46,7 @@ public class LibraryPrototypeProvider extends PrototypeProviderBase { */ public void refreshPrototypes() { prototypes.clear(); + categories.clear(); registerPrototypes(); } @@ -51,6 +54,9 @@ public class LibraryPrototypeProvider extends PrototypeProviderBase { @Override protected void registerPrototypes() { PrototypeCategory libraryCategory = registerPrototypeCategory("Library"); + Map<String, PrototypeCategory> registeredCategoriesMap = + new HashMap<String, PrototypeCategory>(); + for(ILibraryElement libElem : ILibraryService.INSTANCE .getLibraryElementsFromAllWorkspaceLibraries()) { List<ILibraryElementHandler<EObject>> handlers = @@ -64,7 +70,13 @@ public class LibraryPrototypeProvider extends PrototypeProviderBase { prototypes.add(prot); String categoryName = ((ILibraryPackage)libElem.eContainer()).getName(); - PrototypeCategory current = registerPrototypeCategory(libraryCategory, categoryName); + PrototypeCategory current = registeredCategoriesMap.get(categoryName); + + if(current == null) { + current = registerPrototypeCategory(libraryCategory, categoryName); + registeredCategoriesMap.put(categoryName, current); + } + current.add(prot); } } -- GitLab