From a17245bddde4a5abfa930a98e203a7fe5be746f8 Mon Sep 17 00:00:00 2001 From: Sebastian Bergemann <bergemann@fortiss.org> Date: Mon, 25 Sep 2023 18:26:19 +0200 Subject: [PATCH] Solve FIXMEs - YELLOW Issue-Ref: 4323 Issue-Url: https://git.fortiss.org/af3/af3/-/issues/4323 Signed-off-by: Sebastian Bergemann <bergemann@fortiss.org> --- .../fortiss/tooling/base/ui/utils/.ratings | 2 +- .../base/ui/utils/ContextMenuUtils.java | 4 +++ .../fortiss/tooling/ext/reuse/utils/.ratings | 2 +- .../reuse/utils/ReuseLibraryUtilsBasics.java | 19 ------------ .../tooling/kernel/extension/base/.ratings | 2 +- .../extension/base/PrototypeProviderBase.java | 29 ++++++++++--------- .../tooling/kernel/extension/data/.ratings | 2 +- .../kernel/extension/data/Prototype.java | 28 ++++++------------ 8 files changed, 33 insertions(+), 55 deletions(-) diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings index 63b9e58ee..ac3ab5473 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings @@ -1,6 +1,6 @@ AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN -ContextMenuUtils.java 824b943c3f888d8aa1a427131f0bee3e9ad6e8c8 GREEN +ContextMenuUtils.java 75af4d1e995f4baba451e608d1a4716f13388dbd YELLOW EllipseLayoutUIUtils.java 0af2cfc038661828b1bb8c51c0a3816d453e8313 GREEN FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java index 824b943c3..75af4d1e9 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java @@ -90,6 +90,8 @@ public final class ContextMenuUtils { context, prototype.getName()); String libraryName = getNameOfFirstRelatedLibrary(prototypeCopy); menuItem.setText("[" + libraryName + "] " + prototype.getName()); + // To prevent that underscores are swallowed up: + menuItem.setMnemonicParsing(false); reuseMenu.getItems().add(menuItem); } else { prototypesForNewMenu.add(prototype); @@ -117,6 +119,8 @@ public final class ContextMenuUtils { EObject prototypeCopy = prototype.getPrototypeCopy(); MenuItem menuItem = createMenuItemForComposableElement(prototypeCopy, target, context, prototype.getName()); + // To prevent that underscores are swallowed up: + menuItem.setMnemonicParsing(false); newMenu.getItems().add(menuItem); } 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 407db1b3d..a313dabd0 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 3e38a8dab13499aef8dd4706636df298fbc15bc9 RED +ReuseLibraryUtilsBasics.java 56ab0cab9189efd7f2408150b471f3c6cc99f30f 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 3e38a8dab..56ab0cab9 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 @@ -108,25 +108,6 @@ public class ReuseLibraryUtilsBasics { return (element instanceof ReuseLibrary) || isCorrectReuseElement(element); } - /** - * Returns display name and UUID of the first {@link ReuseLibrary} that is related to the - * given reuse element. If this is not the case, an empty {@link String} will be returned. This - * method is perfect for reuse elements within reuse libraries, because they have definitely - * only one connected/related library. - * - * @param element - * The reuse element whose library's name is searched - * @return Display name as string (with UUID!) or empty string - */ - // TODO (TM): This method is never used. Can it be removed? - public static String getIDNameOfFirstRelatedLibrary(EObject element) { - ReuseElementSpec spec = getFirstReuseSpec(element); - if(spec != null) { - return getLibraryIDNameFormat(spec.getSourceLibUUID(), spec.getSourceLibName()); - } - return ""; - } - /** * Returns display name of the first {@link ReuseLibrary} that is related to the given reuse * element. If this is not the case, an empty {@link String} will be returned. This method is diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings index 6ce4c1017..ce83d2733 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings @@ -3,6 +3,6 @@ ConstraintViolationBase.java ec66973ab2183623f0cd4a85c59c886dddad6cf6 GREEN DialogMessage.java 8420640e999e4fb15fa644333e5d71e1d16c2559 GREEN ElementCompositorBase.java 7a445e5adde11878fe0515baca8b915287149b28 GREEN MultiViolationConstraintCheckerBase.java 30886a94c99cf8948f64401b1db821abe06e1e6c GREEN -PrototypeProviderBase.java 00003fe21515ca93ee863960d653c5239ec47fdd RED +PrototypeProviderBase.java 7418c494275bf75318504de65e82035535b9e9d8 YELLOW TransformationContextChainBase.java 1ef37880ab275778c563928e80ba378fec964cb6 GREEN TransformationProviderBase.java 9e91100cc1f2c8fbd8d41af55aedfea34e02ff71 GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/PrototypeProviderBase.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/PrototypeProviderBase.java index 00003fe21..7418c4942 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/PrototypeProviderBase.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/PrototypeProviderBase.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.OptionalInt; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.extension.IPrototypeProvider; @@ -63,22 +64,15 @@ public abstract class PrototypeProviderBase implements IPrototypeProvider { /** Registers all prototypes. Sub-classes must override. */ protected abstract void registerPrototypes(); - // TODO (TM): The following four methods are basically clones. If there was one private method - // `registerPrototype(String name, EObject prototype, String categoryName, bool isPrimary, int - // priority)`, all other methods could be reduced to one line, and code duplication avoided. /** Registers the given {@link EObject} with the given name and category. */ protected final void registerPrototype(String name, EObject prototype, String categoryName) { - Prototype prototypeObject = new Prototype(name, prototype, false); - prototypes.add(prototypeObject); - registerElementInCategory(prototypeObject, categoryName); + registerPrototype(name, prototype, categoryName, false, OptionalInt.empty()); } /** Registers the given {@link EObject} with the given name, category, and priority. */ protected final void registerPrototype(String name, EObject prototype, String categoryName, int priority) { - Prototype prototypeObject = new Prototype(name, prototype, false, priority); - prototypes.add(prototypeObject); - registerElementInCategory(prototypeObject, categoryName); + registerPrototype(name, prototype, categoryName, false, OptionalInt.of(priority)); } /** @@ -87,9 +81,7 @@ public abstract class PrototypeProviderBase implements IPrototypeProvider { */ protected final void registerPrimaryPrototype(String name, EObject prototype, String categoryName) { - Prototype prototypeObject = new Prototype(name, prototype, true); - prototypes.add(prototypeObject); - registerElementInCategory(prototypeObject, categoryName); + registerPrototype(name, prototype, categoryName, true, OptionalInt.empty()); } /** @@ -98,7 +90,18 @@ public abstract class PrototypeProviderBase implements IPrototypeProvider { */ protected final void registerPrimaryPrototype(String name, EObject prototype, String categoryName, int priority) { - Prototype prototypeObject = new Prototype(name, prototype, true, priority); + registerPrototype(name, prototype, categoryName, true, OptionalInt.of(priority)); + } + + /** Base method that actually performs the registration of prototypes. */ + private final void registerPrototype(String name, EObject prototype, String categoryName, + boolean primary, OptionalInt priority) { + Prototype prototypeObject; + if(priority.isPresent()) { + prototypeObject = new Prototype(name, prototype, primary, priority.getAsInt()); + } else { + prototypeObject = new Prototype(name, prototype, primary); + } prototypes.add(prototypeObject); registerElementInCategory(prototypeObject, categoryName); } diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings index 372cbca5c..dcb91fa10 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings @@ -7,7 +7,7 @@ ITransformationContext.java f00a0ab19a410c3ae2fc6256483aeb4207a86395 GREEN LogMessage.java 14204ed9d51b356f50be52362247cfbbe0cbd5c7 GREEN ModelElementTransformationContext.java 5a41bd3a75ce434c3174d50d2fdfab28b66f09f2 GREEN ModelStorageError.java 2aef480044047e960e64811111a7f27310011cc2 GREEN -Prototype.java 97d0fe467887fbbd96664ee8d3639f5a9df6d745 RED +Prototype.java f4b13f86b7511edacc138053ffb80cecbac70868 YELLOW PrototypeCategory.java ca500b4816ed42b9536488669aeab89561d2f08c GREEN TransformationProviderChain.java 67ec6d0b4c23d295323572649606d79f3b897437 GREEN TutorialAtomicStep.java 09c0d6597d542b431b5bbdc790ee9e533d9f77fb GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/Prototype.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/Prototype.java index 97d0fe467..f4b13f86b 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/Prototype.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/Prototype.java @@ -36,19 +36,14 @@ public class Prototype { private final boolean isPrimary; /** Stores the priority of the category. Is important for sorting: lower value = lower prio. */ - // TODO (TM): Is there a reason why this instance variable is not `final`? In my opinion it - // should be, just like the others. - private int prototypePriority; + private final int prototypePriority; /** Constructor. */ public Prototype(String name, EObject prototype, boolean isPrimary) { this.name = name; this.prototype = prototype; this.isPrimary = isPrimary; - // TODO (TM): Is there any reason, while this instance variable is not accessed using `this` - // like the others? I would suggest to so (here and everywhere else in this file), as it - // makes it explicit, that this is an instance variable rather than a local one. - prototypePriority = 0; + this.prototypePriority = 0; } /** Constructor with priority. */ @@ -56,42 +51,37 @@ public class Prototype { this.name = name; this.prototype = prototype; this.isPrimary = isPrimary; - prototypePriority = priority; + this.prototypePriority = priority; } /** Returns the {@link Prototype}'s name. */ public String getName() { - return name; + return this.name; } /** Returns the {@link Prototype} instance (NOT a copy!). */ public EObject getPrototype() { - return prototype; + return this.prototype; } /** Returns a copy of the {@link Prototype}. This method is potentially expensive. */ public EObject getPrototypeCopy() { - return copy(prototype); + return copy(this.prototype); } /** Returns the priority of the prototype. */ public int getPriority() { - return prototypePriority; - } - - /** Sets the priority of the category. */ - public void setPriority(int priority) { - prototypePriority = priority; + return this.prototypePriority; } /** {@inheritDoc} */ @Override public String toString() { - return "Prototype for: " + name; + return "Prototype for: " + this.name; } /** Returns whether this {@link Prototype} is a primary one or not. */ public boolean isPrimary() { - return isPrimary; + return this.isPrimary; } } -- GitLab