View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.referential.replace;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU General Public License as
13   * published by the Free Software Foundation, either version 3 of the
14   * License, or (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 General Public
22   * License along with this program.  If not, see
23   * <http://www.gnu.org/licenses/gpl-3.0.html>.
24   * #L%
25   */
26  
27  import fr.ifremer.tutti.persistence.entities.referential.TuttiReferentialEntity;
28  import fr.ifremer.tutti.ui.swing.TuttiHelpBroker;
29  import fr.ifremer.tutti.ui.swing.TuttiUIContext;
30  import fr.ifremer.tutti.ui.swing.util.TuttiUI;
31  import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
32  import java.awt.BorderLayout;
33  import java.awt.Container;
34  import java.awt.Dialog;
35  import java.awt.Dialog.ModalityType;
36  import java.awt.Frame;
37  import java.awt.GraphicsConfiguration;
38  import java.awt.GridBagConstraints;
39  import java.awt.GridLayout;
40  import java.awt.Insets;
41  import java.awt.Window;
42  import java.awt.event.ItemEvent;
43  import java.awt.event.ItemListener;
44  import java.util.ArrayList;
45  import java.util.HashMap;
46  import java.util.List;
47  import java.util.Map;
48  import java.util.TreeMap;
49  import javax.swing.JButton;
50  import javax.swing.JCheckBox;
51  import javax.swing.JDialog;
52  import javax.swing.JLabel;
53  import javax.swing.JPanel;
54  import javax.swing.JSeparator;
55  import jaxx.runtime.JAXXBinding;
56  import jaxx.runtime.JAXXContext;
57  import jaxx.runtime.JAXXObject;
58  import jaxx.runtime.JAXXObjectDescriptor;
59  import jaxx.runtime.JAXXUtil;
60  import jaxx.runtime.JAXXValidator;
61  import jaxx.runtime.SwingUtil;
62  import jaxx.runtime.binding.DefaultJAXXBinding;
63  import jaxx.runtime.context.DefaultJAXXContext;
64  import jaxx.runtime.swing.Table;
65  import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
66  import jaxx.runtime.validator.swing.SwingValidator;
67  import jaxx.runtime.validator.swing.SwingValidatorUtil;
68  import jaxx.runtime.validator.swing.meta.Validator;
69  import jaxx.runtime.validator.swing.meta.ValidatorField;
70  import jaxx.runtime.validator.swing.ui.ImageValidationUI;
71  import org.apache.commons.logging.Log;
72  import org.apache.commons.logging.LogFactory;
73  import static org.nuiton.i18n.I18n.t;
74  
75  public abstract class AbstractReplaceTemporaryUI<E extends TuttiReferentialEntity, M extends AbstractReplaceTemporaryUIModel<E>> extends JDialog implements JAXXObject, JAXXValidator {
76  
77      /*-----------------------------------------------------------------------*/
78      /*------------------ Constants for all public bindings ------------------*/
79      /*-----------------------------------------------------------------------*/
80  
81      public static final String BINDING_DELETE_CHECK_BOX_SELECTED = "deleteCheckBox.selected";
82      public static final String BINDING_REPLACE_BUTTON_ENABLED = "replaceButton.enabled";
83      public static final String BINDING_SOURCE_LIST_COMBO_BOX_SELECTED_ITEM = "sourceListComboBox.selectedItem";
84      public static final String BINDING_TARGET_LIST_COMBO_BOX_SELECTED_ITEM = "targetListComboBox.selectedItem";
85  
86      /*-----------------------------------------------------------------------*/
87      /*------------------------- Other static fields -------------------------*/
88      /*-----------------------------------------------------------------------*/
89  
90      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1XzW8bRRSfmDjfaWhC0kKLVEJBLaB1KG0JSlWapIpI5EAUO7RqDmG8O4mnjHeXmefGkVXEn8CfAHcuSNzKBSHEmQMX1H8BIQ5cq76ZXe967TX+aCJlZM2b93vv/d7HzP7wN8kqSd54SGs1S1Zd4BVmba3ev/9Z6SGz4S5TtuQ+eJIEf0MZktknk060r4C8uZ/X6rlQPbfuVXzPZW6T9kqeTCg4EUyVGQMgryc1bKVyhUi8UvOrsoEaOZWG+t2//2S+db75PkNIzUfvpjGUS9204kiG8yTDHSCzaOkRzQnqHqEbkrtH6O+03lsXVKlPaYV9Rb4mo3ky4lOJYEAWew/ZYBj9mg9kXjJfUJsVGWpIKk/2Nose7u8cSosfSlZh0oIqALeq3FLH6Itley4gtCXZIdPWORVWiGKtlhRIasNuG6rvG6MjQLIVz2ECyN5pm9jWuLGd8UdUcIdi7EDeTWQhEoTmCnr9vLHZ5CnQkmBAzie0A52iFulz49HxGeVVpc3yXEGelnSIszpptVBjy2zqs7ORymysgjkreWteDciNFHPM4drfEqOutYbLBhfApPahoZcEngEqjxhEvujtcy224yPNGK8lT51BThmw9TKzvzTezSdiauwnlaYubxUY1qamcwnIQkIlkiR1xi5v7VCXiaVW2sxuC75NXZuJNawarBQylzgf7OqTb0UK02H1xLJ3wgOSXEjQjb1vxb0fN+fQPsnKKm5jOey3j4tdFAWD4nzLoNCARvpsYe7PJ09/2mhMhxm0PZ96tGm4Ydf60vOZBK5NzwSjoQpc5Lapv7JPxhXmxw4m38UUxwqhGJ1De2e1uqXVrU+oKiNEdvSvX35d+OKPl0hmg0wIjzobVJ/fJONQlsiCJ5ya//Ed49HU8RiuL+N/BvsLZce7TOkBOgyyimwN6/rE9NSxrkw3Xrn6uIacXEzhJHKsNP77f3OFH+80eBlCP1/teDzmJvuAjHBXcJeZuRmOxNQ5OekrVnW8ePSlDUOCY28hvbfCkXDNrDfbyBjCNjmgjnOP8aMy7LkcGTlXN2POQibibUOHxrhl4tS/bhPfR8PTQnfpPQ5lfa6btZGygQSSubHUAXCyZErdNE83OD2RqQiz2I7X6Zbwu9AyjE1twtrQI/iVevuse6xtshoGci24AVrt7DZdAIecCceKQdDvgzIOfCAr9cX+1S2tu4geTILniSL3i8aRmwMgAffTWGu9D3rgayroZuZsAqsAuRAXUSEUFAwmFhKSG06GEyw/lRCj7YPokgvvoo/qcGUAmha1pdMgOo2hlOuv36Jqv8QGKKoYZKBYY/UXLaompE5F1XKxn0pRFQ1mx6IKxC9cVLHngxZVG9GpRdVeEj2QFJaM1asrwbMojuLD3qMIVKNSGWvQjK6HqeHqrjljMpIspZ5rOrTSoYxannXdCNJvLv7+srvtsornchsz390PfEdwz40e7pVIdyKQbOpnPhkN5VEKlvpFjpNwvVMSdphUqNDiUXqzXu87MuQY42CufjJgFs9GWTTfFKmXfuuTtP8ELPfsZvBY7sT/SCCO6M/1iRuzv9xLCyR9Ss/AB/3CmARMHyhe8QVbNSIgD+qDfWAG0MpaF55i4Vfm3uZqaFA/GFPzmfgm6ZZO/YYT9MTDw+TMLZyo9FKJuw66drsNe0ivE10R9fYTvfycjvB2Dz4Nczv4OuqAcbUnL377H4T3EOE5mRXwR+URAAA=";
91      private static final Log log = LogFactory.getLog(AbstractReplaceTemporaryUI.class);
92      private static final long serialVersionUID = 1L;
93  
94      /*-----------------------------------------------------------------------*/
95      /*--------------------------- Internal states ---------------------------*/
96      /*-----------------------------------------------------------------------*/
97  
98      protected List<Object> $activeBindings = new ArrayList<Object>();
99      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
100     protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
101     protected Map<String, Object> $objectMap = new HashMap<String, Object>();
102     protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
103     private boolean allComponentsCreated;
104     protected final JAXXContext delegateContext = new DefaultJAXXContext();
105 
106     /*-----------------------------------------------------------------------*/
107     /*------------------------ Protected components  ------------------------*/
108     /*-----------------------------------------------------------------------*/
109 
110     protected JButton cancelButton;
111     protected JCheckBox deleteCheckBox;
112     protected AbstractReplaceTemporaryUIModel<E> model;
113     protected JButton replaceButton;
114     protected AbstractReplaceTemporaryUI<E, M> replaceTemporaryUITop = this;
115     @ValidatorField( validatorId = "validator",  propertyName = "selectedSource",  editorName = "sourceListComboBox")
116     protected BeanFilterableComboBox<E> sourceListComboBox;
117     protected JLabel sourceListLabel;
118     protected Table table;
119     @ValidatorField( validatorId = "validator",  propertyName = "selectedTarget",  editorName = "targetListComboBox")
120     protected BeanFilterableComboBox<E> targetListComboBox;
121     protected JLabel targetListLabel;
122     @Validator( validatorId = "validator")
123     protected SwingValidator<AbstractReplaceTemporaryUIModel> validator;
124     protected List<String> validatorIds = new ArrayList<String>();
125 
126     /*-----------------------------------------------------------------------*/
127     /*------------------------- Private components  -------------------------*/
128     /*-----------------------------------------------------------------------*/
129 
130     private JPanel $JPanel0;
131     private JSeparator $JSeparator0;
132 
133     /*-----------------------------------------------------------------------*/
134     /*---------------------------- Constructors  ----------------------------*/
135     /*-----------------------------------------------------------------------*/
136 
137     public AbstractReplaceTemporaryUI(Frame param0, String param1, boolean param2, GraphicsConfiguration param3) {
138         super(param0 ,param1 ,param2 ,param3);
139         $initialize();
140     }
141 
142     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Frame param1, String param2, boolean param3, GraphicsConfiguration param4) {
143         super(param1 ,param2 ,param3 ,param4);
144         JAXXUtil.initContext(this, parentContext);
145         $initialize();
146     }
147 
148     public AbstractReplaceTemporaryUI(Dialog param0) {
149         super(param0);
150         $initialize();
151     }
152 
153     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Dialog param1) {
154         super(param1);
155         JAXXUtil.initContext(this, parentContext);
156         $initialize();
157     }
158 
159     public AbstractReplaceTemporaryUI(Frame param0, String param1, boolean param2) {
160         super(param0 ,param1 ,param2);
161         $initialize();
162     }
163 
164     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Frame param1, String param2, boolean param3) {
165         super(param1 ,param2 ,param3);
166         JAXXUtil.initContext(this, parentContext);
167         $initialize();
168     }
169 
170     public AbstractReplaceTemporaryUI() {
171         $initialize();
172     }
173 
174     public AbstractReplaceTemporaryUI(JAXXContext parentContext) {
175         JAXXUtil.initContext(this, parentContext);
176         $initialize();
177     }
178 
179     public AbstractReplaceTemporaryUI(Frame param0) {
180         super(param0);
181         $initialize();
182     }
183 
184     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Frame param1) {
185         super(param1);
186         JAXXUtil.initContext(this, parentContext);
187         $initialize();
188     }
189 
190     public AbstractReplaceTemporaryUI(Frame param0, boolean param1) {
191         super(param0 ,param1);
192         $initialize();
193     }
194 
195     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Frame param1, boolean param2) {
196         super(param1 ,param2);
197         JAXXUtil.initContext(this, parentContext);
198         $initialize();
199     }
200 
201     public AbstractReplaceTemporaryUI(Frame param0, String param1) {
202         super(param0 ,param1);
203         $initialize();
204     }
205 
206     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Frame param1, String param2) {
207         super(param1 ,param2);
208         JAXXUtil.initContext(this, parentContext);
209         $initialize();
210     }
211 
212     public AbstractReplaceTemporaryUI(Window param0) {
213         super(param0);
214         $initialize();
215     }
216 
217     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Window param1) {
218         super(param1);
219         JAXXUtil.initContext(this, parentContext);
220         $initialize();
221     }
222 
223     public AbstractReplaceTemporaryUI(Window param0, ModalityType param1) {
224         super(param0 ,param1);
225         $initialize();
226     }
227 
228     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Window param1, ModalityType param2) {
229         super(param1 ,param2);
230         JAXXUtil.initContext(this, parentContext);
231         $initialize();
232     }
233 
234     public AbstractReplaceTemporaryUI(Window param0, String param1) {
235         super(param0 ,param1);
236         $initialize();
237     }
238 
239     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Window param1, String param2) {
240         super(param1 ,param2);
241         JAXXUtil.initContext(this, parentContext);
242         $initialize();
243     }
244 
245     public AbstractReplaceTemporaryUI(Window param0, String param1, ModalityType param2) {
246         super(param0 ,param1 ,param2);
247         $initialize();
248     }
249 
250     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3) {
251         super(param1 ,param2 ,param3);
252         JAXXUtil.initContext(this, parentContext);
253         $initialize();
254     }
255 
256     public AbstractReplaceTemporaryUI(Window param0, String param1, ModalityType param2, GraphicsConfiguration param3) {
257         super(param0 ,param1 ,param2 ,param3);
258         $initialize();
259     }
260 
261     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3, GraphicsConfiguration param4) {
262         super(param1 ,param2 ,param3 ,param4);
263         JAXXUtil.initContext(this, parentContext);
264         $initialize();
265     }
266 
267     public AbstractReplaceTemporaryUI(Dialog param0, boolean param1) {
268         super(param0 ,param1);
269         $initialize();
270     }
271 
272     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Dialog param1, boolean param2) {
273         super(param1 ,param2);
274         JAXXUtil.initContext(this, parentContext);
275         $initialize();
276     }
277 
278     public AbstractReplaceTemporaryUI(Dialog param0, String param1) {
279         super(param0 ,param1);
280         $initialize();
281     }
282 
283     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Dialog param1, String param2) {
284         super(param1 ,param2);
285         JAXXUtil.initContext(this, parentContext);
286         $initialize();
287     }
288 
289     public AbstractReplaceTemporaryUI(Dialog param0, String param1, boolean param2) {
290         super(param0 ,param1 ,param2);
291         $initialize();
292     }
293 
294     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3) {
295         super(param1 ,param2 ,param3);
296         JAXXUtil.initContext(this, parentContext);
297         $initialize();
298     }
299 
300     public AbstractReplaceTemporaryUI(Dialog param0, String param1, boolean param2, GraphicsConfiguration param3) {
301         super(param0 ,param1 ,param2 ,param3);
302         $initialize();
303     }
304 
305     public AbstractReplaceTemporaryUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3, GraphicsConfiguration param4) {
306         super(param1 ,param2 ,param3 ,param4);
307         JAXXUtil.initContext(this, parentContext);
308         $initialize();
309     }
310 
311     /*-----------------------------------------------------------------------*/
312     /*--------------------------- Statics methods ---------------------------*/
313     /*-----------------------------------------------------------------------*/
314 
315     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
316         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
317     }
318 
319     /*-----------------------------------------------------------------------*/
320     /*---------------------- JAXXObject implementation ----------------------*/
321     /*-----------------------------------------------------------------------*/
322 
323     @Override
324     public void applyDataBinding(String $binding) {
325         if (allComponentsCreated && $bindings.containsKey($binding)) {
326             getDataBinding($binding).applyDataBinding();
327         }
328         processDataBinding($binding);
329     }
330 
331     @Override
332     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
333         super.firePropertyChange(propertyName, oldValue, newValue);
334     }
335 
336     @Override
337     public Map<String, Object> get$objectMap() {
338         return $objectMap;
339     }
340 
341     @Override
342     public JAXXBinding getDataBinding(String bindingId) {
343         return $bindings.get(bindingId);
344     }
345 
346     @Override
347     public JAXXBinding[] getDataBindings() {
348         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
349     }
350 
351     @Override
352     public Object getObjectById(String id) {
353         return $objectMap.get(id);
354     }
355 
356     @Override
357     public void processDataBinding(String $binding, boolean $force) {
358         if (!$force && $activeBindings.contains($binding)) { 
359             return;
360         }
361         $activeBindings.add($binding);
362         try {
363             if (allComponentsCreated && $bindings.containsKey($binding)) {
364                 getDataBinding($binding).processDataBinding();
365             }
366         } finally {
367             $activeBindings.remove($binding);
368         }
369     }
370 
371     @Override
372     public void processDataBinding(String $binding) {
373         processDataBinding($binding, false);
374     }
375 
376     @Override
377     public void registerDataBinding(JAXXBinding binding) {
378         $bindings.put(binding.getId(), binding);
379     }
380 
381     @Override
382     public void removeDataBinding(String $binding) {
383         if (allComponentsCreated && $bindings.containsKey($binding)) {
384             getDataBinding($binding).removeDataBinding();
385         }
386     }
387 
388     /*-----------------------------------------------------------------------*/
389     /*--------------------- JAXXContext implementation  ---------------------*/
390     /*-----------------------------------------------------------------------*/
391 
392     @Override
393     public <T> T getContextValue(Class<T> clazz) {
394         return delegateContext.getContextValue(clazz, null);
395     }
396 
397     @Override
398     public <T> T getContextValue(Class<T> clazz, String name) {
399         return delegateContext.getContextValue(clazz, name);
400     }
401 
402     @Override
403     public JAXXContext getDelegateContext() {
404         return delegateContext;
405     }
406 
407     @Override
408     public <O extends Container> O getParentContainer(Class<O> clazz) {
409         return SwingUtil.getParentContainer(this, clazz);
410     }
411 
412     @Override
413     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
414         return SwingUtil.getParentContainer(source, clazz);
415     }
416 
417     @Override
418     public <T> void removeContextValue(Class<T> clazz) {
419         delegateContext.removeContextValue(clazz, null);
420     }
421 
422     @Override
423     public <T> void removeContextValue(Class<T> clazz, String name) {
424         delegateContext.removeContextValue(clazz, name);
425     }
426 
427     @Override
428     public <T> void setContextValue(T o) {
429         delegateContext.setContextValue(o, null);
430     }
431 
432     @Override
433     public <T> void setContextValue(T o, String name) {
434         delegateContext.setContextValue(o, name);
435     }
436 
437     /*-----------------------------------------------------------------------*/
438     /*-------------------- JAXXValidator implementation  --------------------*/
439     /*-----------------------------------------------------------------------*/
440 
441     @Override
442     public SwingValidator<?> getValidator(String validatorId) {
443         return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
444     }
445 
446     @Override
447     public List<String> getValidatorIds() {
448         return validatorIds;
449     }
450 
451     @Override
452     public void registerValidatorFields() {
453         SwingValidatorUtil.detectValidatorFields(this);
454     }
455 
456     /*-----------------------------------------------------------------------*/
457     /*---------------------------- Event methods ----------------------------*/
458     /*-----------------------------------------------------------------------*/
459 
460     public void doItemStateChanged__on__deleteCheckBox(ItemEvent event) {
461         if (log.isDebugEnabled()) {
462             log.debug(event);
463         }
464         model.setDelete(event.getStateChange() == ItemEvent.SELECTED);
465     }
466 
467     /*-----------------------------------------------------------------------*/
468     /*----------------------- Public acessor methods  -----------------------*/
469     /*-----------------------------------------------------------------------*/
470 
471     public JButton getCancelButton() {
472         return cancelButton;
473     }
474 
475     public JCheckBox getDeleteCheckBox() {
476         return deleteCheckBox;
477     }
478 
479     public AbstractReplaceTemporaryUIModel<E> getModel() {
480         return model;
481     }
482 
483     public JButton getReplaceButton() {
484         return replaceButton;
485     }
486 
487     public BeanFilterableComboBox<E> getSourceListComboBox() {
488         return sourceListComboBox;
489     }
490 
491     public JLabel getSourceListLabel() {
492         return sourceListLabel;
493     }
494 
495     public Table getTable() {
496         return table;
497     }
498 
499     public BeanFilterableComboBox<E> getTargetListComboBox() {
500         return targetListComboBox;
501     }
502 
503     public JLabel getTargetListLabel() {
504         return targetListLabel;
505     }
506 
507     public SwingValidator<AbstractReplaceTemporaryUIModel> getValidator() {
508         return validator;
509     }
510 
511     /*-----------------------------------------------------------------------*/
512     /*--------------------- Protected acessors methods  ---------------------*/
513     /*-----------------------------------------------------------------------*/
514 
515     protected JPanel get$JPanel0() {
516         return $JPanel0;
517     }
518 
519     protected JSeparator get$JSeparator0() {
520         return $JSeparator0;
521     }
522 
523     /*-----------------------------------------------------------------------*/
524     /*--------------------- Components creation methods ---------------------*/
525     /*-----------------------------------------------------------------------*/
526 
527     protected void addChildrenToReplaceTemporaryUITop() {
528         if (!allComponentsCreated) {
529             return;
530         }
531         add(table, BorderLayout.CENTER);
532     }
533 
534     protected void addChildrenToTable() {
535         if (!allComponentsCreated) {
536             return;
537         }
538         table.add(sourceListLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 17, 0, new Insets(3, 3, 3, 3), 0, 0));
539         table.add(SwingUtil.boxComponentWithJxLayer(sourceListComboBox), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
540         table.add(targetListLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 17, 0, new Insets(3, 3, 3, 3), 0, 0));
541         table.add(SwingUtil.boxComponentWithJxLayer(targetListComboBox), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
542         table.add(deleteCheckBox, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
543         table.add($JSeparator0, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
544         table.add($JPanel0, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0, 15, 1, new Insets(3, 3, 3, 3), 0, 0));
545     }
546 
547     protected void addChildrenToValidator() {
548         if (!allComponentsCreated) {
549             return;
550         }
551         validator.setUiClass(ImageValidationUI.class);
552         validator.setBean(model);
553     }
554 
555     protected void createCancelButton() {
556         $objectMap.put("cancelButton", cancelButton = new JButton());
557         
558         cancelButton.setName("cancelButton");
559         cancelButton.setText(t("tutti.replaceTemporaryReferential.action.cancel"));
560         cancelButton.setToolTipText(t("tutti.replaceTemporaryReferential.action.cancel.tip"));
561         cancelButton.putClientProperty("help", "tutti.replaceTemporaryReferential.action.cancel.help");
562         cancelButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.referential.replace.actions.CloseReplaceUIAction.class);
563     }
564 
565     protected void createDeleteCheckBox() {
566         $objectMap.put("deleteCheckBox", deleteCheckBox = new JCheckBox());
567         
568         deleteCheckBox.setName("deleteCheckBox");
569         deleteCheckBox.setText(t("tutti.replaceTemporaryReferential.field.delete"));
570         deleteCheckBox.setToolTipText(t("tutti.replaceTemporaryReferential.field.delete.tip"));
571         deleteCheckBox.addItemListener(JAXXUtil.getEventListener(ItemListener.class, "itemStateChanged", this, "doItemStateChanged__on__deleteCheckBox"));
572         deleteCheckBox.putClientProperty("help", "tutti.replaceTemporaryReferential.field.delete.help");
573     }
574 
575     protected void createModel() {
576         $objectMap.put("model", model = null);
577     }
578 
579     protected void createReplaceButton() {
580         $objectMap.put("replaceButton", replaceButton = new JButton());
581         
582         replaceButton.setName("replaceButton");
583         replaceButton.setText(t("tutti.replaceTemporaryReferential.action.replace"));
584         replaceButton.setToolTipText(t("tutti.replaceTemporaryReferential.action.replace.tip"));
585         replaceButton.putClientProperty("help", "tutti.replaceTemporaryPerson.action.replace.help");
586     }
587 
588     protected void createSourceListComboBox() {
589         $objectMap.put("sourceListComboBox", sourceListComboBox = new BeanFilterableComboBox<E>(this));
590         
591         sourceListComboBox.setName("sourceListComboBox");
592         sourceListComboBox.setProperty("selectedSource");
593         sourceListComboBox.setShowReset(true);
594         sourceListComboBox.putClientProperty("help", "tutti.replaceTemporaryReferential.field.sourceList.help");
595         sourceListComboBox.putClientProperty("validatorLabel", t("tutti.replaceTemporaryReferential.field.sourceList"));
596     }
597 
598     protected void createSourceListLabel() {
599         $objectMap.put("sourceListLabel", sourceListLabel = new JLabel());
600         
601         sourceListLabel.setName("sourceListLabel");
602         sourceListLabel.setText(t("tutti.replaceTemporaryReferential.field.sourceList"));
603         sourceListLabel.setToolTipText(t("tutti.replaceTemporaryReferential.field.sourceList.tip"));
604         sourceListLabel.putClientProperty("help", "tutti.replaceTemporaryReferential.field.sourceList.help");
605     }
606 
607     protected void createTable() {
608         $objectMap.put("table", table = new Table());
609         
610         table.setName("table");
611     }
612 
613     protected void createTargetListComboBox() {
614         $objectMap.put("targetListComboBox", targetListComboBox = new BeanFilterableComboBox<E>(this));
615         
616         targetListComboBox.setName("targetListComboBox");
617         targetListComboBox.setProperty("selectedTarget");
618         targetListComboBox.setShowReset(true);
619         targetListComboBox.putClientProperty("help", "tutti.replaceTemporaryReferential.field.targetList.help");
620         targetListComboBox.putClientProperty("validatorLabel", t("tutti.replaceTemporaryReferential.field.targetList"));
621     }
622 
623     protected void createTargetListLabel() {
624         $objectMap.put("targetListLabel", targetListLabel = new JLabel());
625         
626         targetListLabel.setName("targetListLabel");
627         targetListLabel.setText(t("tutti.replaceTemporaryReferential.field.targetList"));
628         targetListLabel.setToolTipText(t("tutti.replaceTemporaryReferential.field.targetList.tip"));
629         targetListLabel.putClientProperty("help", "tutti.replaceTemporaryReferential.field.targetList.help");
630     }
631 
632     protected void createValidator() {
633         $objectMap.put("validator", validator = SwingValidator.newValidator(AbstractReplaceTemporaryUIModel.class, null));
634     }
635 
636     /*-----------------------------------------------------------------------*/
637     /*------------------------ Internal jaxx methods ------------------------*/
638     /*-----------------------------------------------------------------------*/
639 
640     private void $completeSetup() {
641         allComponentsCreated = true;
642         if (log.isDebugEnabled()) {
643             log.debug(this);
644         }
645         addChildrenToReplaceTemporaryUITop();
646         addChildrenToValidator();
647         addChildrenToTable();
648         // inline complete setup of $JPanel0
649         $JPanel0.add(cancelButton);
650         $JPanel0.add(replaceButton);
651         
652         // apply 4 data bindings
653         JAXXUtil.applyDataBinding(this, $bindings.keySet());
654         
655         // apply 10 property setters
656         sourceListLabel.setLabelFor(sourceListComboBox);
657         sourceListComboBox.setBean(getModel());
658         targetListLabel.setLabelFor(targetListComboBox);
659         targetListComboBox.setBean(getModel());
660         cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.replaceTemporaryReferential.action.cancel.mnemonic"),'Z'));
661         cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
662         replaceButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.replaceTemporaryReferential.action.replace.mnemonic"),'Z'));
663         replaceButton.setIcon(SwingUtil.createActionIcon("replace"));
664         // late initializer
665         replaceTemporaryUITop.pack();
666         // register 1 validator(s)
667         validatorIds = SwingValidatorUtil.detectValidators(this);
668         SwingValidatorUtil.installUI(this);
669     }
670 
671     private void $initialize() {
672         if (allComponentsCreated) {
673             return;
674         }
675         if (log.isDebugEnabled()) {
676             log.debug(this);
677         }
678         $objectMap.put("replaceTemporaryUITop", replaceTemporaryUITop);
679         createModel();
680         createValidator();
681         createTable();
682         createSourceListLabel();
683         createSourceListComboBox();
684         createTargetListLabel();
685         createTargetListComboBox();
686         createDeleteCheckBox();
687         // inline creation of $JSeparator0
688         $objectMap.put("$JSeparator0", $JSeparator0 = new JSeparator());
689         
690         $JSeparator0.setName("$JSeparator0");
691         // inline creation of $JPanel0
692         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
693         
694         $JPanel0.setName("$JPanel0");
695         $JPanel0.setLayout(new GridLayout(1, 0));
696         createCancelButton();
697         createReplaceButton();
698         // inline creation of replaceTemporaryUITop
699         setName("replaceTemporaryUITop");
700         replaceTemporaryUITop.getContentPane().setLayout(new BorderLayout());
701         setModal(true);
702         
703         // registers 4 data bindings
704         $registerDefaultBindings();
705         $completeSetup();
706     }
707 
708     private void $registerDefaultBindings() {
709         // register 4 data bindings
710         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SOURCE_LIST_COMBO_BOX_SELECTED_ITEM, true) {
711         
712             @Override
713             public void applyDataBinding() {
714                 if (model != null) {
715                     model.addPropertyChangeListener("selectedSource", this);
716                 }
717             }
718         
719             @Override
720             public void processDataBinding() {
721                 if (model != null) {
722                     sourceListComboBox.setSelectedItem(model.getSelectedSource());
723                 }
724             }
725         
726             @Override
727             public void removeDataBinding() {
728                 if (model != null) {
729                     model.removePropertyChangeListener("selectedSource", this);
730                 }
731             }
732         });
733         registerDataBinding(new DefaultJAXXBinding(this, BINDING_TARGET_LIST_COMBO_BOX_SELECTED_ITEM, true) {
734         
735             @Override
736             public void applyDataBinding() {
737                 if (model != null) {
738                     model.addPropertyChangeListener("selectedTarget", this);
739                 }
740             }
741         
742             @Override
743             public void processDataBinding() {
744                 if (model != null) {
745                     targetListComboBox.setSelectedItem(model.getSelectedTarget());
746                 }
747             }
748         
749             @Override
750             public void removeDataBinding() {
751                 if (model != null) {
752                     model.removePropertyChangeListener("selectedTarget", this);
753                 }
754             }
755         });
756         registerDataBinding(new DefaultJAXXBinding(this, BINDING_DELETE_CHECK_BOX_SELECTED, true) {
757         
758             @Override
759             public void applyDataBinding() {
760                 if (model != null) {
761                     model.addPropertyChangeListener("delete", this);
762                 }
763             }
764         
765             @Override
766             public void processDataBinding() {
767                 if (model != null) {
768                     deleteCheckBox.setSelected(model.isDelete());
769                 }
770             }
771         
772             @Override
773             public void removeDataBinding() {
774                 if (model != null) {
775                     model.removePropertyChangeListener("delete", this);
776                 }
777             }
778         });
779         registerDataBinding(new DefaultJAXXBinding(this, BINDING_REPLACE_BUTTON_ENABLED, true) {
780         
781             @Override
782             public void applyDataBinding() {
783                 if (model != null) {
784                     model.addPropertyChangeListener("valid", this);
785                 }
786             }
787         
788             @Override
789             public void processDataBinding() {
790                 if (model != null) {
791                     replaceButton.setEnabled(model.isValid());
792                 }
793             }
794         
795             @Override
796             public void removeDataBinding() {
797                 if (model != null) {
798                     model.removePropertyChangeListener("valid", this);
799                 }
800             }
801         });
802     }
803 
804 }