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