Class MetawidgetBinder

java.lang.Object
microsim.gui.shell.parameter.MetawidgetBinder
All Implemented Interfaces:
org.metawidget.iface.Immutable, org.metawidget.swing.widgetprocessor.binding.BindingConverter, org.metawidget.widgetprocessor.iface.AdvancedWidgetProcessor<JComponent, org.metawidget.swing.SwingMetawidget>, org.metawidget.widgetprocessor.iface.WidgetProcessor<JComponent, org.metawidget.swing.SwingMetawidget>

public class MetawidgetBinder extends Object implements org.metawidget.widgetprocessor.iface.AdvancedWidgetProcessor<JComponent, org.metawidget.swing.SwingMetawidget>, org.metawidget.swing.widgetprocessor.binding.BindingConverter
Property binding implementation based on BeanUtils.

This implementation recognizes the following SwingMetawidget.setParameter parameters:

  • propertyStyle - either PROPERTYSTYLE_JAVABEAN (default) or PROPERTYSTYLE_SCALA (for Scala-style getters and setters).

Note: BeanUtils does not bind actions, such as invoking a method when a JButton is pressed. For that, see ReflectionBindingProcessor and MetawidgetActionStyle or SwingAppFrameworkActionStyle.

Author:
Richard Kennard, Stefan Ackermann
  • Constructor Details

    • MetawidgetBinder

      public MetawidgetBinder()
  • Method Details

    • onStartBuild

      public void onStartBuild(org.metawidget.swing.SwingMetawidget metawidget)
      Specified by:
      onStartBuild in interface org.metawidget.widgetprocessor.iface.AdvancedWidgetProcessor<JComponent, org.metawidget.swing.SwingMetawidget>
    • processWidget

      public JComponent processWidget(JComponent component, String elementName, Map<String,String> attributes, org.metawidget.swing.SwingMetawidget metawidget)
      Specified by:
      processWidget in interface org.metawidget.widgetprocessor.iface.WidgetProcessor<JComponent, org.metawidget.swing.SwingMetawidget>
    • rebind

      public void rebind(Object toRebind, org.metawidget.swing.SwingMetawidget metawidget)
      Rebinds the Metawidget to the given Object.

      This method is an optimization that allows clients to load a new object into the binding without calling setToInspect, and therefore without reinspecting the object or recreating the components. It is the client's responsbility to ensure the rebound object is compatible with the original setToInspect.

    • save

      public void save(org.metawidget.swing.SwingMetawidget metawidget)
    • convertFromString

      public Object convertFromString(String value, Class<?> expectedType)
      Specified by:
      convertFromString in interface org.metawidget.swing.widgetprocessor.binding.BindingConverter
    • onEndBuild

      public void onEndBuild(org.metawidget.swing.SwingMetawidget metawidget)
      Specified by:
      onEndBuild in interface org.metawidget.widgetprocessor.iface.AdvancedWidgetProcessor<JComponent, org.metawidget.swing.SwingMetawidget>
    • retrieveValueFromObject

      protected Object retrieveValueFromObject(org.metawidget.swing.SwingMetawidget metawidget, Object source, String names) throws Exception
      Retrieve value identified by the given names from the given source.

      Clients may override this method to incorporate their own getter convention.

      Parameters:
      metawidget - Metawidget to retrieve value from
      Throws:
      Exception
    • saveValueToObject

      protected void saveValueToObject(org.metawidget.swing.SwingMetawidget metawidget, String names, Object componentValue) throws Exception
      Save the given value into the given source at the location specified by the given names.

      Clients may override this method to incorporate their own setter convention.

      Parameters:
      componentValue - the raw value from the JComponent
      Throws:
      Exception
    • retrieveValueFromWidget

      protected Object retrieveValueFromWidget(microsim.gui.shell.parameter.MetawidgetBinder.SavedBinding binding) throws Exception
      Throws:
      Exception
    • saveValueToWidget

      protected void saveValueToWidget(microsim.gui.shell.parameter.MetawidgetBinder.SavedBinding binding, Object sourceValue) throws Exception
      Throws:
      Exception