Ejemplo n.º 1
0
  public static void bindModelToView(ArrayList fieldsToBind, DomainObject model) {

    BeanAdapter adapter = new BeanAdapter(model, true);
    ValueModel valueModel = null;
    Object field = null;
    ATFieldInfo fieldInfo;
    String fieldName = "";
    ComboBoxAdapter comboBoxAdapter = null;

    for (int i = 0; i < fieldsToBind.size(); i++) {
      field = fieldsToBind.get(i);
      fieldName = ((JComponent) field).getName();
      valueModel = adapter.getValueModel(fieldName);
      if (!ignoreArray.contains(fieldName)) {
        if (field instanceof JFormattedTextField) {
          Bindings.bind((JFormattedTextField) field, valueModel);
        } else if (field instanceof JTextComponent) {
          //						Bindings.bind((JTextComponent) field, valueModel);
        } else if (field instanceof JCheckBox) {
          Bindings.bind((JCheckBox) field, valueModel);
        } else if (field instanceof JComboBox) {
          fieldInfo = ATFieldInfo.getFieldInfo(model.getClass().getName() + "." + fieldName);
          if (fieldInfo != null) {
            Vector<String> values = LookupListUtils.getLookupListValues(fieldInfo.getLookupList());
            if (values != null) {
              comboBoxAdapter = new ComboBoxAdapter(values, valueModel);
              ((JComboBox) field).setModel(comboBoxAdapter);
            }
          }
        } else {
          System.out.println(fieldName + " not bound");
        }
      }
    }
  }
 public void bind(WinrateView view, WinratePresentationModel model) {
   Bindings.bind(
       view.getPlayedLabel(),
       ConverterFactory.createStringConverter(
           model.getComponentModel(MatchRecord.PROPERTY_PLAYED),
           NumberFormat.getIntegerInstance()));
   Bindings.bind(
       view.getWonLabel(),
       ConverterFactory.createStringConverter(
           model.getComponentModel(MatchRecord.PROPERTY_WON), NumberFormat.getIntegerInstance()));
   Bindings.bind(
       view.getLostLabel(),
       ConverterFactory.createStringConverter(
           model.getComponentModel(MatchRecord.PROPERTY_LOST), NumberFormat.getIntegerInstance()));
 }
Ejemplo n.º 3
0
 protected JComponent getControl(String property, Format format) {
   JComponent c = components.get(property);
   if (c == null) {
     JLabel label = createLabel();
     try {
       ValueModel valueModel =
           ConverterFactory.createStringConverter(model.getModel(property), format);
       Bindings.bind(label, valueModel);
     } catch (Exception e) {
       String msg = ExceptionUtils.getRootCauseMessage(e);
       label.setToolTipText("Binding error Property: " + property + "  " + msg);
       System.out.println("Binding error Property: " + property + "  " + msg);
     }
     components.put(property, label);
     return label;
   } else return c;
 }