Package org.springframework.binding.form

Examples of org.springframework.binding.form.FormModel


   * not be dirty.
   * </p>
   */
  public void testFormModelSetFormObjectNotDirty() {
    String someString = "someString";
    FormModel model = getFormModel(new ValueHolder(new TestBean()), false);
    ValueModel valueModel = model.getValueModel("simpleProperty");

    assertEquals("Initial check, formmodel not dirty.", false, model.isDirty());

    valueModel.setValue(someString);
    assertEquals("Value changed, model should be dirty.", true, model.isDirty());

    TestBean newFormObject = new TestBean();
    newFormObject.setSimpleProperty(someString);
    model.setFormObject(newFormObject);
    assertEquals("New formObject is set, model should not be dirty.", false, model.isDirty());
  }
View Full Code Here


    public boolean canClose()
    {
        boolean userBreak = false;
        int answer = JOptionPane.NO_OPTION;

        FormModel detailFormModel = getDetailForm().getFormModel();

        if (detailFormModel.isEnabled() && detailFormModel.isDirty())
        {
            if (detailFormModel.isCommittable())
            {
                answer = RcpSupport.showWarningDialog(getComponent(), UNSAVEDCHANGES_WARNING_ID,
                        JOptionPane.YES_NO_CANCEL_OPTION);
            }
            else // form is uncomittable, change it or revert it
            {
                answer = RcpSupport.showWarningDialog(getComponent(),
                        UNSAVEDCHANGES_UNCOMMITTABLE_WARNING_ID, JOptionPane.YES_NO_OPTION);
                // the following might seem strange, but it aligns the answer with the other part of this if construction
                // if we said 'yes keep editing': don't discard changes, continue editing to save it later on == CANCEL in previous if
                // if we said 'no discard changes': discard changed and switch to other row == NO in previous if
                answer = answer == JOptionPane.YES_OPTION ? JOptionPane.CANCEL_OPTION : JOptionPane.NO_OPTION;
            }

            switch (answer)
            {
                case JOptionPane.CANCEL_OPTION:
                    userBreak = true;
                    break;
                case JOptionPane.YES_OPTION:
                    getCommitCommand().execute();
                    break;
                case JOptionPane.NO_OPTION:
                    detailFormModel.revert();
                    break;
            }
        }

        return !userBreak;
View Full Code Here

        }

    }

    public void testAnnotation() throws Exception {
        FormModel model = new DefaultFormModel(new AnnotationAwareBeanPropertyAccessStrategy(new AnnotatedTestBean()));
        assertEquals(true, model.getFieldMetadata("password").getUserMetadata(UserMetadata.PROTECTED_FIELD));
    }
View Full Code Here

  }
 
  protected JComponent getFormComponentControl(){

    GoogleSettingsBean bean = new GoogleSettingsBean();
      FormModel formModel = FormModelHelper.createFormModel(bean);
      form = new GoogleSettingsForm(formModel);
      form.addFormValueChangeListener("googleKeyTextInput", new PropertyChangeListener(){

      public void propertyChange(PropertyChangeEvent evt) {
        String newValue = (String)evt.getNewValue();
View Full Code Here

        final FormModel[] children = formModel.getChildren();

        if (children == null) return null;

        for (int i = 0; i < children.length; i++) {
            final FormModel child = children[i];
            if (childPageName.equals(child.getId())) return child;
        }

        return null;
    }
View Full Code Here

        return withEditor(new SwingBindingFactory(formModel));
    }
   
    public PropertyColumn withEditor(AbstractDataEditorWidget dataEditor)
    {
        FormModel formModel = dataEditor.getDetailForm().getFormModel();
        BindingFactory bindingFactory = dataEditor.getDetailForm().getBindingFactory();
        return withEditor(new ValueModelTableCellEditor(formModel, getPropertyName(),
                bindingFactory.createBinding(getType(), getPropertyName()).getControl(), dataEditor.getUpdateCommand()));
    }
View Full Code Here

    }

    @Override
    public void commit()
    {
        FormModel formModel = getFormModel();
        if (vetoableCommitListeners != null)
        {
            for (VetoableCommitListener v : vetoableCommitListeners)
            {
                if (!v.proceedWithCommit(formModel))
View Full Code Here

TOP

Related Classes of org.springframework.binding.form.FormModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.