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