Class ResourceFilePropertyDescriptor


public class ResourceFilePropertyDescriptor extends SBPropertyDescriptor
PropertyDescriptor for properties wishing to access external resources at runtime.

The Operator field should be of type String (representing a name/path usually to be looked up via the resource search path of the containing application).

The contents of the resource may be retrieved using Operator.getResourceContents(String), giving the value of the String field as the argument, or you may retrieve (if available) a File using Operator.getResourceFile(String)

Since:
6.5 added restrictFileHints(String[]) to improve user experience selecting a resource in Studio, 7.6.2 a ResourceFilePropertyDescriptor.TypeHint enumeration is provided to indicate to Studio the kind of selector to display
See Also:
  • Constructor Details

    • ResourceFilePropertyDescriptor

      public ResourceFilePropertyDescriptor(String propertyName, Class<?> beanClass) throws IntrospectionException
      Constructs a resource descriptor with standard read/write method names
      Parameters:
      propertyName - the name of the property
      beanClass - the operator class containing the property
      Throws:
      IntrospectionException - if introspection fails
      See Also:
    • ResourceFilePropertyDescriptor

      public ResourceFilePropertyDescriptor(String propertyName, Class<?> beanClass, String readMethodName, String writeMethodName) throws IntrospectionException
      Construct a resource descriptor with non-standard read/write method names.
      Parameters:
      propertyName - the name of the property
      beanClass - the operator class containing the property
      readMethodName - the name of the method used to read the property
      writeMethodName - the name of the method used to write the property
      Throws:
      IntrospectionException - if introspection fails
      See Also:
    • ResourceFilePropertyDescriptor

      public ResourceFilePropertyDescriptor(PropertyDescriptor pd, Class<?> beanClass) throws IntrospectionException
      Copy a property descriptor.
      Parameters:
      pd - a property descriptor to copy from
      beanClass - the operator class containing the property
      Throws:
      IntrospectionException - if introspection fails
      See Also:
  • Method Details

    • restrictFileHints

      public ResourceFilePropertyDescriptor restrictFileHints(String[] restrictions)
      Sets restrictions on the Studio UI used to display a chooser to select a resource file.

      Note that this is a relaxed UI restriction, and does not prevent any value from being typed by the user, nor does it restrict resources the operator can access.

      Two kinds of name restrictions are available:

      • File extension restrictions must be provided as strings starting with a dot, e.g. .xml, and Studio will restrict the chooser to files ending in the provided extension, case insensitively.
      • All other string restrictions are treated as complete file name restrictions, and Studio will restrict the chooser to files matching the name entirely and exactly, case insensitively.
      A file will be allowed to display in the UI chooser when it matches any restriction.
      Parameters:
      restrictions - see method description, must not be null
      Returns:
      this resource file property descriptor for chaining
      Since:
      6.5
    • typeHint

      Parameters:
      type - the new type hint for this descriptor
      Returns:
      this resource file property descriptor for chaining
      Since:
      7.6.2
      See Also:
    • getType

      Returns:
      the type of resource file this descriptor represents
      Since:
      7.6.2
      See Also: