1 package fr.ifremer.reefdb.ui.swing.content.home.survey;
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.table.SwingTable;
30 import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
31 import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
32 import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
33 import java.awt.BorderLayout;
34 import java.awt.Component;
35 import java.awt.Container;
36 import java.awt.FlowLayout;
37 import java.awt.LayoutManager;
38 import java.awt.event.ActionEvent;
39 import java.awt.event.ActionListener;
40 import java.awt.event.MouseEvent;
41 import java.awt.event.MouseListener;
42 import java.util.ArrayList;
43 import java.util.HashMap;
44 import java.util.List;
45 import java.util.Map;
46 import java.util.TreeMap;
47 import javax.swing.BorderFactory;
48 import javax.swing.JButton;
49 import javax.swing.JComboBox;
50 import javax.swing.JMenuItem;
51 import javax.swing.JPanel;
52 import javax.swing.JPopupMenu;
53 import javax.swing.JScrollPane;
54 import jaxx.runtime.JAXXBinding;
55 import jaxx.runtime.JAXXContext;
56 import jaxx.runtime.JAXXObject;
57 import jaxx.runtime.JAXXObjectDescriptor;
58 import jaxx.runtime.JAXXUtil;
59 import jaxx.runtime.SwingUtil;
60 import jaxx.runtime.binding.DefaultJAXXBinding;
61 import jaxx.runtime.context.DefaultJAXXContext;
62 import jaxx.runtime.swing.help.JAXXHelpUI;
63 import org.apache.commons.logging.Log;
64 import org.apache.commons.logging.LogFactory;
65 import static org.nuiton.i18n.I18n.t;
66
67 public class SurveysTableUI extends JPanel implements JAXXHelpUI<ReefDbHelpBroker>, ReefDbUI<SurveysTableUIModel, SurveysTableUIHandler>, JAXXObject {
68
69
70
71
72
73 public static final String BINDING_EDIT_GENERAL_OBSERVATION_ENABLED = "editGeneralObservation.enabled";
74 public static final String BINDING_NEXT_BUTTON_ENABLED = "nextButton.enabled";
75 public static final String BINDING_OBSERVATION_CHANGER_ETAT_COMBOBOX_ENABLED = "observationChangerEtatCombobox.enabled";
76 public static final String BINDING_OBSERVATION_DUPLIQUER_BOUTON_ENABLED = "observationDupliquerBouton.enabled";
77 public static final String BINDING_OBSERVATION_EDITER_COMBOBOX_ENABLED = "observationEditerCombobox.enabled";
78 public static final String BINDING_OBSERVATION_SUPPRIMER_BOUTON_ENABLED = "observationSupprimerBouton.enabled";
79
80
81
82
83
84 private static final String $jaxxObjectDescriptor = "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";
85 private static final Log log = LogFactory.getLog(SurveysTableUI.class);
86 private static final long serialVersionUID = 1L;
87
88
89
90
91
92 protected List<Object> $activeBindings = new ArrayList<Object>();
93 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
94 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
95 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
96 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
97 private boolean allComponentsCreated;
98 protected final JAXXContext delegateContext = new DefaultJAXXContext();
99
100
101
102
103
104 protected ReefDbHelpBroker broker;
105 protected JMenuItem editGeneralObservation;
106 protected final SurveysTableUIHandler handler = createHandler();
107 protected SurveysTableUIModel model;
108 protected JButton nextButton;
109 protected JButton observationChangerEtatBouton;
110 protected JComboBox observationChangerEtatCombobox;
111 protected JButton observationControlerBouton;
112 protected JButton observationDeValiderBouton;
113 protected JButton observationDupliquerBouton;
114 protected JButton observationEditerBouton;
115 protected JComboBox observationEditerCombobox;
116 protected JButton observationEditerGeneralBouton;
117 protected JButton observationEditerMesuresBouton;
118 protected JButton observationEditerPhotoBouton;
119 protected JButton observationNouveauBouton;
120 protected JButton observationSupprimerBouton;
121 protected JButton observationValiderBouton;
122 protected SurveysTableUI observationsPanel = this;
123 protected JPanel observationsPanelButtons;
124 protected SwingTable surveyTable;
125 protected JPopupMenu tablePopup;
126
127
128
129
130
131 private JPanel $JPanel0;
132 private JPanel $JPanel1;
133 private JScrollPane $JScrollPane0;
134
135
136
137
138
139 public SurveysTableUI(ApplicationUI parentUI) {
140 ApplicationUIUtil.setParentUI(this, parentUI);
141 $initialize();
142 }
143
144 public SurveysTableUI(LayoutManager param0, boolean param1) {
145 super(param0 ,param1);
146 $initialize();
147 }
148
149 public SurveysTableUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
150 super(param1 ,param2);
151 JAXXUtil.initContext(this, parentContext);
152 $initialize();
153 }
154
155 public SurveysTableUI(boolean param0) {
156 super(param0);
157 $initialize();
158 }
159
160 public SurveysTableUI(JAXXContext parentContext, boolean param1) {
161 super(param1);
162 JAXXUtil.initContext(this, parentContext);
163 $initialize();
164 }
165
166 public SurveysTableUI() {
167 $initialize();
168 }
169
170 public SurveysTableUI(JAXXContext parentContext) {
171 JAXXUtil.initContext(this, parentContext);
172 $initialize();
173 }
174
175 public SurveysTableUI(LayoutManager param0) {
176 super(param0);
177 $initialize();
178 }
179
180 public SurveysTableUI(JAXXContext parentContext, LayoutManager param1) {
181 super(param1);
182 JAXXUtil.initContext(this, parentContext);
183 $initialize();
184 }
185
186
187
188
189
190 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
191 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
192 }
193
194
195
196
197
198 @Override
199 public void applyDataBinding(String $binding) {
200 if (allComponentsCreated && $bindings.containsKey($binding)) {
201 getDataBinding($binding).applyDataBinding();
202 }
203 processDataBinding($binding);
204 }
205
206 @Override
207 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
208 super.firePropertyChange(propertyName, oldValue, newValue);
209 }
210
211 @Override
212 public Map<String, Object> get$objectMap() {
213 return $objectMap;
214 }
215
216 @Override
217 public JAXXBinding getDataBinding(String bindingId) {
218 return $bindings.get(bindingId);
219 }
220
221 @Override
222 public JAXXBinding[] getDataBindings() {
223 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
224 }
225
226 @Override
227 public Object getObjectById(String id) {
228 return $objectMap.get(id);
229 }
230
231 @Override
232 public void processDataBinding(String $binding, boolean $force) {
233 if (!$force && $activeBindings.contains($binding)) {
234 return;
235 }
236 $activeBindings.add($binding);
237 try {
238 if (allComponentsCreated && $bindings.containsKey($binding)) {
239 getDataBinding($binding).processDataBinding();
240 }
241 } finally {
242 $activeBindings.remove($binding);
243 }
244 }
245
246 @Override
247 public void processDataBinding(String $binding) {
248 processDataBinding($binding, false);
249 }
250
251 @Override
252 public void registerDataBinding(JAXXBinding binding) {
253 $bindings.put(binding.getId(), binding);
254 }
255
256 @Override
257 public void removeDataBinding(String $binding) {
258 if (allComponentsCreated && $bindings.containsKey($binding)) {
259 getDataBinding($binding).removeDataBinding();
260 }
261 }
262
263
264
265
266
267 @Override
268 public <T> T getContextValue(Class<T> clazz) {
269 return delegateContext.getContextValue(clazz, null);
270 }
271
272 @Override
273 public <T> T getContextValue(Class<T> clazz, String name) {
274 return delegateContext.getContextValue(clazz, name);
275 }
276
277 @Override
278 public JAXXContext getDelegateContext() {
279 return delegateContext;
280 }
281
282 @Override
283 public <O extends Container> O getParentContainer(Class<O> clazz) {
284 return SwingUtil.getParentContainer(this, clazz);
285 }
286
287 @Override
288 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
289 return SwingUtil.getParentContainer(source, clazz);
290 }
291
292 @Override
293 public <T> void removeContextValue(Class<T> clazz) {
294 delegateContext.removeContextValue(clazz, null);
295 }
296
297 @Override
298 public <T> void removeContextValue(Class<T> clazz, String name) {
299 delegateContext.removeContextValue(clazz, name);
300 }
301
302 @Override
303 public <T> void setContextValue(T o) {
304 delegateContext.setContextValue(o, null);
305 }
306
307 @Override
308 public <T> void setContextValue(T o, String name) {
309 delegateContext.setContextValue(o, name);
310 }
311
312
313
314
315
316 public void doActionPerformed__on__nextButton(ActionEvent event) {
317 if (log.isDebugEnabled()) {
318 log.debug(event);
319 }
320 handler.onNext();
321 }
322
323 public void doActionPerformed__on__observationNouveauBouton(ActionEvent event) {
324 if (log.isDebugEnabled()) {
325 log.debug(event);
326 }
327 model.addNewRow();
328 }
329
330 public void doMouseClicked__on__surveyTable(MouseEvent event) {
331 if (log.isDebugEnabled()) {
332 log.debug(event);
333 }
334 handler.autoSelectRowInTable(event, tablePopup);
335 }
336
337
338
339
340
341 public ReefDbHelpBroker getBroker() {
342 return broker;
343 }
344
345 public JMenuItem getEditGeneralObservation() {
346 return editGeneralObservation;
347 }
348
349 public SurveysTableUIHandler getHandler() {
350 return handler;
351 }
352
353 public SurveysTableUIModel getModel() {
354 return model;
355 }
356
357 public JButton getNextButton() {
358 return nextButton;
359 }
360
361 public JButton getObservationChangerEtatBouton() {
362 return observationChangerEtatBouton;
363 }
364
365 public JComboBox getObservationChangerEtatCombobox() {
366 return observationChangerEtatCombobox;
367 }
368
369 public JButton getObservationControlerBouton() {
370 return observationControlerBouton;
371 }
372
373 public JButton getObservationDeValiderBouton() {
374 return observationDeValiderBouton;
375 }
376
377 public JButton getObservationDupliquerBouton() {
378 return observationDupliquerBouton;
379 }
380
381 public JButton getObservationEditerBouton() {
382 return observationEditerBouton;
383 }
384
385 public JComboBox getObservationEditerCombobox() {
386 return observationEditerCombobox;
387 }
388
389 public JButton getObservationEditerGeneralBouton() {
390 return observationEditerGeneralBouton;
391 }
392
393 public JButton getObservationEditerMesuresBouton() {
394 return observationEditerMesuresBouton;
395 }
396
397 public JButton getObservationEditerPhotoBouton() {
398 return observationEditerPhotoBouton;
399 }
400
401 public JButton getObservationNouveauBouton() {
402 return observationNouveauBouton;
403 }
404
405 public JButton getObservationSupprimerBouton() {
406 return observationSupprimerBouton;
407 }
408
409 public JButton getObservationValiderBouton() {
410 return observationValiderBouton;
411 }
412
413 public JPanel getObservationsPanelButtons() {
414 return observationsPanelButtons;
415 }
416
417 public SwingTable getSurveyTable() {
418 return surveyTable;
419 }
420
421 public JPopupMenu getTablePopup() {
422 return tablePopup;
423 }
424
425
426
427
428
429 @Override
430 public void registerHelpId(ReefDbHelpBroker broker, Component component, String helpId) {
431 broker.installUI(component, helpId);
432 }
433
434 @Override
435 public void showHelp(String helpId) {
436 getBroker().showHelp(this, helpId);
437 }
438
439
440
441
442
443 protected JPanel get$JPanel0() {
444 return $JPanel0;
445 }
446
447 protected JPanel get$JPanel1() {
448 return $JPanel1;
449 }
450
451 protected JScrollPane get$JScrollPane0() {
452 return $JScrollPane0;
453 }
454
455
456
457
458
459 protected void addChildrenToObservationsPanel() {
460 if (!allComponentsCreated) {
461 return;
462 }
463 add($JScrollPane0);
464 add(observationsPanelButtons, BorderLayout.PAGE_END);
465 }
466
467 protected void addChildrenToObservationsPanelButtons() {
468 if (!allComponentsCreated) {
469 return;
470 }
471 observationsPanelButtons.add($JPanel0, BorderLayout.LINE_START);
472 observationsPanelButtons.add($JPanel1, BorderLayout.LINE_END);
473 }
474
475 protected void addChildrenToTablePopup() {
476 if (!allComponentsCreated) {
477 return;
478 }
479 tablePopup.add(editGeneralObservation);
480 }
481
482 protected void createBroker() {
483 $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
484 }
485
486 protected void createEditGeneralObservation() {
487 $objectMap.put("editGeneralObservation", editGeneralObservation = new JMenuItem());
488
489 editGeneralObservation.setName("editGeneralObservation");
490 editGeneralObservation.setText(t("reefdb.home.survey.menu.edit"));
491 editGeneralObservation.setToolTipText(t("reefdb.home.survey.menu.edit.tip"));
492 editGeneralObservation.putClientProperty("help", "reefdb.main.menu.action.home.help");
493 editGeneralObservation.putClientProperty("applicationAction", EditSurveyDetailsAction.class);
494 }
495
496 protected SurveysTableUIHandler createHandler() {
497 return new SurveysTableUIHandler();
498 }
499
500 protected void createModel() {
501 $objectMap.put("model", model = getContextValue(SurveysTableUIModel.class));
502 }
503
504 protected void createNextButton() {
505 $objectMap.put("nextButton", nextButton = new JButton());
506
507 nextButton.setName("nextButton");
508 nextButton.setText(t("reefdb.common.next"));
509 nextButton.setToolTipText(t("reefdb.home.samplingOperation.new.tip"));
510 nextButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__nextButton"));
511 nextButton.putClientProperty("help", "reefdb.main.menu.action.home.help");
512 }
513
514 protected void createObservationChangerEtatBouton() {
515 $objectMap.put("observationChangerEtatBouton", observationChangerEtatBouton = new JButton());
516
517 observationChangerEtatBouton.setName("observationChangerEtatBouton");
518 observationChangerEtatBouton.setVisible(false);
519 observationChangerEtatBouton.setText(t("reefdb.home.survey.changeStatus"));
520 }
521
522 protected void createObservationChangerEtatCombobox() {
523 $objectMap.put("observationChangerEtatCombobox", observationChangerEtatCombobox = new JComboBox());
524
525 observationChangerEtatCombobox.setName("observationChangerEtatCombobox");
526 }
527
528 protected void createObservationControlerBouton() {
529 $objectMap.put("observationControlerBouton", observationControlerBouton = new JButton());
530
531 observationControlerBouton.setName("observationControlerBouton");
532 observationControlerBouton.setVisible(false);
533 observationControlerBouton.setText(t("reefdb.home.survey.control"));
534 observationControlerBouton.putClientProperty("applicationAction", ControlSurveyAction.class);
535 }
536
537 protected void createObservationDeValiderBouton() {
538 $objectMap.put("observationDeValiderBouton", observationDeValiderBouton = new JButton());
539
540 observationDeValiderBouton.setName("observationDeValiderBouton");
541 observationDeValiderBouton.setVisible(false);
542 observationDeValiderBouton.setText(t("reefdb.home.survey.unvalidate"));
543 observationDeValiderBouton.putClientProperty("applicationAction", UnvalidateSurveyAction.class);
544 }
545
546 protected void createObservationDupliquerBouton() {
547 $objectMap.put("observationDupliquerBouton", observationDupliquerBouton = new JButton());
548
549 observationDupliquerBouton.setName("observationDupliquerBouton");
550 observationDupliquerBouton.setText(t("reefdb.action.duplicate.label"));
551 observationDupliquerBouton.setToolTipText(t("reefdb.action.duplicate.tip"));
552 observationDupliquerBouton.putClientProperty("applicationAction", DuplicateSurveyAction.class);
553 }
554
555 protected void createObservationEditerBouton() {
556 $objectMap.put("observationEditerBouton", observationEditerBouton = new JButton());
557
558 observationEditerBouton.setName("observationEditerBouton");
559 observationEditerBouton.setVisible(false);
560 observationEditerBouton.setText(t("reefdb.common.edit"));
561 }
562
563 protected void createObservationEditerCombobox() {
564 $objectMap.put("observationEditerCombobox", observationEditerCombobox = new JComboBox());
565
566 observationEditerCombobox.setName("observationEditerCombobox");
567 }
568
569 protected void createObservationEditerGeneralBouton() {
570 $objectMap.put("observationEditerGeneralBouton", observationEditerGeneralBouton = new JButton());
571
572 observationEditerGeneralBouton.setName("observationEditerGeneralBouton");
573 observationEditerGeneralBouton.setVisible(false);
574 observationEditerGeneralBouton.setText(t("reefdb.home.survey.edit"));
575 observationEditerGeneralBouton.setToolTipText(t("reefdb.home.survey.edit.tip"));
576 observationEditerGeneralBouton.putClientProperty("applicationAction", EditSurveyDetailsAction.class);
577 }
578
579 protected void createObservationEditerMesuresBouton() {
580 $objectMap.put("observationEditerMesuresBouton", observationEditerMesuresBouton = new JButton());
581
582 observationEditerMesuresBouton.setName("observationEditerMesuresBouton");
583 observationEditerMesuresBouton.setVisible(false);
584 observationEditerMesuresBouton.setText(t("reefdb.home.survey.edit.measurement"));
585 observationEditerMesuresBouton.setToolTipText(t("reefdb.home.survey.edit.measurement.tip"));
586 observationEditerMesuresBouton.putClientProperty("applicationAction", EditSurveyMeasurementsAction.class);
587 }
588
589 protected void createObservationEditerPhotoBouton() {
590 $objectMap.put("observationEditerPhotoBouton", observationEditerPhotoBouton = new JButton());
591
592 observationEditerPhotoBouton.setName("observationEditerPhotoBouton");
593 observationEditerPhotoBouton.setVisible(false);
594 observationEditerPhotoBouton.setText(t("reefdb.home.survey.edit.photo"));
595 observationEditerPhotoBouton.setToolTipText(t("reefdb.home.survey.edit.photo.tip"));
596 observationEditerPhotoBouton.putClientProperty("applicationAction", EditSurveyPhotosAction.class);
597 }
598
599 protected void createObservationNouveauBouton() {
600 $objectMap.put("observationNouveauBouton", observationNouveauBouton = new JButton());
601
602 observationNouveauBouton.setName("observationNouveauBouton");
603 observationNouveauBouton.setText(t("reefdb.common.new"));
604 observationNouveauBouton.setToolTipText(t("reefdb.home.survey.new.tip"));
605 observationNouveauBouton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__observationNouveauBouton"));
606 }
607
608 protected void createObservationSupprimerBouton() {
609 $objectMap.put("observationSupprimerBouton", observationSupprimerBouton = new JButton());
610
611 observationSupprimerBouton.setName("observationSupprimerBouton");
612 observationSupprimerBouton.setText(t("reefdb.common.delete"));
613 observationSupprimerBouton.setToolTipText(t("reefdb.common.delete"));
614 observationSupprimerBouton.putClientProperty("applicationAction", DeleteSurveyAction.class);
615 }
616
617 protected void createObservationValiderBouton() {
618 $objectMap.put("observationValiderBouton", observationValiderBouton = new JButton());
619
620 observationValiderBouton.setName("observationValiderBouton");
621 observationValiderBouton.setVisible(false);
622 observationValiderBouton.setText(t("reefdb.home.survey.validate"));
623 observationValiderBouton.putClientProperty("applicationAction", ValidateSurveyAction.class);
624 }
625
626 protected void createObservationsPanelButtons() {
627 $objectMap.put("observationsPanelButtons", observationsPanelButtons = new JPanel());
628
629 observationsPanelButtons.setName("observationsPanelButtons");
630 observationsPanelButtons.setLayout(new BorderLayout());
631 }
632
633 protected void createSurveyTable() {
634 $objectMap.put("surveyTable", surveyTable = new SwingTable());
635
636 surveyTable.setName("surveyTable");
637 surveyTable.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__surveyTable"));
638 }
639
640 protected void createTablePopup() {
641 $objectMap.put("tablePopup", tablePopup = new JPopupMenu());
642
643 tablePopup.setName("tablePopup");
644 }
645
646
647
648
649
650 private void $completeSetup() {
651 allComponentsCreated = true;
652 if (log.isDebugEnabled()) {
653 log.debug(this);
654 }
655 addChildrenToObservationsPanel();
656
657 $JScrollPane0.getViewport().add(surveyTable);
658 addChildrenToTablePopup();
659 addChildrenToObservationsPanelButtons();
660
661 $JPanel0.add(observationNouveauBouton);
662 $JPanel0.add(observationDupliquerBouton);
663 $JPanel0.add(observationEditerCombobox);
664 $JPanel0.add(observationEditerBouton);
665 $JPanel0.add(observationEditerGeneralBouton);
666 $JPanel0.add(observationEditerMesuresBouton);
667 $JPanel0.add(observationEditerPhotoBouton);
668 $JPanel0.add(observationChangerEtatCombobox);
669 $JPanel0.add(observationControlerBouton);
670 $JPanel0.add(observationValiderBouton);
671 $JPanel0.add(observationDeValiderBouton);
672 $JPanel0.add(observationChangerEtatBouton);
673 $JPanel0.add(observationSupprimerBouton);
674
675 $JPanel1.add(nextButton);
676
677
678 JAXXUtil.applyDataBinding(this, $bindings.keySet());
679
680
681 observationNouveauBouton.setAlignmentX(Component.CENTER_ALIGNMENT);
682 observationDupliquerBouton.setAlignmentX(Component.CENTER_ALIGNMENT);
683 observationEditerCombobox.setAlignmentX(Component.CENTER_ALIGNMENT);
684 observationChangerEtatCombobox.setAlignmentX(Component.CENTER_ALIGNMENT);
685 observationSupprimerBouton.setAlignmentX(Component.CENTER_ALIGNMENT);
686 nextButton.setAlignmentX(Component.CENTER_ALIGNMENT);
687 setBorder(BorderFactory.createTitledBorder(t("reefdb.home.survey.title")));
688 editGeneralObservation.setIcon(SwingUtil.createActionIcon("edit"));
689 observationNouveauBouton.setIcon(SwingUtil.createActionIcon("add"));
690 observationDupliquerBouton.setIcon(SwingUtil.createActionIcon("copy"));
691 observationEditerCombobox.setModel(handler.newActionComboBoxModel(observationEditerBouton, observationEditerGeneralBouton, observationEditerMesuresBouton, observationEditerPhotoBouton));
692 observationEditerBouton.setIcon(SwingUtil.createActionIcon("edit"));
693 observationEditerGeneralBouton.setIcon(SwingUtil.createActionIcon("edit"));
694 observationEditerMesuresBouton.setIcon(SwingUtil.createActionIcon("edit"));
695 observationEditerPhotoBouton.setIcon(SwingUtil.createActionIcon("edit"));
696 observationChangerEtatCombobox.setModel(handler.newActionComboBoxModel(observationChangerEtatBouton, observationControlerBouton, observationValiderBouton, observationDeValiderBouton));
697 observationControlerBouton.setIcon(SwingUtil.createActionIcon("control"));
698 observationControlerBouton.setToolTipText(t("reefdb.home.survey.control"));
699 observationValiderBouton.setIcon(SwingUtil.createActionIcon("accept"));
700 observationValiderBouton.setToolTipText(t("reefdb.home.survey.validate"));
701 observationDeValiderBouton.setIcon(SwingUtil.createActionIcon("cancel"));
702 observationDeValiderBouton.setToolTipText(t("reefdb.home.survey.unvalidate"));
703 observationChangerEtatBouton.setToolTipText(t("reefdb.home.survey.changeStatus"));
704 observationSupprimerBouton.setIcon(SwingUtil.createActionIcon("delete"));
705 nextButton.setIcon(SwingUtil.createActionIcon("next"));
706
707
708 ReefDbHelpBroker _broker = getBroker();
709 registerHelpId(_broker, editGeneralObservation, "reefdb.main.menu.action.home.help");
710 registerHelpId(_broker, nextButton, "reefdb.main.menu.action.home.help");
711 _broker.prepareUI(this);
712 }
713
714 private void $initialize() {
715 if (allComponentsCreated) {
716 return;
717 }
718 if (log.isDebugEnabled()) {
719 log.debug(this);
720 }
721 handler.beforeInit(this);
722 $objectMap.put("observationsPanel", observationsPanel);
723 createModel();
724 createBroker();
725
726 $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
727
728 $JScrollPane0.setName("$JScrollPane0");
729 createTablePopup();
730 createEditGeneralObservation();
731 createSurveyTable();
732 createObservationsPanelButtons();
733
734 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
735
736 $JPanel0.setName("$JPanel0");
737 $JPanel0.setLayout(new FlowLayout());
738 createObservationNouveauBouton();
739 createObservationDupliquerBouton();
740 createObservationEditerCombobox();
741 createObservationEditerBouton();
742 createObservationEditerGeneralBouton();
743 createObservationEditerMesuresBouton();
744 createObservationEditerPhotoBouton();
745 createObservationChangerEtatCombobox();
746 createObservationControlerBouton();
747 createObservationValiderBouton();
748 createObservationDeValiderBouton();
749 createObservationChangerEtatBouton();
750 createObservationSupprimerBouton();
751
752 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
753
754 $JPanel1.setName("$JPanel1");
755 $JPanel1.setLayout(new FlowLayout());
756 createNextButton();
757
758 setName("observationsPanel");
759 setLayout(new BorderLayout());
760 observationsPanel.putClientProperty("panelType", ReefDbUI.EDITION_PANEL_TYPE);
761
762
763 $registerDefaultBindings();
764 $completeSetup();
765 handler.afterInit(this);
766 }
767
768 private void $registerDefaultBindings() {
769
770 registerDataBinding(new DefaultJAXXBinding(this, BINDING_EDIT_GENERAL_OBSERVATION_ENABLED, true) {
771
772 @Override
773 public void applyDataBinding() {
774 if (model != null) {
775 model.addPropertyChangeListener("singleSelectedRow", this);
776 }
777 }
778
779 @Override
780 public void processDataBinding() {
781 if (model != null) {
782 editGeneralObservation.setEnabled(model.getSingleSelectedRow() != null);
783 }
784 }
785
786 @Override
787 public void removeDataBinding() {
788 if (model != null) {
789 model.removePropertyChangeListener("singleSelectedRow", this);
790 }
791 }
792 });
793 registerDataBinding(new DefaultJAXXBinding(this, BINDING_OBSERVATION_DUPLIQUER_BOUTON_ENABLED, true) {
794
795 @Override
796 public void applyDataBinding() {
797 if (model != null) {
798 model.addPropertyChangeListener("selectedRows", this);
799 }
800 }
801
802 @Override
803 public void processDataBinding() {
804 if (model != null && model.getSelectedRows() != null) {
805 observationDupliquerBouton.setEnabled(model.getSelectedRows().size() == 1);
806 }
807 }
808
809 @Override
810 public void removeDataBinding() {
811 if (model != null) {
812 model.removePropertyChangeListener("selectedRows", this);
813 }
814 }
815 });
816 registerDataBinding(new DefaultJAXXBinding(this, BINDING_OBSERVATION_EDITER_COMBOBOX_ENABLED, true) {
817
818 @Override
819 public void applyDataBinding() {
820 if (model != null) {
821 model.addPropertyChangeListener("selectedRows", this);
822 }
823 }
824
825 @Override
826 public void processDataBinding() {
827 if (model != null && model.getSelectedRows() != null) {
828 observationEditerCombobox.setEnabled(model.getSelectedRows().size() == 1);
829 }
830 }
831
832 @Override
833 public void removeDataBinding() {
834 if (model != null) {
835 model.removePropertyChangeListener("selectedRows", this);
836 }
837 }
838 });
839 registerDataBinding(new DefaultJAXXBinding(this, BINDING_OBSERVATION_CHANGER_ETAT_COMBOBOX_ENABLED, true) {
840
841 @Override
842 public void applyDataBinding() {
843 if (model != null) {
844 model.addPropertyChangeListener("selectedRows", this);
845 }
846 }
847
848 @Override
849 public void processDataBinding() {
850 if (model != null && model.getSelectedRows() != null) {
851 observationChangerEtatCombobox.setEnabled(!model.getSelectedRows().isEmpty());
852 }
853 }
854
855 @Override
856 public void removeDataBinding() {
857 if (model != null) {
858 model.removePropertyChangeListener("selectedRows", this);
859 }
860 }
861 });
862 registerDataBinding(new DefaultJAXXBinding(this, BINDING_OBSERVATION_SUPPRIMER_BOUTON_ENABLED, true) {
863
864 @Override
865 public void applyDataBinding() {
866 if (model != null) {
867 model.addPropertyChangeListener("selectedRows", this);
868 }
869 }
870
871 @Override
872 public void processDataBinding() {
873 if (model != null && model.getSelectedRows() != null) {
874 observationSupprimerBouton.setEnabled(!model.getSelectedRows().isEmpty());
875 }
876 }
877
878 @Override
879 public void removeDataBinding() {
880 if (model != null) {
881 model.removePropertyChangeListener("selectedRows", this);
882 }
883 }
884 });
885 registerDataBinding(new DefaultJAXXBinding(this, BINDING_NEXT_BUTTON_ENABLED, true, true) {
886
887 @Override
888 public void applyDataBinding() {
889 if (model != null) {
890 model.addPropertyChangeListener("samplingOperationsLoading", this);
891 }
892 if (model != null) {
893 model.addPropertyChangeListener("selectedSurveyEditable", this);
894 }
895 }
896
897 @Override
898 public void processDataBinding() {
899 if (model != null) {
900 nextButton.setEnabled(!model.isSamplingOperationsLoading() && model.isSelectedSurveyEditable());
901 }
902 }
903
904 @Override
905 public void removeDataBinding() {
906 if (model != null) {
907 model.removePropertyChangeListener("samplingOperationsLoading", this);
908 }
909 if (model != null) {
910 model.removePropertyChangeListener("selectedSurveyEditable", this);
911 }
912 }
913 });
914 }
915
916 }