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