Search in sources :

Example 1 with SwingAdapter

use of org.qi4j.lib.swing.binding.SwingAdapter in project qi4j-sdk by Qi4j.

the class BoundAssociation method use.

public void use(Association<T> actualAssociation) {
    actual = actualAssociation;
    T value = null;
    if (actualAssociation != null) {
        value = actualAssociation.get();
    }
    stateModel.use(value);
    for (JComponent component : components) {
        SwingAdapter adapter = adapters.get(component.getClass());
        adapter.fromAssociationToSwing(component, actualAssociation);
        for (FocusListener listener : component.getFocusListeners()) {
            if (AssociationFocusLostListener.class.isInstance(listener)) {
                ((AssociationFocusLostListener) listener).use(adapter, actual);
            }
        }
    }
}
Also used : SwingAdapter(org.qi4j.lib.swing.binding.SwingAdapter) FocusListener(java.awt.event.FocusListener)

Example 2 with SwingAdapter

use of org.qi4j.lib.swing.binding.SwingAdapter in project qi4j-sdk by Qi4j.

the class BoundProperty method use.

public void use(Property<T> actualProperty) {
    T value = null;
    if (actualProperty != null) {
        value = actualProperty.get();
    }
    stateModel.use(value);
    for (JComponent component : components) {
        SwingAdapter adapter = adapters.get(component.getClass());
        adapter.fromPropertyToSwing(component, actualProperty);
        for (FocusListener listener : component.getFocusListeners()) {
            if (PropertyFocusLostListener.class.isInstance(listener)) {
                ((PropertyFocusLostListener) listener).use(adapter, actualProperty);
            }
        }
    }
}
Also used : SwingAdapter(org.qi4j.lib.swing.binding.SwingAdapter) FocusListener(java.awt.event.FocusListener)

Example 3 with SwingAdapter

use of org.qi4j.lib.swing.binding.SwingAdapter in project qi4j-sdk by Qi4j.

the class AbstractBinding method setupAdapters.

private void setupAdapters(Iterable<SwingAdapter> allAdapters) {
    adapters = new HashMap<Class<? extends JComponent>, SwingAdapter>();
    for (SwingAdapter adapterCandidate : allAdapters) {
        Set<SwingAdapter.Capabilities> canHandle = adapterCandidate.canHandle();
        for (SwingAdapter.Capabilities capabilities : canHandle) {
            if (requiredCapabilitySatisfied(capabilities)) {
                if (capabilities.type.equals(this.type)) {
                    Class<? extends JComponent> component = capabilities.component;
                    adapters.put(component, adapterCandidate);
                }
            }
        }
    }
}
Also used : SwingAdapter(org.qi4j.lib.swing.binding.SwingAdapter)

Aggregations

SwingAdapter (org.qi4j.lib.swing.binding.SwingAdapter)3 FocusListener (java.awt.event.FocusListener)2