View Javadoc
1   package fr.ifremer.quadrige3.ui.swing.synchro;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: UI Swing Common
6    * %%
7    * Copyright (C) 2017 - 2024 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Affero General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Affero General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  
25  import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
26  import fr.ifremer.quadrige3.ui.swing.ApplicationUIContext;
27  import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
28  import java.awt.BorderLayout;
29  import java.awt.Color;
30  import java.awt.Container;
31  import java.awt.GridBagConstraints;
32  import java.awt.Insets;
33  import java.awt.LayoutManager;
34  import java.awt.event.ActionEvent;
35  import java.awt.event.ActionListener;
36  import java.util.ArrayList;
37  import java.util.HashMap;
38  import java.util.List;
39  import java.util.Map;
40  import java.util.TreeMap;
41  import javax.swing.BorderFactory;
42  import javax.swing.BoxLayout;
43  import javax.swing.JButton;
44  import javax.swing.JLabel;
45  import javax.swing.JPanel;
46  import javax.swing.JProgressBar;
47  import javax.swing.JScrollPane;
48  import javax.swing.JTextPane;
49  import jaxx.runtime.JAXXBinding;
50  import jaxx.runtime.JAXXContext;
51  import jaxx.runtime.JAXXObject;
52  import jaxx.runtime.JAXXObjectDescriptor;
53  import jaxx.runtime.JAXXUtil;
54  import jaxx.runtime.SwingUtil;
55  import jaxx.runtime.binding.DefaultJAXXBinding;
56  import jaxx.runtime.context.DefaultJAXXContext;
57  import jaxx.runtime.swing.CardLayout2Ext;
58  import jaxx.runtime.swing.Table;
59  import org.apache.commons.logging.Log;
60  import org.apache.commons.logging.LogFactory;
61  import org.jdesktop.swingx.JXDatePicker;
62  import org.jdesktop.swingx.JXLabel;
63  import static org.nuiton.i18n.I18n.t;
64  
65  public class SynchroUI extends JPanel implements ApplicationUI<SynchroUIContext, SynchroUIHandler>, JAXXObject {
66  
67      /*-----------------------------------------------------------------------*/
68      /*------------------ Constants for all public bindings ------------------*/
69      /*-----------------------------------------------------------------------*/
70  
71      public static final String BINDING_DATA_END_DATE_EDITOR_DATE = "dataEndDateEditor.date";
72      public static final String BINDING_DATA_START_DATE_EDITOR_DATE = "dataStartDateEditor.date";
73      public static final String BINDING_VALID_CHOICE_BUTTON_ENABLED = "validChoiceButton.enabled";
74  
75      /*-----------------------------------------------------------------------*/
76      /*------------------------- Other static fields -------------------------*/
77      /*-----------------------------------------------------------------------*/
78  
79      private static final String $jaxxObjectDescriptor = "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";
80      private static final Log log = LogFactory.getLog(SynchroUI.class);
81      private static final long serialVersionUID = 1L;
82  
83      /*-----------------------------------------------------------------------*/
84      /*--------------------------- Internal states ---------------------------*/
85      /*-----------------------------------------------------------------------*/
86  
87      protected List<Object> $activeBindings = new ArrayList<Object>();
88      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
89      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
90      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
91      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
92      private boolean allComponentsCreated;
93      protected final JAXXContext delegateContext = new DefaultJAXXContext();
94  
95      /*-----------------------------------------------------------------------*/
96      /*------------------------ Protected components  ------------------------*/
97      /*-----------------------------------------------------------------------*/
98  
99      protected JButton applyButton;
100     protected JXLabel applyLabel;
101     protected JButton cancelApplyButton;
102     protected JButton cancelStartButton;
103     protected JButton clearDateButton;
104     protected JXDatePicker dataEndDateEditor;
105     protected JXDatePicker dataStartDateEditor;
106     protected JXLabel dateLabel;
107     protected final SynchroUIHandler handler = createHandler();
108     protected SynchroUIContext model;
109     protected JProgressBar progressBar;
110     protected JButton reportCloseButton;
111     protected JTextPane reportTextPane;
112     protected JButton startButton;
113     protected JXLabel startLabel;
114     protected JXLabel statusLabel;
115     protected JLabel statusSideLabel;
116     protected JButton stopButton;
117     protected JPanel synchroDatePanel;
118     protected JPanel synchroPanel;
119     protected CardLayout2Ext synchroPanelLayout;
120     protected JButton validChoiceButton;
121 
122     /*-----------------------------------------------------------------------*/
123     /*------------------------- Private components  -------------------------*/
124     /*-----------------------------------------------------------------------*/
125 
126     private SynchroUI $JPanel0 = this;
127     private JPanel $JPanel1;
128     private JPanel $JPanel2;
129     private JPanel $JPanel3;
130     private JPanel $JPanel4;
131     private JScrollPane $JScrollPane0;
132     private Table $Table0;
133     private Table $Table1;
134     private Table $Table2;
135     private Table $Table3;
136 
137     /*-----------------------------------------------------------------------*/
138     /*---------------------------- Constructors  ----------------------------*/
139     /*-----------------------------------------------------------------------*/
140 
141     public SynchroUI(ApplicationUI parentUI) {
142         ApplicationUIUtil.setParentUI(this, parentUI);
143             $initialize();
144     }
145 
146     public SynchroUI() {
147         $initialize();
148     }
149 
150     public SynchroUI(JAXXContext parentContext) {
151         JAXXUtil.initContext(this, parentContext);
152         $initialize();
153     }
154 
155     public SynchroUI(boolean param0) {
156         super(param0);
157         $initialize();
158     }
159 
160     public SynchroUI(JAXXContext parentContext, boolean param1) {
161         super(param1);
162         JAXXUtil.initContext(this, parentContext);
163         $initialize();
164     }
165 
166     public SynchroUI(LayoutManager param0) {
167         super(param0);
168         $initialize();
169     }
170 
171     public SynchroUI(JAXXContext parentContext, LayoutManager param1) {
172         super(param1);
173         JAXXUtil.initContext(this, parentContext);
174         $initialize();
175     }
176 
177     public SynchroUI(LayoutManager param0, boolean param1) {
178         super(param0 ,param1);
179         $initialize();
180     }
181 
182     public SynchroUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
183         super(param1 ,param2);
184         JAXXUtil.initContext(this, parentContext);
185         $initialize();
186     }
187 
188     /*-----------------------------------------------------------------------*/
189     /*--------------------------- Statics methods ---------------------------*/
190     /*-----------------------------------------------------------------------*/
191 
192     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
193         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
194     }
195 
196     /*-----------------------------------------------------------------------*/
197     /*---------------------- JAXXObject implementation ----------------------*/
198     /*-----------------------------------------------------------------------*/
199 
200     @Override
201     public void applyDataBinding(String $binding) {
202         if (allComponentsCreated && $bindings.containsKey($binding)) {
203             getDataBinding($binding).applyDataBinding();
204         }
205         processDataBinding($binding);
206     }
207 
208     @Override
209     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
210         super.firePropertyChange(propertyName, oldValue, newValue);
211     }
212 
213     @Override
214     public Map<String, Object> get$objectMap() {
215         return $objectMap;
216     }
217 
218     @Override
219     public JAXXBinding getDataBinding(String bindingId) {
220         return $bindings.get(bindingId);
221     }
222 
223     @Override
224     public JAXXBinding[] getDataBindings() {
225         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
226     }
227 
228     @Override
229     public Object getObjectById(String id) {
230         return $objectMap.get(id);
231     }
232 
233     @Override
234     public void processDataBinding(String $binding, boolean $force) {
235         if (!$force && $activeBindings.contains($binding)) { 
236             return;
237         }
238         $activeBindings.add($binding);
239         try {
240             if (allComponentsCreated && $bindings.containsKey($binding)) {
241                 getDataBinding($binding).processDataBinding();
242             }
243         } finally {
244             $activeBindings.remove($binding);
245         }
246     }
247 
248     @Override
249     public void processDataBinding(String $binding) {
250         processDataBinding($binding, false);
251     }
252 
253     @Override
254     public void registerDataBinding(JAXXBinding binding) {
255         $bindings.put(binding.getId(), binding);
256     }
257 
258     @Override
259     public void removeDataBinding(String $binding) {
260         if (allComponentsCreated && $bindings.containsKey($binding)) {
261             getDataBinding($binding).removeDataBinding();
262         }
263     }
264 
265     /*-----------------------------------------------------------------------*/
266     /*--------------------- JAXXContext implementation  ---------------------*/
267     /*-----------------------------------------------------------------------*/
268 
269     @Override
270     public <T> T getContextValue(Class<T> clazz) {
271         return delegateContext.getContextValue(clazz, null);
272     }
273 
274     @Override
275     public <T> T getContextValue(Class<T> clazz, String name) {
276         return delegateContext.getContextValue(clazz, name);
277     }
278 
279     @Override
280     public JAXXContext getDelegateContext() {
281         return delegateContext;
282     }
283 
284     @Override
285     public <O extends Container> O getParentContainer(Class<O> clazz) {
286         return SwingUtil.getParentContainer(this, clazz);
287     }
288 
289     @Override
290     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
291         return SwingUtil.getParentContainer(source, clazz);
292     }
293 
294     @Override
295     public <T> void removeContextValue(Class<T> clazz) {
296         delegateContext.removeContextValue(clazz, null);
297     }
298 
299     @Override
300     public <T> void removeContextValue(Class<T> clazz, String name) {
301         delegateContext.removeContextValue(clazz, name);
302     }
303 
304     @Override
305     public <T> void setContextValue(T o) {
306         delegateContext.setContextValue(o, null);
307     }
308 
309     @Override
310     public <T> void setContextValue(T o, String name) {
311         delegateContext.setContextValue(o, name);
312     }
313 
314     /*-----------------------------------------------------------------------*/
315     /*---------------------------- Event methods ----------------------------*/
316     /*-----------------------------------------------------------------------*/
317 
318     public void doActionPerformed__on__cancelApplyButton(ActionEvent event) {
319         if (log.isDebugEnabled()) {
320             log.debug(event);
321         }
322         handler.cancelSynchro();
323     }
324 
325     public void doActionPerformed__on__cancelStartButton(ActionEvent event) {
326         if (log.isDebugEnabled()) {
327             log.debug(event);
328         }
329         handler.cancelSynchro();
330     }
331 
332     public void doActionPerformed__on__clearDateButton(ActionEvent event) {
333         if (log.isDebugEnabled()) {
334             log.debug(event);
335         }
336         handler.clearDataDates();
337     }
338 
339     public void doActionPerformed__on__dataEndDateEditor(ActionEvent event) {
340         if (log.isDebugEnabled()) {
341             log.debug(event);
342         }
343         handler.setDate(event, "importDataEndDate");
344     }
345 
346     public void doActionPerformed__on__dataStartDateEditor(ActionEvent event) {
347         if (log.isDebugEnabled()) {
348             log.debug(event);
349         }
350         handler.setDate(event, "importDataStartDate");
351     }
352 
353     public void doActionPerformed__on__reportCloseButton(ActionEvent event) {
354         if (log.isDebugEnabled()) {
355             log.debug(event);
356         }
357         handler.cancelSynchro();
358     }
359 
360     /*-----------------------------------------------------------------------*/
361     /*----------------------- Public acessor methods  -----------------------*/
362     /*-----------------------------------------------------------------------*/
363 
364     public JButton getApplyButton() {
365         return applyButton;
366     }
367 
368     public JXLabel getApplyLabel() {
369         return applyLabel;
370     }
371 
372     public JButton getCancelApplyButton() {
373         return cancelApplyButton;
374     }
375 
376     public JButton getCancelStartButton() {
377         return cancelStartButton;
378     }
379 
380     public JButton getClearDateButton() {
381         return clearDateButton;
382     }
383 
384     public JXDatePicker getDataEndDateEditor() {
385         return dataEndDateEditor;
386     }
387 
388     public JXDatePicker getDataStartDateEditor() {
389         return dataStartDateEditor;
390     }
391 
392     public JXLabel getDateLabel() {
393         return dateLabel;
394     }
395 
396     public SynchroUIHandler getHandler() {
397         return handler;
398     }
399 
400     public SynchroUIContext getModel() {
401         return model;
402     }
403 
404     public JProgressBar getProgressBar() {
405         return progressBar;
406     }
407 
408     public JButton getReportCloseButton() {
409         return reportCloseButton;
410     }
411 
412     public JTextPane getReportTextPane() {
413         return reportTextPane;
414     }
415 
416     public JButton getStartButton() {
417         return startButton;
418     }
419 
420     public JXLabel getStartLabel() {
421         return startLabel;
422     }
423 
424     public JXLabel getStatusLabel() {
425         return statusLabel;
426     }
427 
428     public JLabel getStatusSideLabel() {
429         return statusSideLabel;
430     }
431 
432     public JButton getStopButton() {
433         return stopButton;
434     }
435 
436     public JPanel getSynchroDatePanel() {
437         return synchroDatePanel;
438     }
439 
440     public JPanel getSynchroPanel() {
441         return synchroPanel;
442     }
443 
444     public CardLayout2Ext getSynchroPanelLayout() {
445         return synchroPanelLayout;
446     }
447 
448     public JButton getValidChoiceButton() {
449         return validChoiceButton;
450     }
451 
452     /*-----------------------------------------------------------------------*/
453     /*--------------------- Protected acessors methods  ---------------------*/
454     /*-----------------------------------------------------------------------*/
455 
456     protected JPanel get$JPanel1() {
457         return $JPanel1;
458     }
459 
460     protected JPanel get$JPanel2() {
461         return $JPanel2;
462     }
463 
464     protected JPanel get$JPanel3() {
465         return $JPanel3;
466     }
467 
468     protected JPanel get$JPanel4() {
469         return $JPanel4;
470     }
471 
472     protected JScrollPane get$JScrollPane0() {
473         return $JScrollPane0;
474     }
475 
476     protected Table get$Table0() {
477         return $Table0;
478     }
479 
480     protected Table get$Table1() {
481         return $Table1;
482     }
483 
484     protected Table get$Table2() {
485         return $Table2;
486     }
487 
488     protected Table get$Table3() {
489         return $Table3;
490     }
491 
492     /*-----------------------------------------------------------------------*/
493     /*--------------------- Components creation methods ---------------------*/
494     /*-----------------------------------------------------------------------*/
495 
496     protected void addChildrenToSynchroDatePanel() {
497         if (!allComponentsCreated) {
498             return;
499         }
500         synchroDatePanel.add(dateLabel, BorderLayout.NORTH);
501         synchroDatePanel.add($Table0, BorderLayout.CENTER);
502         synchroDatePanel.add(validChoiceButton, BorderLayout.SOUTH);
503     }
504 
505     protected void addChildrenToSynchroPanel() {
506         if (!allComponentsCreated) {
507             return;
508         }
509         synchroPanel.add($JPanel1, SynchroUIHandler.REPORT_CARD);
510         synchroPanel.add(synchroDatePanel, SynchroUIHandler.DATE_CHOICE_CARD);
511         synchroPanel.add($JPanel2, SynchroUIHandler.VALID_START_CARD);
512         synchroPanel.add($JPanel3, SynchroUIHandler.VALID_APPLY_CARD);
513         synchroPanel.add($JPanel4, SynchroUIHandler.PROGRESS_CARD);
514     }
515 
516     protected void createApplyButton() {
517         $objectMap.put("applyButton", applyButton = new JButton());
518         
519         applyButton.setName("applyButton");
520         applyButton.setText(t("quadrige3.common.validate"));
521         applyButton.setToolTipText(t("quadrige3.synchro.valid.apply.tip"));
522         applyButton.putClientProperty("applicationAction", fr.ifremer.quadrige3.ui.swing.synchro.action.ImportSynchroApplyAction.class);
523     }
524 
525     protected void createApplyLabel() {
526         $objectMap.put("applyLabel", applyLabel = new JXLabel());
527         
528         applyLabel.setName("applyLabel");
529         applyLabel.setText(t("quadrige3.synchro.valid.apply.label"));
530     }
531 
532     protected void createCancelApplyButton() {
533         $objectMap.put("cancelApplyButton", cancelApplyButton = new JButton());
534         
535         cancelApplyButton.setName("cancelApplyButton");
536         cancelApplyButton.setText(t("quadrige3.common.cancel"));
537         cancelApplyButton.setToolTipText(t("quadrige3.synchro.cancel.tip"));
538         cancelApplyButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__cancelApplyButton"));
539     }
540 
541     protected void createCancelStartButton() {
542         $objectMap.put("cancelStartButton", cancelStartButton = new JButton());
543         
544         cancelStartButton.setName("cancelStartButton");
545         cancelStartButton.setText(t("quadrige3.common.cancel"));
546         cancelStartButton.setToolTipText(t("quadrige3.synchro.cancel.tip"));
547         cancelStartButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__cancelStartButton"));
548     }
549 
550     protected void createClearDateButton() {
551         $objectMap.put("clearDateButton", clearDateButton = new JButton());
552         
553         clearDateButton.setName("clearDateButton");
554         clearDateButton.setText(t("quadrige3.synchro.date.reset.label"));
555         clearDateButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__clearDateButton"));
556     }
557 
558     protected void createDataEndDateEditor() {
559         $objectMap.put("dataEndDateEditor", dataEndDateEditor = new JXDatePicker());
560         
561         dataEndDateEditor.setName("dataEndDateEditor");
562         dataEndDateEditor.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__dataEndDateEditor"));
563     }
564 
565     protected void createDataStartDateEditor() {
566         $objectMap.put("dataStartDateEditor", dataStartDateEditor = new JXDatePicker());
567         
568         dataStartDateEditor.setName("dataStartDateEditor");
569         dataStartDateEditor.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__dataStartDateEditor"));
570     }
571 
572     protected void createDateLabel() {
573         $objectMap.put("dateLabel", dateLabel = new JXLabel());
574         
575         dateLabel.setName("dateLabel");
576         dateLabel.setText(t("quadrige3.synchro.date.choice.label"));
577     }
578 
579     protected SynchroUIHandler createHandler() {
580         return new SynchroUIHandler();
581     }
582 
583     protected void createModel() {
584         $objectMap.put("model", model = getContextValue(SynchroUIContext.class));
585     }
586 
587     protected void createProgressBar() {
588         $objectMap.put("progressBar", progressBar = new JProgressBar());
589         
590         progressBar.setName("progressBar");
591     }
592 
593     protected void createReportCloseButton() {
594         $objectMap.put("reportCloseButton", reportCloseButton = new JButton());
595         
596         reportCloseButton.setName("reportCloseButton");
597         reportCloseButton.setText(t("quadrige3.common.close"));
598         reportCloseButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__reportCloseButton"));
599     }
600 
601     protected void createReportTextPane() {
602         $objectMap.put("reportTextPane", reportTextPane = new JTextPane());
603         
604         reportTextPane.setName("reportTextPane");
605         reportTextPane.setOpaque(false);
606         reportTextPane.setEditable(false);
607     }
608 
609     protected void createStartButton() {
610         $objectMap.put("startButton", startButton = new JButton());
611         
612         startButton.setName("startButton");
613         startButton.setText(t("quadrige3.common.validate"));
614         startButton.setToolTipText(t("quadrige3.synchro.valid.start.tip"));
615         startButton.putClientProperty("applicationWorkerAction", fr.ifremer.quadrige3.ui.swing.synchro.action.ImportSynchroStartAction.class);
616     }
617 
618     protected void createStartLabel() {
619         $objectMap.put("startLabel", startLabel = new JXLabel());
620         
621         startLabel.setName("startLabel");
622         startLabel.setText(t("quadrige3.synchro.valid.start.label"));
623     }
624 
625     protected void createStatusLabel() {
626         $objectMap.put("statusLabel", statusLabel = new JXLabel());
627         
628         statusLabel.setName("statusLabel");
629     }
630 
631     protected void createStatusSideLabel() {
632         $objectMap.put("statusSideLabel", statusSideLabel = new JLabel());
633         
634         statusSideLabel.setName("statusSideLabel");
635     }
636 
637     protected void createStopButton() {
638         $objectMap.put("stopButton", stopButton = new JButton());
639         
640         stopButton.setName("stopButton");
641         stopButton.setText(t("quadrige3.common.cancel"));
642         stopButton.setToolTipText(t("quadrige3.synchro.cancel.tip"));
643         stopButton.putClientProperty("applicationWorkerAction", fr.ifremer.quadrige3.ui.swing.synchro.action.SynchroStopAction.class);
644     }
645 
646     protected void createSynchroDatePanel() {
647         $objectMap.put("synchroDatePanel", synchroDatePanel = new JPanel());
648         
649         synchroDatePanel.setName("synchroDatePanel");
650         synchroDatePanel.setLayout(new BorderLayout());
651     }
652 
653     protected void createSynchroPanel() {
654         $objectMap.put("synchroPanel", synchroPanel = new JPanel());
655         
656         synchroPanel.setName("synchroPanel");
657         synchroPanel.setLayout(synchroPanelLayout);
658     }
659 
660     protected void createSynchroPanelLayout() {
661         $objectMap.put("synchroPanelLayout", synchroPanelLayout = new CardLayout2Ext(this, "synchroPanel"));
662     }
663 
664     protected void createValidChoiceButton() {
665         $objectMap.put("validChoiceButton", validChoiceButton = new JButton());
666         
667         validChoiceButton.setName("validChoiceButton");
668         validChoiceButton.setText(t("quadrige3.common.validate"));
669         validChoiceButton.setToolTipText(t("quadrige3.synchro.date.choice.validate.tip"));
670         validChoiceButton.putClientProperty("applicationWorkerAction", fr.ifremer.quadrige3.ui.swing.synchro.action.ImportSynchroCheckAction.class);
671     }
672 
673     /*-----------------------------------------------------------------------*/
674     /*------------------------ Internal jaxx methods ------------------------*/
675     /*-----------------------------------------------------------------------*/
676 
677     private void $completeSetup() {
678         allComponentsCreated = true;
679         if (log.isDebugEnabled()) {
680             log.debug(this);
681         }
682         // inline complete setup of $JPanel0
683         add(synchroPanel);
684         addChildrenToSynchroPanel();
685         // inline complete setup of $JPanel1
686         $JPanel1.add($JScrollPane0, BorderLayout.CENTER);
687         $JPanel1.add(reportCloseButton, BorderLayout.SOUTH);
688         // inline complete setup of $JScrollPane0
689         $JScrollPane0.getViewport().add(reportTextPane);
690         addChildrenToSynchroDatePanel();
691         // inline complete setup of $Table0
692         $Table0.add(clearDateButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
693         $Table0.add(dataStartDateEditor, new GridBagConstraints(1, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
694         $Table0.add(dataEndDateEditor, new GridBagConstraints(2, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
695         // inline complete setup of $JPanel2
696         $JPanel2.add(startLabel);
697         $JPanel2.add($Table1, BorderLayout.SOUTH);
698         // inline complete setup of $Table1
699         $Table1.add(cancelStartButton, new GridBagConstraints(0, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
700         $Table1.add(startButton, new GridBagConstraints(1, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
701         // inline complete setup of $JPanel3
702         $JPanel3.add(applyLabel);
703         $JPanel3.add($Table2, BorderLayout.SOUTH);
704         // inline complete setup of $Table2
705         $Table2.add(cancelApplyButton, new GridBagConstraints(0, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
706         $Table2.add(applyButton, new GridBagConstraints(1, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
707         // inline complete setup of $JPanel4
708         $JPanel4.add($Table3, BorderLayout.CENTER);
709         // inline complete setup of $Table3
710         $Table3.add(statusSideLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
711         $Table3.add(statusLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
712         $Table3.add(progressBar, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
713         $Table3.add(stopButton, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
714         
715         // apply 3 data bindings
716         JAXXUtil.applyDataBinding(this, $bindings.keySet());
717         
718         // apply 35 property setters
719         $JScrollPane0.setBorder(null);
720         reportTextPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
721         reportTextPane.setBackground(new Color(0, 0, 0, 0));
722         reportTextPane.setEditorKit(handler.getNewWrapEditorKit());
723         reportCloseButton.setMnemonic(SwingUtil.getFirstCharAt(t("quadrige3.common.close.mnemonic"),'Z'));
724         reportCloseButton.setIcon(SwingUtil.createActionIcon("close-dialog"));
725         dateLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
726         dateLabel.setLineWrap(true);
727         clearDateButton.setIcon(SwingUtil.createActionIcon("reset"));
728         validChoiceButton.setMnemonic(SwingUtil.getFirstCharAt(t("quadrige3.common.validate.mnemonic"),'Z'));
729         validChoiceButton.setIcon(SwingUtil.createActionIcon("update-referential"));
730         startLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
731         startLabel.setLineWrap(true);
732         cancelStartButton.setMnemonic(SwingUtil.getFirstCharAt(t("quadrige3.common.cancel.mnemonic"),'Z'));
733         cancelStartButton.setIcon(SwingUtil.createActionIcon("cancel"));
734         startButton.setMnemonic(SwingUtil.getFirstCharAt(t("quadrige3.common.validate.mnemonic"),'Z'));
735         startButton.setIcon(SwingUtil.createActionIcon("validate"));
736         applyLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
737         applyLabel.setLineWrap(true);
738         cancelApplyButton.setMnemonic(SwingUtil.getFirstCharAt(t("quadrige3.common.cancel.mnemonic"),'Z'));
739         cancelApplyButton.setIcon(SwingUtil.createActionIcon("cancel"));
740         applyButton.setMnemonic(SwingUtil.getFirstCharAt(t("quadrige3.common.validate.mnemonic"),'Z'));
741         applyButton.setIcon(SwingUtil.createActionIcon("validate"));
742         statusLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
743         statusLabel.setLineWrap(true);
744         progressBar.setIndeterminate(false);
745         stopButton.setMnemonic(SwingUtil.getFirstCharAt(t("quadrige3.common.cancel.mnemonic"),'Z'));
746         stopButton.setIcon(SwingUtil.createActionIcon("cancel"));
747     }
748 
749     private void $initialize() {
750         if (allComponentsCreated) {
751             return;
752         }
753         if (log.isDebugEnabled()) {
754             log.debug(this);
755         }
756         handler.beforeInit(this);
757         $objectMap.put("$JPanel0", $JPanel0);
758         createModel();
759         createSynchroPanelLayout();
760         createSynchroPanel();
761         // inline creation of $JPanel1
762         $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
763         
764         $JPanel1.setName("$JPanel1");
765         $JPanel1.setLayout(new BorderLayout());
766         // inline creation of $JScrollPane0
767         $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
768         
769         $JScrollPane0.setName("$JScrollPane0");
770         createReportTextPane();
771         createReportCloseButton();
772         createSynchroDatePanel();
773         createDateLabel();
774         // inline creation of $Table0
775         $objectMap.put("$Table0", $Table0 = new Table());
776         
777         $Table0.setName("$Table0");
778         createClearDateButton();
779         createDataStartDateEditor();
780         createDataEndDateEditor();
781         createValidChoiceButton();
782         // inline creation of $JPanel2
783         $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
784         
785         $JPanel2.setName("$JPanel2");
786         $JPanel2.setLayout(new BorderLayout());
787         createStartLabel();
788         // inline creation of $Table1
789         $objectMap.put("$Table1", $Table1 = new Table());
790         
791         $Table1.setName("$Table1");
792         createCancelStartButton();
793         createStartButton();
794         // inline creation of $JPanel3
795         $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
796         
797         $JPanel3.setName("$JPanel3");
798         $JPanel3.setLayout(new BorderLayout());
799         createApplyLabel();
800         // inline creation of $Table2
801         $objectMap.put("$Table2", $Table2 = new Table());
802         
803         $Table2.setName("$Table2");
804         createCancelApplyButton();
805         createApplyButton();
806         // inline creation of $JPanel4
807         $objectMap.put("$JPanel4", $JPanel4 = new JPanel());
808         
809         $JPanel4.setName("$JPanel4");
810         $JPanel4.setLayout(new BorderLayout());
811         // inline creation of $Table3
812         $objectMap.put("$Table3", $Table3 = new Table());
813         
814         $Table3.setName("$Table3");
815         createStatusSideLabel();
816         createStatusLabel();
817         createProgressBar();
818         createStopButton();
819         // inline creation of $JPanel0
820         setName("$JPanel0");
821         setLayout(new BorderLayout());
822         
823         // registers 3 data bindings
824         $registerDefaultBindings();
825         $completeSetup();
826         handler.afterInit(this);
827     }
828 
829     private void $registerDefaultBindings() {
830         // register 3 data bindings
831         registerDataBinding(new DefaultJAXXBinding(this, BINDING_DATA_START_DATE_EDITOR_DATE, true) {
832         
833             @Override
834             public void applyDataBinding() {
835                 if (model != null) {
836                     model.addPropertyChangeListener("importDataStartDate", this);
837                 }
838             }
839         
840             @Override
841             public void processDataBinding() {
842                 if (model != null) {
843                     dataStartDateEditor.setDate(model.getImportDataStartDate());
844                 }
845             }
846         
847             @Override
848             public void removeDataBinding() {
849                 if (model != null) {
850                     model.removePropertyChangeListener("importDataStartDate", this);
851                 }
852             }
853         });
854         registerDataBinding(new DefaultJAXXBinding(this, BINDING_DATA_END_DATE_EDITOR_DATE, true) {
855         
856             @Override
857             public void applyDataBinding() {
858                 if (model != null) {
859                     model.addPropertyChangeListener("importDataEndDate", this);
860                 }
861             }
862         
863             @Override
864             public void processDataBinding() {
865                 if (model != null) {
866                     dataEndDateEditor.setDate(model.getImportDataEndDate());
867                 }
868             }
869         
870             @Override
871             public void removeDataBinding() {
872                 if (model != null) {
873                     model.removePropertyChangeListener("importDataEndDate", this);
874                 }
875             }
876         });
877         registerDataBinding(new DefaultJAXXBinding(this, BINDING_VALID_CHOICE_BUTTON_ENABLED, true, true) {
878         
879             @Override
880             public void applyDataBinding() {
881                 if (model != null) {
882                     model.addPropertyChangeListener("importDataStartDate", this);
883                 }
884                 if (model != null) {
885                     model.addPropertyChangeListener("importDataEndDate", this);
886                 }
887             }
888         
889             @Override
890             public void processDataBinding() {
891                 if (model != null) {
892                     validChoiceButton.setEnabled(!(model.getImportDataStartDate() == null ^ model.getImportDataEndDate() == null));
893                 }
894             }
895         
896             @Override
897             public void removeDataBinding() {
898                 if (model != null) {
899                     model.removePropertyChangeListener("importDataStartDate", this);
900                 }
901                 if (model != null) {
902                     model.removePropertyChangeListener("importDataEndDate", this);
903                 }
904             }
905         });
906     }
907 
908 }