1 package fr.ifremer.reefdb.ui.swing.content.manage.program.locations.updatePeriod;
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.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.date.JLocalDatePicker;
31 import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
32 import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
33 import fr.ifremer.reefdb.ui.swing.content.manage.program.locations.LocationsTableUIModel;
34 import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
35 import java.awt.BorderLayout;
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.util.ArrayList;
49 import java.util.HashMap;
50 import java.util.List;
51 import java.util.Map;
52 import java.util.TreeMap;
53 import javax.swing.BorderFactory;
54 import javax.swing.JButton;
55 import javax.swing.JDialog;
56 import javax.swing.JLabel;
57 import javax.swing.JPanel;
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.SwingUtil;
64 import jaxx.runtime.context.DefaultJAXXContext;
65 import jaxx.runtime.swing.Table;
66 import org.apache.commons.logging.Log;
67 import org.apache.commons.logging.LogFactory;
68 import static org.nuiton.i18n.I18n.t;
69
70 public class UpdatePeriodUI extends JDialog implements ReefDbUI<UpdatePeriodUIModel, UpdatePeriodUIHandler>, JAXXObject {
71
72
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xpBBDnmGp8RHwiHE3sThytS4lk3B/vYP2mbEeIasGt0W4S9p2NrKwO+Asj1wlFsPr8OYogTmyUlXZ4w6nam635DiFprOjNGW4KkUllzvslAbcq1B0fpSiAlklatA5R+kahz74xUtyTbJASe7DfyGZAPBLWMGp2eEgj0/CHQU9q+5xRI00nKt/oQoMDmiVEptcbw5Pqpxwv9MevpPXy3USF3aP17BeiO8zbfNelqrhg90MSavqp/8hGNUOuFxDkB0FyWj2XWAkJz0uKTwy7++jHnOfkwdh9JSh6Wv9uJplfiSLW/76uRjgKrgneHNHs2fwnH5uJWcOoGSc++mjPITj7IFUfPsMhvPA8B+EPA+VUQwAAA==";
77 private static final Log log = LogFactory.getLog(UpdatePeriodUI.class);
78 private static final long serialVersionUID = 1L;
79
80
81
82
83
84 protected List<Object> $activeBindings = new ArrayList<Object>();
85 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
86 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
87 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
88 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
89 private boolean allComponentsCreated;
90 protected final JAXXContext delegateContext = new DefaultJAXXContext();
91
92
93
94
95
96 protected JButton cancelButton;
97 protected ExtendedComboBox<DepartmentDTO> departmentCombo;
98 protected JLabel departmentLabel;
99 protected JLocalDatePicker endDateEditor;
100 protected JLabel endDateLabel;
101 protected final UpdatePeriodUIHandler handler = createHandler();
102 protected UpdatePeriodUIModel model;
103 protected JLocalDatePicker startDateEditor;
104 protected JLabel startDateLabel;
105 protected UpdatePeriodUI updatePeriodUI = this;
106 protected JButton validButton;
107
108
109
110
111
112 private JPanel $JPanel0;
113 private JPanel $JPanel1;
114 private Table $Table0;
115
116
117
118
119
120 public UpdatePeriodUI(ApplicationUI parentUI) {
121 ApplicationUIUtil.setParentUI(this, parentUI);
122 $initialize();
123 }
124
125 public UpdatePeriodUI(Frame param0, String param1, boolean param2) {
126 super(param0 ,param1 ,param2);
127 $initialize();
128 }
129
130 public UpdatePeriodUI(JAXXContext parentContext, Frame param1, String param2, boolean param3) {
131 super(param1 ,param2 ,param3);
132 JAXXUtil.initContext(this, parentContext);
133 $initialize();
134 }
135
136 public UpdatePeriodUI(Frame param0, String param1) {
137 super(param0 ,param1);
138 $initialize();
139 }
140
141 public UpdatePeriodUI(JAXXContext parentContext, Frame param1, String param2) {
142 super(param1 ,param2);
143 JAXXUtil.initContext(this, parentContext);
144 $initialize();
145 }
146
147 public UpdatePeriodUI(Frame param0, String param1, boolean param2, GraphicsConfiguration param3) {
148 super(param0 ,param1 ,param2 ,param3);
149 $initialize();
150 }
151
152 public UpdatePeriodUI(JAXXContext parentContext, Frame param1, String param2, boolean param3, GraphicsConfiguration param4) {
153 super(param1 ,param2 ,param3 ,param4);
154 JAXXUtil.initContext(this, parentContext);
155 $initialize();
156 }
157
158 public UpdatePeriodUI(Dialog param0) {
159 super(param0);
160 $initialize();
161 }
162
163 public UpdatePeriodUI(JAXXContext parentContext, Dialog param1) {
164 super(param1);
165 JAXXUtil.initContext(this, parentContext);
166 $initialize();
167 }
168
169 public UpdatePeriodUI(Frame param0, boolean param1) {
170 super(param0 ,param1);
171 $initialize();
172 }
173
174 public UpdatePeriodUI(JAXXContext parentContext, Frame param1, boolean param2) {
175 super(param1 ,param2);
176 JAXXUtil.initContext(this, parentContext);
177 $initialize();
178 }
179
180 public UpdatePeriodUI() {
181 $initialize();
182 }
183
184 public UpdatePeriodUI(JAXXContext parentContext) {
185 JAXXUtil.initContext(this, parentContext);
186 $initialize();
187 }
188
189 public UpdatePeriodUI(Frame param0) {
190 super(param0);
191 $initialize();
192 }
193
194 public UpdatePeriodUI(JAXXContext parentContext, Frame param1) {
195 super(param1);
196 JAXXUtil.initContext(this, parentContext);
197 $initialize();
198 }
199
200 public UpdatePeriodUI(Dialog param0, String param1, boolean param2, GraphicsConfiguration param3) {
201 super(param0 ,param1 ,param2 ,param3);
202 $initialize();
203 }
204
205 public UpdatePeriodUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3, GraphicsConfiguration param4) {
206 super(param1 ,param2 ,param3 ,param4);
207 JAXXUtil.initContext(this, parentContext);
208 $initialize();
209 }
210
211 public UpdatePeriodUI(Window param0) {
212 super(param0);
213 $initialize();
214 }
215
216 public UpdatePeriodUI(JAXXContext parentContext, Window param1) {
217 super(param1);
218 JAXXUtil.initContext(this, parentContext);
219 $initialize();
220 }
221
222 public UpdatePeriodUI(Window param0, ModalityType param1) {
223 super(param0 ,param1);
224 $initialize();
225 }
226
227 public UpdatePeriodUI(JAXXContext parentContext, Window param1, ModalityType param2) {
228 super(param1 ,param2);
229 JAXXUtil.initContext(this, parentContext);
230 $initialize();
231 }
232
233 public UpdatePeriodUI(Window param0, String param1) {
234 super(param0 ,param1);
235 $initialize();
236 }
237
238 public UpdatePeriodUI(JAXXContext parentContext, Window param1, String param2) {
239 super(param1 ,param2);
240 JAXXUtil.initContext(this, parentContext);
241 $initialize();
242 }
243
244 public UpdatePeriodUI(Window param0, String param1, ModalityType param2) {
245 super(param0 ,param1 ,param2);
246 $initialize();
247 }
248
249 public UpdatePeriodUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3) {
250 super(param1 ,param2 ,param3);
251 JAXXUtil.initContext(this, parentContext);
252 $initialize();
253 }
254
255 public UpdatePeriodUI(Window param0, String param1, ModalityType param2, GraphicsConfiguration param3) {
256 super(param0 ,param1 ,param2 ,param3);
257 $initialize();
258 }
259
260 public UpdatePeriodUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3, GraphicsConfiguration param4) {
261 super(param1 ,param2 ,param3 ,param4);
262 JAXXUtil.initContext(this, parentContext);
263 $initialize();
264 }
265
266 public UpdatePeriodUI(Dialog param0, boolean param1) {
267 super(param0 ,param1);
268 $initialize();
269 }
270
271 public UpdatePeriodUI(JAXXContext parentContext, Dialog param1, boolean param2) {
272 super(param1 ,param2);
273 JAXXUtil.initContext(this, parentContext);
274 $initialize();
275 }
276
277 public UpdatePeriodUI(Dialog param0, String param1) {
278 super(param0 ,param1);
279 $initialize();
280 }
281
282 public UpdatePeriodUI(JAXXContext parentContext, Dialog param1, String param2) {
283 super(param1 ,param2);
284 JAXXUtil.initContext(this, parentContext);
285 $initialize();
286 }
287
288 public UpdatePeriodUI(Dialog param0, String param1, boolean param2) {
289 super(param0 ,param1 ,param2);
290 $initialize();
291 }
292
293 public UpdatePeriodUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3) {
294 super(param1 ,param2 ,param3);
295 JAXXUtil.initContext(this, parentContext);
296 $initialize();
297 }
298
299
300
301
302
303 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
304 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
305 }
306
307
308
309
310
311 @Override
312 public void applyDataBinding(String $binding) {
313 if (allComponentsCreated && $bindings.containsKey($binding)) {
314 getDataBinding($binding).applyDataBinding();
315 }
316 processDataBinding($binding);
317 }
318
319 @Override
320 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
321 super.firePropertyChange(propertyName, oldValue, newValue);
322 }
323
324 @Override
325 public Map<String, Object> get$objectMap() {
326 return $objectMap;
327 }
328
329 @Override
330 public JAXXBinding getDataBinding(String bindingId) {
331 return $bindings.get(bindingId);
332 }
333
334 @Override
335 public JAXXBinding[] getDataBindings() {
336 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
337 }
338
339 @Override
340 public Object getObjectById(String id) {
341 return $objectMap.get(id);
342 }
343
344 @Override
345 public void processDataBinding(String $binding, boolean $force) {
346 if (!$force && $activeBindings.contains($binding)) {
347 return;
348 }
349 $activeBindings.add($binding);
350 try {
351 if (allComponentsCreated && $bindings.containsKey($binding)) {
352 getDataBinding($binding).processDataBinding();
353 }
354 } finally {
355 $activeBindings.remove($binding);
356 }
357 }
358
359 @Override
360 public void processDataBinding(String $binding) {
361 processDataBinding($binding, false);
362 }
363
364 @Override
365 public void registerDataBinding(JAXXBinding binding) {
366 $bindings.put(binding.getId(), binding);
367 }
368
369 @Override
370 public void removeDataBinding(String $binding) {
371 if (allComponentsCreated && $bindings.containsKey($binding)) {
372 getDataBinding($binding).removeDataBinding();
373 }
374 }
375
376
377
378
379
380 @Override
381 public <T> T getContextValue(Class<T> clazz) {
382 return delegateContext.getContextValue(clazz, null);
383 }
384
385 @Override
386 public <T> T getContextValue(Class<T> clazz, String name) {
387 return delegateContext.getContextValue(clazz, name);
388 }
389
390 @Override
391 public JAXXContext getDelegateContext() {
392 return delegateContext;
393 }
394
395 @Override
396 public <O extends Container> O getParentContainer(Class<O> clazz) {
397 return SwingUtil.getParentContainer(this, clazz);
398 }
399
400 @Override
401 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
402 return SwingUtil.getParentContainer(source, clazz);
403 }
404
405 @Override
406 public <T> void removeContextValue(Class<T> clazz) {
407 delegateContext.removeContextValue(clazz, null);
408 }
409
410 @Override
411 public <T> void removeContextValue(Class<T> clazz, String name) {
412 delegateContext.removeContextValue(clazz, name);
413 }
414
415 @Override
416 public <T> void setContextValue(T o) {
417 delegateContext.setContextValue(o, null);
418 }
419
420 @Override
421 public <T> void setContextValue(T o, String name) {
422 delegateContext.setContextValue(o, name);
423 }
424
425
426
427
428
429 public void doActionPerformed__on__cancelButton(ActionEvent event) {
430 if (log.isDebugEnabled()) {
431 log.debug(event);
432 }
433 handler.cancel();
434 }
435
436 public void doActionPerformed__on__validButton(ActionEvent event) {
437 if (log.isDebugEnabled()) {
438 log.debug(event);
439 }
440 handler.valid();
441 }
442
443
444
445
446
447 public JButton getCancelButton() {
448 return cancelButton;
449 }
450
451 public ExtendedComboBox<DepartmentDTO> getDepartmentCombo() {
452 return departmentCombo;
453 }
454
455 public JLabel getDepartmentLabel() {
456 return departmentLabel;
457 }
458
459 public JLocalDatePicker getEndDateEditor() {
460 return endDateEditor;
461 }
462
463 public JLabel getEndDateLabel() {
464 return endDateLabel;
465 }
466
467 public UpdatePeriodUIHandler getHandler() {
468 return handler;
469 }
470
471 public UpdatePeriodUIModel getModel() {
472 return model;
473 }
474
475 public JLocalDatePicker getStartDateEditor() {
476 return startDateEditor;
477 }
478
479 public JLabel getStartDateLabel() {
480 return startDateLabel;
481 }
482
483 public JButton getValidButton() {
484 return validButton;
485 }
486
487
488
489
490
491 protected JPanel get$JPanel0() {
492 return $JPanel0;
493 }
494
495 protected JPanel get$JPanel1() {
496 return $JPanel1;
497 }
498
499 protected Table get$Table0() {
500 return $Table0;
501 }
502
503
504
505
506
507 protected void addChildrenToUpdatePeriodUI() {
508 if (!allComponentsCreated) {
509 return;
510 }
511 add($JPanel0);
512 }
513
514 protected void createCancelButton() {
515 $objectMap.put("cancelButton", cancelButton = new JButton());
516
517 cancelButton.setName("cancelButton");
518 cancelButton.setText(t("reefdb.common.cancel"));
519 cancelButton.setToolTipText(t("reefdb.common.cancel"));
520 cancelButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__cancelButton"));
521 }
522
523 protected void createDepartmentCombo() {
524 $objectMap.put("departmentCombo", departmentCombo = new ExtendedComboBox<DepartmentDTO>(this));
525
526 departmentCombo.setName("departmentCombo");
527 }
528
529 protected void createDepartmentLabel() {
530 $objectMap.put("departmentLabel", departmentLabel = new JLabel());
531
532 departmentLabel.setName("departmentLabel");
533 departmentLabel.setText(t("reefdb.program.location.periods.department"));
534 }
535
536 protected void createEndDateEditor() {
537 $objectMap.put("endDateEditor", endDateEditor = new JLocalDatePicker());
538
539 endDateEditor.setName("endDateEditor");
540 endDateEditor.putClientProperty("selectOnFocus", true);
541 }
542
543 protected void createEndDateLabel() {
544 $objectMap.put("endDateLabel", endDateLabel = new JLabel());
545
546 endDateLabel.setName("endDateLabel");
547 endDateLabel.setText(t("reefdb.program.location.periods.endDate"));
548 }
549
550 protected UpdatePeriodUIHandler createHandler() {
551 return new UpdatePeriodUIHandler();
552 }
553
554 protected void createModel() {
555 $objectMap.put("model", model = getContextValue(UpdatePeriodUIModel.class));
556 }
557
558 protected void createStartDateEditor() {
559 $objectMap.put("startDateEditor", startDateEditor = new JLocalDatePicker());
560
561 startDateEditor.setName("startDateEditor");
562 startDateEditor.putClientProperty("selectOnFocus", true);
563 }
564
565 protected void createStartDateLabel() {
566 $objectMap.put("startDateLabel", startDateLabel = new JLabel());
567
568 startDateLabel.setName("startDateLabel");
569 startDateLabel.setText(t("reefdb.program.location.periods.startDate"));
570 }
571
572 protected void createValidButton() {
573 $objectMap.put("validButton", validButton = new JButton());
574
575 validButton.setName("validButton");
576 validButton.setText(t("reefdb.common.validate"));
577 validButton.setToolTipText(t("reefdb.common.validate"));
578 validButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__validButton"));
579 }
580
581
582
583
584
585 private void $completeSetup() {
586 allComponentsCreated = true;
587 if (log.isDebugEnabled()) {
588 log.debug(this);
589 }
590 addChildrenToUpdatePeriodUI();
591
592 $JPanel0.add($Table0);
593 $JPanel0.add($JPanel1, BorderLayout.PAGE_END);
594
595 $Table0.add(startDateLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
596 $Table0.add(startDateEditor, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
597 $Table0.add(endDateLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
598 $Table0.add(endDateEditor, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
599 $Table0.add(departmentLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
600 $Table0.add(departmentCombo, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
601
602 $JPanel1.add(cancelButton);
603 $JPanel1.add(validButton);
604
605
606 $JPanel0.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
607 departmentCombo.setBeanType(DepartmentDTO.class);
608 startDateLabel.setLabelFor(startDateEditor);
609 endDateLabel.setLabelFor(endDateEditor);
610 departmentLabel.setLabelFor(departmentCombo);
611 cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("reefdb.common.cancel.mnemonic"),'Z'));
612 cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
613 validButton.setMnemonic(SwingUtil.getFirstCharAt(t("reefdb.common.validate.mnemonic"),'Z'));
614 validButton.setIcon(SwingUtil.createActionIcon("accept"));
615
616 updatePeriodUI.pack();
617 }
618
619 private void $initialize() {
620 if (allComponentsCreated) {
621 return;
622 }
623 if (log.isDebugEnabled()) {
624 log.debug(this);
625 }
626 handler.beforeInit(this);
627 $objectMap.put("updatePeriodUI", updatePeriodUI);
628 createModel();
629
630 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
631
632 $JPanel0.setName("$JPanel0");
633 $JPanel0.setLayout(new BorderLayout());
634
635 $objectMap.put("$Table0", $Table0 = new Table());
636
637 $Table0.setName("$Table0");
638 createStartDateLabel();
639 createStartDateEditor();
640 createEndDateLabel();
641 createEndDateEditor();
642 createDepartmentLabel();
643 createDepartmentCombo();
644
645 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
646
647 $JPanel1.setName("$JPanel1");
648 $JPanel1.setLayout(new GridLayout(1,0));
649 createCancelButton();
650 createValidButton();
651
652 setName("updatePeriodUI");
653 updatePeriodUI.getContentPane().setLayout(new BorderLayout());
654 setResizable(false);
655 setTitle(t("reefdb.program.location.periods.titre"));
656 setModal(true);
657
658 $completeSetup();
659 handler.afterInit(this);
660 }
661
662 }