Revision 2039 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.services/src/main/java/org/gvsig/tools/dynform/services/dynform/AbeilleJDynForm.java

View differences:

AbeilleJDynForm.java
24 24
import java.awt.event.ActionListener;
25 25
import java.io.File;
26 26
import java.util.ArrayList;
27
import java.util.Iterator;
27 28
import java.util.List;
28 29
import javax.swing.JButton;
29 30
import javax.swing.JLabel;
......
352 353
        return form;
353 354
    }
354 355
    
356
    public Iterator getFieldsIterator() {
357
        if (!this.isContentsInitialized()) {
358
            this.initComponents();
359
        }
360
        return this.components.values().iterator();
361
    }
362

  
363
    @Override
364
    public void setReadOnly(boolean readOnly) {
365
        if( this.isReadOnly() == readOnly ) {
366
            return;
367
        }
368
        super.setReadOnly(readOnly);
369
        if (this.isContentsInitialized()) {
370
            Iterator it = this.getFieldsIterator();
371
            while (it.hasNext()) {
372
                JDynFormField field = (JDynFormField) it.next();
373
                if( readOnly ) {
374
                    field.setReadOnly(true);
375
                } else if( field.getDefinition().isReadOnly() ) {
376
                    field.setReadOnly(true);
377
                } else {
378
                    field.setReadOnly(false);
379
                }
380
            }
381
        }
382
    }
383

  
355 384
    private void bindUserCode(FormPanel form) {
356 385
        Script theScript = this.getScript();
357 386
        if( theScript==null ) {
......
486 515
            return false;
487 516
        }
488 517
        try {
489
            return (boolean) this.callUserFunction(USERCODE_FORM_ISMODIFIED, this, values);
518
            if( this.getScript()!=null ) {
519
                return (boolean) this.callUserFunction(USERCODE_FORM_ISMODIFIED, this, values);
520
            }
490 521
        } catch (NoSuchMethodException ex) {
491 522
        } catch (Exception ex) {
492 523
            LOGGER.warn("Error calling user function form_IsModified.",ex);

Also available in: Unified diff