1 package fr.ifremer.reefdb.ui.swing.content.observation.photo;
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.EnumValueComboBox;
30 import fr.ifremer.quadrige3.ui.swing.plaf.WaitBlockingLayerUI;
31 import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
32 import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
33 import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
34 import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
35 import fr.ifremer.reefdb.ui.swing.util.image.PhotoViewer;
36 import java.awt.BorderLayout;
37 import java.awt.Component;
38 import java.awt.Container;
39 import java.awt.FlowLayout;
40 import java.awt.LayoutManager;
41 import java.awt.event.ActionEvent;
42 import java.awt.event.ActionListener;
43 import java.util.ArrayList;
44 import java.util.HashMap;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.TreeMap;
48 import javax.swing.BorderFactory;
49 import javax.swing.Box;
50 import javax.swing.BoxLayout;
51 import javax.swing.JButton;
52 import javax.swing.JLabel;
53 import javax.swing.JPanel;
54 import javax.swing.JScrollPane;
55 import jaxx.runtime.JAXXBinding;
56 import jaxx.runtime.JAXXContext;
57 import jaxx.runtime.JAXXObject;
58 import jaxx.runtime.JAXXObjectDescriptor;
59 import jaxx.runtime.JAXXUtil;
60 import jaxx.runtime.JAXXValidator;
61 import jaxx.runtime.SwingUtil;
62 import jaxx.runtime.binding.DefaultJAXXBinding;
63 import jaxx.runtime.context.DefaultJAXXContext;
64 import jaxx.runtime.swing.help.JAXXHelpUI;
65 import jaxx.runtime.validator.swing.SwingValidator;
66 import jaxx.runtime.validator.swing.SwingValidatorUtil;
67 import jaxx.runtime.validator.swing.meta.Validator;
68 import jaxx.runtime.validator.swing.meta.ValidatorField;
69 import jaxx.runtime.validator.swing.ui.ImageValidationUI;
70 import org.apache.commons.logging.Log;
71 import org.apache.commons.logging.LogFactory;
72 import org.jdesktop.swingx.JXImageView;
73 import org.jdesktop.swingx.JXList;
74 import static org.nuiton.i18n.I18n.t;
75
76 public class PhotosTabUI extends JPanel implements JAXXHelpUI<ReefDbHelpBroker>, ReefDbUI<PhotosTabUIModel, PhotosTabUIHandler>, JAXXObject, JAXXValidator {
77
78
79
80
81
82 public static final String BINDING_DELETE_PHOTO_BUTTON_ENABLED = "deletePhotoButton.enabled";
83 public static final String BINDING_DOWNLOAD_PHOTO_BUTTON_ENABLED = "downloadPhotoButton.enabled";
84 public static final String BINDING_EXPORT_PHOTO_BUTTON_ENABLED = "exportPhotoButton.enabled";
85 public static final String BINDING_IMPORT_PHOTO_BUTTON_ENABLED = "importPhotoButton.enabled";
86 public static final String BINDING_PHOTO_BLOCK_LAYER_BLOCK = "photoBlockLayer.block";
87
88
89
90
91
92 private static final String $jaxxObjectDescriptor = "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";
93 private static final Log log = LogFactory.getLog(PhotosTabUI.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 protected ReefDbHelpBroker broker;
113 protected JButton deletePhotoButton;
114 protected JButton downloadPhotoButton;
115 protected JButton exportPhotoButton;
116 protected JButton firstPhotoButton;
117 protected JButton fullScreenButton;
118 protected final PhotosTabUIHandler handler = createHandler();
119 protected JButton importPhotoButton;
120 protected JButton lastPhotoButton;
121 protected PhotosTabUIModel model;
122 protected JButton nextPhotoButton;
123 protected WaitBlockingLayerUI photoBlockLayer;
124 protected JLabel photoIndexLabel;
125 protected PhotosTabUI photoTabUI = this;
126 protected SwingTable photoTable;
127 @ValidatorField( validatorId = "validator", propertyName = "instance", editorName = "photoTablePanel")
128 protected JPanel photoTablePanel;
129 protected PhotoViewer<PhotosTableRowModel> photoViewer;
130 protected JButton previousPhotoButton;
131 protected EnumValueComboBox<PhotoViewType> typeDiaporamaComboBox;
132 protected JLabel typeDiaporamaLabel;
133 @Validator( validatorId = "validator")
134 protected SwingValidator<PhotosTabUIModel> validator;
135 protected List<String> validatorIds = new ArrayList<String>();
136
137
138
139
140
141 private JPanel $JPanel0;
142 private JPanel $JPanel1;
143 private JPanel $JPanel2;
144 private JPanel $JPanel3;
145 private JPanel $JPanel4;
146 private JScrollPane $JScrollPane0;
147
148
149
150
151
152 public PhotosTabUI(ApplicationUI parentUI) {
153 ApplicationUIUtil.setParentUI(this, parentUI);
154 $initialize();
155 }
156
157 public PhotosTabUI(LayoutManager param0, boolean param1) {
158 super(param0 ,param1);
159 $initialize();
160 }
161
162 public PhotosTabUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
163 super(param1 ,param2);
164 JAXXUtil.initContext(this, parentContext);
165 $initialize();
166 }
167
168 public PhotosTabUI(boolean param0) {
169 super(param0);
170 $initialize();
171 }
172
173 public PhotosTabUI(JAXXContext parentContext, boolean param1) {
174 super(param1);
175 JAXXUtil.initContext(this, parentContext);
176 $initialize();
177 }
178
179 public PhotosTabUI() {
180 $initialize();
181 }
182
183 public PhotosTabUI(JAXXContext parentContext) {
184 JAXXUtil.initContext(this, parentContext);
185 $initialize();
186 }
187
188 public PhotosTabUI(LayoutManager param0) {
189 super(param0);
190 $initialize();
191 }
192
193 public PhotosTabUI(JAXXContext parentContext, LayoutManager 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 void doActionPerformed__on__deletePhotoButton(ActionEvent event) {
349 if (log.isDebugEnabled()) {
350 log.debug(event);
351 }
352 handler.removePhoto();
353 }
354
355 public void doActionPerformed__on__firstPhotoButton(ActionEvent event) {
356 if (log.isDebugEnabled()) {
357 log.debug(event);
358 }
359 handler.firstPhoto();
360 }
361
362 public void doActionPerformed__on__fullScreenButton(ActionEvent event) {
363 if (log.isDebugEnabled()) {
364 log.debug(event);
365 }
366 handler.fullScreen();
367 }
368
369 public void doActionPerformed__on__lastPhotoButton(ActionEvent event) {
370 if (log.isDebugEnabled()) {
371 log.debug(event);
372 }
373 handler.lastPhoto();
374 }
375
376 public void doActionPerformed__on__nextPhotoButton(ActionEvent event) {
377 if (log.isDebugEnabled()) {
378 log.debug(event);
379 }
380 handler.nextPhoto();
381 }
382
383 public void doActionPerformed__on__previousPhotoButton(ActionEvent event) {
384 if (log.isDebugEnabled()) {
385 log.debug(event);
386 }
387 handler.previousPhoto();
388 }
389
390
391
392
393
394 public ReefDbHelpBroker getBroker() {
395 return broker;
396 }
397
398 public JButton getDeletePhotoButton() {
399 return deletePhotoButton;
400 }
401
402 public JButton getDownloadPhotoButton() {
403 return downloadPhotoButton;
404 }
405
406 public JButton getExportPhotoButton() {
407 return exportPhotoButton;
408 }
409
410 public JButton getFirstPhotoButton() {
411 return firstPhotoButton;
412 }
413
414 public JButton getFullScreenButton() {
415 return fullScreenButton;
416 }
417
418 public PhotosTabUIHandler getHandler() {
419 return handler;
420 }
421
422 public JButton getImportPhotoButton() {
423 return importPhotoButton;
424 }
425
426 public JButton getLastPhotoButton() {
427 return lastPhotoButton;
428 }
429
430 public PhotosTabUIModel getModel() {
431 return model;
432 }
433
434 public JButton getNextPhotoButton() {
435 return nextPhotoButton;
436 }
437
438 public WaitBlockingLayerUI getPhotoBlockLayer() {
439 return photoBlockLayer;
440 }
441
442 public JLabel getPhotoIndexLabel() {
443 return photoIndexLabel;
444 }
445
446 public SwingTable getPhotoTable() {
447 return photoTable;
448 }
449
450 public JPanel getPhotoTablePanel() {
451 return photoTablePanel;
452 }
453
454 public PhotoViewer<PhotosTableRowModel> getPhotoViewer() {
455 return photoViewer;
456 }
457
458 public JButton getPreviousPhotoButton() {
459 return previousPhotoButton;
460 }
461
462 public EnumValueComboBox<PhotoViewType> getTypeDiaporamaComboBox() {
463 return typeDiaporamaComboBox;
464 }
465
466 public JLabel getTypeDiaporamaLabel() {
467 return typeDiaporamaLabel;
468 }
469
470 public SwingValidator<PhotosTabUIModel> getValidator() {
471 return validator;
472 }
473
474
475
476
477
478 @Override
479 public void registerHelpId(ReefDbHelpBroker broker, Component component, String helpId) {
480 broker.installUI(component, helpId);
481 }
482
483 @Override
484 public void showHelp(String helpId) {
485 getBroker().showHelp(this, helpId);
486 }
487
488
489
490
491
492 protected JPanel get$JPanel0() {
493 return $JPanel0;
494 }
495
496 protected JPanel get$JPanel1() {
497 return $JPanel1;
498 }
499
500 protected JPanel get$JPanel2() {
501 return $JPanel2;
502 }
503
504 protected JPanel get$JPanel3() {
505 return $JPanel3;
506 }
507
508 protected JPanel get$JPanel4() {
509 return $JPanel4;
510 }
511
512 protected JScrollPane get$JScrollPane0() {
513 return $JScrollPane0;
514 }
515
516
517
518
519
520 protected void addChildrenToPhotoTabUI() {
521 if (!allComponentsCreated) {
522 return;
523 }
524 add($JPanel0, BorderLayout.CENTER);
525 add(SwingUtil.boxComponentWithJxLayer(photoTablePanel), BorderLayout.PAGE_END);
526 }
527
528 protected void addChildrenToPhotoTablePanel() {
529 if (!allComponentsCreated) {
530 return;
531 }
532 photoTablePanel.add($JScrollPane0, BorderLayout.CENTER);
533 photoTablePanel.add($JPanel2, BorderLayout.PAGE_END);
534 }
535
536 protected void addChildrenToValidator() {
537 if (!allComponentsCreated) {
538 return;
539 }
540 validator.setUiClass(ImageValidationUI.class);
541 validator.setBean(model);
542 }
543
544 protected void createBroker() {
545 $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
546 }
547
548 protected void createDeletePhotoButton() {
549 $objectMap.put("deletePhotoButton", deletePhotoButton = new JButton());
550
551 deletePhotoButton.setName("deletePhotoButton");
552 deletePhotoButton.setText(t("reefdb.common.delete"));
553 deletePhotoButton.setToolTipText(t("reefdb.photo.delete.tip"));
554 deletePhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__deletePhotoButton"));
555 }
556
557 protected void createDownloadPhotoButton() {
558 $objectMap.put("downloadPhotoButton", downloadPhotoButton = new JButton());
559
560 downloadPhotoButton.setName("downloadPhotoButton");
561 downloadPhotoButton.setText(t("reefdb.photo.download"));
562 downloadPhotoButton.setToolTipText(t("reefdb.photo.download.tip"));
563 downloadPhotoButton.putClientProperty("applicationAction", DownloadAction.class);
564 }
565
566 protected void createExportPhotoButton() {
567 $objectMap.put("exportPhotoButton", exportPhotoButton = new JButton());
568
569 exportPhotoButton.setName("exportPhotoButton");
570 exportPhotoButton.setText(t("reefdb.common.export"));
571 exportPhotoButton.setToolTipText(t("reefdb.photo.export.tip"));
572 exportPhotoButton.putClientProperty("applicationAction", ExportAction.class);
573 }
574
575 protected void createFirstPhotoButton() {
576 $objectMap.put("firstPhotoButton", firstPhotoButton = new JButton());
577
578 firstPhotoButton.setName("firstPhotoButton");
579 firstPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__firstPhotoButton"));
580 }
581
582 protected void createFullScreenButton() {
583 $objectMap.put("fullScreenButton", fullScreenButton = new JButton());
584
585 fullScreenButton.setName("fullScreenButton");
586 fullScreenButton.setText(t("reefdb.photo.type.fullScreen"));
587 fullScreenButton.setToolTipText(t("reefdb.photo.type.fullScreen.tip"));
588 fullScreenButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__fullScreenButton"));
589 }
590
591 protected PhotosTabUIHandler createHandler() {
592 return new PhotosTabUIHandler();
593 }
594
595 protected void createImportPhotoButton() {
596 $objectMap.put("importPhotoButton", importPhotoButton = new JButton());
597
598 importPhotoButton.setName("importPhotoButton");
599 importPhotoButton.setText(t("reefdb.common.import"));
600 importPhotoButton.setToolTipText(t("reefdb.photo.import.tip"));
601 importPhotoButton.putClientProperty("applicationAction", ImportAction.class);
602 }
603
604 protected void createLastPhotoButton() {
605 $objectMap.put("lastPhotoButton", lastPhotoButton = new JButton());
606
607 lastPhotoButton.setName("lastPhotoButton");
608 lastPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__lastPhotoButton"));
609 }
610
611 protected void createModel() {
612 $objectMap.put("model", model = getContextValue(PhotosTabUIModel.class));
613 }
614
615 protected void createNextPhotoButton() {
616 $objectMap.put("nextPhotoButton", nextPhotoButton = new JButton());
617
618 nextPhotoButton.setName("nextPhotoButton");
619 nextPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__nextPhotoButton"));
620 }
621
622 protected void createPhotoBlockLayer() {
623 $objectMap.put("photoBlockLayer", photoBlockLayer = new WaitBlockingLayerUI());
624 }
625
626 protected void createPhotoIndexLabel() {
627 $objectMap.put("photoIndexLabel", photoIndexLabel = new JLabel());
628
629 photoIndexLabel.setName("photoIndexLabel");
630 }
631
632 protected void createPhotoTable() {
633 $objectMap.put("photoTable", photoTable = new SwingTable());
634
635 photoTable.setName("photoTable");
636 }
637
638 protected void createPhotoTablePanel() {
639 $objectMap.put("photoTablePanel", photoTablePanel = new JPanel());
640
641 photoTablePanel.setName("photoTablePanel");
642 photoTablePanel.setLayout(new BorderLayout());
643 photoTablePanel.putClientProperty("validatorLabel", t("reefdb.photo.table"));
644 }
645
646 protected void createPhotoViewer() {
647 $objectMap.put("photoViewer", photoViewer = new PhotoViewer<PhotosTableRowModel>());
648
649 photoViewer.setName("photoViewer");
650 }
651
652 protected void createPreviousPhotoButton() {
653 $objectMap.put("previousPhotoButton", previousPhotoButton = new JButton());
654
655 previousPhotoButton.setName("previousPhotoButton");
656 previousPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__previousPhotoButton"));
657 }
658
659 protected void createTypeDiaporamaComboBox() {
660 $objectMap.put("typeDiaporamaComboBox", typeDiaporamaComboBox = new EnumValueComboBox<PhotoViewType>(PhotoViewType.class));
661
662 typeDiaporamaComboBox.setName("typeDiaporamaComboBox");
663 }
664
665 protected void createTypeDiaporamaLabel() {
666 $objectMap.put("typeDiaporamaLabel", typeDiaporamaLabel = new JLabel());
667
668 typeDiaporamaLabel.setName("typeDiaporamaLabel");
669 typeDiaporamaLabel.setText(t("reefdb.photo.type.label"));
670 }
671
672 protected void createValidator() {
673 $objectMap.put("validator", validator = SwingValidator.newValidator(PhotosTabUIModel.class, null));
674 }
675
676
677
678
679
680 private void $completeSetup() {
681 allComponentsCreated = true;
682 if (log.isDebugEnabled()) {
683 log.debug(this);
684 }
685 addChildrenToPhotoTabUI();
686 addChildrenToValidator();
687
688 $JPanel0.add(SwingUtil.boxComponentWithJxLayer(photoViewer), BorderLayout.CENTER);
689 $JPanel0.add($JPanel1, BorderLayout.PAGE_END);
690
691 $JPanel1.add(firstPhotoButton);
692 $JPanel1.add(previousPhotoButton);
693 $JPanel1.add(photoIndexLabel);
694 $JPanel1.add(nextPhotoButton);
695 $JPanel1.add(lastPhotoButton);
696 $JPanel1.add(typeDiaporamaLabel);
697 $JPanel1.add(typeDiaporamaComboBox);
698 $JPanel1.add(fullScreenButton);
699 addChildrenToPhotoTablePanel();
700
701 $JScrollPane0.getViewport().add(photoTable);
702
703 $JPanel2.add($JPanel3, BorderLayout.LINE_START);
704 $JPanel2.add($JPanel4, BorderLayout.LINE_END);
705
706 $JPanel3.add(importPhotoButton);
707 $JPanel3.add(downloadPhotoButton);
708 $JPanel3.add(deletePhotoButton);
709
710 $JPanel4.add(exportPhotoButton);
711
712
713 JAXXUtil.applyDataBinding(this, $bindings.keySet());
714
715
716 importPhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
717 downloadPhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
718 deletePhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
719 exportPhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
720 photoBlockLayer.setBlockingColor(handler.getConfig().getColorBlockingLayer());
721 firstPhotoButton.setIcon(SwingUtil.createActionIcon("premier"));
722 previousPhotoButton.setIcon(SwingUtil.createActionIcon("precedent"));
723 nextPhotoButton.setIcon(SwingUtil.createActionIcon("suivant"));
724 lastPhotoButton.setIcon(SwingUtil.createActionIcon("dernier"));
725 typeDiaporamaLabel.setLabelFor(typeDiaporamaComboBox);
726 fullScreenButton.setIcon(SwingUtil.createActionIcon("fullScreen"));
727 photoTablePanel.setBorder(BorderFactory.createTitledBorder(t("reefdb.photo.table")));
728 importPhotoButton.setIcon(SwingUtil.createActionIcon("import"));
729 downloadPhotoButton.setIcon(SwingUtil.createActionIcon("synchro-import"));
730 deletePhotoButton.setIcon(SwingUtil.createActionIcon("delete"));
731 exportPhotoButton.setIcon(SwingUtil.createActionIcon("export"));
732
733
734 validatorIds = SwingValidatorUtil.detectValidators(this);
735 SwingValidatorUtil.installUI(this);
736 }
737
738 private void $initialize() {
739 if (allComponentsCreated) {
740 return;
741 }
742 if (log.isDebugEnabled()) {
743 log.debug(this);
744 }
745 handler.beforeInit(this);
746 $objectMap.put("photoTabUI", photoTabUI);
747 createModel();
748 createBroker();
749 createValidator();
750 createPhotoBlockLayer();
751
752 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
753
754 $JPanel0.setName("$JPanel0");
755 $JPanel0.setLayout(new BorderLayout());
756 createPhotoViewer();
757
758 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
759
760 $JPanel1.setName("$JPanel1");
761 createFirstPhotoButton();
762 createPreviousPhotoButton();
763 createPhotoIndexLabel();
764 createNextPhotoButton();
765 createLastPhotoButton();
766 createTypeDiaporamaLabel();
767 createTypeDiaporamaComboBox();
768 createFullScreenButton();
769 createPhotoTablePanel();
770
771 $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
772
773 $JScrollPane0.setName("$JScrollPane0");
774 createPhotoTable();
775
776 $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
777
778 $JPanel2.setName("$JPanel2");
779 $JPanel2.setLayout(new BorderLayout());
780
781 $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
782
783 $JPanel3.setName("$JPanel3");
784 createImportPhotoButton();
785 createDownloadPhotoButton();
786 createDeletePhotoButton();
787
788 $objectMap.put("$JPanel4", $JPanel4 = new JPanel());
789
790 $JPanel4.setName("$JPanel4");
791 createExportPhotoButton();
792
793 setName("photoTabUI");
794 setLayout(new BorderLayout());
795 photoTabUI.putClientProperty("panelType", ReefDbUI.EDITION_PANEL_TYPE);
796
797
798 $registerDefaultBindings();
799 $completeSetup();
800 handler.afterInit(this);
801 }
802
803 private void $registerDefaultBindings() {
804
805 registerDataBinding(new DefaultJAXXBinding(this, BINDING_PHOTO_BLOCK_LAYER_BLOCK, true) {
806
807 @Override
808 public void applyDataBinding() {
809 if (model != null) {
810 model.addPropertyChangeListener("loading", this);
811 }
812 }
813
814 @Override
815 public void processDataBinding() {
816 if (model != null) {
817 photoBlockLayer.setBlock(model.isLoading());
818 }
819 }
820
821 @Override
822 public void removeDataBinding() {
823 if (model != null) {
824 model.removePropertyChangeListener("loading", this);
825 }
826 }
827 });
828 registerDataBinding(new DefaultJAXXBinding(this, BINDING_IMPORT_PHOTO_BUTTON_ENABLED, true) {
829
830 @Override
831 public void applyDataBinding() {
832 if (model != null) {
833 model.addPropertyChangeListener("observationModel", this);
834 }
835 }
836
837 @Override
838 public void processDataBinding() {
839 if (model != null && model.getObservationModel() != null) {
840 importPhotoButton.setEnabled(model.getObservationModel().isEditable());
841 }
842 }
843
844 @Override
845 public void removeDataBinding() {
846 if (model != null) {
847 model.removePropertyChangeListener("observationModel", this);
848 }
849 }
850 });
851 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DOWNLOAD_PHOTO_BUTTON_ENABLED, true, true) {
852
853 @Override
854 public void applyDataBinding() {
855 if (model != null) {
856 model.addPropertyChangeListener("selectedRows", this);
857 }
858 if (model != null) {
859 model.addPropertyChangeListener("downloadEnabled", this);
860 }
861 }
862
863 @Override
864 public void processDataBinding() {
865 if (model != null && model.getSelectedRows() != null) {
866 downloadPhotoButton.setEnabled(!model.getSelectedRows().isEmpty() && model.isDownloadEnabled());
867 }
868 }
869
870 @Override
871 public void removeDataBinding() {
872 if (model != null) {
873 model.removePropertyChangeListener("selectedRows", this);
874 }
875 if (model != null) {
876 model.removePropertyChangeListener("downloadEnabled", this);
877 }
878 }
879 });
880 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DELETE_PHOTO_BUTTON_ENABLED, true, true) {
881
882 @Override
883 public void applyDataBinding() {
884 if (model != null) {
885 model.addPropertyChangeListener("observationModel", this);
886 }
887 if (model != null) {
888 model.addPropertyChangeListener("selectedRows", this);
889 }
890 }
891
892 @Override
893 public void processDataBinding() {
894 if (model != null && model.getSelectedRows() != null && model.getObservationModel() != null) {
895 deletePhotoButton.setEnabled(model.getObservationModel().isEditable() && !model.getSelectedRows().isEmpty());
896 }
897 }
898
899 @Override
900 public void removeDataBinding() {
901 if (model != null) {
902 model.removePropertyChangeListener("observationModel", this);
903 }
904 if (model != null) {
905 model.removePropertyChangeListener("selectedRows", this);
906 }
907 }
908 });
909 registerDataBinding(new DefaultJAXXBinding(this, BINDING_EXPORT_PHOTO_BUTTON_ENABLED, true, true) {
910
911 @Override
912 public void applyDataBinding() {
913 if (model != null) {
914 model.addPropertyChangeListener("selectedRows", this);
915 }
916 if (model != null) {
917 model.addPropertyChangeListener("exportEnabled", this);
918 }
919 }
920
921 @Override
922 public void processDataBinding() {
923 if (model != null && model.getSelectedRows() != null) {
924 exportPhotoButton.setEnabled(!model.getSelectedRows().isEmpty() && model.isExportEnabled());
925 }
926 }
927
928 @Override
929 public void removeDataBinding() {
930 if (model != null) {
931 model.removePropertyChangeListener("selectedRows", this);
932 }
933 if (model != null) {
934 model.removePropertyChangeListener("exportEnabled", this);
935 }
936 }
937 });
938 }
939
940 }