1 package fr.ifremer.dali.ui.swing.content.home.survey;
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.quadrige3.ui.swing.ApplicationUI;
7 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
8 import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
9 import java.awt.BorderLayout;
10 import java.awt.Component;
11 import java.awt.Container;
12 import java.awt.LayoutManager;
13 import java.awt.event.ActionEvent;
14 import java.awt.event.ActionListener;
15 import java.awt.event.ComponentEvent;
16 import java.awt.event.ComponentListener;
17 import java.awt.event.MouseEvent;
18 import java.awt.event.MouseListener;
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.TreeMap;
24 import javax.swing.BorderFactory;
25 import javax.swing.JButton;
26 import javax.swing.JComboBox;
27 import javax.swing.JMenuItem;
28 import javax.swing.JPanel;
29 import javax.swing.JPopupMenu;
30 import javax.swing.JScrollPane;
31 import jaxx.runtime.JAXXBinding;
32 import jaxx.runtime.JAXXContext;
33 import jaxx.runtime.JAXXObject;
34 import jaxx.runtime.JAXXObjectDescriptor;
35 import jaxx.runtime.JAXXUtil;
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 org.apache.commons.logging.Log;
41 import org.apache.commons.logging.LogFactory;
42 import static org.nuiton.i18n.I18n.t;
43
44 public class SurveysTableUI extends JPanel implements JAXXHelpUI<DaliHelpBroker>, DaliUI<SurveysTableUIModel, SurveysTableUIHandler>, JAXXObject {
45
46
47
48
49
50 public static final String BINDING_DELETE_BUTTON_ENABLED = "deleteButton.enabled";
51 public static final String BINDING_DUPLICATE_BUTTON_ENABLED = "duplicateButton.enabled";
52 public static final String BINDING_EDIT_COMBO_ENABLED = "editCombo.enabled";
53 public static final String BINDING_EDIT_MENU_ITEM_ENABLED = "editMenuItem.enabled";
54 public static final String BINDING_HIDE_MAP_BUTTON_VISIBLE = "hideMapButton.visible";
55 public static final String BINDING_NEXT_BUTTON_ENABLED = "nextButton.enabled";
56 public static final String BINDING_SHOW_MAP_BUTTON_ENABLED = "showMapButton.enabled";
57 public static final String BINDING_STATE_COMBO_ENABLED = "stateCombo.enabled";
58
59
60
61
62
63 private static final String $jaxxObjectDescriptor = "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";
64 private static final Log log = LogFactory.getLog(SurveysTableUI.class);
65 private static final long serialVersionUID = 1L;
66
67
68
69
70
71 protected List<Object> $activeBindings = new ArrayList<Object>();
72 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
73 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
74 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
75 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
76 private boolean allComponentsCreated;
77 protected final JAXXContext delegateContext = new DefaultJAXXContext();
78
79
80
81
82
83 protected DaliHelpBroker broker;
84 protected JButton controlButton;
85 protected JButton deleteButton;
86 protected JButton duplicateButton;
87 protected JComboBox editCombo;
88 protected JButton editDummyButton;
89 protected JButton editMeasurementButton;
90 protected JMenuItem editMenuItem;
91 protected JButton editPhotoButton;
92 protected JButton editSurveyButton;
93 protected final SurveysTableUIHandler handler = createHandler();
94 protected JButton hideMapButton;
95 protected SurveysTableUIModel model;
96 protected JButton newButton;
97 protected JButton nextButton;
98 protected JButton qualifyButton;
99 protected JButton showMapButton;
100 protected JComboBox stateCombo;
101 protected JButton stateDummyButton;
102 protected SwingTable surveysTable;
103 protected SurveysTableUI surveysTableUI = this;
104 protected JPanel surveysTableUIButtons;
105 protected JPopupMenu tablePopup;
106 protected JButton unvalidateButton;
107 protected JButton validateButton;
108
109
110
111
112
113 private JPanel $JPanel0;
114 private JPanel $JPanel1;
115 private JScrollPane $JScrollPane0;
116
117
118
119
120
121 public SurveysTableUI(ApplicationUI parentUI) {
122 ApplicationUIUtil.setParentUI(this, parentUI);
123 $initialize();
124 }
125
126 public SurveysTableUI() {
127 $initialize();
128 }
129
130 public SurveysTableUI(JAXXContext parentContext) {
131 JAXXUtil.initContext(this, parentContext);
132 $initialize();
133 }
134
135 public SurveysTableUI(boolean param0) {
136 super(param0);
137 $initialize();
138 }
139
140 public SurveysTableUI(JAXXContext parentContext, boolean param1) {
141 super(param1);
142 JAXXUtil.initContext(this, parentContext);
143 $initialize();
144 }
145
146 public SurveysTableUI(LayoutManager param0) {
147 super(param0);
148 $initialize();
149 }
150
151 public SurveysTableUI(JAXXContext parentContext, LayoutManager param1) {
152 super(param1);
153 JAXXUtil.initContext(this, parentContext);
154 $initialize();
155 }
156
157 public SurveysTableUI(LayoutManager param0, boolean param1) {
158 super(param0 ,param1);
159 $initialize();
160 }
161
162 public SurveysTableUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
163 super(param1 ,param2);
164 JAXXUtil.initContext(this, parentContext);
165 $initialize();
166 }
167
168
169
170
171
172 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
173 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
174 }
175
176
177
178
179
180 @Override
181 public void applyDataBinding(String $binding) {
182 if (allComponentsCreated && $bindings.containsKey($binding)) {
183 getDataBinding($binding).applyDataBinding();
184 }
185 processDataBinding($binding);
186 }
187
188 @Override
189 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
190 super.firePropertyChange(propertyName, oldValue, newValue);
191 }
192
193 @Override
194 public Map<String, Object> get$objectMap() {
195 return $objectMap;
196 }
197
198 @Override
199 public JAXXBinding getDataBinding(String bindingId) {
200 return $bindings.get(bindingId);
201 }
202
203 @Override
204 public JAXXBinding[] getDataBindings() {
205 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
206 }
207
208 @Override
209 public Object getObjectById(String id) {
210 return $objectMap.get(id);
211 }
212
213 @Override
214 public void processDataBinding(String $binding, boolean $force) {
215 if (!$force && $activeBindings.contains($binding)) {
216 return;
217 }
218 $activeBindings.add($binding);
219 try {
220 if (allComponentsCreated && $bindings.containsKey($binding)) {
221 getDataBinding($binding).processDataBinding();
222 }
223 } finally {
224 $activeBindings.remove($binding);
225 }
226 }
227
228 @Override
229 public void processDataBinding(String $binding) {
230 processDataBinding($binding, false);
231 }
232
233 @Override
234 public void registerDataBinding(JAXXBinding binding) {
235 $bindings.put(binding.getId(), binding);
236 }
237
238 @Override
239 public void removeDataBinding(String $binding) {
240 if (allComponentsCreated && $bindings.containsKey($binding)) {
241 getDataBinding($binding).removeDataBinding();
242 }
243 }
244
245
246
247
248
249 @Override
250 public <T> T getContextValue(Class<T> clazz) {
251 return delegateContext.getContextValue(clazz, null);
252 }
253
254 @Override
255 public <T> T getContextValue(Class<T> clazz, String name) {
256 return delegateContext.getContextValue(clazz, name);
257 }
258
259 @Override
260 public JAXXContext getDelegateContext() {
261 return delegateContext;
262 }
263
264 @Override
265 public <O extends Container> O getParentContainer(Class<O> clazz) {
266 return SwingUtil.getParentContainer(this, clazz);
267 }
268
269 @Override
270 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
271 return SwingUtil.getParentContainer(source, clazz);
272 }
273
274 @Override
275 public <T> void removeContextValue(Class<T> clazz) {
276 delegateContext.removeContextValue(clazz, null);
277 }
278
279 @Override
280 public <T> void removeContextValue(Class<T> clazz, String name) {
281 delegateContext.removeContextValue(clazz, name);
282 }
283
284 @Override
285 public <T> void setContextValue(T o) {
286 delegateContext.setContextValue(o, null);
287 }
288
289 @Override
290 public <T> void setContextValue(T o, String name) {
291 delegateContext.setContextValue(o, name);
292 }
293
294
295
296
297
298 public void doActionPerformed__on__hideMapButton(ActionEvent event) {
299 if (log.isDebugEnabled()) {
300 log.debug(event);
301 }
302 handler.hideMap();
303 }
304
305 public void doActionPerformed__on__newButton(ActionEvent event) {
306 if (log.isDebugEnabled()) {
307 log.debug(event);
308 }
309 model.addNewRow();
310 }
311
312 public void doActionPerformed__on__nextButton(ActionEvent event) {
313 if (log.isDebugEnabled()) {
314 log.debug(event);
315 }
316 handler.onNext();
317 }
318
319 public void doActionPerformed__on__showMapButton(ActionEvent event) {
320 if (log.isDebugEnabled()) {
321 log.debug(event);
322 }
323 handler.showMap();
324 }
325
326 public void doMouseClicked__on__surveysTable(MouseEvent event) {
327 if (log.isDebugEnabled()) {
328 log.debug(event);
329 }
330 handler.autoSelectRowInTable(event, tablePopup);
331 }
332
333
334
335
336
337 public DaliHelpBroker getBroker() {
338 return broker;
339 }
340
341 public JButton getControlButton() {
342 return controlButton;
343 }
344
345 public JButton getDeleteButton() {
346 return deleteButton;
347 }
348
349 public JButton getDuplicateButton() {
350 return duplicateButton;
351 }
352
353 public JComboBox getEditCombo() {
354 return editCombo;
355 }
356
357 public JButton getEditDummyButton() {
358 return editDummyButton;
359 }
360
361 public JButton getEditMeasurementButton() {
362 return editMeasurementButton;
363 }
364
365 public JMenuItem getEditMenuItem() {
366 return editMenuItem;
367 }
368
369 public JButton getEditPhotoButton() {
370 return editPhotoButton;
371 }
372
373 public JButton getEditSurveyButton() {
374 return editSurveyButton;
375 }
376
377 public SurveysTableUIHandler getHandler() {
378 return handler;
379 }
380
381 public JButton getHideMapButton() {
382 return hideMapButton;
383 }
384
385 public SurveysTableUIModel getModel() {
386 return model;
387 }
388
389 public JButton getNewButton() {
390 return newButton;
391 }
392
393 public JButton getNextButton() {
394 return nextButton;
395 }
396
397 public JButton getQualifyButton() {
398 return qualifyButton;
399 }
400
401 public JButton getShowMapButton() {
402 return showMapButton;
403 }
404
405 public JComboBox getStateCombo() {
406 return stateCombo;
407 }
408
409 public JButton getStateDummyButton() {
410 return stateDummyButton;
411 }
412
413 public SwingTable getSurveysTable() {
414 return surveysTable;
415 }
416
417 public JPanel getSurveysTableUIButtons() {
418 return surveysTableUIButtons;
419 }
420
421 public JPopupMenu getTablePopup() {
422 return tablePopup;
423 }
424
425 public JButton getUnvalidateButton() {
426 return unvalidateButton;
427 }
428
429 public JButton getValidateButton() {
430 return validateButton;
431 }
432
433
434
435
436
437 @Override
438 public void registerHelpId(DaliHelpBroker broker, Component component, String helpId) {
439 broker.installUI(component, helpId);
440 }
441
442 @Override
443 public void showHelp(String helpId) {
444 getBroker().showHelp(this, helpId);
445 }
446
447
448
449
450
451 protected JPanel get$JPanel0() {
452 return $JPanel0;
453 }
454
455 protected JPanel get$JPanel1() {
456 return $JPanel1;
457 }
458
459 protected JScrollPane get$JScrollPane0() {
460 return $JScrollPane0;
461 }
462
463
464
465
466
467 protected void addChildrenToSurveysTableUI() {
468 if (!allComponentsCreated) {
469 return;
470 }
471 add($JScrollPane0);
472 add(surveysTableUIButtons, BorderLayout.PAGE_END);
473 }
474
475 protected void addChildrenToSurveysTableUIButtons() {
476 if (!allComponentsCreated) {
477 return;
478 }
479 surveysTableUIButtons.add($JPanel0, BorderLayout.LINE_START);
480 surveysTableUIButtons.add($JPanel1, BorderLayout.LINE_END);
481 }
482
483 protected void addChildrenToTablePopup() {
484 if (!allComponentsCreated) {
485 return;
486 }
487 tablePopup.add(editMenuItem);
488 }
489
490 protected void createBroker() {
491 $objectMap.put("broker", broker = new DaliHelpBroker("dali.home.help"));
492 }
493
494 protected void createControlButton() {
495 $objectMap.put("controlButton", controlButton = new JButton());
496
497 controlButton.setName("controlButton");
498 controlButton.setVisible(false);
499 controlButton.setText(t("dali.home.survey.control"));
500 controlButton.putClientProperty("applicationAction", ControlSurveyAction.class);
501 }
502
503 protected void createDeleteButton() {
504 $objectMap.put("deleteButton", deleteButton = new JButton());
505
506 deleteButton.setName("deleteButton");
507 deleteButton.setText(t("dali.common.delete"));
508 deleteButton.setToolTipText(t("dali.common.delete"));
509 deleteButton.putClientProperty("applicationAction", DeleteSurveyAction.class);
510 }
511
512 protected void createDuplicateButton() {
513 $objectMap.put("duplicateButton", duplicateButton = new JButton());
514
515 duplicateButton.setName("duplicateButton");
516 duplicateButton.setText(t("dali.action.duplicate.label"));
517 duplicateButton.setToolTipText(t("dali.action.duplicate.tip"));
518 duplicateButton.putClientProperty("applicationAction", DuplicateSurveyAction.class);
519 }
520
521 protected void createEditCombo() {
522 $objectMap.put("editCombo", editCombo = new JComboBox());
523
524 editCombo.setName("editCombo");
525 }
526
527 protected void createEditDummyButton() {
528 $objectMap.put("editDummyButton", editDummyButton = new JButton());
529
530 editDummyButton.setName("editDummyButton");
531 editDummyButton.setVisible(false);
532 editDummyButton.setText(t("dali.common.edit"));
533 }
534
535 protected void createEditMeasurementButton() {
536 $objectMap.put("editMeasurementButton", editMeasurementButton = new JButton());
537
538 editMeasurementButton.setName("editMeasurementButton");
539 editMeasurementButton.setVisible(false);
540 editMeasurementButton.setText(t("dali.home.survey.edit.measurement"));
541 editMeasurementButton.setToolTipText(t("dali.home.survey.edit.measurement.tip"));
542 editMeasurementButton.putClientProperty("applicationAction", EditSurveyMeasurementsAction.class);
543 }
544
545 protected void createEditMenuItem() {
546 $objectMap.put("editMenuItem", editMenuItem = new JMenuItem());
547
548 editMenuItem.setName("editMenuItem");
549 editMenuItem.setText(t("dali.home.survey.menu.edit"));
550 editMenuItem.setToolTipText(t("dali.home.survey.menu.edit.tip"));
551 editMenuItem.putClientProperty("help", "dali.main.menu.action.home.help");
552 editMenuItem.putClientProperty("applicationAction", EditSurveyDetailsAction.class);
553 }
554
555 protected void createEditPhotoButton() {
556 $objectMap.put("editPhotoButton", editPhotoButton = new JButton());
557
558 editPhotoButton.setName("editPhotoButton");
559 editPhotoButton.setVisible(false);
560 editPhotoButton.setText(t("dali.home.survey.edit.photo"));
561 editPhotoButton.setToolTipText(t("dali.home.survey.edit.photo.tip"));
562 editPhotoButton.putClientProperty("applicationAction", EditSurveyPhotosAction.class);
563 }
564
565 protected void createEditSurveyButton() {
566 $objectMap.put("editSurveyButton", editSurveyButton = new JButton());
567
568 editSurveyButton.setName("editSurveyButton");
569 editSurveyButton.setVisible(false);
570 editSurveyButton.setText(t("dali.home.survey.edit"));
571 editSurveyButton.setToolTipText(t("dali.home.survey.edit.tip"));
572 editSurveyButton.putClientProperty("applicationAction", EditSurveyDetailsAction.class);
573 }
574
575 protected SurveysTableUIHandler createHandler() {
576 return new SurveysTableUIHandler();
577 }
578
579 protected void createHideMapButton() {
580 $objectMap.put("hideMapButton", hideMapButton = new JButton());
581
582 hideMapButton.setName("hideMapButton");
583 hideMapButton.setText(t("dali.action.map.hide"));
584 hideMapButton.setToolTipText(t("dali.action.map.hide.tip"));
585 hideMapButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__hideMapButton"));
586 }
587
588 protected void createModel() {
589 $objectMap.put("model", model = getContextValue(SurveysTableUIModel.class));
590 }
591
592 protected void createNewButton() {
593 $objectMap.put("newButton", newButton = new JButton());
594
595 newButton.setName("newButton");
596 newButton.setText(t("dali.common.new"));
597 newButton.setToolTipText(t("dali.home.survey.new.tip"));
598 newButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__newButton"));
599 }
600
601 protected void createNextButton() {
602 $objectMap.put("nextButton", nextButton = new JButton());
603
604 nextButton.setName("nextButton");
605 nextButton.setText(t("dali.common.next"));
606 nextButton.setToolTipText(t("dali.home.samplingOperation.newOne.tip"));
607 nextButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__nextButton"));
608 nextButton.putClientProperty("help", "dali.main.menu.action.home.help");
609 }
610
611 protected void createQualifyButton() {
612 $objectMap.put("qualifyButton", qualifyButton = new JButton());
613
614 qualifyButton.setName("qualifyButton");
615 qualifyButton.setVisible(false);
616 qualifyButton.setText(t("dali.home.survey.qualify"));
617 qualifyButton.putClientProperty("applicationAction", QualifySurveyAction.class);
618 }
619
620 protected void createShowMapButton() {
621 $objectMap.put("showMapButton", showMapButton = new JButton());
622
623 showMapButton.setName("showMapButton");
624 showMapButton.setVisible(true);
625 showMapButton.setText(t("dali.action.map.show"));
626 showMapButton.setToolTipText(t("dali.action.map.show.tip"));
627 showMapButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__showMapButton"));
628 }
629
630 protected void createStateCombo() {
631 $objectMap.put("stateCombo", stateCombo = new JComboBox());
632
633 stateCombo.setName("stateCombo");
634 }
635
636 protected void createStateDummyButton() {
637 $objectMap.put("stateDummyButton", stateDummyButton = new JButton());
638
639 stateDummyButton.setName("stateDummyButton");
640 stateDummyButton.setVisible(false);
641 stateDummyButton.setText(t("dali.home.survey.changeStatus"));
642 }
643
644 protected void createSurveysTable() {
645 $objectMap.put("surveysTable", surveysTable = new SwingTable());
646
647 surveysTable.setName("surveysTable");
648 surveysTable.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__surveysTable"));
649 }
650
651 protected void createSurveysTableUIButtons() {
652 $objectMap.put("surveysTableUIButtons", surveysTableUIButtons = new JPanel());
653
654 surveysTableUIButtons.setName("surveysTableUIButtons");
655 surveysTableUIButtons.setLayout(new BorderLayout());
656 }
657
658 protected void createTablePopup() {
659 $objectMap.put("tablePopup", tablePopup = new JPopupMenu());
660
661 tablePopup.setName("tablePopup");
662 }
663
664 protected void createUnvalidateButton() {
665 $objectMap.put("unvalidateButton", unvalidateButton = new JButton());
666
667 unvalidateButton.setName("unvalidateButton");
668 unvalidateButton.setVisible(false);
669 unvalidateButton.setText(t("dali.home.survey.unvalidate"));
670 unvalidateButton.putClientProperty("applicationAction", UnvalidateSurveyAction.class);
671 }
672
673 protected void createValidateButton() {
674 $objectMap.put("validateButton", validateButton = new JButton());
675
676 validateButton.setName("validateButton");
677 validateButton.setVisible(false);
678 validateButton.setText(t("dali.home.survey.validate"));
679 validateButton.putClientProperty("applicationAction", ValidateSurveyAction.class);
680 }
681
682
683
684
685
686 private void $completeSetup() {
687 allComponentsCreated = true;
688 if (log.isDebugEnabled()) {
689 log.debug(this);
690 }
691 addChildrenToSurveysTableUI();
692
693 $JScrollPane0.getViewport().add(surveysTable);
694 addChildrenToTablePopup();
695 addChildrenToSurveysTableUIButtons();
696
697 $JPanel0.add(newButton);
698 $JPanel0.add(duplicateButton);
699 $JPanel0.add(editCombo);
700 $JPanel0.add(editDummyButton);
701 $JPanel0.add(editSurveyButton);
702 $JPanel0.add(editMeasurementButton);
703 $JPanel0.add(editPhotoButton);
704 $JPanel0.add(stateCombo);
705 $JPanel0.add(stateDummyButton);
706 $JPanel0.add(controlButton);
707 $JPanel0.add(validateButton);
708 $JPanel0.add(unvalidateButton);
709 $JPanel0.add(qualifyButton);
710 $JPanel0.add(showMapButton);
711 $JPanel0.add(hideMapButton);
712 $JPanel0.add(deleteButton);
713
714 $JPanel1.add(nextButton);
715
716
717 JAXXUtil.applyDataBinding(this, $bindings.keySet());
718
719
720 newButton.setAlignmentX(Component.CENTER_ALIGNMENT);
721 duplicateButton.setAlignmentX(Component.CENTER_ALIGNMENT);
722 editCombo.setAlignmentX(Component.CENTER_ALIGNMENT);
723 stateCombo.setAlignmentX(Component.CENTER_ALIGNMENT);
724 showMapButton.setAlignmentX(Component.CENTER_ALIGNMENT);
725 hideMapButton.setAlignmentX(Component.CENTER_ALIGNMENT);
726 deleteButton.setAlignmentX(Component.CENTER_ALIGNMENT);
727 nextButton.setAlignmentX(Component.CENTER_ALIGNMENT);
728 setBorder(BorderFactory.createTitledBorder(t("dali.home.survey.title")));
729 editMenuItem.setIcon(SwingUtil.createActionIcon("edit"));
730 newButton.setIcon(SwingUtil.createActionIcon("add"));
731 duplicateButton.setIcon(SwingUtil.createActionIcon("copy"));
732 editCombo.setModel(handler.newActionComboBoxModel(editDummyButton, editSurveyButton, editMeasurementButton, editPhotoButton));
733 editDummyButton.setIcon(SwingUtil.createActionIcon("edit"));
734 editSurveyButton.setIcon(SwingUtil.createActionIcon("edit"));
735 editMeasurementButton.setIcon(SwingUtil.createActionIcon("edit"));
736 editPhotoButton.setIcon(SwingUtil.createActionIcon("edit"));
737 stateCombo.setModel(handler.newActionComboBoxModel(stateDummyButton, controlButton, validateButton, unvalidateButton, qualifyButton));
738 stateDummyButton.setToolTipText(t("dali.home.survey.changeStatus"));
739 controlButton.setIcon(SwingUtil.createActionIcon("control"));
740 controlButton.setToolTipText(t("dali.home.survey.control"));
741 validateButton.setIcon(SwingUtil.createActionIcon("accept"));
742 validateButton.setToolTipText(t("dali.home.survey.validate"));
743 unvalidateButton.setIcon(SwingUtil.createActionIcon("cancel"));
744 unvalidateButton.setToolTipText(t("dali.home.survey.unvalidate"));
745 qualifyButton.setIcon(SwingUtil.createActionIcon("qualify"));
746 qualifyButton.setToolTipText(t("dali.home.survey.qualify"));
747 showMapButton.setIcon(SwingUtil.createActionIcon("map"));
748 hideMapButton.setIcon(SwingUtil.createActionIcon("map"));
749 deleteButton.setIcon(SwingUtil.createActionIcon("delete"));
750 nextButton.setIcon(SwingUtil.createActionIcon("next"));
751
752
753 DaliHelpBroker _broker = getBroker();
754 registerHelpId(_broker, editMenuItem, "dali.main.menu.action.home.help");
755 registerHelpId(_broker, nextButton, "dali.main.menu.action.home.help");
756 _broker.prepareUI(this);
757 }
758
759 private void $initialize() {
760 if (allComponentsCreated) {
761 return;
762 }
763 if (log.isDebugEnabled()) {
764 log.debug(this);
765 }
766 handler.beforeInit(this);
767 $objectMap.put("surveysTableUI", surveysTableUI);
768 createModel();
769 createBroker();
770
771 $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
772
773 $JScrollPane0.setName("$JScrollPane0");
774 createTablePopup();
775 createEditMenuItem();
776 createSurveysTable();
777 createSurveysTableUIButtons();
778
779 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
780
781 $JPanel0.setName("$JPanel0");
782 createNewButton();
783 createDuplicateButton();
784 createEditCombo();
785 createEditDummyButton();
786 createEditSurveyButton();
787 createEditMeasurementButton();
788 createEditPhotoButton();
789 createStateCombo();
790 createStateDummyButton();
791 createControlButton();
792 createValidateButton();
793 createUnvalidateButton();
794 createQualifyButton();
795 createShowMapButton();
796 createHideMapButton();
797 createDeleteButton();
798
799 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
800
801 $JPanel1.setName("$JPanel1");
802 createNextButton();
803
804 setName("surveysTableUI");
805 setLayout(new BorderLayout());
806 surveysTableUI.putClientProperty("panelType", DaliUI.EDITION_PANEL_TYPE);
807
808
809 $registerDefaultBindings();
810 $completeSetup();
811 handler.afterInit(this);
812 }
813
814 private void $registerDefaultBindings() {
815
816 registerDataBinding(new DefaultJAXXBinding(this, BINDING_EDIT_MENU_ITEM_ENABLED, true) {
817
818 @Override
819 public void applyDataBinding() {
820 if (model != null) {
821 model.addPropertyChangeListener("singleSelectedRow", this);
822 }
823 }
824
825 @Override
826 public void processDataBinding() {
827 if (model != null) {
828 editMenuItem.setEnabled(model.getSingleSelectedRow() != null);
829 }
830 }
831
832 @Override
833 public void removeDataBinding() {
834 if (model != null) {
835 model.removePropertyChangeListener("singleSelectedRow", this);
836 }
837 }
838 });
839 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DUPLICATE_BUTTON_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 duplicateButton.setEnabled(model.getSelectedRows().size() == 1);
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_EDIT_COMBO_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 editCombo.setEnabled(model.getSelectedRows().size() == 1);
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_STATE_COMBO_ENABLED, true) {
886
887 @Override
888 public void applyDataBinding() {
889 if (model != null) {
890 model.addPropertyChangeListener("selectedRows", this);
891 }
892 }
893
894 @Override
895 public void processDataBinding() {
896 if (model != null && model.getSelectedRows() != null) {
897 stateCombo.setEnabled(!model.getSelectedRows().isEmpty());
898 }
899 }
900
901 @Override
902 public void removeDataBinding() {
903 if (model != null) {
904 model.removePropertyChangeListener("selectedRows", this);
905 }
906 }
907 });
908 registerDataBinding(new DefaultJAXXBinding(this, BINDING_SHOW_MAP_BUTTON_ENABLED, true) {
909
910 @Override
911 public void applyDataBinding() {
912 if (model != null) {
913 model.addPropertyChangeListener("selectedRows", this);
914 }
915 }
916
917 @Override
918 public void processDataBinding() {
919 if (model != null && model.getSelectedRows() != null) {
920 showMapButton.setEnabled(!model.getSelectedRows().isEmpty());
921 }
922 }
923
924 @Override
925 public void removeDataBinding() {
926 if (model != null) {
927 model.removePropertyChangeListener("selectedRows", this);
928 }
929 }
930 });
931 registerDataBinding(new DefaultJAXXBinding(this, BINDING_HIDE_MAP_BUTTON_VISIBLE, true) {
932
933 @Override
934 public void applyDataBinding() {
935 if (showMapButton != null) {
936 $bindingSources.put("showMapButton", showMapButton);
937 showMapButton.addComponentListener( JAXXUtil.getEventListener(ComponentListener.class, this, "$pr$u0"));
938 }
939 }
940
941 @Override
942 public void processDataBinding() {
943 if (showMapButton != null) {
944 hideMapButton.setVisible(!showMapButton.isVisible());
945 }
946 }
947
948 @Override
949 public void removeDataBinding() {
950 if (showMapButton != null) {
951 JButton $target = (JButton) $bindingSources.remove("showMapButton");
952 if ($target != null) {
953 $target.removeComponentListener( JAXXUtil.getEventListener(ComponentListener.class, this, "$pr$u0"));
954 }
955 }
956 }
957
958 public void $pr$u0(ComponentEvent event) {
959 if (log.isDebugEnabled()) {
960 log.debug(event);
961 }
962 propertyChange(null);
963 }
964 });
965 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DELETE_BUTTON_ENABLED, true) {
966
967 @Override
968 public void applyDataBinding() {
969 if (model != null) {
970 model.addPropertyChangeListener("selectedRows", this);
971 }
972 }
973
974 @Override
975 public void processDataBinding() {
976 if (model != null && model.getSelectedRows() != null) {
977 deleteButton.setEnabled(!model.getSelectedRows().isEmpty());
978 }
979 }
980
981 @Override
982 public void removeDataBinding() {
983 if (model != null) {
984 model.removePropertyChangeListener("selectedRows", this);
985 }
986 }
987 });
988 registerDataBinding(new DefaultJAXXBinding(this, BINDING_NEXT_BUTTON_ENABLED, true, true) {
989
990 @Override
991 public void applyDataBinding() {
992 if (model != null) {
993 model.addPropertyChangeListener("samplingOperationsLoading", this);
994 }
995 if (model != null) {
996 model.addPropertyChangeListener("selectedSurveyEditable", this);
997 }
998 }
999
1000 @Override
1001 public void processDataBinding() {
1002 if (model != null) {
1003 nextButton.setEnabled(!model.isSamplingOperationsLoading() && model.isSelectedSurveyEditable());
1004 }
1005 }
1006
1007 @Override
1008 public void removeDataBinding() {
1009 if (model != null) {
1010 model.removePropertyChangeListener("samplingOperationsLoading", this);
1011 }
1012 if (model != null) {
1013 model.removePropertyChangeListener("selectedSurveyEditable", this);
1014 }
1015 }
1016 });
1017 }
1018
1019 }