Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8258777

SkinBase: add api to un-/register invalidation-/listChange listeners

    XMLWordPrintable

    Details

      Description

      .. just the same as done for changeListeners:

          /**
           * Subclasses can invoke this method to register that they want to listen to
           * invalidation events for the given property. Registered {@link Consumer} instances
           * will be executed in the order in which they are registered.
           * @param property the property
           * @param consumer the consumer
           */
          protected final void registerInvalidationListener(ObservableValue<?> property, Consumer<ObservableValue<?>> consumer) {
       
          /**
           * Unregisters all invalidation listeners that have been registered using {@link #registerInvalidationListener(ObservableValue, Consumer)}
           * for the given property. The end result is that the given property is no longer observed by any of the invalidation
           * listeners, but it may still have additional listeners registered on it through means outside of
           * {@link #registerInvalidationListener(ObservableValue, Consumer)}.
           *
           * @param property The property for which all listeners should be removed.
           * @return A single chained {@link Consumer} consisting of all {@link Consumer consumers} registered through
           * {@link #registerInvalidationListener(ObservableValue, Consumer)}. If no consumers have been registered on this
           * property, null will be returned.
           * @since 9
           */
          protected final Consumer<ObservableValue<?>> unregisterInvalidationListeners(ObservableValue<?> property) {

      Internally, this boils down to adding api to LambdaMultiplePropertyChangeListenerHandler (though doing so will make the name a bit .. inappropriate), probably simply duplicating the existing xxChangeYY to xxInvalidationYY and including both in its dispose.

      Why?

      There are skins (f.i. TextFieldSkin, see JDK-8240506) that rely heavily on manually registered InvalidationListeners - each of which must be removed manually in dispose. With enhanced skin api, those could be registered via the multipleProp listener and automatically removed in dispose.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fastegal Jeanette Winzenburg
              Reporter:
              fastegal Jeanette Winzenburg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: