View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.observation.operation.measurement.grouped.initGrid;
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.ExtendedComboBox;
30  import fr.ifremer.quadrige3.ui.swing.component.number.NumberEditor;
31  import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
32  import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
33  import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
34  import java.awt.BorderLayout;
35  import java.awt.Component;
36  import java.awt.Container;
37  import java.awt.Dialog;
38  import java.awt.Dialog.ModalityType;
39  import java.awt.FlowLayout;
40  import java.awt.Frame;
41  import java.awt.GraphicsConfiguration;
42  import java.awt.GridBagConstraints;
43  import java.awt.GridLayout;
44  import java.awt.Insets;
45  import java.awt.Window;
46  import java.awt.event.ActionEvent;
47  import java.awt.event.ActionListener;
48  import java.awt.event.ItemEvent;
49  import java.awt.event.ItemListener;
50  import java.util.ArrayList;
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.JButton;
57  import javax.swing.JCheckBox;
58  import javax.swing.JDialog;
59  import javax.swing.JLabel;
60  import javax.swing.JPanel;
61  import javax.swing.SwingConstants;
62  import jaxx.runtime.JAXXBinding;
63  import jaxx.runtime.JAXXContext;
64  import jaxx.runtime.JAXXObject;
65  import jaxx.runtime.JAXXObjectDescriptor;
66  import jaxx.runtime.JAXXUtil;
67  import jaxx.runtime.JAXXValidator;
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.validator.swing.SwingValidator;
73  import jaxx.runtime.validator.swing.SwingValidatorUtil;
74  import jaxx.runtime.validator.swing.meta.Validator;
75  import jaxx.runtime.validator.swing.meta.ValidatorField;
76  import jaxx.runtime.validator.swing.ui.ImageValidationUI;
77  import org.apache.commons.logging.Log;
78  import org.apache.commons.logging.LogFactory;
79  import static org.nuiton.i18n.I18n.t;
80  
81  public class InitGridUI extends JDialog implements ReefDbUI<InitGridUIModel, InitGridUIHandler>, JAXXObject, JAXXValidator {
82  
83      /*-----------------------------------------------------------------------*/
84      /*------------------ Constants for all public bindings ------------------*/
85      /*-----------------------------------------------------------------------*/
86  
87      public static final String BINDING_ALL_SAMPLING_OPERATION_CHECK_BOX_SELECTED = "allSamplingOperationCheckBox.selected";
88      public static final String BINDING_CONTIGUOUS_SAMPLING_OPERATION_CHECK_BOX_ENABLED = "contiguousSamplingOperationCheckBox.enabled";
89      public static final String BINDING_CONTIGUOUS_SAMPLING_OPERATION_CHECK_BOX_SELECTED = "contiguousSamplingOperationCheckBox.selected";
90      public static final String BINDING_LENGTH_FIELD_NUMBER_VALUE = "lengthField.numberValue";
91      public static final String BINDING_ORIGIN_FIELD_NUMBER_VALUE = "originField.numberValue";
92      public static final String BINDING_SAMPLING_OPERATION_COMBO_BOX_ENABLED = "samplingOperationComboBox.enabled";
93      public static final String BINDING_SAMPLING_OPERATION_COMBO_BOX_SELECTED_ITEM = "samplingOperationComboBox.selectedItem";
94      public static final String BINDING_TRANSITION_FIELD_NUMBER_VALUE = "transitionField.numberValue";
95      public static final String BINDING_VALID_BUTTON_ENABLED = "validButton.enabled";
96  
97      /*-----------------------------------------------------------------------*/
98      /*------------------------- Other static fields -------------------------*/
99      /*-----------------------------------------------------------------------*/
100 
101     private static final String $jaxxObjectDescriptor = "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";
102     private static final Log log = LogFactory.getLog(InitGridUI.class);
103     private static final long serialVersionUID = 1L;
104 
105     /*-----------------------------------------------------------------------*/
106     /*--------------------------- Internal states ---------------------------*/
107     /*-----------------------------------------------------------------------*/
108 
109     protected List<Object> $activeBindings = new ArrayList<Object>();
110     protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
111     protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
112     protected Map<String, Object> $objectMap = new HashMap<String, Object>();
113     protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
114     private boolean allComponentsCreated;
115     protected final JAXXContext delegateContext = new DefaultJAXXContext();
116 
117     /*-----------------------------------------------------------------------*/
118     /*------------------------ Protected components  ------------------------*/
119     /*-----------------------------------------------------------------------*/
120 
121     protected JCheckBox allSamplingOperationCheckBox;
122     protected JButton cancelButton;
123     protected JCheckBox contiguousSamplingOperationCheckBox;
124     protected final InitGridUIHandler handler = createHandler();
125     protected InitGridUI initGridUI = this;
126     @ValidatorField( validatorId = "validator",  propertyName = "length",  editorName = "lengthField")
127     protected NumberEditor lengthField;
128     protected JLabel lengthLabel;
129     protected JLabel lengthUnit;
130     protected InitGridUIModel model;
131     @ValidatorField( validatorId = "validator",  propertyName = "origin",  editorName = "originField")
132     protected NumberEditor originField;
133     protected JLabel originLabel;
134     protected JLabel originUnit;
135     @ValidatorField( validatorId = "validator",  propertyName = "samplingOperation",  editorName = "samplingOperationComboBox")
136     protected ExtendedComboBox<SamplingOperationDTO> samplingOperationComboBox;
137     protected JLabel samplingOperationLabel;
138     @ValidatorField( validatorId = "validator",  propertyName = "transition",  editorName = "transitionField")
139     protected NumberEditor transitionField;
140     protected JLabel transitionLabel;
141     protected JLabel transitionUnit;
142     protected JButton validButton;
143     @Validator( validatorId = "validator")
144     protected SwingValidator<InitGridUIModel> validator;
145     protected List<String> validatorIds = new ArrayList<String>();
146 
147     /*-----------------------------------------------------------------------*/
148     /*------------------------- Private components  -------------------------*/
149     /*-----------------------------------------------------------------------*/
150 
151     private JLabel $JLabel0;
152     private JLabel $JLabel1;
153     private JPanel $JPanel0;
154     private Table $Table0;
155 
156     /*-----------------------------------------------------------------------*/
157     /*---------------------------- Constructors  ----------------------------*/
158     /*-----------------------------------------------------------------------*/
159 
160     public InitGridUI(ApplicationUI parentUI) {
161         ApplicationUIUtil.setParentUI(this, parentUI);
162             $initialize();
163     }
164 
165     public InitGridUI(Frame param0, String param1, boolean param2) {
166         super(param0 ,param1 ,param2);
167         $initialize();
168     }
169 
170     public InitGridUI(JAXXContext parentContext, Frame param1, String param2, boolean param3) {
171         super(param1 ,param2 ,param3);
172         JAXXUtil.initContext(this, parentContext);
173         $initialize();
174     }
175 
176     public InitGridUI(Frame param0, String param1) {
177         super(param0 ,param1);
178         $initialize();
179     }
180 
181     public InitGridUI(JAXXContext parentContext, Frame param1, String param2) {
182         super(param1 ,param2);
183         JAXXUtil.initContext(this, parentContext);
184         $initialize();
185     }
186 
187     public InitGridUI(Frame param0, String param1, boolean param2, GraphicsConfiguration param3) {
188         super(param0 ,param1 ,param2 ,param3);
189         $initialize();
190     }
191 
192     public InitGridUI(JAXXContext parentContext, Frame param1, String param2, boolean param3, GraphicsConfiguration param4) {
193         super(param1 ,param2 ,param3 ,param4);
194         JAXXUtil.initContext(this, parentContext);
195         $initialize();
196     }
197 
198     public InitGridUI(Dialog param0) {
199         super(param0);
200         $initialize();
201     }
202 
203     public InitGridUI(JAXXContext parentContext, Dialog param1) {
204         super(param1);
205         JAXXUtil.initContext(this, parentContext);
206         $initialize();
207     }
208 
209     public InitGridUI(Frame param0, boolean param1) {
210         super(param0 ,param1);
211         $initialize();
212     }
213 
214     public InitGridUI(JAXXContext parentContext, Frame param1, boolean param2) {
215         super(param1 ,param2);
216         JAXXUtil.initContext(this, parentContext);
217         $initialize();
218     }
219 
220     public InitGridUI() {
221         $initialize();
222     }
223 
224     public InitGridUI(JAXXContext parentContext) {
225         JAXXUtil.initContext(this, parentContext);
226         $initialize();
227     }
228 
229     public InitGridUI(Frame param0) {
230         super(param0);
231         $initialize();
232     }
233 
234     public InitGridUI(JAXXContext parentContext, Frame param1) {
235         super(param1);
236         JAXXUtil.initContext(this, parentContext);
237         $initialize();
238     }
239 
240     public InitGridUI(Dialog param0, String param1, boolean param2, GraphicsConfiguration param3) {
241         super(param0 ,param1 ,param2 ,param3);
242         $initialize();
243     }
244 
245     public InitGridUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3, GraphicsConfiguration param4) {
246         super(param1 ,param2 ,param3 ,param4);
247         JAXXUtil.initContext(this, parentContext);
248         $initialize();
249     }
250 
251     public InitGridUI(Window param0) {
252         super(param0);
253         $initialize();
254     }
255 
256     public InitGridUI(JAXXContext parentContext, Window param1) {
257         super(param1);
258         JAXXUtil.initContext(this, parentContext);
259         $initialize();
260     }
261 
262     public InitGridUI(Window param0, ModalityType param1) {
263         super(param0 ,param1);
264         $initialize();
265     }
266 
267     public InitGridUI(JAXXContext parentContext, Window param1, ModalityType param2) {
268         super(param1 ,param2);
269         JAXXUtil.initContext(this, parentContext);
270         $initialize();
271     }
272 
273     public InitGridUI(Window param0, String param1) {
274         super(param0 ,param1);
275         $initialize();
276     }
277 
278     public InitGridUI(JAXXContext parentContext, Window param1, String param2) {
279         super(param1 ,param2);
280         JAXXUtil.initContext(this, parentContext);
281         $initialize();
282     }
283 
284     public InitGridUI(Window param0, String param1, ModalityType param2) {
285         super(param0 ,param1 ,param2);
286         $initialize();
287     }
288 
289     public InitGridUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3) {
290         super(param1 ,param2 ,param3);
291         JAXXUtil.initContext(this, parentContext);
292         $initialize();
293     }
294 
295     public InitGridUI(Window param0, String param1, ModalityType param2, GraphicsConfiguration param3) {
296         super(param0 ,param1 ,param2 ,param3);
297         $initialize();
298     }
299 
300     public InitGridUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3, GraphicsConfiguration param4) {
301         super(param1 ,param2 ,param3 ,param4);
302         JAXXUtil.initContext(this, parentContext);
303         $initialize();
304     }
305 
306     public InitGridUI(Dialog param0, boolean param1) {
307         super(param0 ,param1);
308         $initialize();
309     }
310 
311     public InitGridUI(JAXXContext parentContext, Dialog param1, boolean param2) {
312         super(param1 ,param2);
313         JAXXUtil.initContext(this, parentContext);
314         $initialize();
315     }
316 
317     public InitGridUI(Dialog param0, String param1) {
318         super(param0 ,param1);
319         $initialize();
320     }
321 
322     public InitGridUI(JAXXContext parentContext, Dialog param1, String param2) {
323         super(param1 ,param2);
324         JAXXUtil.initContext(this, parentContext);
325         $initialize();
326     }
327 
328     public InitGridUI(Dialog param0, String param1, boolean param2) {
329         super(param0 ,param1 ,param2);
330         $initialize();
331     }
332 
333     public InitGridUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3) {
334         super(param1 ,param2 ,param3);
335         JAXXUtil.initContext(this, parentContext);
336         $initialize();
337     }
338 
339     /*-----------------------------------------------------------------------*/
340     /*--------------------------- Statics methods ---------------------------*/
341     /*-----------------------------------------------------------------------*/
342 
343     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
344         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
345     }
346 
347     /*-----------------------------------------------------------------------*/
348     /*---------------------- JAXXObject implementation ----------------------*/
349     /*-----------------------------------------------------------------------*/
350 
351     @Override
352     public void applyDataBinding(String $binding) {
353         if (allComponentsCreated && $bindings.containsKey($binding)) {
354             getDataBinding($binding).applyDataBinding();
355         }
356         processDataBinding($binding);
357     }
358 
359     @Override
360     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
361         super.firePropertyChange(propertyName, oldValue, newValue);
362     }
363 
364     @Override
365     public Map<String, Object> get$objectMap() {
366         return $objectMap;
367     }
368 
369     @Override
370     public JAXXBinding getDataBinding(String bindingId) {
371         return $bindings.get(bindingId);
372     }
373 
374     @Override
375     public JAXXBinding[] getDataBindings() {
376         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
377     }
378 
379     @Override
380     public Object getObjectById(String id) {
381         return $objectMap.get(id);
382     }
383 
384     @Override
385     public void processDataBinding(String $binding, boolean $force) {
386         if (!$force && $activeBindings.contains($binding)) { 
387             return;
388         }
389         $activeBindings.add($binding);
390         try {
391             if (allComponentsCreated && $bindings.containsKey($binding)) {
392                 getDataBinding($binding).processDataBinding();
393             }
394         } finally {
395             $activeBindings.remove($binding);
396         }
397     }
398 
399     @Override
400     public void processDataBinding(String $binding) {
401         processDataBinding($binding, false);
402     }
403 
404     @Override
405     public void registerDataBinding(JAXXBinding binding) {
406         $bindings.put(binding.getId(), binding);
407     }
408 
409     @Override
410     public void removeDataBinding(String $binding) {
411         if (allComponentsCreated && $bindings.containsKey($binding)) {
412             getDataBinding($binding).removeDataBinding();
413         }
414     }
415 
416     /*-----------------------------------------------------------------------*/
417     /*--------------------- JAXXContext implementation  ---------------------*/
418     /*-----------------------------------------------------------------------*/
419 
420     @Override
421     public <T> T getContextValue(Class<T> clazz) {
422         return delegateContext.getContextValue(clazz, null);
423     }
424 
425     @Override
426     public <T> T getContextValue(Class<T> clazz, String name) {
427         return delegateContext.getContextValue(clazz, name);
428     }
429 
430     @Override
431     public JAXXContext getDelegateContext() {
432         return delegateContext;
433     }
434 
435     @Override
436     public <O extends Container> O getParentContainer(Class<O> clazz) {
437         return SwingUtil.getParentContainer(this, clazz);
438     }
439 
440     @Override
441     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
442         return SwingUtil.getParentContainer(source, clazz);
443     }
444 
445     @Override
446     public <T> void removeContextValue(Class<T> clazz) {
447         delegateContext.removeContextValue(clazz, null);
448     }
449 
450     @Override
451     public <T> void removeContextValue(Class<T> clazz, String name) {
452         delegateContext.removeContextValue(clazz, name);
453     }
454 
455     @Override
456     public <T> void setContextValue(T o) {
457         delegateContext.setContextValue(o, null);
458     }
459 
460     @Override
461     public <T> void setContextValue(T o, String name) {
462         delegateContext.setContextValue(o, name);
463     }
464 
465     /*-----------------------------------------------------------------------*/
466     /*-------------------- JAXXValidator implementation  --------------------*/
467     /*-----------------------------------------------------------------------*/
468 
469     @Override
470     public SwingValidator<?> getValidator(String validatorId) {
471         return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
472     }
473 
474     @Override
475     public List<String> getValidatorIds() {
476         return validatorIds;
477     }
478 
479     @Override
480     public void registerValidatorFields() {
481         SwingValidatorUtil.detectValidatorFields(this);
482     }
483 
484     /*-----------------------------------------------------------------------*/
485     /*---------------------------- Event methods ----------------------------*/
486     /*-----------------------------------------------------------------------*/
487 
488     public void doActionPerformed__on__cancelButton(ActionEvent event) {
489         if (log.isDebugEnabled()) {
490             log.debug(event);
491         }
492         handler.cancel();
493     }
494 
495     public void doActionPerformed__on__validButton(ActionEvent event) {
496         if (log.isDebugEnabled()) {
497             log.debug(event);
498         }
499         handler.valid();
500     }
501 
502     public void doItemStateChanged__on__allSamplingOperationCheckBox(ItemEvent event) {
503         if (log.isDebugEnabled()) {
504             log.debug(event);
505         }
506         handler.setBoolean(event, InitGridUIModel.PROPERTY_ALL_SAMPLING_OPERATIONS);
507     }
508 
509     public void doItemStateChanged__on__contiguousSamplingOperationCheckBox(ItemEvent event) {
510         if (log.isDebugEnabled()) {
511             log.debug(event);
512         }
513         handler.setBoolean(event, InitGridUIModel.PROPERTY_CONTIGUOUS_SAMPLING_OPERATIONS);
514     }
515 
516     /*-----------------------------------------------------------------------*/
517     /*----------------------- Public acessor methods  -----------------------*/
518     /*-----------------------------------------------------------------------*/
519 
520     public JCheckBox getAllSamplingOperationCheckBox() {
521         return allSamplingOperationCheckBox;
522     }
523 
524     public JButton getCancelButton() {
525         return cancelButton;
526     }
527 
528     public JCheckBox getContiguousSamplingOperationCheckBox() {
529         return contiguousSamplingOperationCheckBox;
530     }
531 
532     public InitGridUIHandler getHandler() {
533         return handler;
534     }
535 
536     public NumberEditor getLengthField() {
537         return lengthField;
538     }
539 
540     public JLabel getLengthLabel() {
541         return lengthLabel;
542     }
543 
544     public JLabel getLengthUnit() {
545         return lengthUnit;
546     }
547 
548     public InitGridUIModel getModel() {
549         return model;
550     }
551 
552     public NumberEditor getOriginField() {
553         return originField;
554     }
555 
556     public JLabel getOriginLabel() {
557         return originLabel;
558     }
559 
560     public JLabel getOriginUnit() {
561         return originUnit;
562     }
563 
564     public ExtendedComboBox<SamplingOperationDTO> getSamplingOperationComboBox() {
565         return samplingOperationComboBox;
566     }
567 
568     public JLabel getSamplingOperationLabel() {
569         return samplingOperationLabel;
570     }
571 
572     public NumberEditor getTransitionField() {
573         return transitionField;
574     }
575 
576     public JLabel getTransitionLabel() {
577         return transitionLabel;
578     }
579 
580     public JLabel getTransitionUnit() {
581         return transitionUnit;
582     }
583 
584     public JButton getValidButton() {
585         return validButton;
586     }
587 
588     public SwingValidator<InitGridUIModel> getValidator() {
589         return validator;
590     }
591 
592     /*-----------------------------------------------------------------------*/
593     /*--------------------- Protected acessors methods  ---------------------*/
594     /*-----------------------------------------------------------------------*/
595 
596     protected JLabel get$JLabel0() {
597         return $JLabel0;
598     }
599 
600     protected JLabel get$JLabel1() {
601         return $JLabel1;
602     }
603 
604     protected JPanel get$JPanel0() {
605         return $JPanel0;
606     }
607 
608     protected Table get$Table0() {
609         return $Table0;
610     }
611 
612     /*-----------------------------------------------------------------------*/
613     /*--------------------- Components creation methods ---------------------*/
614     /*-----------------------------------------------------------------------*/
615 
616     protected void addChildrenToInitGridUI() {
617         if (!allComponentsCreated) {
618             return;
619         }
620         add($Table0);
621         add($JPanel0, BorderLayout.PAGE_END);
622     }
623 
624     protected void addChildrenToValidator() {
625         if (!allComponentsCreated) {
626             return;
627         }
628         validator.setUiClass(ImageValidationUI.class);
629         validator.setBean(model);
630     }
631 
632     protected void createAllSamplingOperationCheckBox() {
633         $objectMap.put("allSamplingOperationCheckBox", allSamplingOperationCheckBox = new JCheckBox());
634         
635         allSamplingOperationCheckBox.setName("allSamplingOperationCheckBox");
636         allSamplingOperationCheckBox.setText(t("reefdb.samplingOperation.measurement.grouped.init.allSamplingOperations"));
637         allSamplingOperationCheckBox.addItemListener(JAXXUtil.getEventListener(ItemListener.class, "itemStateChanged", this, "doItemStateChanged__on__allSamplingOperationCheckBox"));
638     }
639 
640     protected void createCancelButton() {
641         $objectMap.put("cancelButton", cancelButton = new JButton());
642         
643         cancelButton.setName("cancelButton");
644         cancelButton.setText(t("reefdb.common.cancel"));
645         cancelButton.setToolTipText(t("reefdb.common.cancel"));
646         cancelButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__cancelButton"));
647     }
648 
649     protected void createContiguousSamplingOperationCheckBox() {
650         $objectMap.put("contiguousSamplingOperationCheckBox", contiguousSamplingOperationCheckBox = new JCheckBox());
651         
652         contiguousSamplingOperationCheckBox.setName("contiguousSamplingOperationCheckBox");
653         contiguousSamplingOperationCheckBox.setText(t("reefdb.samplingOperation.measurement.grouped.init.contiguousSamplingOperations"));
654         contiguousSamplingOperationCheckBox.addItemListener(JAXXUtil.getEventListener(ItemListener.class, "itemStateChanged", this, "doItemStateChanged__on__contiguousSamplingOperationCheckBox"));
655     }
656 
657     protected InitGridUIHandler createHandler() {
658         return new InitGridUIHandler();
659     }
660 
661     protected void createLengthField() {
662         $objectMap.put("lengthField", lengthField = new NumberEditor(this));
663         
664         lengthField.setName("lengthField");
665         lengthField.setProperty("length");
666         lengthField.setShowReset(false);
667         lengthField.putClientProperty("selectOnFocus", true);
668     }
669 
670     protected void createLengthLabel() {
671         $objectMap.put("lengthLabel", lengthLabel = new JLabel());
672         
673         lengthLabel.setName("lengthLabel");
674         lengthLabel.setText(t("reefdb.samplingOperation.measurement.grouped.init.length"));
675     }
676 
677     protected void createLengthUnit() {
678         $objectMap.put("lengthUnit", lengthUnit = new JLabel());
679         
680         lengthUnit.setName("lengthUnit");
681     }
682 
683     protected void createModel() {
684         $objectMap.put("model", model = getContextValue(InitGridUIModel.class));
685     }
686 
687     protected void createOriginField() {
688         $objectMap.put("originField", originField = new NumberEditor(this));
689         
690         originField.setName("originField");
691         originField.setProperty("origin");
692         originField.setShowReset(false);
693         originField.putClientProperty("selectOnFocus", true);
694     }
695 
696     protected void createOriginLabel() {
697         $objectMap.put("originLabel", originLabel = new JLabel());
698         
699         originLabel.setName("originLabel");
700         originLabel.setText(t("reefdb.samplingOperation.measurement.grouped.init.origin"));
701     }
702 
703     protected void createOriginUnit() {
704         $objectMap.put("originUnit", originUnit = new JLabel());
705         
706         originUnit.setName("originUnit");
707     }
708 
709     protected void createSamplingOperationComboBox() {
710         $objectMap.put("samplingOperationComboBox", samplingOperationComboBox = new ExtendedComboBox<SamplingOperationDTO>(this));
711         
712         samplingOperationComboBox.setName("samplingOperationComboBox");
713         samplingOperationComboBox.setFilterable(true);
714         samplingOperationComboBox.setShowDecorator(false);
715         samplingOperationComboBox.setProperty("samplingOperation");
716         samplingOperationComboBox.setShowReset(false);
717     }
718 
719     protected void createSamplingOperationLabel() {
720         $objectMap.put("samplingOperationLabel", samplingOperationLabel = new JLabel());
721         
722         samplingOperationLabel.setName("samplingOperationLabel");
723         samplingOperationLabel.setText(t("reefdb.property.samplingOperation"));
724     }
725 
726     protected void createTransitionField() {
727         $objectMap.put("transitionField", transitionField = new NumberEditor(this));
728         
729         transitionField.setName("transitionField");
730         transitionField.setProperty("transition");
731         transitionField.setShowReset(false);
732         transitionField.putClientProperty("selectOnFocus", true);
733     }
734 
735     protected void createTransitionLabel() {
736         $objectMap.put("transitionLabel", transitionLabel = new JLabel());
737         
738         transitionLabel.setName("transitionLabel");
739         transitionLabel.setText(t("reefdb.samplingOperation.measurement.grouped.init.transition"));
740     }
741 
742     protected void createTransitionUnit() {
743         $objectMap.put("transitionUnit", transitionUnit = new JLabel());
744         
745         transitionUnit.setName("transitionUnit");
746     }
747 
748     protected void createValidButton() {
749         $objectMap.put("validButton", validButton = new JButton());
750         
751         validButton.setName("validButton");
752         validButton.setText(t("reefdb.common.validate"));
753         validButton.setToolTipText(t("reefdb.common.validate"));
754         validButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__validButton"));
755     }
756 
757     protected void createValidator() {
758         $objectMap.put("validator", validator = SwingValidator.newValidator(InitGridUIModel.class, null));
759     }
760 
761     /*-----------------------------------------------------------------------*/
762     /*------------------------ Internal jaxx methods ------------------------*/
763     /*-----------------------------------------------------------------------*/
764 
765     private void $completeSetup() {
766         allComponentsCreated = true;
767         if (log.isDebugEnabled()) {
768             log.debug(this);
769         }
770         addChildrenToInitGridUI();
771         addChildrenToValidator();
772         // inline complete setup of $Table0
773         $Table0.add($JLabel0, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
774         $Table0.add(allSamplingOperationCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
775         $Table0.add(contiguousSamplingOperationCheckBox, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
776         $Table0.add($JLabel1, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
777         $Table0.add(samplingOperationLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
778         $Table0.add(SwingUtil.boxComponentWithJxLayer(samplingOperationComboBox), new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
779         $Table0.add(originLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
780         $Table0.add(SwingUtil.boxComponentWithJxLayer(originField), new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
781         $Table0.add(originUnit, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
782         $Table0.add(transitionLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
783         $Table0.add(SwingUtil.boxComponentWithJxLayer(transitionField), new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
784         $Table0.add(transitionUnit, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
785         $Table0.add(lengthLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
786         $Table0.add(SwingUtil.boxComponentWithJxLayer(lengthField), new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
787         $Table0.add(lengthUnit, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
788         // inline complete setup of $JPanel0
789         $JPanel0.add(cancelButton);
790         $JPanel0.add(validButton);
791         
792         // apply 9 data bindings
793         JAXXUtil.applyDataBinding(this, $bindings.keySet());
794         
795         // apply 32 property setters
796         $Table0.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
797         samplingOperationComboBox.setBeanType(SamplingOperationDTO.class);
798         allSamplingOperationCheckBox.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
799         allSamplingOperationCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
800         contiguousSamplingOperationCheckBox.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
801         contiguousSamplingOperationCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
802         samplingOperationLabel.setLabelFor(samplingOperationComboBox);
803         samplingOperationComboBox.setBean(model);
804         originLabel.setLabelFor(originField);
805         originField.setAutoPopup(handler.getConfig().isAutoPopupNumberEditor());
806         originField.setNumberType(Integer.class);
807         originField.setNumberPattern(INT_7_DIGITS_PATTERN);
808         originField.setShowPopupButton(handler.getConfig().isShowNumberEditorButton());
809         originField.setBean(model);
810         transitionLabel.setLabelFor(transitionField);
811         transitionField.setAutoPopup(handler.getConfig().isAutoPopupNumberEditor());
812         transitionField.setNumberType(Integer.class);
813         transitionField.setNumberPattern(INT_7_DIGITS_PATTERN);
814         transitionField.setShowPopupButton(handler.getConfig().isShowNumberEditorButton());
815         transitionField.setBean(model);
816         lengthLabel.setLabelFor(lengthField);
817         lengthField.setAutoPopup(handler.getConfig().isAutoPopupNumberEditor());
818         lengthField.setNumberType(Integer.class);
819         lengthField.setNumberPattern(INT_7_DIGITS_PATTERN);
820         lengthField.setShowPopupButton(handler.getConfig().isShowNumberEditorButton());
821         lengthField.setBean(model);
822         cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("reefdb.common.cancel.mnemonic"),'Z'));
823         cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
824         validButton.setMnemonic(SwingUtil.getFirstCharAt(t("reefdb.common.validate.mnemonic"),'Z'));
825         validButton.setIcon(SwingUtil.createActionIcon("accept"));
826         // late initializer
827         initGridUI.pack();
828         // register 1 validator(s)
829         validatorIds = SwingValidatorUtil.detectValidators(this);
830         SwingValidatorUtil.installUI(this);
831     }
832 
833     private void $initialize() {
834         if (allComponentsCreated) {
835             return;
836         }
837         if (log.isDebugEnabled()) {
838             log.debug(this);
839         }
840         handler.beforeInit(this);
841         $objectMap.put("initGridUI", initGridUI);
842         createModel();
843         createValidator();
844         // inline creation of $Table0
845         $objectMap.put("$Table0", $Table0 = new Table());
846         
847         $Table0.setName("$Table0");
848         // inline creation of $JLabel0
849         $objectMap.put("$JLabel0", $JLabel0 = new JLabel());
850         
851         $JLabel0.setName("$JLabel0");
852         createAllSamplingOperationCheckBox();
853         createContiguousSamplingOperationCheckBox();
854         // inline creation of $JLabel1
855         $objectMap.put("$JLabel1", $JLabel1 = new JLabel());
856         
857         $JLabel1.setName("$JLabel1");
858         createSamplingOperationLabel();
859         createSamplingOperationComboBox();
860         createOriginLabel();
861         createOriginField();
862         createOriginUnit();
863         createTransitionLabel();
864         createTransitionField();
865         createTransitionUnit();
866         createLengthLabel();
867         createLengthField();
868         createLengthUnit();
869         // inline creation of $JPanel0
870         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
871         
872         $JPanel0.setName("$JPanel0");
873         $JPanel0.setLayout(new GridLayout(1,0));
874         createCancelButton();
875         createValidButton();
876         // inline creation of initGridUI
877         setName("initGridUI");
878         initGridUI.getContentPane().setLayout(new BorderLayout());
879         setResizable(false);
880         setTitle(t("reefdb.samplingOperation.measurement.grouped.init.title"));
881         setModal(true);
882         
883         // registers 9 data bindings
884         $registerDefaultBindings();
885         $completeSetup();
886         handler.afterInit(this);
887     }
888 
889     private void $registerDefaultBindings() {
890         // register 9 data bindings
891         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ALL_SAMPLING_OPERATION_CHECK_BOX_SELECTED, true) {
892         
893             @Override
894             public void applyDataBinding() {
895                 if (model != null) {
896                     model.addPropertyChangeListener("allSamplingOperations", this);
897                 }
898             }
899         
900             @Override
901             public void processDataBinding() {
902                 if (model != null) {
903                     allSamplingOperationCheckBox.setSelected(model.isAllSamplingOperations());
904                 }
905             }
906         
907             @Override
908             public void removeDataBinding() {
909                 if (model != null) {
910                     model.removePropertyChangeListener("allSamplingOperations", this);
911                 }
912             }
913         });
914         registerDataBinding(new DefaultJAXXBinding(this, BINDING_CONTIGUOUS_SAMPLING_OPERATION_CHECK_BOX_SELECTED, true) {
915         
916             @Override
917             public void applyDataBinding() {
918                 if (model != null) {
919                     model.addPropertyChangeListener("contiguousSamplingOperations", this);
920                 }
921             }
922         
923             @Override
924             public void processDataBinding() {
925                 if (model != null) {
926                     contiguousSamplingOperationCheckBox.setSelected(model.isContiguousSamplingOperations());
927                 }
928             }
929         
930             @Override
931             public void removeDataBinding() {
932                 if (model != null) {
933                     model.removePropertyChangeListener("contiguousSamplingOperations", this);
934                 }
935             }
936         });
937         registerDataBinding(new DefaultJAXXBinding(this, BINDING_CONTIGUOUS_SAMPLING_OPERATION_CHECK_BOX_ENABLED, true) {
938         
939             @Override
940             public void applyDataBinding() {
941                 if (model != null) {
942                     model.addPropertyChangeListener("allSamplingOperations", this);
943                 }
944             }
945         
946             @Override
947             public void processDataBinding() {
948                 if (model != null) {
949                     contiguousSamplingOperationCheckBox.setEnabled(model.isAllSamplingOperations());
950                 }
951             }
952         
953             @Override
954             public void removeDataBinding() {
955                 if (model != null) {
956                     model.removePropertyChangeListener("allSamplingOperations", this);
957                 }
958             }
959         });
960         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAMPLING_OPERATION_COMBO_BOX_SELECTED_ITEM, true) {
961         
962             @Override
963             public void applyDataBinding() {
964                 if (model != null) {
965                     model.addPropertyChangeListener("samplingOperation", this);
966                 }
967             }
968         
969             @Override
970             public void processDataBinding() {
971                 if (model != null) {
972                     samplingOperationComboBox.setSelectedItem(model.getSamplingOperation());
973                 }
974             }
975         
976             @Override
977             public void removeDataBinding() {
978                 if (model != null) {
979                     model.removePropertyChangeListener("samplingOperation", this);
980                 }
981             }
982         });
983         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAMPLING_OPERATION_COMBO_BOX_ENABLED, true) {
984         
985             @Override
986             public void applyDataBinding() {
987                 if (model != null) {
988                     model.addPropertyChangeListener("allSamplingOperations", this);
989                 }
990             }
991         
992             @Override
993             public void processDataBinding() {
994                 if (model != null) {
995                     samplingOperationComboBox.setEnabled(!model.isAllSamplingOperations());
996                 }
997             }
998         
999             @Override
1000             public void removeDataBinding() {
1001                 if (model != null) {
1002                     model.removePropertyChangeListener("allSamplingOperations", this);
1003                 }
1004             }
1005         });
1006         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ORIGIN_FIELD_NUMBER_VALUE, true) {
1007         
1008             @Override
1009             public void applyDataBinding() {
1010                 if (model != null) {
1011                     model.addPropertyChangeListener("origin", this);
1012                 }
1013             }
1014         
1015             @Override
1016             public void processDataBinding() {
1017                 if (model != null) {
1018                     originField.setNumberValue(model.getOrigin());
1019                 }
1020             }
1021         
1022             @Override
1023             public void removeDataBinding() {
1024                 if (model != null) {
1025                     model.removePropertyChangeListener("origin", this);
1026                 }
1027             }
1028         });
1029         registerDataBinding(new DefaultJAXXBinding(this, BINDING_TRANSITION_FIELD_NUMBER_VALUE, true) {
1030         
1031             @Override
1032             public void applyDataBinding() {
1033                 if (model != null) {
1034                     model.addPropertyChangeListener("transition", this);
1035                 }
1036             }
1037         
1038             @Override
1039             public void processDataBinding() {
1040                 if (model != null) {
1041                     transitionField.setNumberValue(model.getTransition());
1042                 }
1043             }
1044         
1045             @Override
1046             public void removeDataBinding() {
1047                 if (model != null) {
1048                     model.removePropertyChangeListener("transition", this);
1049                 }
1050             }
1051         });
1052         registerDataBinding(new DefaultJAXXBinding(this, BINDING_LENGTH_FIELD_NUMBER_VALUE, true) {
1053         
1054             @Override
1055             public void applyDataBinding() {
1056                 if (model != null) {
1057                     model.addPropertyChangeListener("length", this);
1058                 }
1059             }
1060         
1061             @Override
1062             public void processDataBinding() {
1063                 if (model != null) {
1064                     lengthField.setNumberValue(model.getLength());
1065                 }
1066             }
1067         
1068             @Override
1069             public void removeDataBinding() {
1070                 if (model != null) {
1071                     model.removePropertyChangeListener("length", this);
1072                 }
1073             }
1074         });
1075         registerDataBinding(new DefaultJAXXBinding(this, BINDING_VALID_BUTTON_ENABLED, true) {
1076         
1077             @Override
1078             public void applyDataBinding() {
1079                 if (model != null) {
1080                     model.addPropertyChangeListener("valid", this);
1081                 }
1082             }
1083         
1084             @Override
1085             public void processDataBinding() {
1086                 if (model != null) {
1087                     validButton.setEnabled(model.isValid());
1088                 }
1089             }
1090         
1091             @Override
1092             public void removeDataBinding() {
1093                 if (model != null) {
1094                     model.removePropertyChangeListener("valid", this);
1095                 }
1096             }
1097         });
1098     }
1099 
1100 }