View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.synchro.program;
2   
3   /*-
4    * #%L
5    * Reef DB :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2022 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  
27  import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
28  import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
29  import fr.ifremer.quadrige3.ui.swing.component.bean.ExtendedBeanDoubleList;
30  import fr.ifremer.quadrige3.ui.swing.component.bean.ExtendedComboBox;
31  import fr.ifremer.quadrige3.ui.swing.component.date.JDatePicker;
32  import fr.ifremer.reefdb.dto.SearchDateDTO;
33  import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
34  import fr.ifremer.reefdb.service.StatusFilter;
35  import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
36  import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
37  import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
38  import java.awt.BorderLayout;
39  import java.awt.Component;
40  import java.awt.Container;
41  import java.awt.GridBagConstraints;
42  import java.awt.GridLayout;
43  import java.awt.Insets;
44  import java.awt.LayoutManager;
45  import java.awt.event.ActionEvent;
46  import java.awt.event.ActionListener;
47  import java.awt.event.ItemEvent;
48  import java.awt.event.ItemListener;
49  import java.util.ArrayList;
50  import java.util.Collection;
51  import java.util.HashMap;
52  import java.util.List;
53  import java.util.Map;
54  import java.util.TreeMap;
55  import javax.swing.BorderFactory;
56  import javax.swing.BoxLayout;
57  import javax.swing.JButton;
58  import javax.swing.JCheckBox;
59  import javax.swing.JLabel;
60  import javax.swing.JPanel;
61  import javax.swing.JSeparator;
62  import javax.swing.SwingConstants;
63  import jaxx.runtime.JAXXBinding;
64  import jaxx.runtime.JAXXContext;
65  import jaxx.runtime.JAXXObject;
66  import jaxx.runtime.JAXXObjectDescriptor;
67  import jaxx.runtime.JAXXUtil;
68  import jaxx.runtime.SwingUtil;
69  import jaxx.runtime.binding.DefaultJAXXBinding;
70  import jaxx.runtime.context.DefaultJAXXContext;
71  import jaxx.runtime.swing.Table;
72  import jaxx.runtime.swing.help.JAXXHelpUI;
73  import org.apache.commons.logging.Log;
74  import org.apache.commons.logging.LogFactory;
75  import static org.nuiton.i18n.I18n.t;
76  
77  public class ProgramSelectUI extends JPanel implements JAXXHelpUI<ReefDbHelpBroker>, ReefDbUI<ProgramSelectUIModel, ProgramSelectUIHandler>, JAXXObject {
78  
79      /*-----------------------------------------------------------------------*/
80      /*------------------ Constants for all public bindings ------------------*/
81      /*-----------------------------------------------------------------------*/
82  
83      public static final String BINDING_ENABLE_PHOTO_CHECK_BOX_SELECTED = "enablePhotoCheckBox.selected";
84      public static final String BINDING_END_DATE_EDITOR_DATE = "endDateEditor.date";
85      public static final String BINDING_ONLY_DIRTY_CHECK_BOX_SELECTED = "onlyDirtyCheckBox.selected";
86      public static final String BINDING_SEARCH_DATE_COMBO_SELECTED_ITEM = "searchDateCombo.selectedItem";
87      public static final String BINDING_SELECT_BOUTON_ENABLED = "selectBouton.enabled";
88      public static final String BINDING_START_DATE_EDITOR_DATE = "startDateEditor.date";
89  
90      /*-----------------------------------------------------------------------*/
91      /*------------------------- Other static fields -------------------------*/
92      /*-----------------------------------------------------------------------*/
93  
94      private static final String $jaxxObjectDescriptor = "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";
95      private static final Log log = LogFactory.getLog(ProgramSelectUI.class);
96      private static final long serialVersionUID = 1L;
97  
98      /*-----------------------------------------------------------------------*/
99      /*--------------------------- Internal states ---------------------------*/
100     /*-----------------------------------------------------------------------*/
101 
102     protected List<Object> $activeBindings = new ArrayList<Object>();
103     protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
104     protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
105     protected Map<String, Object> $objectMap = new HashMap<String, Object>();
106     protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
107     private boolean allComponentsCreated;
108     protected final JAXXContext delegateContext = new DefaultJAXXContext();
109 
110     /*-----------------------------------------------------------------------*/
111     /*------------------------ Protected components  ------------------------*/
112     /*-----------------------------------------------------------------------*/
113 
114     protected JLabel andLabel;
115     protected JLabel availableProgramLabel;
116     protected ReefDbHelpBroker broker;
117     protected JButton cancelBouton;
118     protected JLabel dateLabel;
119     protected JPanel datesPanel;
120     protected JCheckBox enablePhotoCheckBox;
121     protected JDatePicker endDateEditor;
122     protected Boolean fileSynchro;
123     protected final ProgramSelectUIHandler handler = createHandler();
124     protected Collection<String> initialProgramCodes;
125     protected ProgramSelectUIModel model;
126     protected JCheckBox onlyDirtyCheckBox;
127     protected Table optionsPanel;
128     protected Boolean photoSynchro;
129     protected ExtendedBeanDoubleList<ProgramDTO> programDoubleList;
130     protected ProgramSelectUI programSelectUI = this;
131     protected StatusFilter programStatusFilter;
132     protected ExtendedComboBox<SearchDateDTO> searchDateCombo;
133     protected JButton selectBouton;
134     protected JLabel selectedProgramLabel;
135     protected JDatePicker startDateEditor;
136     protected Integer userIdFilter;
137 
138     /*-----------------------------------------------------------------------*/
139     /*------------------------- Private components  -------------------------*/
140     /*-----------------------------------------------------------------------*/
141 
142     private JPanel $JPanel0;
143     private JPanel $JPanel1;
144     private JSeparator $JSeparator0;
145     private Table $Table0;
146 
147     /*-----------------------------------------------------------------------*/
148     /*---------------------------- Constructors  ----------------------------*/
149     /*-----------------------------------------------------------------------*/
150 
151     public ProgramSelectUI(ApplicationUI parentUI, Integer userIdFilter, StatusFilter programStatusFilter, Collection initialProgramCodes, boolean fileSynchro, boolean photoSynchro) {
152         ApplicationUIUtil.setParentUI(this, parentUI);
153                     this.userIdFilter = userIdFilter;
154                     this.programStatusFilter = programStatusFilter;
155                     this.initialProgramCodes = initialProgramCodes;
156                     this.fileSynchro = fileSynchro;
157                     this.photoSynchro = photoSynchro;
158             $initialize();
159     }
160 
161     public ProgramSelectUI(LayoutManager param0, boolean param1) {
162         super(param0 ,param1);
163         $initialize();
164     }
165 
166     public ProgramSelectUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
167         super(param1 ,param2);
168         JAXXUtil.initContext(this, parentContext);
169         $initialize();
170     }
171 
172     public ProgramSelectUI(boolean param0) {
173         super(param0);
174         $initialize();
175     }
176 
177     public ProgramSelectUI(JAXXContext parentContext, boolean param1) {
178         super(param1);
179         JAXXUtil.initContext(this, parentContext);
180         $initialize();
181     }
182 
183     public ProgramSelectUI() {
184         $initialize();
185     }
186 
187     public ProgramSelectUI(JAXXContext parentContext) {
188         JAXXUtil.initContext(this, parentContext);
189         $initialize();
190     }
191 
192     public ProgramSelectUI(LayoutManager param0) {
193         super(param0);
194         $initialize();
195     }
196 
197     public ProgramSelectUI(JAXXContext parentContext, LayoutManager param1) {
198         super(param1);
199         JAXXUtil.initContext(this, parentContext);
200         $initialize();
201     }
202 
203     /*-----------------------------------------------------------------------*/
204     /*--------------------------- Statics methods ---------------------------*/
205     /*-----------------------------------------------------------------------*/
206 
207     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
208         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
209     }
210 
211     /*-----------------------------------------------------------------------*/
212     /*---------------------- JAXXObject implementation ----------------------*/
213     /*-----------------------------------------------------------------------*/
214 
215     @Override
216     public void applyDataBinding(String $binding) {
217         if (allComponentsCreated && $bindings.containsKey($binding)) {
218             getDataBinding($binding).applyDataBinding();
219         }
220         processDataBinding($binding);
221     }
222 
223     @Override
224     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
225         super.firePropertyChange(propertyName, oldValue, newValue);
226     }
227 
228     @Override
229     public Map<String, Object> get$objectMap() {
230         return $objectMap;
231     }
232 
233     @Override
234     public JAXXBinding getDataBinding(String bindingId) {
235         return $bindings.get(bindingId);
236     }
237 
238     @Override
239     public JAXXBinding[] getDataBindings() {
240         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
241     }
242 
243     @Override
244     public Object getObjectById(String id) {
245         return $objectMap.get(id);
246     }
247 
248     @Override
249     public void processDataBinding(String $binding, boolean $force) {
250         if (!$force && $activeBindings.contains($binding)) { 
251             return;
252         }
253         $activeBindings.add($binding);
254         try {
255             if (allComponentsCreated && $bindings.containsKey($binding)) {
256                 getDataBinding($binding).processDataBinding();
257             }
258         } finally {
259             $activeBindings.remove($binding);
260         }
261     }
262 
263     @Override
264     public void processDataBinding(String $binding) {
265         processDataBinding($binding, false);
266     }
267 
268     @Override
269     public void registerDataBinding(JAXXBinding binding) {
270         $bindings.put(binding.getId(), binding);
271     }
272 
273     @Override
274     public void removeDataBinding(String $binding) {
275         if (allComponentsCreated && $bindings.containsKey($binding)) {
276             getDataBinding($binding).removeDataBinding();
277         }
278     }
279 
280     /*-----------------------------------------------------------------------*/
281     /*--------------------- JAXXContext implementation  ---------------------*/
282     /*-----------------------------------------------------------------------*/
283 
284     @Override
285     public <T> T getContextValue(Class<T> clazz) {
286         return delegateContext.getContextValue(clazz, null);
287     }
288 
289     @Override
290     public <T> T getContextValue(Class<T> clazz, String name) {
291         return delegateContext.getContextValue(clazz, name);
292     }
293 
294     @Override
295     public JAXXContext getDelegateContext() {
296         return delegateContext;
297     }
298 
299     @Override
300     public <O extends Container> O getParentContainer(Class<O> clazz) {
301         return SwingUtil.getParentContainer(this, clazz);
302     }
303 
304     @Override
305     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
306         return SwingUtil.getParentContainer(source, clazz);
307     }
308 
309     @Override
310     public <T> void removeContextValue(Class<T> clazz) {
311         delegateContext.removeContextValue(clazz, null);
312     }
313 
314     @Override
315     public <T> void removeContextValue(Class<T> clazz, String name) {
316         delegateContext.removeContextValue(clazz, name);
317     }
318 
319     @Override
320     public <T> void setContextValue(T o) {
321         delegateContext.setContextValue(o, null);
322     }
323 
324     @Override
325     public <T> void setContextValue(T o, String name) {
326         delegateContext.setContextValue(o, name);
327     }
328 
329     /*-----------------------------------------------------------------------*/
330     /*---------------------------- Event methods ----------------------------*/
331     /*-----------------------------------------------------------------------*/
332 
333     public void doActionPerformed__on__cancelBouton(ActionEvent event) {
334         if (log.isDebugEnabled()) {
335             log.debug(event);
336         }
337         handler.cancel();
338     }
339 
340     public void doActionPerformed__on__endDateEditor(ActionEvent event) {
341         if (log.isDebugEnabled()) {
342             log.debug(event);
343         }
344         handler.setDate(event, "endDate");
345     }
346 
347     public void doActionPerformed__on__selectBouton(ActionEvent event) {
348         if (log.isDebugEnabled()) {
349             log.debug(event);
350         }
351         handler.select();
352     }
353 
354     public void doActionPerformed__on__startDateEditor(ActionEvent event) {
355         if (log.isDebugEnabled()) {
356             log.debug(event);
357         }
358         handler.setDate(event, "startDate");
359     }
360 
361     public void doItemStateChanged__on__enablePhotoCheckBox(ItemEvent event) {
362         if (log.isDebugEnabled()) {
363             log.debug(event);
364         }
365         handler.setBoolean(event, ProgramSelectUIModel.PROPERTY_ENABLE_PHOTO);
366     }
367 
368     public void doItemStateChanged__on__onlyDirtyCheckBox(ItemEvent event) {
369         if (log.isDebugEnabled()) {
370             log.debug(event);
371         }
372         handler.setBoolean(event, ProgramSelectUIModel.PROPERTY_DIRTY_ONLY);
373     }
374 
375     /*-----------------------------------------------------------------------*/
376     /*----------------------- Public acessor methods  -----------------------*/
377     /*-----------------------------------------------------------------------*/
378 
379     public JLabel getAndLabel() {
380         return andLabel;
381     }
382 
383     public JLabel getAvailableProgramLabel() {
384         return availableProgramLabel;
385     }
386 
387     public ReefDbHelpBroker getBroker() {
388         return broker;
389     }
390 
391     public JButton getCancelBouton() {
392         return cancelBouton;
393     }
394 
395     public JLabel getDateLabel() {
396         return dateLabel;
397     }
398 
399     public JPanel getDatesPanel() {
400         return datesPanel;
401     }
402 
403     public JCheckBox getEnablePhotoCheckBox() {
404         return enablePhotoCheckBox;
405     }
406 
407     public JDatePicker getEndDateEditor() {
408         return endDateEditor;
409     }
410 
411     public Boolean getFileSynchro() {
412         return fileSynchro;
413     }
414 
415     public ProgramSelectUIHandler getHandler() {
416         return handler;
417     }
418 
419     public Collection<String> getInitialProgramCodes() {
420         return initialProgramCodes;
421     }
422 
423     public ProgramSelectUIModel getModel() {
424         return model;
425     }
426 
427     public JCheckBox getOnlyDirtyCheckBox() {
428         return onlyDirtyCheckBox;
429     }
430 
431     public Table getOptionsPanel() {
432         return optionsPanel;
433     }
434 
435     public Boolean getPhotoSynchro() {
436         return photoSynchro;
437     }
438 
439     public ExtendedBeanDoubleList<ProgramDTO> getProgramDoubleList() {
440         return programDoubleList;
441     }
442 
443     public StatusFilter getProgramStatusFilter() {
444         return programStatusFilter;
445     }
446 
447     public ExtendedComboBox<SearchDateDTO> getSearchDateCombo() {
448         return searchDateCombo;
449     }
450 
451     public JButton getSelectBouton() {
452         return selectBouton;
453     }
454 
455     public JLabel getSelectedProgramLabel() {
456         return selectedProgramLabel;
457     }
458 
459     public JDatePicker getStartDateEditor() {
460         return startDateEditor;
461     }
462 
463     public Integer getUserIdFilter() {
464         return userIdFilter;
465     }
466 
467     /*-----------------------------------------------------------------------*/
468     /*---------------------------- Other methods ----------------------------*/
469     /*-----------------------------------------------------------------------*/
470 
471     @Override
472     public void registerHelpId(ReefDbHelpBroker broker, Component component, String helpId) {
473         broker.installUI(component, helpId);
474     }
475 
476     @Override
477     public void showHelp(String helpId) {
478         getBroker().showHelp(this, helpId);
479     }
480 
481     /*-----------------------------------------------------------------------*/
482     /*--------------------- Protected acessors methods  ---------------------*/
483     /*-----------------------------------------------------------------------*/
484 
485     protected JPanel get$JPanel0() {
486         return $JPanel0;
487     }
488 
489     protected JPanel get$JPanel1() {
490         return $JPanel1;
491     }
492 
493     protected JSeparator get$JSeparator0() {
494         return $JSeparator0;
495     }
496 
497     protected Table get$Table0() {
498         return $Table0;
499     }
500 
501     /*-----------------------------------------------------------------------*/
502     /*--------------------- Components creation methods ---------------------*/
503     /*-----------------------------------------------------------------------*/
504 
505     protected void addChildrenToDatesPanel() {
506         if (!allComponentsCreated) {
507             return;
508         }
509         datesPanel.add(dateLabel, BorderLayout.PAGE_START);
510         datesPanel.add(searchDateCombo, BorderLayout.LINE_START);
511         datesPanel.add(startDateEditor);
512         datesPanel.add(andLabel);
513         datesPanel.add(endDateEditor, BorderLayout.LINE_END);
514     }
515 
516     protected void addChildrenToOptionsPanel() {
517         if (!allComponentsCreated) {
518             return;
519         }
520         optionsPanel.add($JSeparator0, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
521         optionsPanel.add(enablePhotoCheckBox, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
522         optionsPanel.add(onlyDirtyCheckBox, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
523         optionsPanel.add(datesPanel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
524     }
525 
526     protected void addChildrenToProgramSelectUI() {
527         if (!allComponentsCreated) {
528             return;
529         }
530         add($JPanel0);
531         add($JPanel1, BorderLayout.PAGE_END);
532     }
533 
534     protected void createAndLabel() {
535         $objectMap.put("andLabel", andLabel = new JLabel());
536         
537         andLabel.setName("andLabel");
538         andLabel.setText(t("reefdb.property.and"));
539     }
540 
541     protected void createAvailableProgramLabel() {
542         $objectMap.put("availableProgramLabel", availableProgramLabel = new JLabel());
543         
544         availableProgramLabel.setName("availableProgramLabel");
545         availableProgramLabel.setText(t("reefdb.synchro.program.available"));
546     }
547 
548     protected void createBroker() {
549         $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
550     }
551 
552     protected void createCancelBouton() {
553         $objectMap.put("cancelBouton", cancelBouton = new JButton());
554         
555         cancelBouton.setName("cancelBouton");
556         cancelBouton.setText(t("reefdb.common.cancel"));
557         cancelBouton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__cancelBouton"));
558     }
559 
560     protected void createDateLabel() {
561         $objectMap.put("dateLabel", dateLabel = new JLabel());
562         
563         dateLabel.setName("dateLabel");
564         dateLabel.setText(t("reefdb.property.date"));
565     }
566 
567     protected void createDatesPanel() {
568         $objectMap.put("datesPanel", datesPanel = new JPanel());
569         
570         datesPanel.setName("datesPanel");
571         datesPanel.setLayout(new BoxLayout(datesPanel, BoxLayout.LINE_AXIS));
572     }
573 
574     protected void createEnablePhotoCheckBox() {
575         $objectMap.put("enablePhotoCheckBox", enablePhotoCheckBox = new JCheckBox());
576         
577         enablePhotoCheckBox.setName("enablePhotoCheckBox");
578         enablePhotoCheckBox.setText(t("reefdb.synchro.photo.enable.label"));
579         enablePhotoCheckBox.addItemListener(JAXXUtil.getEventListener(ItemListener.class, "itemStateChanged", this, "doItemStateChanged__on__enablePhotoCheckBox"));
580     }
581 
582     protected void createEndDateEditor() {
583         $objectMap.put("endDateEditor", endDateEditor = new JDatePicker());
584         
585         endDateEditor.setName("endDateEditor");
586         endDateEditor.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__endDateEditor"));
587         endDateEditor.putClientProperty("selectOnFocus", true);
588     }
589 
590     protected void createFileSynchro() {
591         $objectMap.put("fileSynchro", fileSynchro = this.fileSynchro);
592     }
593 
594     protected ProgramSelectUIHandler createHandler() {
595         return new ProgramSelectUIHandler();
596     }
597 
598     protected void createInitialProgramCodes() {
599         $objectMap.put("initialProgramCodes", initialProgramCodes = this.initialProgramCodes);
600     }
601 
602     protected void createModel() {
603         $objectMap.put("model", model = getContextValue(ProgramSelectUIModel.class));
604     }
605 
606     protected void createOnlyDirtyCheckBox() {
607         $objectMap.put("onlyDirtyCheckBox", onlyDirtyCheckBox = new JCheckBox());
608         
609         onlyDirtyCheckBox.setName("onlyDirtyCheckBox");
610         onlyDirtyCheckBox.setText(t("reefdb.synchro.export.dirtyOnly.label"));
611         onlyDirtyCheckBox.addItemListener(JAXXUtil.getEventListener(ItemListener.class, "itemStateChanged", this, "doItemStateChanged__on__onlyDirtyCheckBox"));
612     }
613 
614     protected void createOptionsPanel() {
615         $objectMap.put("optionsPanel", optionsPanel = new Table());
616         
617         optionsPanel.setName("optionsPanel");
618     }
619 
620     protected void createPhotoSynchro() {
621         $objectMap.put("photoSynchro", photoSynchro = this.photoSynchro);
622     }
623 
624     protected void createProgramDoubleList() {
625         $objectMap.put("programDoubleList", programDoubleList = new ExtendedBeanDoubleList<ProgramDTO>());
626         
627         programDoubleList.setName("programDoubleList");
628         programDoubleList.setFilterable(true);
629         programDoubleList.setShowDecorator(false);
630         programDoubleList.setShowSelectPopupEnabled(true);
631         programDoubleList.setProperty("selectedPrograms");
632         programDoubleList.setShowReset(true);
633         programDoubleList.setHighlightFilterText(true);
634         programDoubleList.setUseMultiSelect(false);
635         programDoubleList.setToolTipText(t("reefdb.synchro.program.available.filter"));
636     }
637 
638     protected void createProgramStatusFilter() {
639         $objectMap.put("programStatusFilter", programStatusFilter = this.programStatusFilter);
640     }
641 
642     protected void createSearchDateCombo() {
643         $objectMap.put("searchDateCombo", searchDateCombo = new ExtendedComboBox<SearchDateDTO>(this));
644         
645         searchDateCombo.setName("searchDateCombo");
646         searchDateCombo.setFilterable(true);
647         searchDateCombo.setShowDecorator(false);
648         searchDateCombo.setProperty("searchDate");
649         searchDateCombo.setShowReset(true);
650     }
651 
652     protected void createSelectBouton() {
653         $objectMap.put("selectBouton", selectBouton = new JButton());
654         
655         selectBouton.setName("selectBouton");
656         selectBouton.setText(t("reefdb.common.select"));
657         selectBouton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__selectBouton"));
658     }
659 
660     protected void createSelectedProgramLabel() {
661         $objectMap.put("selectedProgramLabel", selectedProgramLabel = new JLabel());
662         
663         selectedProgramLabel.setName("selectedProgramLabel");
664         selectedProgramLabel.setText(t("reefdb.synchro.program.selected"));
665     }
666 
667     protected void createStartDateEditor() {
668         $objectMap.put("startDateEditor", startDateEditor = new JDatePicker());
669         
670         startDateEditor.setName("startDateEditor");
671         startDateEditor.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__startDateEditor"));
672         startDateEditor.putClientProperty("selectOnFocus", true);
673     }
674 
675     protected void createUserIdFilter() {
676         $objectMap.put("userIdFilter", userIdFilter = this.userIdFilter);
677     }
678 
679     /*-----------------------------------------------------------------------*/
680     /*------------------------ Internal jaxx methods ------------------------*/
681     /*-----------------------------------------------------------------------*/
682 
683     private void $completeSetup() {
684         allComponentsCreated = true;
685         if (log.isDebugEnabled()) {
686             log.debug(this);
687         }
688         addChildrenToProgramSelectUI();
689         // inline complete setup of $JPanel0
690         $JPanel0.add($Table0, BorderLayout.CENTER);
691         $JPanel0.add(optionsPanel, BorderLayout.PAGE_END);
692         // inline complete setup of $Table0
693         $Table0.add(availableProgramLabel, new GridBagConstraints(0, 0, 1, 1, 0.5, 0.0, 10, 2, new Insets(3, 3, 3, 3), 0, 0));
694         $Table0.add(selectedProgramLabel, new GridBagConstraints(1, 0, 1, 1, 0.5, 0.0, 10, 2, new Insets(3, 3, 3, 3), 0, 0));
695         $Table0.add(programDoubleList, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
696         addChildrenToOptionsPanel();
697         addChildrenToDatesPanel();
698         // inline complete setup of $JPanel1
699         $JPanel1.add(cancelBouton);
700         $JPanel1.add(selectBouton);
701         
702         // apply 6 data bindings
703         JAXXUtil.applyDataBinding(this, $bindings.keySet());
704         
705         // apply 22 property setters
706         programDoubleList.setBeanType(ProgramDTO.class);
707         searchDateCombo.setBeanType(SearchDateDTO.class);
708         andLabel.setHorizontalAlignment(JLabel.RIGHT);
709         cancelBouton.setAlignmentX(Component.CENTER_ALIGNMENT);
710         selectBouton.setAlignmentX(Component.CENTER_ALIGNMENT);
711         availableProgramLabel.setHorizontalAlignment(SwingConstants.CENTER);
712         selectedProgramLabel.setHorizontalAlignment(SwingConstants.CENTER);
713         programDoubleList.setBean(model);
714         enablePhotoCheckBox.setBorder(BorderFactory.createEmptyBorder(10,0,10,0));
715         enablePhotoCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
716         onlyDirtyCheckBox.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
717         onlyDirtyCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
718         datesPanel.setBorder(BorderFactory.createEmptyBorder(0,0,10,0));
719         searchDateCombo.setBean(model);
720         cancelBouton.setMnemonic(SwingUtil.getFirstCharAt(t("reefdb.common.cancel.mnemonic"),'Z'));
721         cancelBouton.setIcon(SwingUtil.createActionIcon("cancel"));
722         selectBouton.setMnemonic(SwingUtil.getFirstCharAt(t("reefdb.common.select.mnemonic"),'Z'));
723         selectBouton.setIcon(SwingUtil.createActionIcon("validate"));
724     }
725 
726     private void $initialize() {
727         if (allComponentsCreated) {
728             return;
729         }
730         if (log.isDebugEnabled()) {
731             log.debug(this);
732         }
733         handler.beforeInit(this);
734         $objectMap.put("programSelectUI", programSelectUI);
735         createModel();
736         createBroker();
737         createProgramStatusFilter();
738         createUserIdFilter();
739         createInitialProgramCodes();
740         createFileSynchro();
741         createPhotoSynchro();
742         // inline creation of $JPanel0
743         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
744         
745         $JPanel0.setName("$JPanel0");
746         $JPanel0.setLayout(new BorderLayout());
747         // inline creation of $Table0
748         $objectMap.put("$Table0", $Table0 = new Table());
749         
750         $Table0.setName("$Table0");
751         createAvailableProgramLabel();
752         createSelectedProgramLabel();
753         createProgramDoubleList();
754         createOptionsPanel();
755         // inline creation of $JSeparator0
756         $objectMap.put("$JSeparator0", $JSeparator0 = new JSeparator(SwingConstants.HORIZONTAL));
757         
758         $JSeparator0.setName("$JSeparator0");
759         createEnablePhotoCheckBox();
760         createOnlyDirtyCheckBox();
761         createDatesPanel();
762         createDateLabel();
763         createSearchDateCombo();
764         createStartDateEditor();
765         createAndLabel();
766         createEndDateEditor();
767         // inline creation of $JPanel1
768         $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
769         
770         $JPanel1.setName("$JPanel1");
771         $JPanel1.setLayout(new GridLayout(1,0));
772         createCancelBouton();
773         createSelectBouton();
774         // inline creation of programSelectUI
775         setName("programSelectUI");
776         setLayout(new BorderLayout());
777         
778         // registers 6 data bindings
779         $registerDefaultBindings();
780         $completeSetup();
781         handler.afterInit(this);
782     }
783 
784     private void $registerDefaultBindings() {
785         // register 6 data bindings
786         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ENABLE_PHOTO_CHECK_BOX_SELECTED, true) {
787         
788             @Override
789             public void applyDataBinding() {
790                 if (model != null) {
791                     model.addPropertyChangeListener("enablePhoto", this);
792                 }
793             }
794         
795             @Override
796             public void processDataBinding() {
797                 if (model != null) {
798                     enablePhotoCheckBox.setSelected(model.isEnablePhoto());
799                 }
800             }
801         
802             @Override
803             public void removeDataBinding() {
804                 if (model != null) {
805                     model.removePropertyChangeListener("enablePhoto", this);
806                 }
807             }
808         });
809         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ONLY_DIRTY_CHECK_BOX_SELECTED, true) {
810         
811             @Override
812             public void applyDataBinding() {
813                 if (model != null) {
814                     model.addPropertyChangeListener("dirtyOnly", this);
815                 }
816             }
817         
818             @Override
819             public void processDataBinding() {
820                 if (model != null) {
821                     onlyDirtyCheckBox.setSelected(model.isDirtyOnly());
822                 }
823             }
824         
825             @Override
826             public void removeDataBinding() {
827                 if (model != null) {
828                     model.removePropertyChangeListener("dirtyOnly", this);
829                 }
830             }
831         });
832         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SEARCH_DATE_COMBO_SELECTED_ITEM, true) {
833         
834             @Override
835             public void applyDataBinding() {
836                 if (model != null) {
837                     model.addPropertyChangeListener("searchDate", this);
838                 }
839             }
840         
841             @Override
842             public void processDataBinding() {
843                 if (model != null) {
844                     searchDateCombo.setSelectedItem(model.getSearchDate());
845                 }
846             }
847         
848             @Override
849             public void removeDataBinding() {
850                 if (model != null) {
851                     model.removePropertyChangeListener("searchDate", this);
852                 }
853             }
854         });
855         registerDataBinding(new DefaultJAXXBinding(this, BINDING_START_DATE_EDITOR_DATE, true) {
856         
857             @Override
858             public void applyDataBinding() {
859                 if (model != null) {
860                     model.addPropertyChangeListener("startDate", this);
861                 }
862             }
863         
864             @Override
865             public void processDataBinding() {
866                 if (model != null) {
867                     startDateEditor.setDate(model.getStartDate());
868                 }
869             }
870         
871             @Override
872             public void removeDataBinding() {
873                 if (model != null) {
874                     model.removePropertyChangeListener("startDate", this);
875                 }
876             }
877         });
878         registerDataBinding(new DefaultJAXXBinding(this, BINDING_END_DATE_EDITOR_DATE, true) {
879         
880             @Override
881             public void applyDataBinding() {
882                 if (model != null) {
883                     model.addPropertyChangeListener("endDate", this);
884                 }
885             }
886         
887             @Override
888             public void processDataBinding() {
889                 if (model != null) {
890                     endDateEditor.setDate(model.getEndDate());
891                 }
892             }
893         
894             @Override
895             public void removeDataBinding() {
896                 if (model != null) {
897                     model.removePropertyChangeListener("endDate", this);
898                 }
899             }
900         });
901         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SELECT_BOUTON_ENABLED, true) {
902         
903             @Override
904             public void applyDataBinding() {
905                 if (model != null) {
906                     model.addPropertyChangeListener("selectedPrograms", this);
907                 }
908             }
909         
910             @Override
911             public void processDataBinding() {
912                 if (model != null && model.getSelectedPrograms() != null) {
913                     selectBouton.setEnabled(!model.getSelectedPrograms().isEmpty());
914                 }
915             }
916         
917             @Override
918             public void removeDataBinding() {
919                 if (model != null) {
920                     model.removePropertyChangeListener("selectedPrograms", this);
921                 }
922             }
923         });
924     }
925 
926 }