Class CFClassifier


  • public final class CFClassifier
    extends CFAbstractItem
    Classifier is a code representation for conditional formatting. Follow the link to understand how conditional formatting works.

    This class is an entry point for managing bin sets (known as Type of formatting) and expression sets, where each expression set is associated with one bin set in 1:N relation. I.e. one bin set might be used by more expression sets.

    Author:
    Petr Hamernik
    • Field Detail

      • PROP_BIN_SETS

        public static final java.lang.String PROP_BIN_SETS
        Name of property change event fired when bin sets of this classifier have changed.
        See Also:
        Constant Field Values
      • PROP_EXPRESSION_SETS

        public static final java.lang.String PROP_EXPRESSION_SETS
        Name of property change event fired when expression sets of this classifier have changed.
        See Also:
        Constant Field Values
    • Method Detail

      • createNewClassifier

        public static CFClassifier createNewClassifier()
        Create a new classifier. Usually you won't need this constructor since the "higher-level" API usually provides their API client with an instance. E.g. grid view instance from Forms Model API is already associated with a default (or deserialized) instance of classifier instance.
        Returns:
        new empty classifier
      • clone

        public CFClassifier clone()
        This method can be used for deep cloning of whole classifier with all its CFBinSets and CFExpressionSets.
        Overrides:
        clone in class java.lang.Object
        Returns:
        newly cloned classifier
      • getBinSets

        public java.util.List<CFBinSet> getBinSets()
        Returns:
        bin sets belonging to this classifier
      • addBinSet

        public CFBinSet addBinSet​(java.lang.String displayName)
        Create a new bin set and return it.
        Parameters:
        displayName - Display name of a new bin set
        Returns:
        new instance of bin set which belong to this classifier.
      • addBinSetFromTemplate

        public CFBinSet addBinSetFromTemplate​(CFBinSet template)
        Create a new bin set from template. That is deep copy of a bin set with all of its bins.
        Parameters:
        template - template to be copied
        Returns:
        new replica with unique ID
      • restoreBinSet

        public CFBinSet restoreBinSet​(java.lang.String displayName,
                                      java.lang.String id)
        Use only for persistence.
      • removeBinSet

        public void removeBinSet​(CFBinSet bs)
        Remove the given bin set. Since each expression set must be associated with at least one bin set this method also removes all expression sets belonging to this classifier which are currently associated with the given bin set.
        Parameters:
        bs - bin set to be removed
      • findBinSetById

        public CFBinSet findBinSetById​(java.lang.String id)
        Tries to find a bin set with given id and, in case it is found, returns it.
        Parameters:
        id - id of bin set to be found
        Returns:
        found bin set or null
      • createExpressionSetFor

        public CFExpressionSet createExpressionSetFor​(CFBinSet binSet,
                                                      java.lang.String displayName,
                                                      CFFieldType fieldType,
                                                      CFBin defaultBin)
        Creates new empty expression set. I.e. with no expression.
        Parameters:
        binSet - bin set used by the new expression set
        displayName - display name used in UI
        fieldType - field type
        defaultBin - default bin used when no expression matches
        Returns:
        newly created expression set
      • restoreExpressionSet

        public CFExpressionSet restoreExpressionSet​(CFBinSet binSet,
                                                    java.lang.String displayName,
                                                    CFFieldType fieldType,
                                                    CFBin defaultBin,
                                                    java.lang.String id)
        Do NOT use. Only for persistence.
      • removeExpressionSet

        public void removeExpressionSet​(CFExpressionSet es)
        Removes given expression set from this classifier.
        Parameters:
        es - expression set to be removed
      • getExpressionsSets

        public java.util.List<CFExpressionSet> getExpressionsSets()
        Returns:
        expression sets belonging to this classifier
      • findExpressionSetById

        public CFExpressionSet findExpressionSetById​(java.lang.String id)
        Tries to find a expression set with given id and, in case it is found, returns it.
        Parameters:
        id - id of expression set to be found
        Returns:
        found expression set or null
      • updateWith

        public void updateWith​(CFClassifier source)
        Updates this classifier using bin sets and expression sets from the given source classifier. Used when copy-pasting widgets between forms.
        Parameters:
        source - classifier of the source form
        Since:
        18.23.0
      • addChangeListener

        public void addChangeListener​(javax.swing.event.ChangeListener listener)
        Add change listener to know about any change in this CFClassifier and in all of subelements (all CFBinSets and their CFBins, also in all CFExpressionSets). Leaves elements CFFormatter and CFExpression are immutable, so no change can happen there.

        It means you don't need to register PropertyChangeListener to each bin set, bin and expression set, but you can be notified through this single listener about all changes in the whole hierarchy (e.g. when some bin changes its CFFormatter, when new bin set is added etc.)

        Parameters:
        listener - to be added