/** * Indexes all bindable models within the binding context. If there are two bindable models * in a class hierarchy with identical names then they are indexed as * "DeclaringClass.modelFieldName". If this is not unique then one of them will win * non-deterministically, don't do this. * @return the index */ private Map<String, Field> indexBindableModels() { return dotIndex(getBindableModelFields(), Reflections.FIELD_TO_CONTAINING_CLASS_NAME, Reflections.FIELD_TO_NAME); }
public void release(BindableModel model) { for (Binding binding : bindings) { model.unbind(binding); } }
public void updateAll() { for (Binding binding : bindings) { binding.update(ModelUpdates.ALL); } } }
public void bind(Object object) { bindWithoutUpdate(object); updateAll(); }
@CallOnUpdate(model = "demoModel") public void callback1() { count1++; }
@Override protected void setUp() { bindings.bind(this); }
public static class NonfinalNotBindableModel { @NotBindable private SimpleModel model = new SimpleModel(); private final Bindings bindings = new Bindings(); public NonfinalNotBindableModel() { bindings.bind(this); } }
/** * Performs a model update of type {@link ModelUpdates#UNSPECIFIED} - convenience method * for most models. */ public void update() { this.modelUpdated(ModelUpdates.UNSPECIFIED); }
/** * Binds this model to some component with a {@link Binding} object. This method is called by * the various {@link WiringHarness} objects to bind individual components to this model. * * @param binding */ public void bind(Binding binding) { support.bind(binding); }
/** * {@inheritDoc} */ public <T extends Enum<T> & ModelUpdate> void modelUpdated(T... changed) { support.modelUpdated(changed); }
public static class NonfinalController { @Bindable private SimpleController controller; private final Bindings bindings = new Bindings(); public NonfinalController() { bindings.bind(this); } }
@CallOnUpdate(on = {"MULTI_1", "MULTI_2"}) public void multiMethod() { multiCount++; }
@Override protected void setUp() { bindings.bind(BoundJComboBoxTest.this); }
class GoodView { final Model model = new Model(); @NotBindable Model tempModel; final Bindings bindings = new Bindings(); public GoodView() { bindings.bind(this); } }
/** * {@inheritDoc} */ public <T extends Enum<T> & ModelUpdate> void modelUpdated(T... changed) { for (Binding binding : bindings) { binding.update(changed); } }
@CallOnUpdate(model = "demoModel", on = "LIST") public void callback2() { count2++; }
public BadView() { bindings.bind(this); } }
@CallOnUpdate(model = "otherModel") public void otherCount() { otherCount++; }
@SuppressWarnings("unused") @CallOnUpdate private void privateMethod() { privateCount++; }
@CallOnUpdate(model = "DerivedView.otherModel") public void otherCount2() { otherCount++; } }