Class WidgetProperty<T>

  • Type Parameters:
    T - Type of the property's value
    Direct Known Subclasses:
    org.csstudio.display.builder.model.RuntimeWidgetProperty, org.csstudio.display.builder.model.StructuredWidgetProperty

    public abstract class WidgetProperty<T>
    extends org.csstudio.display.builder.model.properties.PropertyChangeHandler<T>
    Base class for all widget properties.

    The property name identifies a property inside the model. A separate description, which can be localized, is meant for user interfaces that present the property to humans.

    • Method Detail

      • getWidget

        public Widget getWidget()
        Returns:
        Widget that has this property
      • getCategory

        public org.csstudio.display.builder.model.WidgetPropertyCategory getCategory()
        Returns:
        WidgetPropertyCategory of this property
      • getName

        public java.lang.String getName()
        Returns:
        Name that identifies the property within the model API
      • getPath

        public java.lang.String getPath()
        Get full path to property

        A widget property 'visible' might be the basic widget's 'visible' property, or the 'visible' property of an element in a structure within an array, like ImageWidget's 'color_bar.visible'.

        The path is seldom needed, so properties do not carry a 'parent' reference for fast determination of the path. Instead, the path is determined at runtime by searching down from the top-level widget properties.

        Returns:
        The full path to property.
      • getDescription

        public java.lang.String getDescription()
        Returns:
        Human-readable description of the property
      • isReadonly

        public boolean isReadonly()
        Returns:
        true if this property prohibits write access
      • getDefaultValue

        public T getDefaultValue()
        Returns:
        Default value of the property
      • getValue

        public T getValue()
        Returns:
        Current value of the property
      • isDefaultValue

        public boolean isDefaultValue()
        Returns:
        true if current value matches the default value
      • useWidgetClass

        public void useWidgetClass​(boolean use_class)
        Parameters:
        use_class - Should value of this property follow the suggestion from the class support?
      • isUsingWidgetClass

        public boolean isUsingWidgetClass()
        Returns:
        Is value of this property following the suggestion from the class support?
      • setValue

        public void setValue​(T value)
        Parameters:
        value - New value of the property
      • setValueFromObject

        public abstract void setValueFromObject​(java.lang.Object value)
                                         throws java.lang.Exception
        Set value from Object.

        Type-safe access via setValue() is preferred,Helper for implementing Runtime properties but if property type is not known, this method allows setting the property value from an Object.

        Parameters:
        value - New value of the property
        Throws:
        java.lang.Exception - if value type is not applicable to this property
      • writeToXML

        public abstract void writeToXML​(org.csstudio.display.builder.model.persist.ModelWriter model_writer,
                                        javax.xml.stream.XMLStreamWriter writer)
                                 throws java.lang.Exception
        Persist value to XML

        Writer will be positioned inside the property. Implementation needs to write the property's value.

        Parameters:
        model_writer - ModelWriter
        writer - Stream writer
        Throws:
        java.lang.Exception - on error
      • readFromXML

        public abstract void readFromXML​(org.csstudio.display.builder.model.persist.ModelReader model_reader,
                                         org.w3c.dom.Element property_xml)
                                  throws java.lang.Exception
        Read value from persisted XML
        Parameters:
        model_reader - ModelReader
        property_xml - XML element
        Throws:
        java.lang.Exception - on error
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        Debug representation