From 6a2787a14e3989693df357c97befdc2c30bbaaac Mon Sep 17 00:00:00 2001
From: Sebastian Bergemann <bergemann@fortiss.org>
Date: Thu, 21 Sep 2023 18:02:46 +0200
Subject: [PATCH] Improve performance of context menu creation

Issue-Ref: 4323
Issue-Url: https://git.fortiss.org/af3/af3/-/issues/4323

Signed-off-by: Sebastian Bergemann <bergemann@fortiss.org>
---
 .../fortiss/tooling/ext/reuse/utils/.ratings   |  2 +-
 .../reuse/utils/ReuseLibraryUtilsBasics.java   | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings
index 7e4e034ed..38cd9e2f3 100644
--- a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings
+++ b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings
@@ -1,3 +1,3 @@
 ReuseLibraryModelElementFactory.java 4ee3eb7449e212643992a3dec6cfb8f4278efb70 GREEN
-ReuseLibraryUtilsBasics.java c5206709acec88ef1281a270472bc4cc1a8f7436 YELLOW
+ReuseLibraryUtilsBasics.java c077150bba8303aecbde635e35117cc247d0c07e YELLOW
 ReuseLibraryUtilsManipulation.java 77a646db5a63ba7c61664dbcaf34a9036003fde5 GREEN
diff --git a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java
index c5206709a..c077150bb 100644
--- a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java
+++ b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java
@@ -119,9 +119,9 @@ public class ReuseLibraryUtilsBasics {
 	 * @return Display name as string (with UUID!) or empty string
 	 */
 	public static String getIDNameOfFirstRelatedLibrary(EObject element) {
-		ReuseLibrary library = getFirstSourceLibraryOfElement(element);
-		if(library != null) {
-			return getLibraryIDName(library);
+		ReuseElementSpec spec = getFirstReuseSpec(element);
+		if(spec != null) {
+			return getLibraryIDNameFormat(spec.getSourceLibUUID(), spec.getSourceLibName());
 		}
 		return "";
 	}
@@ -137,9 +137,9 @@ public class ReuseLibraryUtilsBasics {
 	 * @return Display name as string or empty string
 	 */
 	public static String getNameOfFirstRelatedLibrary(EObject element) {
-		ReuseLibrary library = getFirstSourceLibraryOfElement(element);
-		if(library != null) {
-			return library.getName();
+		ReuseElementSpec spec = getFirstReuseSpec(element);
+		if(spec != null) {
+			return spec.getSourceLibName();
 		}
 		return "";
 	}
@@ -451,14 +451,14 @@ public class ReuseLibraryUtilsBasics {
 	}
 
 	/**
-	 * Returns the first {@link ReuseElementSpec}s of the given element to a
+	 * Returns the first {@link ReuseElementSpec} of the given element to a
 	 * {@link ReuseLibrary}. If none exist, null will be returned.
 	 *
 	 * @param element
 	 *            The target reuse element
 	 * @return The first reuse element specification (or null)
 	 */
-	public static ReuseElementSpec getFirstReuseSpecs(EObject element) {
+	public static ReuseElementSpec getFirstReuseSpec(EObject element) {
 		List<ReuseElementSpec> specs = getAllReuseSpecs(element);
 		if(!specs.isEmpty()) {
 			// get(0) safe due to empty check above
@@ -555,7 +555,7 @@ public class ReuseLibraryUtilsBasics {
 	 * @return The requested reuse library (or null)
 	 */
 	public static ReuseLibrary getFirstSourceLibraryOfElement(EObject element) {
-		ReuseElementSpec spec = getFirstReuseSpecs(element);
+		ReuseElementSpec spec = getFirstReuseSpec(element);
 		if(spec != null) {
 			String libraryUUID = spec.getSourceLibUUID();
 			return getLocalReuseLibraryByID(libraryUUID);
-- 
GitLab