1 package fr.ifremer.dali.ui.swing.content.observation.photo;
2
3 import fr.ifremer.dali.ui.swing.DaliHelpBroker;
4 import fr.ifremer.dali.ui.swing.DaliUIContext;
5 import fr.ifremer.dali.ui.swing.util.DaliUI;
6 import fr.ifremer.dali.ui.swing.util.image.PhotoViewer;
7 import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
8 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
9 import fr.ifremer.quadrige3.ui.swing.component.EnumValueComboBox;
10 import fr.ifremer.quadrige3.ui.swing.plaf.WaitBlockingLayerUI;
11 import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
12 import java.awt.BorderLayout;
13 import java.awt.Component;
14 import java.awt.Container;
15 import java.awt.LayoutManager;
16 import java.awt.event.ActionEvent;
17 import java.awt.event.ActionListener;
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22 import java.util.TreeMap;
23 import javax.swing.BorderFactory;
24 import javax.swing.Box;
25 import javax.swing.BoxLayout;
26 import javax.swing.JButton;
27 import javax.swing.JLabel;
28 import javax.swing.JPanel;
29 import javax.swing.JScrollPane;
30 import jaxx.runtime.JAXXBinding;
31 import jaxx.runtime.JAXXContext;
32 import jaxx.runtime.JAXXObject;
33 import jaxx.runtime.JAXXObjectDescriptor;
34 import jaxx.runtime.JAXXUtil;
35 import jaxx.runtime.JAXXValidator;
36 import jaxx.runtime.SwingUtil;
37 import jaxx.runtime.binding.DefaultJAXXBinding;
38 import jaxx.runtime.context.DefaultJAXXContext;
39 import jaxx.runtime.swing.help.JAXXHelpUI;
40 import jaxx.runtime.validator.swing.SwingValidator;
41 import jaxx.runtime.validator.swing.SwingValidatorUtil;
42 import jaxx.runtime.validator.swing.meta.Validator;
43 import jaxx.runtime.validator.swing.meta.ValidatorField;
44 import jaxx.runtime.validator.swing.ui.ImageValidationUI;
45 import org.apache.commons.logging.Log;
46 import org.apache.commons.logging.LogFactory;
47 import org.jdesktop.swingx.JXImageView;
48 import org.jdesktop.swingx.JXList;
49 import static org.nuiton.i18n.I18n.t;
50
51 public class PhotosTabUI extends JPanel implements JAXXHelpUI<DaliHelpBroker>, DaliUI<PhotosTabUIModel, PhotosTabUIHandler>, JAXXObject, JAXXValidator {
52
53
54
55
56
57 public static final String BINDING_DELETE_PHOTO_BUTTON_ENABLED = "deletePhotoButton.enabled";
58 public static final String BINDING_DOWNLOAD_PHOTO_BUTTON_ENABLED = "downloadPhotoButton.enabled";
59 public static final String BINDING_EXPORT_PHOTO_BUTTON_ENABLED = "exportPhotoButton.enabled";
60 public static final String BINDING_IMPORT_PHOTO_BUTTON_ENABLED = "importPhotoButton.enabled";
61 public static final String BINDING_PHOTO_BLOCK_LAYER_BLOCK = "photoBlockLayer.block";
62
63
64
65
66
67 private static final String $jaxxObjectDescriptor = "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";
68 private static final Log log = LogFactory.getLog(PhotosTabUI.class);
69 private static final long serialVersionUID = 1L;
70
71
72
73
74
75 protected List<Object> $activeBindings = new ArrayList<Object>();
76 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
77 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
78 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
79 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
80 private boolean allComponentsCreated;
81 protected final JAXXContext delegateContext = new DefaultJAXXContext();
82
83
84
85
86
87 protected DaliHelpBroker broker;
88 protected JButton deletePhotoButton;
89 protected JButton downloadPhotoButton;
90 protected JButton exportPhotoButton;
91 protected JButton firstPhotoButton;
92 protected JButton fullScreenButton;
93 protected final PhotosTabUIHandler handler = createHandler();
94 protected JButton importPhotoButton;
95 protected JButton lastPhotoButton;
96 protected PhotosTabUIModel model;
97 protected JButton nextPhotoButton;
98 protected WaitBlockingLayerUI photoBlockLayer;
99 protected JLabel photoIndexLabel;
100 protected PhotosTabUI photoTabUI = this;
101 protected SwingTable photoTable;
102 @ValidatorField( validatorId = "validator", propertyName = "instance", editorName = "photoTablePanel")
103 protected JPanel photoTablePanel;
104 protected PhotoViewer<PhotosTableRowModel> photoViewer;
105 protected JButton previousPhotoButton;
106 protected EnumValueComboBox<PhotoViewType> typeDiaporamaComboBox;
107 protected JLabel typeDiaporamaLabel;
108 @Validator( validatorId = "validator")
109 protected SwingValidator<PhotosTabUIModel> validator;
110 protected List<String> validatorIds = new ArrayList<String>();
111
112
113
114
115
116 private JPanel $JPanel0;
117 private JPanel $JPanel1;
118 private JPanel $JPanel2;
119 private JPanel $JPanel3;
120 private JPanel $JPanel4;
121 private JScrollPane $JScrollPane0;
122
123
124
125
126
127 public PhotosTabUI(ApplicationUI parentUI) {
128 ApplicationUIUtil.setParentUI(this, parentUI);
129 $initialize();
130 }
131
132 public PhotosTabUI() {
133 $initialize();
134 }
135
136 public PhotosTabUI(JAXXContext parentContext) {
137 JAXXUtil.initContext(this, parentContext);
138 $initialize();
139 }
140
141 public PhotosTabUI(boolean param0) {
142 super(param0);
143 $initialize();
144 }
145
146 public PhotosTabUI(JAXXContext parentContext, boolean param1) {
147 super(param1);
148 JAXXUtil.initContext(this, parentContext);
149 $initialize();
150 }
151
152 public PhotosTabUI(LayoutManager param0) {
153 super(param0);
154 $initialize();
155 }
156
157 public PhotosTabUI(JAXXContext parentContext, LayoutManager param1) {
158 super(param1);
159 JAXXUtil.initContext(this, parentContext);
160 $initialize();
161 }
162
163 public PhotosTabUI(LayoutManager param0, boolean param1) {
164 super(param0 ,param1);
165 $initialize();
166 }
167
168 public PhotosTabUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
169 super(param1 ,param2);
170 JAXXUtil.initContext(this, parentContext);
171 $initialize();
172 }
173
174
175
176
177
178 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
179 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
180 }
181
182
183
184
185
186 @Override
187 public void applyDataBinding(String $binding) {
188 if (allComponentsCreated && $bindings.containsKey($binding)) {
189 getDataBinding($binding).applyDataBinding();
190 }
191 processDataBinding($binding);
192 }
193
194 @Override
195 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
196 super.firePropertyChange(propertyName, oldValue, newValue);
197 }
198
199 @Override
200 public Map<String, Object> get$objectMap() {
201 return $objectMap;
202 }
203
204 @Override
205 public JAXXBinding getDataBinding(String bindingId) {
206 return $bindings.get(bindingId);
207 }
208
209 @Override
210 public JAXXBinding[] getDataBindings() {
211 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
212 }
213
214 @Override
215 public Object getObjectById(String id) {
216 return $objectMap.get(id);
217 }
218
219 @Override
220 public void processDataBinding(String $binding, boolean $force) {
221 if (!$force && $activeBindings.contains($binding)) {
222 return;
223 }
224 $activeBindings.add($binding);
225 try {
226 if (allComponentsCreated && $bindings.containsKey($binding)) {
227 getDataBinding($binding).processDataBinding();
228 }
229 } finally {
230 $activeBindings.remove($binding);
231 }
232 }
233
234 @Override
235 public void processDataBinding(String $binding) {
236 processDataBinding($binding, false);
237 }
238
239 @Override
240 public void registerDataBinding(JAXXBinding binding) {
241 $bindings.put(binding.getId(), binding);
242 }
243
244 @Override
245 public void removeDataBinding(String $binding) {
246 if (allComponentsCreated && $bindings.containsKey($binding)) {
247 getDataBinding($binding).removeDataBinding();
248 }
249 }
250
251
252
253
254
255 @Override
256 public <T> T getContextValue(Class<T> clazz) {
257 return delegateContext.getContextValue(clazz, null);
258 }
259
260 @Override
261 public <T> T getContextValue(Class<T> clazz, String name) {
262 return delegateContext.getContextValue(clazz, name);
263 }
264
265 @Override
266 public JAXXContext getDelegateContext() {
267 return delegateContext;
268 }
269
270 @Override
271 public <O extends Container> O getParentContainer(Class<O> clazz) {
272 return SwingUtil.getParentContainer(this, clazz);
273 }
274
275 @Override
276 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
277 return SwingUtil.getParentContainer(source, clazz);
278 }
279
280 @Override
281 public <T> void removeContextValue(Class<T> clazz) {
282 delegateContext.removeContextValue(clazz, null);
283 }
284
285 @Override
286 public <T> void removeContextValue(Class<T> clazz, String name) {
287 delegateContext.removeContextValue(clazz, name);
288 }
289
290 @Override
291 public <T> void setContextValue(T o) {
292 delegateContext.setContextValue(o, null);
293 }
294
295 @Override
296 public <T> void setContextValue(T o, String name) {
297 delegateContext.setContextValue(o, name);
298 }
299
300
301
302
303
304 @Override
305 public SwingValidator<?> getValidator(String validatorId) {
306 return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
307 }
308
309 @Override
310 public List<String> getValidatorIds() {
311 return validatorIds;
312 }
313
314 @Override
315 public void registerValidatorFields() {
316 SwingValidatorUtil.detectValidatorFields(this);
317 }
318
319
320
321
322
323 public void doActionPerformed__on__deletePhotoButton(ActionEvent event) {
324 if (log.isDebugEnabled()) {
325 log.debug(event);
326 }
327 handler.removePhoto();
328 }
329
330 public void doActionPerformed__on__firstPhotoButton(ActionEvent event) {
331 if (log.isDebugEnabled()) {
332 log.debug(event);
333 }
334 handler.firstPhoto();
335 }
336
337 public void doActionPerformed__on__fullScreenButton(ActionEvent event) {
338 if (log.isDebugEnabled()) {
339 log.debug(event);
340 }
341 handler.fullScreen();
342 }
343
344 public void doActionPerformed__on__lastPhotoButton(ActionEvent event) {
345 if (log.isDebugEnabled()) {
346 log.debug(event);
347 }
348 handler.lastPhoto();
349 }
350
351 public void doActionPerformed__on__nextPhotoButton(ActionEvent event) {
352 if (log.isDebugEnabled()) {
353 log.debug(event);
354 }
355 handler.nextPhoto();
356 }
357
358 public void doActionPerformed__on__previousPhotoButton(ActionEvent event) {
359 if (log.isDebugEnabled()) {
360 log.debug(event);
361 }
362 handler.previousPhoto();
363 }
364
365
366
367
368
369 public DaliHelpBroker getBroker() {
370 return broker;
371 }
372
373 public JButton getDeletePhotoButton() {
374 return deletePhotoButton;
375 }
376
377 public JButton getDownloadPhotoButton() {
378 return downloadPhotoButton;
379 }
380
381 public JButton getExportPhotoButton() {
382 return exportPhotoButton;
383 }
384
385 public JButton getFirstPhotoButton() {
386 return firstPhotoButton;
387 }
388
389 public JButton getFullScreenButton() {
390 return fullScreenButton;
391 }
392
393 public PhotosTabUIHandler getHandler() {
394 return handler;
395 }
396
397 public JButton getImportPhotoButton() {
398 return importPhotoButton;
399 }
400
401 public JButton getLastPhotoButton() {
402 return lastPhotoButton;
403 }
404
405 public PhotosTabUIModel getModel() {
406 return model;
407 }
408
409 public JButton getNextPhotoButton() {
410 return nextPhotoButton;
411 }
412
413 public WaitBlockingLayerUI getPhotoBlockLayer() {
414 return photoBlockLayer;
415 }
416
417 public JLabel getPhotoIndexLabel() {
418 return photoIndexLabel;
419 }
420
421 public SwingTable getPhotoTable() {
422 return photoTable;
423 }
424
425 public JPanel getPhotoTablePanel() {
426 return photoTablePanel;
427 }
428
429 public PhotoViewer<PhotosTableRowModel> getPhotoViewer() {
430 return photoViewer;
431 }
432
433 public JButton getPreviousPhotoButton() {
434 return previousPhotoButton;
435 }
436
437 public EnumValueComboBox<PhotoViewType> getTypeDiaporamaComboBox() {
438 return typeDiaporamaComboBox;
439 }
440
441 public JLabel getTypeDiaporamaLabel() {
442 return typeDiaporamaLabel;
443 }
444
445 public SwingValidator<PhotosTabUIModel> getValidator() {
446 return validator;
447 }
448
449
450
451
452
453 @Override
454 public void registerHelpId(DaliHelpBroker broker, Component component, String helpId) {
455 broker.installUI(component, helpId);
456 }
457
458 @Override
459 public void showHelp(String helpId) {
460 getBroker().showHelp(this, helpId);
461 }
462
463
464
465
466
467 protected JPanel get$JPanel0() {
468 return $JPanel0;
469 }
470
471 protected JPanel get$JPanel1() {
472 return $JPanel1;
473 }
474
475 protected JPanel get$JPanel2() {
476 return $JPanel2;
477 }
478
479 protected JPanel get$JPanel3() {
480 return $JPanel3;
481 }
482
483 protected JPanel get$JPanel4() {
484 return $JPanel4;
485 }
486
487 protected JScrollPane get$JScrollPane0() {
488 return $JScrollPane0;
489 }
490
491
492
493
494
495 protected void addChildrenToPhotoTabUI() {
496 if (!allComponentsCreated) {
497 return;
498 }
499 add($JPanel0, BorderLayout.CENTER);
500 add(SwingUtil.boxComponentWithJxLayer(photoTablePanel), BorderLayout.PAGE_END);
501 }
502
503 protected void addChildrenToPhotoTablePanel() {
504 if (!allComponentsCreated) {
505 return;
506 }
507 photoTablePanel.add($JScrollPane0, BorderLayout.CENTER);
508 photoTablePanel.add($JPanel2, BorderLayout.PAGE_END);
509 }
510
511 protected void addChildrenToValidator() {
512 if (!allComponentsCreated) {
513 return;
514 }
515 validator.setUiClass(ImageValidationUI.class);
516 validator.setBean(model);
517 }
518
519 protected void createBroker() {
520 $objectMap.put("broker", broker = new DaliHelpBroker("dali.home.help"));
521 }
522
523 protected void createDeletePhotoButton() {
524 $objectMap.put("deletePhotoButton", deletePhotoButton = new JButton());
525
526 deletePhotoButton.setName("deletePhotoButton");
527 deletePhotoButton.setText(t("dali.common.delete"));
528 deletePhotoButton.setToolTipText(t("dali.photo.delete.tip"));
529 deletePhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__deletePhotoButton"));
530 }
531
532 protected void createDownloadPhotoButton() {
533 $objectMap.put("downloadPhotoButton", downloadPhotoButton = new JButton());
534
535 downloadPhotoButton.setName("downloadPhotoButton");
536 downloadPhotoButton.setText(t("dali.photo.download"));
537 downloadPhotoButton.setToolTipText(t("dali.photo.download.tip"));
538 downloadPhotoButton.putClientProperty("applicationAction", DownloadAction.class);
539 }
540
541 protected void createExportPhotoButton() {
542 $objectMap.put("exportPhotoButton", exportPhotoButton = new JButton());
543
544 exportPhotoButton.setName("exportPhotoButton");
545 exportPhotoButton.setText(t("dali.common.export"));
546 exportPhotoButton.setToolTipText(t("dali.photo.export.tip"));
547 exportPhotoButton.putClientProperty("applicationAction", ExportAction.class);
548 }
549
550 protected void createFirstPhotoButton() {
551 $objectMap.put("firstPhotoButton", firstPhotoButton = new JButton());
552
553 firstPhotoButton.setName("firstPhotoButton");
554 firstPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__firstPhotoButton"));
555 }
556
557 protected void createFullScreenButton() {
558 $objectMap.put("fullScreenButton", fullScreenButton = new JButton());
559
560 fullScreenButton.setName("fullScreenButton");
561 fullScreenButton.setText(t("dali.photo.type.fullScreen"));
562 fullScreenButton.setToolTipText(t("dali.photo.type.fullScreen.tip"));
563 fullScreenButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__fullScreenButton"));
564 }
565
566 protected PhotosTabUIHandler createHandler() {
567 return new PhotosTabUIHandler();
568 }
569
570 protected void createImportPhotoButton() {
571 $objectMap.put("importPhotoButton", importPhotoButton = new JButton());
572
573 importPhotoButton.setName("importPhotoButton");
574 importPhotoButton.setText(t("dali.common.import"));
575 importPhotoButton.setToolTipText(t("dali.photo.import.tip"));
576 importPhotoButton.putClientProperty("applicationAction", ImportAction.class);
577 }
578
579 protected void createLastPhotoButton() {
580 $objectMap.put("lastPhotoButton", lastPhotoButton = new JButton());
581
582 lastPhotoButton.setName("lastPhotoButton");
583 lastPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__lastPhotoButton"));
584 }
585
586 protected void createModel() {
587 $objectMap.put("model", model = getContextValue(PhotosTabUIModel.class));
588 }
589
590 protected void createNextPhotoButton() {
591 $objectMap.put("nextPhotoButton", nextPhotoButton = new JButton());
592
593 nextPhotoButton.setName("nextPhotoButton");
594 nextPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__nextPhotoButton"));
595 }
596
597 protected void createPhotoBlockLayer() {
598 $objectMap.put("photoBlockLayer", photoBlockLayer = new WaitBlockingLayerUI());
599 }
600
601 protected void createPhotoIndexLabel() {
602 $objectMap.put("photoIndexLabel", photoIndexLabel = new JLabel());
603
604 photoIndexLabel.setName("photoIndexLabel");
605 }
606
607 protected void createPhotoTable() {
608 $objectMap.put("photoTable", photoTable = new SwingTable());
609
610 photoTable.setName("photoTable");
611 }
612
613 protected void createPhotoTablePanel() {
614 $objectMap.put("photoTablePanel", photoTablePanel = new JPanel());
615
616 photoTablePanel.setName("photoTablePanel");
617 photoTablePanel.setLayout(new BorderLayout());
618 photoTablePanel.putClientProperty("validatorLabel", t("dali.photo.table"));
619 }
620
621 protected void createPhotoViewer() {
622 $objectMap.put("photoViewer", photoViewer = new PhotoViewer<PhotosTableRowModel>());
623
624 photoViewer.setName("photoViewer");
625 }
626
627 protected void createPreviousPhotoButton() {
628 $objectMap.put("previousPhotoButton", previousPhotoButton = new JButton());
629
630 previousPhotoButton.setName("previousPhotoButton");
631 previousPhotoButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__previousPhotoButton"));
632 }
633
634 protected void createTypeDiaporamaComboBox() {
635 $objectMap.put("typeDiaporamaComboBox", typeDiaporamaComboBox = new EnumValueComboBox<PhotoViewType>(PhotoViewType.class));
636
637 typeDiaporamaComboBox.setName("typeDiaporamaComboBox");
638 }
639
640 protected void createTypeDiaporamaLabel() {
641 $objectMap.put("typeDiaporamaLabel", typeDiaporamaLabel = new JLabel());
642
643 typeDiaporamaLabel.setName("typeDiaporamaLabel");
644 typeDiaporamaLabel.setText(t("dali.photo.type.label"));
645 }
646
647 protected void createValidator() {
648 $objectMap.put("validator", validator = SwingValidator.newValidator(PhotosTabUIModel.class, null));
649 }
650
651
652
653
654
655 private void $completeSetup() {
656 allComponentsCreated = true;
657 if (log.isDebugEnabled()) {
658 log.debug(this);
659 }
660 addChildrenToPhotoTabUI();
661 addChildrenToValidator();
662
663 $JPanel0.add(SwingUtil.boxComponentWithJxLayer(photoViewer), BorderLayout.CENTER);
664 $JPanel0.add($JPanel1, BorderLayout.PAGE_END);
665
666 $JPanel1.add(firstPhotoButton);
667 $JPanel1.add(previousPhotoButton);
668 $JPanel1.add(photoIndexLabel);
669 $JPanel1.add(nextPhotoButton);
670 $JPanel1.add(lastPhotoButton);
671 $JPanel1.add(typeDiaporamaLabel);
672 $JPanel1.add(typeDiaporamaComboBox);
673 $JPanel1.add(fullScreenButton);
674 addChildrenToPhotoTablePanel();
675
676 $JScrollPane0.getViewport().add(photoTable);
677
678 $JPanel2.add($JPanel3, BorderLayout.LINE_START);
679 $JPanel2.add($JPanel4, BorderLayout.LINE_END);
680
681 $JPanel3.add(importPhotoButton);
682 $JPanel3.add(downloadPhotoButton);
683 $JPanel3.add(deletePhotoButton);
684
685 $JPanel4.add(exportPhotoButton);
686
687
688 JAXXUtil.applyDataBinding(this, $bindings.keySet());
689
690
691 importPhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
692 downloadPhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
693 deletePhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
694 exportPhotoButton.setAlignmentX(Component.CENTER_ALIGNMENT);
695 photoBlockLayer.setBlockingColor(handler.getConfig().getColorBlockingLayer());
696 firstPhotoButton.setIcon(SwingUtil.createActionIcon("premier"));
697 previousPhotoButton.setIcon(SwingUtil.createActionIcon("precedent"));
698 nextPhotoButton.setIcon(SwingUtil.createActionIcon("suivant"));
699 lastPhotoButton.setIcon(SwingUtil.createActionIcon("dernier"));
700 typeDiaporamaLabel.setLabelFor(typeDiaporamaComboBox);
701 fullScreenButton.setIcon(SwingUtil.createActionIcon("fullScreen"));
702 photoTablePanel.setBorder(BorderFactory.createTitledBorder(t("dali.photo.table")));
703 importPhotoButton.setIcon(SwingUtil.createActionIcon("import"));
704 downloadPhotoButton.setIcon(SwingUtil.createActionIcon("synchro-import"));
705 deletePhotoButton.setIcon(SwingUtil.createActionIcon("delete"));
706 exportPhotoButton.setIcon(SwingUtil.createActionIcon("export"));
707
708
709 validatorIds = SwingValidatorUtil.detectValidators(this);
710 SwingValidatorUtil.installUI(this);
711 }
712
713 private void $initialize() {
714 if (allComponentsCreated) {
715 return;
716 }
717 if (log.isDebugEnabled()) {
718 log.debug(this);
719 }
720 handler.beforeInit(this);
721 $objectMap.put("photoTabUI", photoTabUI);
722 createModel();
723 createBroker();
724 createValidator();
725 createPhotoBlockLayer();
726
727 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
728
729 $JPanel0.setName("$JPanel0");
730 $JPanel0.setLayout(new BorderLayout());
731 createPhotoViewer();
732
733 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
734
735 $JPanel1.setName("$JPanel1");
736 createFirstPhotoButton();
737 createPreviousPhotoButton();
738 createPhotoIndexLabel();
739 createNextPhotoButton();
740 createLastPhotoButton();
741 createTypeDiaporamaLabel();
742 createTypeDiaporamaComboBox();
743 createFullScreenButton();
744 createPhotoTablePanel();
745
746 $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
747
748 $JScrollPane0.setName("$JScrollPane0");
749 createPhotoTable();
750
751 $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
752
753 $JPanel2.setName("$JPanel2");
754 $JPanel2.setLayout(new BorderLayout());
755
756 $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
757
758 $JPanel3.setName("$JPanel3");
759 createImportPhotoButton();
760 createDownloadPhotoButton();
761 createDeletePhotoButton();
762
763 $objectMap.put("$JPanel4", $JPanel4 = new JPanel());
764
765 $JPanel4.setName("$JPanel4");
766 createExportPhotoButton();
767
768 setName("photoTabUI");
769 setLayout(new BorderLayout());
770 photoTabUI.putClientProperty("panelType", DaliUI.EDITION_PANEL_TYPE);
771
772
773 $registerDefaultBindings();
774 $completeSetup();
775 handler.afterInit(this);
776 }
777
778 private void $registerDefaultBindings() {
779
780 registerDataBinding(new DefaultJAXXBinding(this, BINDING_PHOTO_BLOCK_LAYER_BLOCK, true) {
781
782 @Override
783 public void applyDataBinding() {
784 if (model != null) {
785 model.addPropertyChangeListener("loading", this);
786 }
787 }
788
789 @Override
790 public void processDataBinding() {
791 if (model != null) {
792 photoBlockLayer.setBlock(model.isLoading());
793 }
794 }
795
796 @Override
797 public void removeDataBinding() {
798 if (model != null) {
799 model.removePropertyChangeListener("loading", this);
800 }
801 }
802 });
803 registerDataBinding(new DefaultJAXXBinding(this, BINDING_IMPORT_PHOTO_BUTTON_ENABLED, true) {
804
805 @Override
806 public void applyDataBinding() {
807 if (model != null) {
808 model.addPropertyChangeListener("observationModel", this);
809 }
810 }
811
812 @Override
813 public void processDataBinding() {
814 if (model != null && model.getObservationModel() != null) {
815 importPhotoButton.setEnabled(model.getObservationModel().isEditable());
816 }
817 }
818
819 @Override
820 public void removeDataBinding() {
821 if (model != null) {
822 model.removePropertyChangeListener("observationModel", this);
823 }
824 }
825 });
826 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DOWNLOAD_PHOTO_BUTTON_ENABLED, true, true) {
827
828 @Override
829 public void applyDataBinding() {
830 if (model != null) {
831 model.addPropertyChangeListener("selectedRows", this);
832 }
833 if (model != null) {
834 model.addPropertyChangeListener("downloadEnabled", this);
835 }
836 }
837
838 @Override
839 public void processDataBinding() {
840 if (model != null && model.getSelectedRows() != null) {
841 downloadPhotoButton.setEnabled(!model.getSelectedRows().isEmpty() && model.isDownloadEnabled());
842 }
843 }
844
845 @Override
846 public void removeDataBinding() {
847 if (model != null) {
848 model.removePropertyChangeListener("selectedRows", this);
849 }
850 if (model != null) {
851 model.removePropertyChangeListener("downloadEnabled", this);
852 }
853 }
854 });
855 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DELETE_PHOTO_BUTTON_ENABLED, true, true) {
856
857 @Override
858 public void applyDataBinding() {
859 if (model != null) {
860 model.addPropertyChangeListener("observationModel", this);
861 }
862 if (model != null) {
863 model.addPropertyChangeListener("selectedRows", this);
864 }
865 }
866
867 @Override
868 public void processDataBinding() {
869 if (model != null && model.getSelectedRows() != null && model.getObservationModel() != null) {
870 deletePhotoButton.setEnabled(model.getObservationModel().isEditable() && !model.getSelectedRows().isEmpty());
871 }
872 }
873
874 @Override
875 public void removeDataBinding() {
876 if (model != null) {
877 model.removePropertyChangeListener("observationModel", this);
878 }
879 if (model != null) {
880 model.removePropertyChangeListener("selectedRows", this);
881 }
882 }
883 });
884 registerDataBinding(new DefaultJAXXBinding(this, BINDING_EXPORT_PHOTO_BUTTON_ENABLED, true, true) {
885
886 @Override
887 public void applyDataBinding() {
888 if (model != null) {
889 model.addPropertyChangeListener("selectedRows", this);
890 }
891 if (model != null) {
892 model.addPropertyChangeListener("exportEnabled", this);
893 }
894 }
895
896 @Override
897 public void processDataBinding() {
898 if (model != null && model.getSelectedRows() != null) {
899 exportPhotoButton.setEnabled(!model.getSelectedRows().isEmpty() && model.isExportEnabled());
900 }
901 }
902
903 @Override
904 public void removeDataBinding() {
905 if (model != null) {
906 model.removePropertyChangeListener("selectedRows", this);
907 }
908 if (model != null) {
909 model.removePropertyChangeListener("exportEnabled", this);
910 }
911 }
912 });
913 }
914
915 }