Statistics
| Revision:

gvsig-tools / 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 / dynformset / base / BaseJDynFormSet.java @ 2754

History | View | Annotate | Download (24.7 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.tools.dynform.services.dynformset.base;
24

    
25
import java.awt.BorderLayout;
26
import java.awt.Color;
27
import java.awt.Component;
28
import java.awt.event.MouseAdapter;
29
import java.awt.event.MouseEvent;
30
import java.util.ArrayList;
31
import java.util.Iterator;
32
import java.util.List;
33
import javax.swing.Action;
34
import javax.swing.BorderFactory;
35
import javax.swing.BoxLayout;
36

    
37
import javax.swing.JComponent;
38
import javax.swing.JLabel;
39
import javax.swing.JOptionPane;
40
import javax.swing.JPanel;
41
import org.gvsig.tools.ToolsLocator;
42

    
43
import org.gvsig.tools.dynform.AbortActionException;
44
import org.gvsig.tools.dynform.DynFormDefinition;
45
import org.gvsig.tools.dynform.JDynForm;
46
import org.gvsig.tools.dynform.JDynForm.JDynFormListener;
47
import org.gvsig.tools.dynform.JDynFormField;
48
import org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.FormSetListener;
49
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_CANCEL_NEW;
50
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_CLOSE;
51
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_DELETE;
52
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_FIRST;
53
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_LAST;
54
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_NEW;
55
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_NEXT;
56
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_PREVIOUS;
57
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_SAVE;
58
import static org.gvsig.tools.dynform.services.dynformset.base.FormSetButtonBar.ID_ACTION_SEARCH;
59
import org.gvsig.tools.dynform.spi.dynformset.AbstractJDynFormSet;
60
import org.gvsig.tools.dynform.spi.dynformset.ActionStore;
61
import org.gvsig.tools.dynform.spi.DynFormSPIManager;
62
import org.gvsig.tools.dynform.spi.dynformset.JDynFormSetFactory;
63
import org.gvsig.tools.dynobject.DynObject;
64
import org.gvsig.tools.dynobject.DynObjectSet;
65
import org.gvsig.tools.dynobject.Tags;
66
import org.gvsig.tools.exception.BaseException;
67
import org.gvsig.tools.visitor.VisitCanceledException;
68
import org.gvsig.tools.visitor.Visitor;
69

    
70
@SuppressWarnings("UseSpecificCatch")
71
public class BaseJDynFormSet extends AbstractJDynFormSet implements FormSetListener, JDynFormListener {
72

    
73
    private JLabel jlabel_messages = null;
74
    private JDynForm form = null;
75
    private FormSetButtonBar buttonBar = null;
76
    private int current = 0;
77

    
78
    public BaseJDynFormSet(
79
            DynFormSPIManager manager, 
80
            JDynFormSetFactory factory,
81
            JDynForm.DynFormContext context,
82
            DynFormDefinition definition,
83
            Tags contextTags
84
        ) {
85
        super(manager, factory,context, definition, contextTags);
86
    }
87

    
88
    @Override
89
    public JComponent asJComponent() {
90
        if (this.contents == null) {
91
            this.initComponents();
92
            if (this.buttonBar != null) {
93
                this.buttonBar.setReadOnly(this.isReadOnly());
94
            }
95
            if (this.form != null) {
96
                this.form.setReadOnly(this.isReadOnly());
97
            }
98
        }
99
        this.fireFormMovedToEvent(current);
100
        return this.contents;
101
    }
102
    
103
    public JDynForm getForm() {
104
        return this.form;
105
    }
106

    
107
    public JLabel getMessagesJLabel() {
108
        if (this.jlabel_messages == null) {
109
            this.jlabel_messages = new JLabel();
110
//                        this.jlabel_messages.setBorder( BorderFactory.createLoweredBevelBorder());
111
            this.jlabel_messages.setText(" ");
112
            this.jlabel_messages.addMouseListener(new MouseAdapter() {
113
                @Override
114
                public void mouseClicked(MouseEvent evt) {
115
                    int count = evt.getClickCount();
116
                    if (count == 2) {
117
                        JOptionPane.showMessageDialog(contents, jlabel_messages.getText(), "Status", JOptionPane.INFORMATION_MESSAGE);
118
                    }
119
                }
120
            });
121
        }
122
        return this.jlabel_messages;
123
    }
124

    
125
    @Override
126
    public void message() {
127
        this.getMessagesJLabel().setText(" ");
128
    }
129

    
130
    @Override
131
    public void message(String msg) {
132
        this.getMessagesJLabel().setText(msg);
133
    }
134

    
135
    private FormSetButtonBar getButtonBar() {
136
        if (this.buttonBar == null) {
137
            initComponents();
138
        }
139
        return this.buttonBar;
140
    }
141

    
142
    private void initComponents() {
143
        this.contents = new JPanel();
144
        this.contents.setBorder(BorderFactory.createLineBorder(Color.GRAY));
145
        this.contents.setLayout(new BorderLayout());
146

    
147
        this.form = this.getManager().getDynFormManager().createJDynForm(this.getContext(), this.getDefinition());
148
        this.form.setReadOnly(this.isReadOnly());
149
        this.form.setLayoutMode(this.getLayoutMode());
150
        this.form.setUseScrollBars(this.getUseScrollBars());
151
        this.form.addListener(this);
152

    
153
        if (!actionsBuffer.isEmpty()) {
154
            for (ActionStore actStore : actionsBuffer) {
155
                if (actStore.isSeparator()) {
156
                    form.addSeparatorToPopupMenu(
157
                            actStore.getDataType());
158
                } else {
159
                    form.addActionToPopupMenu(
160
                            actStore.getDataType(),
161
                            actStore.getActionName(),
162
                            actStore.getAction());
163
                }
164
            }
165
        }
166
        if (this.getUseScrollBars()) {
167
            if (this.formHeight > -1 && this.formWidth > -1) {
168
                this.setFormSize(this.formWidth, this.formHeight);
169
            }
170
        }
171
        this.form.setShowMessageStatus(false);
172
        //this.form.setLayoutMode(this.layoutMode);
173
        this.form.addListener(this);
174

    
175
        this.buttonBar = new FormSetButtonBar();
176
        this.buttonBar.addListener(this);
177
        this.buttonBar.setActionActive(ID_ACTION_DELETE, this.allowDelete());
178
        this.buttonBar.setActionActive(ID_ACTION_NEW, this.allowNew());
179
        this.buttonBar.setActionActive(ID_ACTION_CANCEL_NEW, this.allowNew());
180
        this.buttonBar.setActionActive(ID_ACTION_SAVE, this.allowUpdate());
181
        this.buttonBar.setActionActive(ID_ACTION_SEARCH, this.allowSearch());
182
        this.buttonBar.setActionActive(ID_ACTION_CLOSE, this.allowClose());
183
        this.buttonBar.setVisible(ID_ACTION_CANCEL_NEW, false);
184
        this.buttonBar.setReadOnly(this.isReadOnly());
185
        this.contents.add(this.form.asJComponent(), BorderLayout.CENTER);
186
        
187
        JPanel p = new JPanel();
188
        p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
189
        this.buttonBar.asJComponent().setAlignmentX(Component.LEFT_ALIGNMENT);
190
        this.getMessagesJLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
191
        p.add(this.buttonBar.asJComponent());
192
        p.add(this.getMessagesJLabel());
193
        this.contents.add(p, BorderLayout.SOUTH);
194
        
195
        doChangeValues();
196
    }
197

    
198
    @Override
199
    public void setAllowDelete(boolean allowDelete) {
200
        super.setAllowDelete(allowDelete);
201
        if( this.buttonBar!=null ) {
202
            this.buttonBar.setActionActive(ID_ACTION_DELETE, this.allowDelete());
203
        }
204
    }
205

    
206
    @Override
207
    public void setAllowNew(boolean allowNew) {
208
        super.setAllowNew(allowNew);
209
        if( this.buttonBar!=null ) {
210
            this.buttonBar.setActionActive(ID_ACTION_NEW, this.allowNew());
211
        }
212
    }
213
    
214
    private void doChangeValues() {
215
        this.current = 0;
216
        if (this.values == null || this.values.isEmpty()) {
217
            this.form.setReadOnly(true);
218
            this.getButtonBar().setEnabled(ID_ACTION_DELETE, false);
219
            this.getButtonBar().setEnabled(ID_ACTION_SAVE, false);
220
            this.getButtonBar().setEnabled(ID_ACTION_NEW,
221
                    this.allowNew() && !this.isReadOnly());
222
            this.getButtonBar().setNumrecords(0);
223
            this.form.clear();
224
        } else {
225
            this.form.setValues((DynObject) this.values.get(this.current));
226
            this.getButtonBar().setEnabled(ID_ACTION_DELETE,
227
                    this.allowDelete() && !this.isReadOnly());
228
            this.getButtonBar().setEnabled(ID_ACTION_SAVE,
229
                    this.allowUpdate() && !this.isReadOnly());
230
            this.getButtonBar().setNumrecords(this.values.size());
231
        }
232
        this.getButtonBar().setCurrent(this.current);
233
    }
234

    
235
    @Override
236
    public void setValues(List values) {
237
        super.setValues(values);
238
        if (this.contents != null) {
239
            doChangeValues();
240
        }
241
    }
242

    
243
    @Override
244
    public void setValues(DynObjectSet values) {
245
        super.setValues(values);
246
        if (this.contents != null) {
247
            doChangeValues();
248
        }
249
    }
250

    
251
    @Override
252
    public void setReadOnly(boolean readOnly) {
253
//        if( this.isReadOnly() == readOnly ) {
254
//            return;
255
//        }
256
        super.setReadOnly(readOnly);
257
        if (this.buttonBar != null) {
258
            this.buttonBar.setReadOnly(readOnly);
259
        }
260
        if (this.form != null) {
261
            this.form.setReadOnly(readOnly);
262
        }
263
    }
264

    
265
    @Override
266
    public boolean doActionFirst() {
267
        if (this.values.isEmpty()) {
268
            return false;
269
        }
270

    
271
        if (autosave) {
272
            if (this.form.isModified() || this.isInNewState() ) {
273
                if (!doActionSave()) {
274
                    return false;
275
                }
276
            }
277
        }
278
        callUserEvent("form_beforeFirst", this.getForm());
279
        this.current = 0;
280
        this.form.setValues((DynObject) this.values.get(this.current));
281
        this.buttonBar.setCurrent(this.current);
282
        try {
283
            this.getButtonBar().setEnabled(ID_ACTION_DELETE,
284
                    this.allowDelete() && !this.isReadOnly());
285
            this.getButtonBar().setEnabled(ID_ACTION_SAVE,
286
                    this.allowUpdate() && !this.isReadOnly());
287
        } catch (Exception ex) {
288
            LOGGER.warn("Can't enable/disable delete and save buttons",ex);
289
        }
290
        callUserEvent("form_afterFirst", this.getForm());
291
        this.fireFormMovedToEvent(this.current);
292
        return true;
293
    }
294

    
295
    @Override
296
    public boolean doActionPrevious() {
297
        if (this.values.isEmpty()) {
298
            return false;
299
        }
300

    
301
        if (autosave) {
302
            if (this.form.isModified() || this.isInNewState() ) {
303
                if (!doActionSave()) {
304
                    return false;
305
                }
306
            }
307
        }
308
        callUserEvent("form_beforePrevious", this.getForm());
309
        if (this.current > 0) {
310
            this.current--;
311
        }
312
        this.form.setValues((DynObject) this.values.get(this.current));
313
        this.buttonBar.setCurrent(this.current);
314
        callUserEvent("form_afterPrevious", this.getForm());
315
        this.fireFormMovedToEvent(this.current);
316
        return true;
317
    }
318

    
319
    @Override
320
    public boolean doActionNext() {
321
        if (this.values.isEmpty()) {
322
            return false;
323
        }
324

    
325
        if (autosave) {
326
            if (this.form.isModified() || this.isInNewState() ) {
327
                if (!doActionSave()) {
328
                    return false;
329
                }
330
            }
331
        }
332
        callUserEvent("form_beforeNext", this.getForm());
333
        if (this.current < this.values.size() - 1) {
334
            this.current++;
335
        }
336
        this.form.setValues((DynObject) this.values.get(this.current));
337
        this.buttonBar.setCurrent(this.current);
338
        callUserEvent("form_afterNext", this.getForm());
339
        this.fireFormMovedToEvent(this.current);
340
        return true;
341
    }
342

    
343
    @Override
344
    public boolean doActionLast() {
345
        if (this.values.isEmpty()) {
346
            return false;
347
        }
348

    
349
        if (autosave) {
350
            if (this.form.isModified() || this.isInNewState() ) {
351
                if (!doActionSave()) {
352
                    return false;
353
                }
354
            }
355
        }
356
        callUserEvent("form_beforeLast", this.getForm());
357
        this.current = this.values.size() - 1;
358
        this.form.setValues((DynObject) this.values.get(this.current));
359
        this.buttonBar.setCurrent(this.current);
360
        callUserEvent("form_afterLast", this.getForm());
361
        this.fireFormMovedToEvent(this.current);
362
        return true;
363
    }
364

    
365
    @Override
366
    public boolean doActionSave() {
367
        if ( !this.isInNewState() && this.values.isEmpty()) {
368
            return false;
369
        }
370
        try {
371
            this.listeners.accept(new Visitor() {
372
                @Override
373
                public void visit(Object listener) throws VisitCanceledException, BaseException {
374
                    ((JDynFormSetListener) listener).formBeforeSave(BaseJDynFormSet.this);
375
                }
376
            });
377
        } catch (AbortActionException e) {
378
            return false;
379
        } catch (BaseException e) {
380
            LOGGER.warn("Can't notify to listeners before save.",e);
381
            return false;
382
        }
383
        callUserEvent("form_beforeSave", this.getForm());
384

    
385
        List<String> fieldsName = new ArrayList<>();
386
        if (!this.form.hasValidValues(fieldsName)) {
387
            String errores = "";
388
            Iterator<String> it = fieldsName.iterator();
389
            while (it.hasNext()) {
390
                String name = (String) it.next();
391
                errores = errores + "     - " + name + "\n";
392
            }
393
            int r = confirmDialog(
394
                    "There are incorrect data in the following fields:\n" + errores + "\nContinuing the incorrect values โ€‹will not be saved. Do you want to continue?", "warning",
395
                    JOptionPane.WARNING_MESSAGE,
396
                    JOptionPane.YES_NO_OPTION);
397
            if (r != JOptionPane.YES_OPTION) {
398
                return false;
399
            }
400
        }
401
        if( !this.isInNewState() ) {
402
            if (this.current >= 0 && this.current < this.values.size()) {
403
                this.form.getValues((DynObject) this.values.get(this.current));
404
            } else {
405
                LOGGER.warn("current out of range.");
406
            }
407
        }
408
        
409
        this.leaveTheNewState();
410
        callUserEvent("form_afterSave", this.getForm());
411
        
412
        try {
413
            this.listeners.accept(new Visitor() {
414
                @Override
415
                public void visit(Object listener) throws VisitCanceledException, BaseException {
416
                    ((JDynFormSetListener) listener).formAfterSave(BaseJDynFormSet.this);
417
                }
418
            });
419
        } catch (AbortActionException e) {
420
            return false;
421
        } catch (BaseException e) {
422
            LOGGER.warn("Can't notify to listeners after save.",e);
423
            return false;
424
        }
425
        return true;
426
    }
427

    
428
    @Override
429
    public boolean doActionNew() {
430
        try {
431
            this.listeners.accept(new Visitor() {
432
                @Override
433
                public void visit(Object listener) throws VisitCanceledException, BaseException {
434
                    ((JDynFormSetListener) listener).formBeforeNew(BaseJDynFormSet.this);
435
                }
436
            });
437
        } catch (BaseException e) {
438
            return true;
439
        }
440
        callUserEvent("form_beforeNew", this.getForm());
441
        this.enterStateNew();
442
        callUserEvent("form_afterNew", this.getForm());
443
        try {
444
            this.listeners.accept(new Visitor() {
445
                @Override
446
                public void visit(Object listener) throws VisitCanceledException, BaseException {
447
                    ((JDynFormSetListener) listener).formAfterNew(BaseJDynFormSet.this);
448
                }
449
            });
450
        } catch (BaseException e) {
451
            return true;
452
        }
453
        return true;
454
    }
455

    
456
    @Override
457
    public boolean doActionCancelNew() {
458
        try {
459
            this.listeners.accept(new Visitor() {
460
                @Override
461
                public void visit(Object listener) throws VisitCanceledException, BaseException {
462
                    ((JDynFormSetListener) listener).formBeforeCancelNew(BaseJDynFormSet.this);
463
                }
464
            });
465
        } catch (BaseException e) {
466
            return true;
467
        }
468
        callUserEvent("form_beforeCancelNew", this.getForm());
469
        this.leaveTheNewState();
470
        callUserEvent("form_afterCancelNew", this.getForm());
471
        try {
472
            this.listeners.accept(new Visitor() {
473
                @Override
474
                public void visit(Object listener) throws VisitCanceledException, BaseException {
475
                    ((JDynFormSetListener) listener).formAfterCancelNew(BaseJDynFormSet.this);
476
                }
477
            });
478
        } catch (BaseException e) {
479
            return true;
480
        }
481
        return true;
482
    }
483

    
484
    @Override
485
    protected void enterStateNew() {
486
        if( this.isInNewState() ) {
487
            return;
488
        }
489
        try {
490
            FormSetButtonBar bar = this.getButtonBar();
491
            super.enterStateNew();
492
            bar.setCurrentLabel(ToolsLocator.getI18nManager().getTranslation("nuevo"));
493
            bar.setNumrecords(this.countValues());
494

    
495
            bar.setVisible(ID_ACTION_CANCEL_NEW, true);
496
            bar.setVisible(ID_ACTION_NEW, false);
497
            
498
            bar.setEnabled(ID_ACTION_SAVE,true);
499
            bar.setEnabled(ID_ACTION_CANCEL_NEW,true);
500
            bar.setEnabled(ID_ACTION_DELETE,false);
501
            bar.setEnabled(ID_ACTION_FIRST,false);
502
            bar.setEnabled(ID_ACTION_NEXT,false);
503
            bar.setEnabled(ID_ACTION_PREVIOUS,false);
504
            bar.setEnabled(ID_ACTION_LAST,false);
505
            bar.setEnabled(ID_ACTION_SEARCH,false);
506
        } catch (Exception ex) {
507
            LOGGER.warn("Can't enable/disable delete and save buttons",ex);
508
        }
509
    }
510

    
511
    @Override
512
    protected void leaveTheNewState() {
513
        if( !(this.isInNewState()) ) {
514
            return;
515
        }
516
        super.leaveTheNewState();
517
        try {
518
            FormSetButtonBar bar = this.getButtonBar();
519

    
520
            bar.setVisible(ID_ACTION_CANCEL_NEW, false);
521
            bar.setVisible(ID_ACTION_NEW, true);
522
            
523
            bar.setEnabled(ID_ACTION_SAVE,true);
524
            bar.setEnabled(ID_ACTION_NEW,true);
525
            bar.setEnabled(ID_ACTION_DELETE,true);
526
            bar.setEnabled(ID_ACTION_SEARCH,true);
527

    
528
            bar.setCurrentLabel(null);
529
            bar.setNumrecords(this.countValues());
530
            bar.setCurrent(this.current);
531
        } catch (Exception ex) {
532
            LOGGER.warn("Can't enable/disable delete and save buttons",ex);
533
        }
534
    }
535
    
536
    @Override
537
    public boolean doActionDelete() {
538
        if (this.values.isEmpty()) {
539
            return false;
540
        }
541

    
542
        if (this.countValues() < 1) {
543
            return true;
544
        }
545
        try {
546
            this.listeners.accept(new Visitor() {
547
                @Override
548
                public void visit(Object listener) throws VisitCanceledException, BaseException {
549
                    ((JDynFormSetListener) listener).formBeforeDelete(BaseJDynFormSet.this);
550
                }
551
            });
552
        } catch (BaseException e) {
553
            return true;
554
        }
555

    
556
        if (this.current >= countValues()) {
557
            this.current = countValues() - 1;
558
        }
559
        if (this.current > -1) {
560
            this.form.setValues((DynObject) this.values.get(this.current));
561
        }
562
        this.buttonBar.setNumrecords(this.countValues());
563
        this.buttonBar.setCurrent(this.current);
564

    
565
        try {
566
            this.listeners.accept(new Visitor() {
567
                @Override
568
                public void visit(Object listener) throws VisitCanceledException, BaseException {
569
                    ((JDynFormSetListener) listener).formAfterDelete(BaseJDynFormSet.this);
570
                }
571
            });
572
        } catch (BaseException e) {
573
            return true;
574
        }
575
        return true;
576
    }
577

    
578
    @Override
579
    public boolean doActionSearch() {
580
        if (this.values.isEmpty()) {
581
            return false;
582
        }
583

    
584
        try {
585
            this.listeners.accept(new Visitor() {
586
                @Override
587
                public void visit(Object listener) throws VisitCanceledException, BaseException {
588
                    ((JDynFormSetListener) listener).formBeforeSearch(BaseJDynFormSet.this);
589
                }
590
            });
591
        } catch (BaseException e) {
592
            return true;
593
        }
594
        // Do search
595
        try {
596
            this.listeners.accept(new Visitor() {
597
                @Override
598
                public void visit(Object listener) throws VisitCanceledException, BaseException {
599
                    ((JDynFormSetListener) listener).formAfterSearch(BaseJDynFormSet.this);
600
                }
601
            });
602
        } catch (BaseException e) {
603
            return true;
604
        }
605
        return true;
606
    }
607

    
608
    @Override
609
    public boolean doActionClose() {
610
        fireCloseEvent();
611
        return true;
612
    }
613

    
614
    @Override
615
    public void doSetCurrentRecord(int index) {
616
        this.setCurrentIndex(index);
617
    }
618
    
619
    @Override
620
    public void setFormSize(int width, int height) {
621
        super.setFormSize(width, height);
622
        if (this.form != null) {
623
            this.form.setFormSize(width, height);
624
        }
625
    }
626

    
627
    @Override
628
    public int getCurrentIndex() {
629
        return this.current;
630
    }
631

    
632
    @Override
633
    public void setCurrentIndex(int index) {
634
        if (index < 0 || index > countValues()) {
635
            throw new IllegalArgumentException("Index (" + index + ") out of range [0.." + countValues() + "].");
636
        }
637
        // Don't call doActionSave, crash with stack overflow
638
        this.current = index;
639
        this.form.setValues((DynObject) this.values.get(this.current));
640
        this.buttonBar.setCurrent(this.current);
641
        this.fireFormMovedToEvent(this.current);
642
    }
643

    
644
    @Override
645
    public void fieldChanged(JDynFormField field) {
646
        LOGGER.debug("Ha cambiado el field: " + field.getName() + " con el valor => " + field.getValue());
647
    }
648

    
649
    @Override
650
    public DynObject get(int position) {
651
        LOGGER.debug("Recojo el field: " + position);
652
        return (DynObject) this.values.get(position);
653
    }
654

    
655
    @Override
656
    public List getValues() {
657
        if (this.current >= 0 && this.current < this.values.size()) {
658
            this.form.getValues((DynObject) this.values.get(this.current));
659
        }
660
        return this.values;
661
    }
662

    
663
    @Override
664
    public boolean hasValidValues() {
665
        return this.form.hasValidValues();
666
    }
667

    
668
    @Override
669
    public boolean hasValidValues(List<String> fieldsName) {
670
        return this.form.hasValidValues(fieldsName);
671
    }
672

    
673
    public void clear() {
674
        if (this.form != null) {
675
            this.form.clear();
676
        }
677
    }
678

    
679
    @Override
680
    public void getFormValues(DynObject values) {
681
        this.form.getValues(values);
682
    }
683

    
684
    @Override
685
    public void addAction(Action action) {
686
        this.getButtonBar().addAction(action);
687
    }
688
    
689
    @Override
690
    public Action getAction(String actionId) {
691
        return this.getButtonBar().getAction(actionId);
692
    }
693

    
694
    @Override
695
    public List<Action> getActions() {
696
        return this.getButtonBar().getActions();
697
    }
698

    
699
    @Override
700
    public void setActionVisible(String action, boolean visible) {
701
        this.getButtonBar().setVisible(action, visible);
702
    }
703

    
704
    @Override
705
    public void setActionEnabled(String action, boolean enabled) {
706
        this.getButtonBar().setEnabled(action, enabled);
707
    }
708

    
709
    @Override
710
    public boolean isActionEnabled(String action) {
711
        return this.getButtonBar().isEnabled(action);
712
    }
713

    
714
    @Override
715
    public boolean isActionVisible(String action) {
716
        return this.getButtonBar().isVisible(action);
717
    }
718

    
719
    @Override
720
    public JComponent getActionButton(String action) {
721
        return this.getButtonBar().getActionButton(action);
722
    }
723

    
724
    @Override
725
    public void fireEvent(String action, Object value) {
726
        this.getButtonBar().fireEvent(action, value);
727
    }
728
    
729
}