1 package fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
28 import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
29 import fr.ifremer.tutti.persistence.entities.referential.Species;
30 import fr.ifremer.tutti.ui.swing.TuttiHelpBroker;
31 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
32 import fr.ifremer.tutti.ui.swing.util.TuttiUI;
33 import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
34 import java.awt.BorderLayout;
35 import java.awt.Component;
36 import java.awt.Container;
37 import java.awt.GridBagConstraints;
38 import java.awt.GridLayout;
39 import java.awt.Insets;
40 import java.awt.LayoutManager;
41 import java.util.ArrayList;
42 import java.util.HashMap;
43 import java.util.List;
44 import java.util.Map;
45 import java.util.TreeMap;
46 import javax.swing.JButton;
47 import javax.swing.JLabel;
48 import javax.swing.JPanel;
49 import jaxx.runtime.JAXXBinding;
50 import jaxx.runtime.JAXXContext;
51 import jaxx.runtime.JAXXObject;
52 import jaxx.runtime.JAXXObjectDescriptor;
53 import jaxx.runtime.JAXXUtil;
54 import jaxx.runtime.JAXXValidator;
55 import jaxx.runtime.SwingUtil;
56 import jaxx.runtime.binding.DefaultJAXXBinding;
57 import jaxx.runtime.binding.SimpleJAXXObjectBinding;
58 import jaxx.runtime.context.DefaultJAXXContext;
59 import jaxx.runtime.swing.Table;
60 import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
61 import jaxx.runtime.swing.help.JAXXHelpUI;
62 import jaxx.runtime.validator.swing.SwingValidator;
63 import jaxx.runtime.validator.swing.SwingValidatorUtil;
64 import jaxx.runtime.validator.swing.meta.Validator;
65 import jaxx.runtime.validator.swing.meta.ValidatorField;
66 import jaxx.runtime.validator.swing.ui.ImageValidationUI;
67 import org.apache.commons.logging.Log;
68 import org.apache.commons.logging.LogFactory;
69 import org.nuiton.jaxx.widgets.number.NumberEditor;
70 import static org.nuiton.i18n.I18n.t;
71
72 public class CreateAccidentalBatchUI extends JPanel implements JAXXHelpUI<TuttiHelpBroker>, TuttiUI<CreateAccidentalBatchUIModel, CreateAccidentalBatchUIHandler>, JAXXObject, JAXXValidator {
73
74
75
76
77
78 public static final String BINDING_ACCIDENTAL_DEAD_OR_ALIVE_COMBO_BOX_SELECTED_ITEM = "accidentalDeadOrAliveComboBox.selectedItem";
79 public static final String BINDING_ACCIDENTAL_GENDER_COMBO_BOX_SELECTED_ITEM = "accidentalGenderComboBox.selectedItem";
80 public static final String BINDING_ACCIDENTAL_LENGTH_STEP_CARACTERISTIC_COMBO_BOX_SELECTED_ITEM = "accidentalLengthStepCaracteristicComboBox.selectedItem";
81 public static final String BINDING_ACCIDENTAL_SIZE_FIELD_NUMBER_PATTERN = "accidentalSizeField.numberPattern";
82 public static final String BINDING_ACCIDENTAL_SIZE_FIELD_NUMBER_VALUE = "accidentalSizeField.numberValue";
83 public static final String BINDING_ACCIDENTAL_SPECIES_COMBO_BOX_SELECTED_ITEM = "accidentalSpeciesComboBox.selectedItem";
84 public static final String BINDING_ACCIDENTAL_WEIGHT_FIELD_NUMBER_VALUE = "accidentalWeightField.numberValue";
85 public static final String BINDING_SAVE_AND_CLOSE_BUTTON_ENABLED = "saveAndCloseButton.enabled";
86 public static final String BINDING_SAVE_AND_CONTINUE_BUTTON_ENABLED = "saveAndContinueButton.enabled";
87
88
89
90
91
92 private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAL1ZzW/cRBSfbJPNV1NoQtL0I6ItVdWowgn9gFQp0GSbbVM2TdSktCJC6aw92Z3itY09m2xYivgT+BPgzgWJGyfEgTMHLoh/ASEOXBFvxt4de3e8a2/SVqqbet77vY/5+b03k+//QgOeiy48x7Wa5lYtRitEe7D09Ol68TnR2V3i6S51mO0i/09fBmW20ajRfO8x9NZ2gavPBepzObvi2BaxQtqLBTTisQOTeGVCGEMzU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";
93 private static final Log log = LogFactory.getLog(CreateAccidentalBatchUI.class);
94 private static final long serialVersionUID = 1L;
95
96
97
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
110
111
112 @ValidatorField( validatorId = "validator", propertyName = "deadOrAlive", editorName = "accidentalDeadOrAliveComboBox")
113 protected BeanFilterableComboBox<CaracteristicQualitativeValue> accidentalDeadOrAliveComboBox;
114 protected JLabel accidentalDeadOrAliveLabel;
115 @ValidatorField( validatorId = "validator", propertyName = "gender", editorName = "accidentalGenderComboBox")
116 protected BeanFilterableComboBox<CaracteristicQualitativeValue> accidentalGenderComboBox;
117 protected JLabel accidentalGenderLabel;
118 @ValidatorField( validatorId = "validator", propertyName = "lengthStepCaracteristic", editorName = "accidentalLengthStepCaracteristicComboBox")
119 protected BeanFilterableComboBox<Caracteristic> accidentalLengthStepCaracteristicComboBox;
120 protected JLabel accidentalLengthStepCaracteristicLabel;
121 @ValidatorField( validatorId = "validator", propertyName = "size", editorName = "accidentalSizeField")
122 protected NumberEditor accidentalSizeField;
123 protected JLabel accidentalSizeLabel;
124 @ValidatorField( validatorId = "validator", propertyName = "species", editorName = "accidentalSpeciesComboBox")
125 protected BeanFilterableComboBox<Species> accidentalSpeciesComboBox;
126 protected JLabel accidentalSpeciesLabel;
127 @ValidatorField( validatorId = "validator", propertyName = "weight", editorName = "accidentalWeightField")
128 protected NumberEditor accidentalWeightField;
129 protected JLabel accidentalWeightLabel;
130 protected TuttiHelpBroker broker;
131 protected JButton cancelButton;
132 protected Table configurationPanel;
133 protected CreateAccidentalBatchUI createAccidentalBatchTopPanel = this;
134 protected final CreateAccidentalBatchUIHandler handler = createHandler();
135 protected CreateAccidentalBatchUIModel model;
136 protected JButton saveAndCloseButton;
137 protected JButton saveAndContinueButton;
138 @Validator( validatorId = "validator")
139 protected SwingValidator<CreateAccidentalBatchUIModel> validator;
140 protected List<String> validatorIds = new ArrayList<String>();
141
142
143
144
145
146 private JPanel $JPanel0;
147
148
149
150
151
152 public CreateAccidentalBatchUI(EditCatchesUI parentUI) {
153 TuttiUIUtil.setParentUI(this, parentUI);
154 $initialize();
155 }
156
157 public CreateAccidentalBatchUI(LayoutManager param0, boolean param1) {
158 super(param0 ,param1);
159 $initialize();
160 }
161
162 public CreateAccidentalBatchUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
163 super(param1 ,param2);
164 JAXXUtil.initContext(this, parentContext);
165 $initialize();
166 }
167
168 public CreateAccidentalBatchUI(LayoutManager param0) {
169 super(param0);
170 $initialize();
171 }
172
173 public CreateAccidentalBatchUI(JAXXContext parentContext, LayoutManager param1) {
174 super(param1);
175 JAXXUtil.initContext(this, parentContext);
176 $initialize();
177 }
178
179 public CreateAccidentalBatchUI() {
180 $initialize();
181 }
182
183 public CreateAccidentalBatchUI(JAXXContext parentContext) {
184 JAXXUtil.initContext(this, parentContext);
185 $initialize();
186 }
187
188 public CreateAccidentalBatchUI(boolean param0) {
189 super(param0);
190 $initialize();
191 }
192
193 public CreateAccidentalBatchUI(JAXXContext parentContext, boolean param1) {
194 super(param1);
195 JAXXUtil.initContext(this, parentContext);
196 $initialize();
197 }
198
199
200
201
202
203 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
204 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
205 }
206
207
208
209
210
211 @Override
212 public void applyDataBinding(String $binding) {
213 if (allComponentsCreated && $bindings.containsKey($binding)) {
214 getDataBinding($binding).applyDataBinding();
215 }
216 processDataBinding($binding);
217 }
218
219 @Override
220 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
221 super.firePropertyChange(propertyName, oldValue, newValue);
222 }
223
224 @Override
225 public Map<String, Object> get$objectMap() {
226 return $objectMap;
227 }
228
229 @Override
230 public JAXXBinding getDataBinding(String bindingId) {
231 return $bindings.get(bindingId);
232 }
233
234 @Override
235 public JAXXBinding[] getDataBindings() {
236 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
237 }
238
239 @Override
240 public Object getObjectById(String id) {
241 return $objectMap.get(id);
242 }
243
244 @Override
245 public void processDataBinding(String $binding, boolean $force) {
246 if (!$force && $activeBindings.contains($binding)) {
247 return;
248 }
249 $activeBindings.add($binding);
250 try {
251 if (allComponentsCreated && $bindings.containsKey($binding)) {
252 getDataBinding($binding).processDataBinding();
253 }
254 } finally {
255 $activeBindings.remove($binding);
256 }
257 }
258
259 @Override
260 public void processDataBinding(String $binding) {
261 processDataBinding($binding, false);
262 }
263
264 @Override
265 public void registerDataBinding(JAXXBinding binding) {
266 $bindings.put(binding.getId(), binding);
267 }
268
269 @Override
270 public void removeDataBinding(String $binding) {
271 if (allComponentsCreated && $bindings.containsKey($binding)) {
272 getDataBinding($binding).removeDataBinding();
273 }
274 }
275
276
277
278
279
280 @Override
281 public <T> T getContextValue(Class<T> clazz) {
282 return delegateContext.getContextValue(clazz, null);
283 }
284
285 @Override
286 public <T> T getContextValue(Class<T> clazz, String name) {
287 return delegateContext.getContextValue(clazz, name);
288 }
289
290 @Override
291 public JAXXContext getDelegateContext() {
292 return delegateContext;
293 }
294
295 @Override
296 public <O extends Container> O getParentContainer(Class<O> clazz) {
297 return SwingUtil.getParentContainer(this, clazz);
298 }
299
300 @Override
301 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
302 return SwingUtil.getParentContainer(source, clazz);
303 }
304
305 @Override
306 public <T> void removeContextValue(Class<T> clazz) {
307 delegateContext.removeContextValue(clazz, null);
308 }
309
310 @Override
311 public <T> void removeContextValue(Class<T> clazz, String name) {
312 delegateContext.removeContextValue(clazz, name);
313 }
314
315 @Override
316 public <T> void setContextValue(T o) {
317 delegateContext.setContextValue(o, null);
318 }
319
320 @Override
321 public <T> void setContextValue(T o, String name) {
322 delegateContext.setContextValue(o, name);
323 }
324
325
326
327
328
329 @Override
330 public SwingValidator<?> getValidator(String validatorId) {
331 return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
332 }
333
334 @Override
335 public List<String> getValidatorIds() {
336 return validatorIds;
337 }
338
339 @Override
340 public void registerValidatorFields() {
341 SwingValidatorUtil.detectValidatorFields(this);
342 }
343
344
345
346
347
348 public BeanFilterableComboBox<CaracteristicQualitativeValue> getAccidentalDeadOrAliveComboBox() {
349 return accidentalDeadOrAliveComboBox;
350 }
351
352 public JLabel getAccidentalDeadOrAliveLabel() {
353 return accidentalDeadOrAliveLabel;
354 }
355
356 public BeanFilterableComboBox<CaracteristicQualitativeValue> getAccidentalGenderComboBox() {
357 return accidentalGenderComboBox;
358 }
359
360 public JLabel getAccidentalGenderLabel() {
361 return accidentalGenderLabel;
362 }
363
364 public BeanFilterableComboBox<Caracteristic> getAccidentalLengthStepCaracteristicComboBox() {
365 return accidentalLengthStepCaracteristicComboBox;
366 }
367
368 public JLabel getAccidentalLengthStepCaracteristicLabel() {
369 return accidentalLengthStepCaracteristicLabel;
370 }
371
372 public NumberEditor getAccidentalSizeField() {
373 return accidentalSizeField;
374 }
375
376 public JLabel getAccidentalSizeLabel() {
377 return accidentalSizeLabel;
378 }
379
380 public BeanFilterableComboBox<Species> getAccidentalSpeciesComboBox() {
381 return accidentalSpeciesComboBox;
382 }
383
384 public JLabel getAccidentalSpeciesLabel() {
385 return accidentalSpeciesLabel;
386 }
387
388 public NumberEditor getAccidentalWeightField() {
389 return accidentalWeightField;
390 }
391
392 public JLabel getAccidentalWeightLabel() {
393 return accidentalWeightLabel;
394 }
395
396 public TuttiHelpBroker getBroker() {
397 return broker;
398 }
399
400 public JButton getCancelButton() {
401 return cancelButton;
402 }
403
404 public Table getConfigurationPanel() {
405 return configurationPanel;
406 }
407
408 public CreateAccidentalBatchUIHandler getHandler() {
409 return handler;
410 }
411
412 public CreateAccidentalBatchUIModel getModel() {
413 return model;
414 }
415
416 public JButton getSaveAndCloseButton() {
417 return saveAndCloseButton;
418 }
419
420 public JButton getSaveAndContinueButton() {
421 return saveAndContinueButton;
422 }
423
424 public SwingValidator<CreateAccidentalBatchUIModel> getValidator() {
425 return validator;
426 }
427
428
429
430
431
432 @Override
433 public void registerHelpId(TuttiHelpBroker broker, Component component, String helpId) {
434 broker.installUI(component, helpId);
435 }
436
437 @Override
438 public void showHelp(String helpId) {
439 getBroker().showHelp(this, helpId);
440 }
441
442
443
444
445
446 protected JPanel get$JPanel0() {
447 return $JPanel0;
448 }
449
450
451
452
453
454 protected void addChildrenToConfigurationPanel() {
455 if (!allComponentsCreated) {
456 return;
457 }
458 configurationPanel.add(accidentalSpeciesLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
459 configurationPanel.add(SwingUtil.boxComponentWithJxLayer(accidentalSpeciesComboBox), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
460 configurationPanel.add(accidentalGenderLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
461 configurationPanel.add(SwingUtil.boxComponentWithJxLayer(accidentalGenderComboBox), new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
462 configurationPanel.add(accidentalWeightLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
463 configurationPanel.add(SwingUtil.boxComponentWithJxLayer(accidentalWeightField), new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
464 configurationPanel.add(accidentalSizeLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
465 configurationPanel.add(SwingUtil.boxComponentWithJxLayer(accidentalSizeField), new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
466 configurationPanel.add(accidentalLengthStepCaracteristicLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
467 configurationPanel.add(SwingUtil.boxComponentWithJxLayer(accidentalLengthStepCaracteristicComboBox), new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
468 configurationPanel.add(accidentalDeadOrAliveLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
469 configurationPanel.add(SwingUtil.boxComponentWithJxLayer(accidentalDeadOrAliveComboBox), new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
470 }
471
472 protected void addChildrenToCreateAccidentalBatchTopPanel() {
473 if (!allComponentsCreated) {
474 return;
475 }
476 add(configurationPanel, BorderLayout.NORTH);
477 add($JPanel0, BorderLayout.SOUTH);
478 }
479
480 protected void addChildrenToValidator() {
481 if (!allComponentsCreated) {
482 return;
483 }
484 validator.setUiClass(ImageValidationUI.class);
485 validator.setBean(model);
486 }
487
488 protected void createAccidentalDeadOrAliveComboBox() {
489 $objectMap.put("accidentalDeadOrAliveComboBox", accidentalDeadOrAliveComboBox = new BeanFilterableComboBox<CaracteristicQualitativeValue>(this));
490
491 accidentalDeadOrAliveComboBox.setName("accidentalDeadOrAliveComboBox");
492 accidentalDeadOrAliveComboBox.setProperty("deadOrAlive");
493 accidentalDeadOrAliveComboBox.setShowReset(true);
494 accidentalDeadOrAliveComboBox.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalDeadOrAlive.help");
495 }
496
497 protected void createAccidentalDeadOrAliveLabel() {
498 $objectMap.put("accidentalDeadOrAliveLabel", accidentalDeadOrAliveLabel = new JLabel());
499
500 accidentalDeadOrAliveLabel.setName("accidentalDeadOrAliveLabel");
501 accidentalDeadOrAliveLabel.setText(t("tutti.createAccidentalBatch.field.accidentalDeadOrAlive"));
502 accidentalDeadOrAliveLabel.setToolTipText(t("tutti.createAccidentalBatch.field.accidentalDeadOrAlive.tip"));
503 accidentalDeadOrAliveLabel.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalDeadOrAlive.help");
504 }
505
506 protected void createAccidentalGenderComboBox() {
507 $objectMap.put("accidentalGenderComboBox", accidentalGenderComboBox = new BeanFilterableComboBox<CaracteristicQualitativeValue>(this));
508
509 accidentalGenderComboBox.setName("accidentalGenderComboBox");
510 accidentalGenderComboBox.setProperty("gender");
511 accidentalGenderComboBox.setShowReset(true);
512 accidentalGenderComboBox.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalGender.help");
513 }
514
515 protected void createAccidentalGenderLabel() {
516 $objectMap.put("accidentalGenderLabel", accidentalGenderLabel = new JLabel());
517
518 accidentalGenderLabel.setName("accidentalGenderLabel");
519 accidentalGenderLabel.setText(t("tutti.createAccidentalBatch.field.accidentalGender"));
520 accidentalGenderLabel.setToolTipText(t("tutti.createAccidentalBatch.field.accidentalGender.tip"));
521 accidentalGenderLabel.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalGender.help");
522 }
523
524 protected void createAccidentalLengthStepCaracteristicComboBox() {
525 $objectMap.put("accidentalLengthStepCaracteristicComboBox", accidentalLengthStepCaracteristicComboBox = new BeanFilterableComboBox<Caracteristic>(this));
526
527 accidentalLengthStepCaracteristicComboBox.setName("accidentalLengthStepCaracteristicComboBox");
528 accidentalLengthStepCaracteristicComboBox.setProperty("lengthStepCaracteristic");
529 accidentalLengthStepCaracteristicComboBox.setShowReset(true);
530 accidentalLengthStepCaracteristicComboBox.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalLengthStepCaracteristic.help");
531 }
532
533 protected void createAccidentalLengthStepCaracteristicLabel() {
534 $objectMap.put("accidentalLengthStepCaracteristicLabel", accidentalLengthStepCaracteristicLabel = new JLabel());
535
536 accidentalLengthStepCaracteristicLabel.setName("accidentalLengthStepCaracteristicLabel");
537 accidentalLengthStepCaracteristicLabel.setText(t("tutti.createAccidentalBatch.field.accidentalLengthStepCaracteristic"));
538 accidentalLengthStepCaracteristicLabel.setToolTipText(t("tutti.createAccidentalBatch.field.accidentalLengthStepCaracteristic.tip"));
539 accidentalLengthStepCaracteristicLabel.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalLengthStepCaracteristic.help");
540 }
541
542 protected void createAccidentalSizeField() {
543 $objectMap.put("accidentalSizeField", accidentalSizeField = new NumberEditor(this));
544
545 accidentalSizeField.setName("accidentalSizeField");
546 accidentalSizeField.setProperty("size");
547 accidentalSizeField.setShowReset(true);
548 accidentalSizeField.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalSize.help");
549 }
550
551 protected void createAccidentalSizeLabel() {
552 $objectMap.put("accidentalSizeLabel", accidentalSizeLabel = new JLabel());
553
554 accidentalSizeLabel.setName("accidentalSizeLabel");
555 accidentalSizeLabel.setText(t("tutti.createAccidentalBatch.field.accidentalSize"));
556 accidentalSizeLabel.setToolTipText(t("tutti.createAccidentalBatch.field.accidentalSize.tip"));
557 accidentalSizeLabel.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalSize.help");
558 }
559
560 protected void createAccidentalSpeciesComboBox() {
561 $objectMap.put("accidentalSpeciesComboBox", accidentalSpeciesComboBox = new BeanFilterableComboBox<Species>(this));
562
563 accidentalSpeciesComboBox.setName("accidentalSpeciesComboBox");
564 accidentalSpeciesComboBox.setProperty("species");
565 accidentalSpeciesComboBox.setShowReset(true);
566 accidentalSpeciesComboBox.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalSpecies.help");
567 }
568
569 protected void createAccidentalSpeciesLabel() {
570 $objectMap.put("accidentalSpeciesLabel", accidentalSpeciesLabel = new JLabel());
571
572 accidentalSpeciesLabel.setName("accidentalSpeciesLabel");
573 accidentalSpeciesLabel.setText(t("tutti.createAccidentalBatch.field.accidentalSpecies"));
574 accidentalSpeciesLabel.setToolTipText(t("tutti.createAccidentalBatch.field.accidentalSpecies.tip"));
575 accidentalSpeciesLabel.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalSpecies.help");
576 }
577
578 protected void createAccidentalWeightField() {
579 $objectMap.put("accidentalWeightField", accidentalWeightField = new NumberEditor(this));
580
581 accidentalWeightField.setName("accidentalWeightField");
582 accidentalWeightField.setProperty("weight");
583 accidentalWeightField.setShowReset(true);
584 accidentalWeightField.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalWeight.help");
585 }
586
587 protected void createAccidentalWeightLabel() {
588 $objectMap.put("accidentalWeightLabel", accidentalWeightLabel = new JLabel());
589
590 accidentalWeightLabel.setName("accidentalWeightLabel");
591 accidentalWeightLabel.setText(t("tutti.createAccidentalBatch.field.accidentalWeight"));
592 accidentalWeightLabel.setToolTipText(t("tutti.createAccidentalBatch.field.accidentalWeight.tip"));
593 accidentalWeightLabel.putClientProperty("help", "tutti.createAccidentalBatch.field.accidentalWeight.help");
594 accidentalWeightLabel.putClientProperty("addWeightUnit", handler.getConfig().getAccidentalCatchWeightUnit());
595 }
596
597 protected void createBroker() {
598 $objectMap.put("broker", broker = new TuttiHelpBroker("tutti.createAccidentalBatch.help"));
599 }
600
601 protected void createCancelButton() {
602 $objectMap.put("cancelButton", cancelButton = new JButton());
603
604 cancelButton.setName("cancelButton");
605 cancelButton.setText(t("tutti.createAccidentalBatch.action.cancel"));
606 cancelButton.setToolTipText(t("tutti.createAccidentalBatch.action.cancel.tip"));
607 cancelButton.putClientProperty("help", "tutti.createAccidentalBatch.action.cancel.help");
608 cancelButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create.actions.CreateAccidentalBatchCancelAction.class);
609 }
610
611 protected void createConfigurationPanel() {
612 $objectMap.put("configurationPanel", configurationPanel = new Table());
613
614 configurationPanel.setName("configurationPanel");
615 }
616
617 protected CreateAccidentalBatchUIHandler createHandler() {
618 return new CreateAccidentalBatchUIHandler();
619 }
620
621 protected void createModel() {
622 $objectMap.put("model", model = getContextValue(CreateAccidentalBatchUIModel.class));
623 }
624
625 protected void createSaveAndCloseButton() {
626 $objectMap.put("saveAndCloseButton", saveAndCloseButton = new JButton());
627
628 saveAndCloseButton.setName("saveAndCloseButton");
629 saveAndCloseButton.setText(t("tutti.createAccidentalBatch.action.saveAndClose"));
630 saveAndCloseButton.setToolTipText(t("tutti.createAccidentalBatch.action.saveAndClose.tip"));
631 saveAndCloseButton.putClientProperty("help", "tutti.createAccidentalBatch.action.saveAndClose.help");
632 saveAndCloseButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create.actions.CreateAccidentalBatchAndCloseAction.class);
633 }
634
635 protected void createSaveAndContinueButton() {
636 $objectMap.put("saveAndContinueButton", saveAndContinueButton = new JButton());
637
638 saveAndContinueButton.setName("saveAndContinueButton");
639 saveAndContinueButton.setText(t("tutti.createAccidentalBatch.action.saveAndContinue"));
640 saveAndContinueButton.setToolTipText(t("tutti.createAccidentalBatch.action.saveAndContinue.tip"));
641 saveAndContinueButton.putClientProperty("help", "tutti.createAccidentalBatch.action.saveAndContinue.help");
642 saveAndContinueButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create.actions.CreateAccidentalBatchAndContinueAction.class);
643 }
644
645 protected void createValidator() {
646 $objectMap.put("validator", validator = SwingValidator.newValidator(CreateAccidentalBatchUIModel.class, null));
647 }
648
649
650
651
652
653 private void $completeSetup() {
654 allComponentsCreated = true;
655 if (log.isDebugEnabled()) {
656 log.debug(this);
657 }
658 addChildrenToCreateAccidentalBatchTopPanel();
659 addChildrenToValidator();
660 addChildrenToConfigurationPanel();
661
662 $JPanel0.add(cancelButton);
663 $JPanel0.add(saveAndContinueButton);
664 $JPanel0.add(saveAndCloseButton);
665
666
667 JAXXUtil.applyDataBinding(this, $bindings.keySet());
668
669
670 accidentalSpeciesComboBox.setBeanType(Species.class);
671 accidentalGenderComboBox.setBeanType(CaracteristicQualitativeValue.class);
672 accidentalLengthStepCaracteristicComboBox.setBeanType(Caracteristic.class);
673 accidentalDeadOrAliveComboBox.setBeanType(CaracteristicQualitativeValue.class);
674 accidentalSpeciesLabel.setLabelFor(accidentalSpeciesComboBox);
675 accidentalSpeciesComboBox.setBean(model);
676 accidentalGenderLabel.setLabelFor(accidentalGenderComboBox);
677 accidentalGenderComboBox.setBean(model);
678 accidentalWeightLabel.setLabelFor(accidentalWeightField);
679 accidentalWeightField.setAutoPopup(handler.getConfig().isAutoPopupNumberEditor());
680 accidentalWeightField.setNumberType(Float.class);
681 accidentalWeightField.setShowPopupButton(handler.getConfig().isShowNumberEditorButton());
682 accidentalWeightField.setBean(model);
683 accidentalSizeLabel.setLabelFor(accidentalSizeField);
684 accidentalSizeField.setAutoPopup(handler.getConfig().isAutoPopupNumberEditor());
685 accidentalSizeField.setNumberType(Float.class);
686 accidentalSizeField.setShowPopupButton(handler.getConfig().isShowNumberEditorButton());
687 accidentalSizeField.setBean(model);
688 accidentalLengthStepCaracteristicLabel.setLabelFor(accidentalLengthStepCaracteristicComboBox);
689 accidentalLengthStepCaracteristicComboBox.setBean(model);
690 accidentalDeadOrAliveLabel.setLabelFor(accidentalDeadOrAliveComboBox);
691 accidentalDeadOrAliveComboBox.setBean(model);
692 cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.createAccidentalBatch.action.cancel.mnemonic"),'Z'));
693 cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
694 saveAndContinueButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.createAccidentalBatch.action.saveAndContinue.mnemonic"),'Z'));
695 saveAndContinueButton.setIcon(SwingUtil.createActionIcon("save"));
696 saveAndCloseButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.createAccidentalBatch.action.saveAndClose.mnemonic"),'Z'));
697 saveAndCloseButton.setIcon(SwingUtil.createActionIcon("save"));
698
699
700 TuttiHelpBroker _broker = getBroker();
701 registerHelpId(_broker, createAccidentalBatchTopPanel, "tutti.createIndividualObservationBatch.help");
702 registerHelpId(_broker, accidentalSpeciesLabel, "tutti.createAccidentalBatch.field.accidentalSpecies.help");
703 registerHelpId(_broker, accidentalSpeciesComboBox, "tutti.createAccidentalBatch.field.accidentalSpecies.help");
704 registerHelpId(_broker, accidentalGenderLabel, "tutti.createAccidentalBatch.field.accidentalGender.help");
705 registerHelpId(_broker, accidentalGenderComboBox, "tutti.createAccidentalBatch.field.accidentalGender.help");
706 registerHelpId(_broker, accidentalWeightLabel, "tutti.createAccidentalBatch.field.accidentalWeight.help");
707 registerHelpId(_broker, accidentalWeightField, "tutti.createAccidentalBatch.field.accidentalWeight.help");
708 registerHelpId(_broker, accidentalSizeLabel, "tutti.createAccidentalBatch.field.accidentalSize.help");
709 registerHelpId(_broker, accidentalSizeField, "tutti.createAccidentalBatch.field.accidentalSize.help");
710 registerHelpId(_broker, accidentalLengthStepCaracteristicLabel, "tutti.createAccidentalBatch.field.accidentalLengthStepCaracteristic.help");
711 registerHelpId(_broker, accidentalLengthStepCaracteristicComboBox, "tutti.createAccidentalBatch.field.accidentalLengthStepCaracteristic.help");
712 registerHelpId(_broker, accidentalDeadOrAliveLabel, "tutti.createAccidentalBatch.field.accidentalDeadOrAlive.help");
713 registerHelpId(_broker, accidentalDeadOrAliveComboBox, "tutti.createAccidentalBatch.field.accidentalDeadOrAlive.help");
714 registerHelpId(_broker, cancelButton, "tutti.createAccidentalBatch.action.cancel.help");
715 registerHelpId(_broker, saveAndContinueButton, "tutti.createAccidentalBatch.action.saveAndContinue.help");
716 registerHelpId(_broker, saveAndCloseButton, "tutti.createAccidentalBatch.action.saveAndClose.help");
717 _broker.prepareUI(this);
718
719 validatorIds = SwingValidatorUtil.detectValidators(this);
720 SwingValidatorUtil.installUI(this);
721 }
722
723 private void $initialize() {
724 if (allComponentsCreated) {
725 return;
726 }
727 if (log.isDebugEnabled()) {
728 log.debug(this);
729 }
730 handler.beforeInit(this);
731 $objectMap.put("createAccidentalBatchTopPanel", createAccidentalBatchTopPanel);
732 createModel();
733 createValidator();
734 createBroker();
735 createConfigurationPanel();
736 createAccidentalSpeciesLabel();
737 createAccidentalSpeciesComboBox();
738 createAccidentalGenderLabel();
739 createAccidentalGenderComboBox();
740 createAccidentalWeightLabel();
741 createAccidentalWeightField();
742 createAccidentalSizeLabel();
743 createAccidentalSizeField();
744 createAccidentalLengthStepCaracteristicLabel();
745 createAccidentalLengthStepCaracteristicComboBox();
746 createAccidentalDeadOrAliveLabel();
747 createAccidentalDeadOrAliveComboBox();
748
749 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
750
751 $JPanel0.setName("$JPanel0");
752 $JPanel0.setLayout(new GridLayout(1, 0));
753 SwingUtil.setComponentHeight($JPanel0,50);
754 createCancelButton();
755 createSaveAndContinueButton();
756 createSaveAndCloseButton();
757
758 setName("createAccidentalBatchTopPanel");
759 setLayout(new BorderLayout());
760 createAccidentalBatchTopPanel.putClientProperty("help", "tutti.createIndividualObservationBatch.help");
761
762
763 $registerDefaultBindings();
764 $completeSetup();
765 handler.afterInit(this);
766 }
767
768 private void $registerDefaultBindings() {
769
770 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ACCIDENTAL_SPECIES_COMBO_BOX_SELECTED_ITEM, true) {
771
772 @Override
773 public void applyDataBinding() {
774 if (model != null) {
775 model.addPropertyChangeListener("species", this);
776 }
777 }
778
779 @Override
780 public void processDataBinding() {
781 if (model != null) {
782 accidentalSpeciesComboBox.setSelectedItem(model.getSpecies());
783 }
784 }
785
786 @Override
787 public void removeDataBinding() {
788 if (model != null) {
789 model.removePropertyChangeListener("species", this);
790 }
791 }
792 });
793 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ACCIDENTAL_GENDER_COMBO_BOX_SELECTED_ITEM, true) {
794
795 @Override
796 public void applyDataBinding() {
797 if (model != null) {
798 model.addPropertyChangeListener("gender", this);
799 }
800 }
801
802 @Override
803 public void processDataBinding() {
804 if (model != null) {
805 accidentalGenderComboBox.setSelectedItem(model.getGender());
806 }
807 }
808
809 @Override
810 public void removeDataBinding() {
811 if (model != null) {
812 model.removePropertyChangeListener("gender", this);
813 }
814 }
815 });
816 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ACCIDENTAL_WEIGHT_FIELD_NUMBER_VALUE, true) {
817
818 @Override
819 public void applyDataBinding() {
820 if (model != null) {
821 model.addPropertyChangeListener("weight", this);
822 }
823 }
824
825 @Override
826 public void processDataBinding() {
827 if (model != null) {
828 accidentalWeightField.setNumberValue(model.getWeight());
829 }
830 }
831
832 @Override
833 public void removeDataBinding() {
834 if (model != null) {
835 model.removePropertyChangeListener("weight", this);
836 }
837 }
838 });
839 registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_ACCIDENTAL_SIZE_FIELD_NUMBER_PATTERN, true ,"DECIMAL3_PATTERN") {
840
841 @Override
842 public void processDataBinding() {
843 accidentalSizeField.setNumberPattern(DECIMAL3_PATTERN);
844 }
845 });
846 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ACCIDENTAL_SIZE_FIELD_NUMBER_VALUE, true) {
847
848 @Override
849 public void applyDataBinding() {
850 if (model != null) {
851 model.addPropertyChangeListener("size", this);
852 }
853 }
854
855 @Override
856 public void processDataBinding() {
857 if (model != null) {
858 accidentalSizeField.setNumberValue(model.getSize());
859 }
860 }
861
862 @Override
863 public void removeDataBinding() {
864 if (model != null) {
865 model.removePropertyChangeListener("size", this);
866 }
867 }
868 });
869 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ACCIDENTAL_LENGTH_STEP_CARACTERISTIC_COMBO_BOX_SELECTED_ITEM, true) {
870
871 @Override
872 public void applyDataBinding() {
873 if (model != null) {
874 model.addPropertyChangeListener("lengthStepCaracteristic", this);
875 }
876 }
877
878 @Override
879 public void processDataBinding() {
880 if (model != null) {
881 accidentalLengthStepCaracteristicComboBox.setSelectedItem(model.getLengthStepCaracteristic());
882 }
883 }
884
885 @Override
886 public void removeDataBinding() {
887 if (model != null) {
888 model.removePropertyChangeListener("lengthStepCaracteristic", this);
889 }
890 }
891 });
892 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ACCIDENTAL_DEAD_OR_ALIVE_COMBO_BOX_SELECTED_ITEM, true) {
893
894 @Override
895 public void applyDataBinding() {
896 if (model != null) {
897 model.addPropertyChangeListener("deadOrAlive", this);
898 }
899 }
900
901 @Override
902 public void processDataBinding() {
903 if (model != null) {
904 accidentalDeadOrAliveComboBox.setSelectedItem(model.getDeadOrAlive());
905 }
906 }
907
908 @Override
909 public void removeDataBinding() {
910 if (model != null) {
911 model.removePropertyChangeListener("deadOrAlive", this);
912 }
913 }
914 });
915 registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAVE_AND_CONTINUE_BUTTON_ENABLED, true) {
916
917 @Override
918 public void applyDataBinding() {
919 if (model != null) {
920 model.addPropertyChangeListener("valid", this);
921 }
922 }
923
924 @Override
925 public void processDataBinding() {
926 if (model != null) {
927 saveAndContinueButton.setEnabled(model.isValid());
928 }
929 }
930
931 @Override
932 public void removeDataBinding() {
933 if (model != null) {
934 model.removePropertyChangeListener("valid", this);
935 }
936 }
937 });
938 registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAVE_AND_CLOSE_BUTTON_ENABLED, true) {
939
940 @Override
941 public void applyDataBinding() {
942 if (model != null) {
943 model.addPropertyChangeListener("valid", this);
944 }
945 }
946
947 @Override
948 public void processDataBinding() {
949 if (model != null) {
950 saveAndCloseButton.setEnabled(model.isValid());
951 }
952 }
953
954 @Override
955 public void removeDataBinding() {
956 if (model != null) {
957 model.removePropertyChangeListener("valid", this);
958 }
959 }
960 });
961 }
962
963 }