Class OnePerWidget<WidgetType extends Widget,T>

java.lang.Object
com.diffplug.common.swt.OnePerWidget<WidgetType,T>

public abstract class OnePerWidget<WidgetType extends Widget,T> extends Object
Maintains a cache of values which are mapped to SWT widgets. The cache is automatically updated as these widgets are disposed. Useful for implementing resource managers, such as ColorPool.
  • Constructor Details

    • OnePerWidget

      public OnePerWidget()
  • Method Details

    • from

      public static <WidgetType extends Widget, T> OnePerWidget<WidgetType,T> from(Function<? super WidgetType,? extends T> creator)
      Creates a OnePerWidget instance where objects are created using the given function.
    • forWidget

      public T forWidget(WidgetType ctl)
      Returns the object for the given control.
    • create

      protected abstract T create(WidgetType ctl)
      Creates a new object for the control.