Class StyleManager

  • All Implemented Interfaces:
    com.nomagic.magicdraw.core.project.options.PersistentStyleManager, PropertyVisitorAcceptor, java.beans.PropertyChangeListener, java.lang.Cloneable, java.util.EventListener

    @OpenApiAll
    public class StyleManager
    extends java.lang.Object
    implements PropertyVisitorAcceptor, java.beans.PropertyChangeListener, java.lang.Cloneable, com.nomagic.magicdraw.core.project.options.PersistentStyleManager
    Style manager stores and manages a set of Styles.
    • Field Detail

      • styles

        private java.util.List<Style> styles
        Styles list.
      • defaultStyle

        @CheckForNull
        private Style defaultStyle
        Default style
      • STYLE_BY_NAME_COMPARATOR

        private static final java.util.Comparator<Style> STYLE_BY_NAME_COMPARATOR
        Comparator for comparing two styles by name.
    • Constructor Detail

      • StyleManager

        public StyleManager()
        Default constructor.
    • Method Detail

      • addStyle

        public void addStyle​(Style style)
        Adds given style.
        Parameters:
        style - the style to add.
      • removeStyle

        public void removeStyle​(Style style)
        Removes given style.
        Parameters:
        style - the style to remove.
      • getDefaultStyle

        @CheckForNull
        public Style getDefaultStyle()
        Returns default style.
        Returns:
        the default style of this manager.
      • getStyle

        @CheckForNull
        public Style getStyle​(java.lang.String name)
        Returns style with the specified name.
        Parameters:
        name - style name.
        Returns:
        style if such exists or null if not found.
      • getStyleByID

        @CheckForNull
        public Style getStyleByID​(@CheckForNull
                                  java.lang.String id)
      • setDefaultStyle

        public void setDefaultStyle​(@CheckForNull
                                    Style style)
        Sets default style for this manager.
        Parameters:
        style - - the style to be default.
      • getStyles

        public java.util.List<Style> getStyles()
        Returns all styles of this manager.
        Returns:
        all styles. Collection is unmodifiable.
      • getOrderedStyles

        public java.util.List<Style> getOrderedStyles()
        Returns styles ordered by names.
        Returns:
        all styles ordered by name.
      • setStyles

        public void setStyles​(java.util.Collection<Style> styles)
        Sets all styles.
        Parameters:
        styles - a collection of new styles.
      • accept

        public void accept​(PropertyVisitor visitor)
                    throws java.lang.Exception
        Accepts the given visitor.
        Specified by:
        accept in interface PropertyVisitorAcceptor
        Parameters:
        visitor - the PropertyVisitor.
        Throws:
        java.lang.Exception
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Listens to PropertyNames.STYLE_MANAGER property change event. Takes StyleManagerfrom new value and sets all styles from this manager to itself.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Parameters:
        e - the property change event.
      • clone

        public java.lang.Object clone()
        Makes a copy of this manager. Does deep clone.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a clone of this manager.
      • fireStyleAdded

        public static void fireStyleAdded​(StyleManager manager,
                                          Style style)
      • addStyleListener

        public static void addStyleListener​(StyleManager.StyleListener listener)
        Adds static listener for listen style event. Listener is added in application scope and does not depends on project.
        Parameters:
        listener - Listener to be added.
      • removeStyleListener

        public static void removeStyleListener​(StyleManager.StyleListener listener)
        Removes listener for listen style creation event.
        Parameters:
        listener - Listener to be removed.