Class CompartmentManager
java.lang.Object
com.nomagic.magicdraw.uml.symbols.CompartmentManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidhideCompartmentElement(PresentationElement view, String compartmentID, Element element) Hides an element in a compartment.static voidhideCompartmentElementProperties(PresentationElement view, List<String> propertyNames) Hides the specified properties from the element's property compartment on the given symbol.static voidhideCompartmentElementProperty(PresentationElement view, String propertyName) Hides a property from the element's property compartment on the given symbol.static voidhideCompartmentElements(PresentationElement view, String compartmentID, List<Element> elements) Hides elements in a compartment.static voidshowCompartmentElement(PresentationElement view, String compartmentID, Element element) Shows element in a compartment.static voidshowCompartmentElementProperties(PresentationElement view, List<String> propertyNames) Displays the specified properties in the element's property compartment on the given symbol.static voidshowCompartmentElementProperty(PresentationElement view, String propertyName) Displays a property in the element's property compartment on the given symbol.static voidshowCompartmentElements(PresentationElement view, String compartmentID, List<Element> elements) Shows elements in a compartment.
-
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
Displays a property in the element's property compartment on the given symbol.- Parameters:
view- the symbol on which the property should be displayedpropertyName- 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 displayedpropertyNames- the names of the properties to display
-
hideCompartmentElementProperty
Hides a property from the element's property compartment on the given symbol.- Parameters:
view- the symbol from which the property should be hiddenpropertyName- 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 hiddenpropertyNames- the names of the properties to hide
-