Class CompartmentManager

java.lang.Object
com.nomagic.magicdraw.uml.symbols.CompartmentManager

@OpenApiAll public class CompartmentManager extends Object
Utility methods for showing/hiding elements on compartments.

This class provides helper APIs for showing and hiding model elements and element properties within diagram compartments (for example, attributes, tagged values, or property compartments on shapes).

Example 1: Display a property in a compartment


 Property property = ...;   // Property model element
 ClassView classView = ...; // Class symbol

 SessionManager.getInstance().executeInsideSession(
     Project.getProject(property),
     "Show Property",
     () -> CompartmentManager.showCompartmentElement(
         classView, CompartmentID.ATTRIBUTES, property)
 );
 

Example 2: Hide a slot on a class shape


 Slot slot = ...;           // Slot model element
 ClassView classView = ...; // Class symbol

 SessionManager.getInstance().executeInsideSession(
     Project.getProject(slot),
     "Hide Slot",
     () -> CompartmentManager.hideCompartmentElement(
         classView, CompartmentID.TAGGED_VALUES_ON_SHAPE, slot)
 );
 

Example 3: Show element properties on a class shape


 ClassView classView = ...; // Class symbol

 SessionManager.getInstance().executeInsideSession(
     Project.getProject(classView),
     "Show Properties",
     () -> CompartmentManager.showCompartmentElementProperties(
         classView,
         Arrays.asList(
             PropertyNames.OWNER,
             PropertyNames.VISIBILITY,
             PropertyNames.APPLIED_STEREOTYPE
         )
     )
 );
 

Example 4: Hide an element property from a class shape


 ClassView classView = ...; // Class symbol

 SessionManager.getInstance().executeInsideSession(
     Project.getProject(classView),
     "Hide Property",
     () -> CompartmentManager.hideCompartmentElementProperty(
         classView, PropertyNames.IS_ABSTRACT)
 );
 
See Also:
  • Constructor Details

    • CompartmentManager

      public CompartmentManager()
  • Method Details

    • showCompartmentElement

      public static void showCompartmentElement(PresentationElement view, String compartmentID, Element element)
      Shows element in a compartment.
      Parameters:
      view - symbol which contains the compartment.
      compartmentID - id of the compartment.
      element - element to show.
    • showCompartmentElements

      public static void showCompartmentElements(PresentationElement view, String compartmentID, List<Element> elements)
      Shows elements in a compartment.
      Parameters:
      view - symbol which contains the compartment.
      compartmentID - id of the compartment.
      elements - elements to show.
    • hideCompartmentElement

      public static void hideCompartmentElement(PresentationElement view, String compartmentID, Element element)
      Hides an element in a compartment.
      Parameters:
      view - symbol which contains the compartment.
      compartmentID - id of the compartment.
      element - element to hide.
    • hideCompartmentElements

      public static void hideCompartmentElements(PresentationElement view, String compartmentID, List<Element> elements)
      Hides elements in a compartment.
      Parameters:
      view - symbol which contains the compartment.
      compartmentID - id of the compartment.
      elements - elements to hide.
    • showCompartmentElementProperty

      public static void showCompartmentElementProperty(PresentationElement view, String propertyName)
      Displays a property in the element's property compartment on the given symbol.
      Parameters:
      view - the symbol on which the property should be displayed
      propertyName - the name of the property to display
    • showCompartmentElementProperties

      public static void showCompartmentElementProperties(PresentationElement view, List<String> propertyNames)
      Displays the specified properties in the element's property compartment on the given symbol.
      Parameters:
      view - the symbol on which the properties should be displayed
      propertyNames - the names of the properties to display
    • hideCompartmentElementProperty

      public static void hideCompartmentElementProperty(PresentationElement view, String propertyName)
      Hides a property from the element's property compartment on the given symbol.
      Parameters:
      view - the symbol from which the property should be hidden
      propertyName - the name of the property to hide
    • hideCompartmentElementProperties

      public static void hideCompartmentElementProperties(PresentationElement view, List<String> propertyNames)
      Hides the specified properties from the element's property compartment on the given symbol.
      Parameters:
      view - the symbol from which the properties should be hidden
      propertyNames - the names of the properties to hide