Class JListWiringHarness

  • All Implemented Interfaces:
    WiringHarness<Bound,​java.lang.reflect.Field>

    public class JListWiringHarness
    extends java.lang.Object
    implements WiringHarness<Bound,​java.lang.reflect.Field>

    Wires up a JList to a List in a BindableModel. Whenever the contents of the bound List change (and the BindableModel's update is called) the JList's model will be swapped out with a new model with the new contents. Selection of values is maintained between model swaps.

    This bindings is only one way. The JList will modify itself to reflect the contents of the List in the BindableModel. However, changes to the JList's model after that will not be reflected in the model. The idea here is that if the user takes some action to remove an item from the list then that should be accomplished by removing an item from the underlying BindableModel, not the JList.

    Implementation notes: a DefaultTableModel is used to back the JList. Maintaining selection between model swaps is simply done with Object.equals(Object) comparisons.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<Binding> wire​(Bound bound, BindingContext context, java.lang.reflect.Field field)
      Performs the wiring of a specific component based on the passed binding annotation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JListWiringHarness

        public JListWiringHarness()
    • Method Detail

      • wire

        public java.util.Collection<Binding> wire​(Bound bound,
                                                  BindingContext context,
                                                  java.lang.reflect.Field field)
                                           throws java.lang.IllegalAccessException,
                                                  java.beans.IntrospectionException
        Description copied from interface: WiringHarness
        Performs the wiring of a specific component based on the passed binding annotation.
        Specified by:
        wire in interface WiringHarness<Bound,​java.lang.reflect.Field>
        Parameters:
        bound - annotation containing the data needed to wire this component to the context.
        context - metadata about the context for wiring.
        field - the component to be wired by this harness.
        Returns:
        one or more Binding objects represent the wirings performed by this harness.
        Throws:
        java.lang.IllegalAccessException
        java.beans.IntrospectionException