1 package fr.ifremer.dali.ui.swing.content.manage.program.locations;
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.component.ToggleButton;
9 import fr.ifremer.quadrige3.ui.swing.plaf.WaitBlockingLayerUI;
10 import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
11 import java.awt.BorderLayout;
12 import java.awt.Component;
13 import java.awt.Container;
14 import java.awt.GridBagConstraints;
15 import java.awt.Insets;
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.JCheckBox;
28 import javax.swing.JComboBox;
29 import javax.swing.JPanel;
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.Table;
40 import jaxx.runtime.swing.help.JAXXHelpUI;
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43 import static org.nuiton.i18n.I18n.t;
44
45 public class LocationsTableUI extends Table implements JAXXHelpUI<DaliHelpBroker>, DaliUI<LocationsTableUIModel, LocationsTableUIHandler>, JAXXObject {
46
47
48
49
50
51 public static final String BINDING_ADD_LOCATIONS_BUTTON_ENABLED = "addLocationsButton.enabled";
52 public static final String BINDING_EDIT_COMBOBOX_ENABLED = "editCombobox.enabled";
53 public static final String BINDING_LOCATIONS_TABLE_EDITABLE = "locationsTable.editable";
54 public static final String BINDING_REMOVE_LOCATIONS_BUTTON_ENABLED = "removeLocationsButton.enabled";
55 public static final String BINDING_SHOW_STRATEGIES_BUTTON_ENABLED = "showStrategiesButton.enabled";
56 public static final String BINDING_STRATEGY_FILTER_CHECKBOX_ENABLED = "strategyFilterCheckbox.enabled";
57 public static final String BINDING_TABLE_BLOCK_LAYER_BLOCK = "tableBlockLayer.block";
58 public static final String BINDING_UPDATE_PERIOD_BUTTON_ENABLED = "updatePeriodButton.enabled";
59
60
61
62
63
64 private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAALVXzW8bRRSfuLHz1TaQNKHQpHLc0DiiXUNBCBQ+mo9GTeTSqk5FRA4w9k6cScY7291xYisK4k/gT4A7FyTEpSfEgTMSXBD/AkIcuCLem/Xueu31R3DxYbWeee837/3em9/MfvMHSboOWTiktZrhVC3FK8zYXt3dfVg8ZCW1wdySw20lHeL9hhIksUcmzGDcVeTGXh7dcw333Lqs2NJiVpP3Sp6Mu6oumHvAmFJkPupRct1cIZheqdlVx0cNgopD/eqvPxNfml98nSCkZkN0L0Aq6V5eYSbDeZLgpiJTsNIxzQlqlSEMh1tliPcSjq0L6rof0Qp7Sj4nI3mSsqkDYIpk+k9ZY2j/mq3IuKJFwR5RiwlFtvcdg+87rMIcw6SCG1VuuCewvlGSlgI4o0ItWmaG7ciyQyuGkCWquLRcI++/7SDeky3b1mukFElWpIngD58f+ANEDFdIFR15xBxFljousQH/7oPPmrYMXSd1+muw1FGe1hHj7SaMp1VqOrzM3gyBbEH3jY8pV9oHRrRbc74eZKHkSCGQV0VewtLVGgDb4Qw6jAV+l0UkS0WM7pHoZYwCvmsHhJkJ0EYXt3VRX4d2iiyvR6Mr+7Zv4P95fFwL5qaoaQb0r1WVglqR6QiiN4r21wO3i8zkCrqwKIuypshMxEGPr8la1GWqaptUsUfM4dIMMTNRqyvugTyBTQGWZc7cjnYzwJs8Zi2hxxjOuh5YfZMLxZz1A1Y6iosZx9ti9pm7E8Pc7H5VCCg2Y9aOLJehyxrsvdW9riV/7xrNbgias0FPrkX0BJTKCJUqlJKhPZJ0qjCsyNW9dnF7DFOerF1tkTUE1LP/zE7/+uz37zZ9LZuFtWdiTZukGDQGdq8N+4jj0pOekFUVF7kH1F7ZI2MuE6DjWqfnYgIrNKYhOFjvRXQ30N24T90DgEiO/PbDj7Of/XyBJDbJuJDU3KRov0XG1IEDLEhh1uwP7+qILp6MoghjbCgS0jFxg2+cruk3z7FuQIWg/jtcCWZ6M1mVzWj5aFUiQ6FVZnn5rAbUzcVQF8RfHPvp7+nCt3d9+oYgnZc7mocUJj8hKW4JbjF9GDR0Plb8J2yXVU0Z6nmcwpOIxNsNmXpXP9+P42kUd64nQFdOtXQb3L3XGMti5ui6qlPCt3XSJl29VhmGmIB8sN9C6ScXQGMUjLIanGSTmnnYBBXg22InikwoKcUOt3f0/Hx8ZcASqgMH2gizMAYAzAbh56FPmJldTt+8me4zpRjdO29aKViIKRZkNtWcmT8XTS4dn5xn3JrfUZ/54eiCP+zJq3vPA4lMlpny+pGZj+WJm11GlIqt6h0oipfYXiwlAj5ejSTry3DTsS9oES8OYcZG14xbU4sNuoPc9xG1f4/ZPj2glilAvKHnVnW9/QNN30uy7efYrXTcqbV81pzbO7G5/cfSRI7fXrklW/p2GJ0htGPucq0DyX0q3LCPO+xA26O/taUXulq39vThOXr6f2jpmDtIL/bw5vIptW3Bvcy8joDT7bQQqbk3bpRQm8/OyXgHWXAD8FbSF3s5tPL+XLsv9o7WB4+QA154TI+UW6f6bvsET3/vjF4NKMtmqtZmcL3K4E7ynT0Cbpz6Z7h3TT7mcD60+USKMB7e16CkPlozq0u9QJFVDdyo2yutxs1LRCt2vbMposZKWfwFsx8pK+LHC9zjI1UHsrMY/KVi49NmXQoJF6bbgeBBI6xLa5+DnfcO85HvoA4N0fqV1cc1JCVoXUI+5PJ7sCNpusgtDPCDNvghfM71gTgOBJetClC/izbfxyMt9ETC4WddEBYHRlgaGGF5YITXBka43UdNhnnJ+7QZqBq/DMxlN4T+uOyG0B+X3RDuAMK/Q+JXLhsTAAA=";
65 private static final Log log = LogFactory.getLog(LocationsTableUI.class);
66 private static final long serialVersionUID = 1L;
67
68
69
70
71
72 protected List<Object> $activeBindings = new ArrayList<Object>();
73 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
74 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
75 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
76 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
77 private boolean allComponentsCreated;
78 protected final JAXXContext delegateContext = new DefaultJAXXContext();
79
80
81
82
83
84 protected JButton addLocationsButton;
85 protected DaliHelpBroker broker;
86 protected JComboBox editCombobox;
87 protected ToggleButton fullScreenToggleButton;
88 protected final LocationsTableUIHandler handler = createHandler();
89 protected SwingTable locationsTable;
90 protected LocationsTableUIModel model;
91 protected JButton removeLocationsButton;
92 protected JButton showStrategiesButton;
93 protected JCheckBox strategyFilterCheckbox;
94 protected WaitBlockingLayerUI tableBlockLayer;
95 protected LocationsTableUI tablePanel = this;
96 protected JScrollPane tableScrollPane;
97 protected JButton updatePeriodButton;
98
99
100
101
102
103 private JPanel $JPanel0;
104 private JPanel $JPanel1;
105 private JPanel $JPanel2;
106
107
108
109
110
111 public LocationsTableUI(ApplicationUI parentUI) {
112 ApplicationUIUtil.setParentUI(this, parentUI);
113 $initialize();
114 }
115
116 public LocationsTableUI() {
117 $initialize();
118 }
119
120 public LocationsTableUI(JAXXContext parentContext) {
121 JAXXUtil.initContext(this, parentContext);
122 $initialize();
123 }
124
125
126
127
128
129 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
130 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
131 }
132
133
134
135
136
137 @Override
138 public void applyDataBinding(String $binding) {
139 if (allComponentsCreated && $bindings.containsKey($binding)) {
140 getDataBinding($binding).applyDataBinding();
141 }
142 processDataBinding($binding);
143 }
144
145 @Override
146 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
147 super.firePropertyChange(propertyName, oldValue, newValue);
148 }
149
150 @Override
151 public Map<String, Object> get$objectMap() {
152 return $objectMap;
153 }
154
155 @Override
156 public JAXXBinding getDataBinding(String bindingId) {
157 return $bindings.get(bindingId);
158 }
159
160 @Override
161 public JAXXBinding[] getDataBindings() {
162 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
163 }
164
165 @Override
166 public Object getObjectById(String id) {
167 return $objectMap.get(id);
168 }
169
170 @Override
171 public void processDataBinding(String $binding, boolean $force) {
172 if (!$force && $activeBindings.contains($binding)) {
173 return;
174 }
175 $activeBindings.add($binding);
176 try {
177 if (allComponentsCreated && $bindings.containsKey($binding)) {
178 getDataBinding($binding).processDataBinding();
179 }
180 } finally {
181 $activeBindings.remove($binding);
182 }
183 }
184
185 @Override
186 public void processDataBinding(String $binding) {
187 processDataBinding($binding, false);
188 }
189
190 @Override
191 public void registerDataBinding(JAXXBinding binding) {
192 $bindings.put(binding.getId(), binding);
193 }
194
195 @Override
196 public void removeDataBinding(String $binding) {
197 if (allComponentsCreated && $bindings.containsKey($binding)) {
198 getDataBinding($binding).removeDataBinding();
199 }
200 }
201
202
203
204
205
206 @Override
207 public <T> T getContextValue(Class<T> clazz) {
208 return delegateContext.getContextValue(clazz, null);
209 }
210
211 @Override
212 public <T> T getContextValue(Class<T> clazz, String name) {
213 return delegateContext.getContextValue(clazz, name);
214 }
215
216 @Override
217 public JAXXContext getDelegateContext() {
218 return delegateContext;
219 }
220
221 @Override
222 public <O extends Container> O getParentContainer(Class<O> clazz) {
223 return SwingUtil.getParentContainer(this, clazz);
224 }
225
226 @Override
227 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
228 return SwingUtil.getParentContainer(source, clazz);
229 }
230
231 @Override
232 public <T> void removeContextValue(Class<T> clazz) {
233 delegateContext.removeContextValue(clazz, null);
234 }
235
236 @Override
237 public <T> void removeContextValue(Class<T> clazz, String name) {
238 delegateContext.removeContextValue(clazz, name);
239 }
240
241 @Override
242 public <T> void setContextValue(T o) {
243 delegateContext.setContextValue(o, null);
244 }
245
246 @Override
247 public <T> void setContextValue(T o, String name) {
248 delegateContext.setContextValue(o, name);
249 }
250
251
252
253
254
255 public void doActionPerformed__on__addLocationsButton(ActionEvent event) {
256 if (log.isDebugEnabled()) {
257 log.debug(event);
258 }
259 handler.addLocations();
260 }
261
262 public void doActionPerformed__on__fullScreenToggleButton(ActionEvent event) {
263 if (log.isDebugEnabled()) {
264 log.debug(event);
265 }
266 handler.toggleFullScreen(tablePanel, fullScreenToggleButton);
267 }
268
269 public void doActionPerformed__on__removeLocationsButton(ActionEvent event) {
270 if (log.isDebugEnabled()) {
271 log.debug(event);
272 }
273 handler.removeLocations();
274 }
275
276 public void doActionPerformed__on__updatePeriodButton(ActionEvent event) {
277 if (log.isDebugEnabled()) {
278 log.debug(event);
279 }
280 handler.updatePeriod();
281 }
282
283
284
285
286
287 public JButton getAddLocationsButton() {
288 return addLocationsButton;
289 }
290
291 public DaliHelpBroker getBroker() {
292 return broker;
293 }
294
295 public JComboBox getEditCombobox() {
296 return editCombobox;
297 }
298
299 public ToggleButton getFullScreenToggleButton() {
300 return fullScreenToggleButton;
301 }
302
303 public LocationsTableUIHandler getHandler() {
304 return handler;
305 }
306
307 public SwingTable getLocationsTable() {
308 return locationsTable;
309 }
310
311 public LocationsTableUIModel getModel() {
312 return model;
313 }
314
315 public JButton getRemoveLocationsButton() {
316 return removeLocationsButton;
317 }
318
319 public JButton getShowStrategiesButton() {
320 return showStrategiesButton;
321 }
322
323 public JCheckBox getStrategyFilterCheckbox() {
324 return strategyFilterCheckbox;
325 }
326
327 public WaitBlockingLayerUI getTableBlockLayer() {
328 return tableBlockLayer;
329 }
330
331 public JScrollPane getTableScrollPane() {
332 return tableScrollPane;
333 }
334
335 public JButton getUpdatePeriodButton() {
336 return updatePeriodButton;
337 }
338
339
340
341
342
343 @Override
344 public void registerHelpId(DaliHelpBroker broker, Component component, String helpId) {
345 broker.installUI(component, helpId);
346 }
347
348 @Override
349 public void showHelp(String helpId) {
350 getBroker().showHelp(this, helpId);
351 }
352
353
354
355
356
357 protected JPanel get$JPanel0() {
358 return $JPanel0;
359 }
360
361 protected JPanel get$JPanel1() {
362 return $JPanel1;
363 }
364
365 protected JPanel get$JPanel2() {
366 return $JPanel2;
367 }
368
369
370
371
372
373 protected void addChildrenToTablePanel() {
374 if (!allComponentsCreated) {
375 return;
376 }
377 add(SwingUtil.boxComponentWithJxLayer(tableScrollPane), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
378 add($JPanel0, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
379 }
380
381 protected void addChildrenToTableScrollPane() {
382 if (!allComponentsCreated) {
383 return;
384 }
385 tableScrollPane.getViewport().add(locationsTable);
386 }
387
388 protected void createAddLocationsButton() {
389 $objectMap.put("addLocationsButton", addLocationsButton = new JButton());
390
391 addLocationsButton.setName("addLocationsButton");
392 addLocationsButton.setText(t("dali.common.new"));
393 addLocationsButton.setToolTipText(t("dali.program.location.new.tip"));
394 addLocationsButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__addLocationsButton"));
395 }
396
397 protected void createBroker() {
398 $objectMap.put("broker", broker = new DaliHelpBroker("dali.home.help"));
399 }
400
401 protected void createEditCombobox() {
402 $objectMap.put("editCombobox", editCombobox = new JComboBox());
403
404 editCombobox.setName("editCombobox");
405 }
406
407 protected void createFullScreenToggleButton() {
408 $objectMap.put("fullScreenToggleButton", fullScreenToggleButton = new ToggleButton());
409
410 fullScreenToggleButton.setName("fullScreenToggleButton");
411 fullScreenToggleButton.setText(t("dali.table.view.fullScreen"));
412 fullScreenToggleButton.setToolTipText(t("dali.table.view.fullScreen.tip"));
413 fullScreenToggleButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__fullScreenToggleButton"));
414 }
415
416 protected LocationsTableUIHandler createHandler() {
417 return new LocationsTableUIHandler();
418 }
419
420 protected void createLocationsTable() {
421 $objectMap.put("locationsTable", locationsTable = new SwingTable());
422
423 locationsTable.setName("locationsTable");
424 }
425
426 protected void createModel() {
427 $objectMap.put("model", model = getContextValue(LocationsTableUIModel.class));
428 }
429
430 protected void createRemoveLocationsButton() {
431 $objectMap.put("removeLocationsButton", removeLocationsButton = new JButton());
432
433 removeLocationsButton.setName("removeLocationsButton");
434 removeLocationsButton.setText(t("dali.common.delete"));
435 removeLocationsButton.setToolTipText(t("dali.program.location.delete.tip"));
436 removeLocationsButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__removeLocationsButton"));
437 }
438
439 protected void createShowStrategiesButton() {
440 $objectMap.put("showStrategiesButton", showStrategiesButton = new JButton());
441
442 showStrategiesButton.setName("showStrategiesButton");
443 showStrategiesButton.setVisible(false);
444 showStrategiesButton.setText(t("dali.program.location.strategies"));
445 showStrategiesButton.setToolTipText(t("dali.program.location.strategies.tip"));
446 showStrategiesButton.putClientProperty("applicationAction", ShowStrategiesAction.class);
447 }
448
449 protected void createStrategyFilterCheckbox() {
450 $objectMap.put("strategyFilterCheckbox", strategyFilterCheckbox = new JCheckBox());
451
452 strategyFilterCheckbox.setName("strategyFilterCheckbox");
453 strategyFilterCheckbox.setText(t("dali.program.strategy.locations.label"));
454 }
455
456 protected void createTableBlockLayer() {
457 $objectMap.put("tableBlockLayer", tableBlockLayer = new WaitBlockingLayerUI());
458 }
459
460 protected void createTableScrollPane() {
461 $objectMap.put("tableScrollPane", tableScrollPane = new JScrollPane());
462
463 tableScrollPane.setName("tableScrollPane");
464 }
465
466 protected void createUpdatePeriodButton() {
467 $objectMap.put("updatePeriodButton", updatePeriodButton = new JButton());
468
469 updatePeriodButton.setName("updatePeriodButton");
470 updatePeriodButton.setVisible(false);
471 updatePeriodButton.setText(t("dali.program.location.periods"));
472 updatePeriodButton.setToolTipText(t("dali.program.location.periods.tip"));
473 updatePeriodButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__updatePeriodButton"));
474 }
475
476
477
478
479
480 private void $completeSetup() {
481 allComponentsCreated = true;
482 if (log.isDebugEnabled()) {
483 log.debug(this);
484 }
485 addChildrenToTablePanel();
486 addChildrenToTableScrollPane();
487
488 $JPanel0.add($JPanel1, BorderLayout.LINE_START);
489 $JPanel0.add($JPanel2, BorderLayout.LINE_END);
490
491 $JPanel1.add(addLocationsButton);
492 $JPanel1.add(editCombobox);
493 $JPanel1.add(updatePeriodButton);
494 $JPanel1.add(showStrategiesButton);
495 $JPanel1.add(removeLocationsButton);
496 $JPanel1.add(strategyFilterCheckbox);
497
498 $JPanel2.add(fullScreenToggleButton);
499
500
501 JAXXUtil.applyDataBinding(this, $bindings.keySet());
502
503
504 addLocationsButton.setAlignmentX(Component.CENTER_ALIGNMENT);
505 editCombobox.setAlignmentX(Component.CENTER_ALIGNMENT);
506 updatePeriodButton.setAlignmentX(Component.CENTER_ALIGNMENT);
507 showStrategiesButton.setAlignmentX(Component.CENTER_ALIGNMENT);
508 removeLocationsButton.setAlignmentX(Component.CENTER_ALIGNMENT);
509 strategyFilterCheckbox.setAlignmentX(Component.CENTER_ALIGNMENT);
510 setBorder(BorderFactory.createTitledBorder(t("dali.program.location.title")));
511 tableBlockLayer.setBlockingColor(handler.getConfig().getColorBlockingLayer());
512 addLocationsButton.setIcon(SwingUtil.createActionIcon("add"));
513 editCombobox.setModel(handler.newActionComboBoxModel(updatePeriodButton, showStrategiesButton));
514 updatePeriodButton.setIcon(SwingUtil.createActionIcon("edit"));
515 showStrategiesButton.setIcon(SwingUtil.createActionIcon("edit"));
516 removeLocationsButton.setIcon(SwingUtil.createActionIcon("delete"));
517 fullScreenToggleButton.setToggledIcon(SwingUtil.createActionIcon("unFullScreen"));
518 fullScreenToggleButton.setToggledText(t("dali.table.view.unFullScreen"));
519 fullScreenToggleButton.setIcon(SwingUtil.createActionIcon("fullScreen"));
520 fullScreenToggleButton.setToggledToolTipText(t("dali.table.view.unFullScreen.tip"));
521 }
522
523 private void $initialize() {
524 if (allComponentsCreated) {
525 return;
526 }
527 if (log.isDebugEnabled()) {
528 log.debug(this);
529 }
530 handler.beforeInit(this);
531 $objectMap.put("tablePanel", tablePanel);
532 createModel();
533 createBroker();
534 createTableBlockLayer();
535 createTableScrollPane();
536 createLocationsTable();
537
538 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
539
540 $JPanel0.setName("$JPanel0");
541 $JPanel0.setLayout(new BorderLayout());
542
543 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
544
545 $JPanel1.setName("$JPanel1");
546 createAddLocationsButton();
547 createEditCombobox();
548 createUpdatePeriodButton();
549 createShowStrategiesButton();
550 createRemoveLocationsButton();
551 createStrategyFilterCheckbox();
552
553 $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
554
555 $JPanel2.setName("$JPanel2");
556 createFullScreenToggleButton();
557
558 setName("tablePanel");
559
560
561 $registerDefaultBindings();
562 $completeSetup();
563 handler.afterInit(this);
564 }
565
566 private void $registerDefaultBindings() {
567
568 registerDataBinding(new DefaultJAXXBinding(this, BINDING_TABLE_BLOCK_LAYER_BLOCK, true) {
569
570 @Override
571 public void applyDataBinding() {
572 if (model != null) {
573 model.addPropertyChangeListener("loading", this);
574 }
575 }
576
577 @Override
578 public void processDataBinding() {
579 if (model != null) {
580 tableBlockLayer.setBlock(model.isLoading());
581 }
582 }
583
584 @Override
585 public void removeDataBinding() {
586 if (model != null) {
587 model.removePropertyChangeListener("loading", this);
588 }
589 }
590 });
591 registerDataBinding(new DefaultJAXXBinding(this, BINDING_LOCATIONS_TABLE_EDITABLE, true) {
592
593 @Override
594 public void applyDataBinding() {
595 if (model != null) {
596 model.addPropertyChangeListener("editable", this);
597 }
598 }
599
600 @Override
601 public void processDataBinding() {
602 if (model != null) {
603 locationsTable.setEditable(model.isEditable());
604 }
605 }
606
607 @Override
608 public void removeDataBinding() {
609 if (model != null) {
610 model.removePropertyChangeListener("editable", this);
611 }
612 }
613 });
614 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ADD_LOCATIONS_BUTTON_ENABLED, true, true) {
615
616 @Override
617 public void applyDataBinding() {
618 if (model != null) {
619 model.addPropertyChangeListener("loaded", this);
620 }
621 if (model != null) {
622 model.addPropertyChangeListener("editable", this);
623 }
624 }
625
626 @Override
627 public void processDataBinding() {
628 if (model != null) {
629 addLocationsButton.setEnabled(model.isLoaded() && model.isEditable());
630 }
631 }
632
633 @Override
634 public void removeDataBinding() {
635 if (model != null) {
636 model.removePropertyChangeListener("loaded", this);
637 }
638 if (model != null) {
639 model.removePropertyChangeListener("editable", this);
640 }
641 }
642 });
643 registerDataBinding(new DefaultJAXXBinding(this, BINDING_EDIT_COMBOBOX_ENABLED, true, true) {
644
645 @Override
646 public void applyDataBinding() {
647 if (model != null) {
648 model.addPropertyChangeListener("loaded", this);
649 }
650 if (model != null) {
651 model.addPropertyChangeListener("selectedRows", this);
652 }
653 }
654
655 @Override
656 public void processDataBinding() {
657 if (model != null && model.getSelectedRows() != null) {
658 editCombobox.setEnabled(model.isLoaded() && !model.getSelectedRows().isEmpty());
659 }
660 }
661
662 @Override
663 public void removeDataBinding() {
664 if (model != null) {
665 model.removePropertyChangeListener("loaded", this);
666 }
667 if (model != null) {
668 model.removePropertyChangeListener("selectedRows", this);
669 }
670 }
671 });
672 registerDataBinding(new DefaultJAXXBinding(this, BINDING_UPDATE_PERIOD_BUTTON_ENABLED, true, true) {
673
674 @Override
675 public void applyDataBinding() {
676 if (model != null) {
677 model.addPropertyChangeListener("loaded", this);
678 }
679 if (model != null) {
680 model.addPropertyChangeListener("editable", this);
681 }
682 if (model != null) {
683 model.addPropertyChangeListener("periodsEnabled", this);
684 }
685 if (model != null) {
686 model.addPropertyChangeListener("selectedRows", this);
687 }
688 }
689
690 @Override
691 public void processDataBinding() {
692 if (model != null && model.getSelectedRows() != null) {
693 updatePeriodButton.setEnabled(model.isLoaded() && model.isEditable() && model.isPeriodsEnabled() && !model.getSelectedRows().isEmpty());
694 }
695 }
696
697 @Override
698 public void removeDataBinding() {
699 if (model != null) {
700 model.removePropertyChangeListener("loaded", this);
701 }
702 if (model != null) {
703 model.removePropertyChangeListener("editable", this);
704 }
705 if (model != null) {
706 model.removePropertyChangeListener("periodsEnabled", this);
707 }
708 if (model != null) {
709 model.removePropertyChangeListener("selectedRows", this);
710 }
711 }
712 });
713 registerDataBinding(new DefaultJAXXBinding(this, BINDING_SHOW_STRATEGIES_BUTTON_ENABLED, true, true) {
714
715 @Override
716 public void applyDataBinding() {
717 if (model != null) {
718 model.addPropertyChangeListener("loaded", this);
719 }
720 if (model != null) {
721 model.addPropertyChangeListener("selectedRows", this);
722 }
723 }
724
725 @Override
726 public void processDataBinding() {
727 if (model != null && model.getSelectedRows() != null) {
728 showStrategiesButton.setEnabled(model.isLoaded() && !model.getSelectedRows().isEmpty());
729 }
730 }
731
732 @Override
733 public void removeDataBinding() {
734 if (model != null) {
735 model.removePropertyChangeListener("loaded", this);
736 }
737 if (model != null) {
738 model.removePropertyChangeListener("selectedRows", this);
739 }
740 }
741 });
742 registerDataBinding(new DefaultJAXXBinding(this, BINDING_REMOVE_LOCATIONS_BUTTON_ENABLED, true, true) {
743
744 @Override
745 public void applyDataBinding() {
746 if (model != null) {
747 model.addPropertyChangeListener("loaded", this);
748 }
749 if (model != null) {
750 model.addPropertyChangeListener("editable", this);
751 }
752 if (model != null) {
753 model.addPropertyChangeListener("periodsEnabled", this);
754 }
755 if (model != null) {
756 model.addPropertyChangeListener("selectedRows", this);
757 }
758 }
759
760 @Override
761 public void processDataBinding() {
762 if (model != null && model.getSelectedRows() != null) {
763 removeLocationsButton.setEnabled(model.isLoaded() && model.isEditable() && !model.isPeriodsEnabled() && !model.getSelectedRows().isEmpty());
764 }
765 }
766
767 @Override
768 public void removeDataBinding() {
769 if (model != null) {
770 model.removePropertyChangeListener("loaded", this);
771 }
772 if (model != null) {
773 model.removePropertyChangeListener("editable", this);
774 }
775 if (model != null) {
776 model.removePropertyChangeListener("periodsEnabled", this);
777 }
778 if (model != null) {
779 model.removePropertyChangeListener("selectedRows", this);
780 }
781 }
782 });
783 registerDataBinding(new DefaultJAXXBinding(this, BINDING_STRATEGY_FILTER_CHECKBOX_ENABLED, true, true) {
784
785 @Override
786 public void applyDataBinding() {
787 if (model != null) {
788 model.addPropertyChangeListener("loaded", this);
789 }
790 if (model != null) {
791 model.addPropertyChangeListener("periodsEnabled", this);
792 }
793 }
794
795 @Override
796 public void processDataBinding() {
797 if (model != null) {
798 strategyFilterCheckbox.setEnabled(model.isLoaded() && model.isPeriodsEnabled());
799 }
800 }
801
802 @Override
803 public void removeDataBinding() {
804 if (model != null) {
805 model.removePropertyChangeListener("loaded", this);
806 }
807 if (model != null) {
808 model.removePropertyChangeListener("periodsEnabled", this);
809 }
810 }
811 });
812 }
813
814 }