View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.cruise;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU General Public License as
13   * published by the Free Software Foundation, either version 3 of the
14   * License, or (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public
22   * License along with this program.  If not, see
23   * <http://www.gnu.org/licenses/gpl-3.0.html>.
24   * #L%
25   */
26  
27  import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
28  import fr.ifremer.tutti.ui.swing.util.TuttiUI;
29  import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
30  import java.awt.Color;
31  import java.awt.Container;
32  import java.awt.GridBagConstraints;
33  import java.awt.GridLayout;
34  import java.awt.Insets;
35  import java.awt.event.KeyEvent;
36  import java.awt.event.KeyListener;
37  import java.awt.event.MouseEvent;
38  import java.awt.event.MouseListener;
39  import java.util.ArrayList;
40  import java.util.HashMap;
41  import java.util.List;
42  import java.util.Map;
43  import java.util.TreeMap;
44  import javax.swing.JButton;
45  import javax.swing.JMenuItem;
46  import javax.swing.JPanel;
47  import javax.swing.JPopupMenu;
48  import javax.swing.JScrollPane;
49  import javax.swing.ListSelectionModel;
50  import jaxx.runtime.JAXXBinding;
51  import jaxx.runtime.JAXXContext;
52  import jaxx.runtime.JAXXObject;
53  import jaxx.runtime.JAXXObjectDescriptor;
54  import jaxx.runtime.JAXXUtil;
55  import jaxx.runtime.SwingUtil;
56  import jaxx.runtime.binding.DefaultJAXXBinding;
57  import jaxx.runtime.context.DefaultJAXXContext;
58  import jaxx.runtime.swing.Table;
59  import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
60  import org.apache.commons.logging.Log;
61  import org.apache.commons.logging.LogFactory;
62  import org.jdesktop.swingx.JXTable;
63  import static org.nuiton.i18n.I18n.t;
64  
65  public class GearCaracteristicsEditorUI extends Table implements TuttiUI<GearCaracteristicsEditorUIModel, GearCaracteristicsEditorUIHandler>, JAXXObject {
66  
67      /*-----------------------------------------------------------------------*/
68      /*------------------ Constants for all public bindings ------------------*/
69      /*-----------------------------------------------------------------------*/
70  
71      public static final String BINDING_ADD_ROW_ENABLED = "addRow.enabled";
72      public static final String BINDING_ADD_ROW_VISIBLE = "addRow.visible";
73      public static final String BINDING_GEAR_CARACTERISTICS_EDITOR_TABLE_EDITABLE = "gearCaracteristicsEditorTable.editable";
74      public static final String BINDING_NEW_ROW_KEY_ENABLED = "newRowKey.enabled";
75      public static final String BINDING_NEW_ROW_KEY_VISIBLE = "newRowKey.visible";
76      public static final String BINDING_REMOVE_CARACTERISTIC_MENU_ENABLED = "removeCaracteristicMenu.enabled";
77      public static final String BINDING_SAVE_BUTTON_ENABLED = "saveButton.enabled";
78  
79      /*-----------------------------------------------------------------------*/
80      /*------------------------- Other static fields -------------------------*/
81      /*-----------------------------------------------------------------------*/
82  
83      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAALVXTW8bRRieOLHz6QYakrS0lZIQQpFgU5CKitLSxm7SOHWSErttIIcw3p3Yk453ltlZx5FVxE/gJ8CNAxcQN06IA2cOXBB/ASEOXBHvzK693nhdhyTksIpm5n3e5/143hl/8wdKugLNHuB63RCeLWmVGOvLOztbpQNiyvvENQV1JBfI/+tLoMQuGrVa665Er+3mlfliYL6Y5VWH28Rus17KoxFXHjHiVgiREl2LWpiuu1hobS/VHU80UVuk4lC//OvPxBfW518lEKo7wG4UQpnpZRVGMpBHCWpJdBE81fAiw3YZaAhql4FvWq1lGXbdTVwln6LP0GAepRwsAEyiuZOHrDG0fd2RaHC+iEuM3JAouy8Mui9IlQhDelJSw6OGewjeDZPbEsAMU3jUJcYDgkUWC2xKIqgrqemuWBRcPM45jkZOSZSscoswidbOAXVDQYXQI1IxfsQdD/hPqbTUA8R1vbhBbC88PQ2+eY1EkNUJiSYjpmotJ0lVmY23rIdtcrjNDx+SI4luRirpmxFN0SgRbBsZ+KxSBk4UPyhBiWd4XQENt/BS2LIAT6KJiPMMZIbb0aPp+fWCKThjj7Ct6jMdsQi3olbXyl3SqMss0RUuysYB6OWZ5I4PVjfWd/SugrjSQhqaX1fwDFxfjCZZrWqvEo2WNHO91DQcM7FtEhbG9Kr6zIb1c3GNdO4KdCWSYBChEYowVEnfLkoKD5YlurTbqdtt2PIVe+mYYhWg3v1nauLXH37/frUp03HwPRl7tG3KgHwcwR0iJFWux32NepKyxQ3sLO2iYZcwGFF6BF2NIVYItoEc+HtZmRvK3FjDbgUgkoO//fjT1Ce/9KPEKhphHFurWJ3PQZ4rArLAmVV37t7TjMYOh+D7kuIGTQp7h9vEVZNsQAqP1CH6qzHRtyiUhn/+e6Lw7b1mBvqA0eWux8MsJD9GKWozahM9qoIpFDuaRh2XeBYPp03c/EFKwfG6CRRs6O+7cWFf2AMxPSW0XJGPbQqxTzf00DHKRIbL1998XvcUxns6TvXfLeQ44DjNcImwp1RW1Lle3lIVDSlR4uaNLoAdYugG1w9zt0ZdqhX5SsCaaqGqFABlkF/QbTB4Jv3OIlZE14BBbHUcboy3YjBmFhZmZlvjS21VHXkUm472Oef0SPwACBhIUG7n1ABH/VCEE4QTcl3qwjWkCvUrBBGriQzbs3dmbI8xwEnvubTqMLKsKUj0pHHiC8Zn7XZeNMt6JvuIhqnaMzZHwezulaAkDHe/YACXweazsuCeDYGnGkEM4fYqF6S5nW5kOYO7JJNfzj5UDUCC9HRvEZeL4ERyHzPQP0q3oNWlKdHrjTyEWGhfZEYht/kgv7JXWMmvZIu5rc3YaF98kfRKgroG6Du37A0bbl9bNeuHfnFUUDnbojVqeZhtlVwialhRi7oKimXEXN5GtYUZacSxEpZm5W0IkEiiBiGpg1rXzsstyFtyzorUKWrg/LnFI6nTro/bXfTRXN3uhFjxbXVTHBfIR+cgEN/lSTTS7bX13/vl/qny6z89urVIyt9uNcfSGXyA5vYq8CwFpo25s3BVIHPPj7fX3bNA6o76PyZlVuP37ILIC7BX6Qc7Sp85VezqVdmt8ANqs1X290+NHxY9c8qia5bxJb9zesBjI+SNHiPkCWY0floUz6FJCsCoZ4u0/Qjo1SDw+BpSP7CKRw4U4MJtC0s8U6KQIrv8QQd2n/pOnQAzxfAR96Ta/zoeZe4EKAPU9H/GdMGY6Imhlr97AcLlMyMsnBnhOiD8C+4B60WbEQAA";
84      private static final Log log = LogFactory.getLog(GearCaracteristicsEditorUI.class);
85      private static final long serialVersionUID = 1L;
86  
87      /*-----------------------------------------------------------------------*/
88      /*--------------------------- Internal states ---------------------------*/
89      /*-----------------------------------------------------------------------*/
90  
91      protected List<Object> $activeBindings = new ArrayList<Object>();
92      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
93      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
94      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
95      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
96      private boolean allComponentsCreated;
97      protected final JAXXContext delegateContext = new DefaultJAXXContext();
98  
99      /*-----------------------------------------------------------------------*/
100     /*------------------------ Protected components  ------------------------*/
101     /*-----------------------------------------------------------------------*/
102 
103     protected JButton addRow;
104     protected JButton cancelButton;
105     protected JXTable gearCaracteristicsEditorTable;
106     protected final GearCaracteristicsEditorUIHandler handler = createHandler();
107     protected GearCaracteristicsEditorUIModel model;
108     protected BeanFilterableComboBox<Caracteristic> newRowKey;
109     protected JMenuItem removeCaracteristicMenu;
110     protected JButton saveButton;
111     protected JPopupMenu tablePopup;
112 
113     /*-----------------------------------------------------------------------*/
114     /*------------------------- Private components  -------------------------*/
115     /*-----------------------------------------------------------------------*/
116 
117     private JPanel $JPanel0;
118     private JScrollPane $JScrollPane0;
119     private GearCaracteristicsEditorUI $Table0 = this;
120 
121     /*-----------------------------------------------------------------------*/
122     /*---------------------------- Constructors  ----------------------------*/
123     /*-----------------------------------------------------------------------*/
124 
125     public GearCaracteristicsEditorUI(TuttiUI parentUI) {
126         TuttiUIUtil.setParentUI(this, parentUI);
127             $initialize();
128     }
129 
130     public GearCaracteristicsEditorUI() {
131         $initialize();
132     }
133 
134     public GearCaracteristicsEditorUI(JAXXContext parentContext) {
135         JAXXUtil.initContext(this, parentContext);
136         $initialize();
137     }
138 
139     /*-----------------------------------------------------------------------*/
140     /*--------------------------- Statics methods ---------------------------*/
141     /*-----------------------------------------------------------------------*/
142 
143     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
144         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
145     }
146 
147     /*-----------------------------------------------------------------------*/
148     /*---------------------- JAXXObject implementation ----------------------*/
149     /*-----------------------------------------------------------------------*/
150 
151     @Override
152     public void applyDataBinding(String $binding) {
153         if (allComponentsCreated && $bindings.containsKey($binding)) {
154             getDataBinding($binding).applyDataBinding();
155         }
156         processDataBinding($binding);
157     }
158 
159     @Override
160     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
161         super.firePropertyChange(propertyName, oldValue, newValue);
162     }
163 
164     @Override
165     public Map<String, Object> get$objectMap() {
166         return $objectMap;
167     }
168 
169     @Override
170     public JAXXBinding getDataBinding(String bindingId) {
171         return $bindings.get(bindingId);
172     }
173 
174     @Override
175     public JAXXBinding[] getDataBindings() {
176         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
177     }
178 
179     @Override
180     public Object getObjectById(String id) {
181         return $objectMap.get(id);
182     }
183 
184     @Override
185     public void processDataBinding(String $binding, boolean $force) {
186         if (!$force && $activeBindings.contains($binding)) { 
187             return;
188         }
189         $activeBindings.add($binding);
190         try {
191             if (allComponentsCreated && $bindings.containsKey($binding)) {
192                 getDataBinding($binding).processDataBinding();
193             }
194         } finally {
195             $activeBindings.remove($binding);
196         }
197     }
198 
199     @Override
200     public void processDataBinding(String $binding) {
201         processDataBinding($binding, false);
202     }
203 
204     @Override
205     public void registerDataBinding(JAXXBinding binding) {
206         $bindings.put(binding.getId(), binding);
207     }
208 
209     @Override
210     public void removeDataBinding(String $binding) {
211         if (allComponentsCreated && $bindings.containsKey($binding)) {
212             getDataBinding($binding).removeDataBinding();
213         }
214     }
215 
216     /*-----------------------------------------------------------------------*/
217     /*--------------------- JAXXContext implementation  ---------------------*/
218     /*-----------------------------------------------------------------------*/
219 
220     @Override
221     public <T> T getContextValue(Class<T> clazz) {
222         return delegateContext.getContextValue(clazz, null);
223     }
224 
225     @Override
226     public <T> T getContextValue(Class<T> clazz, String name) {
227         return delegateContext.getContextValue(clazz, name);
228     }
229 
230     @Override
231     public JAXXContext getDelegateContext() {
232         return delegateContext;
233     }
234 
235     @Override
236     public <O extends Container> O getParentContainer(Class<O> clazz) {
237         return SwingUtil.getParentContainer(this, clazz);
238     }
239 
240     @Override
241     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
242         return SwingUtil.getParentContainer(source, clazz);
243     }
244 
245     @Override
246     public <T> void removeContextValue(Class<T> clazz) {
247         delegateContext.removeContextValue(clazz, null);
248     }
249 
250     @Override
251     public <T> void removeContextValue(Class<T> clazz, String name) {
252         delegateContext.removeContextValue(clazz, name);
253     }
254 
255     @Override
256     public <T> void setContextValue(T o) {
257         delegateContext.setContextValue(o, null);
258     }
259 
260     @Override
261     public <T> void setContextValue(T o, String name) {
262         delegateContext.setContextValue(o, name);
263     }
264 
265     /*-----------------------------------------------------------------------*/
266     /*---------------------------- Event methods ----------------------------*/
267     /*-----------------------------------------------------------------------*/
268 
269     public void doKeyPressed__on__gearCaracteristicsEditorTable(KeyEvent event) {
270         if (log.isDebugEnabled()) {
271             log.debug(event);
272         }
273         handler.openRowMenu(event, tablePopup);
274     }
275 
276     public void doMouseClicked__on__gearCaracteristicsEditorTable(MouseEvent event) {
277         if (log.isDebugEnabled()) {
278             log.debug(event);
279         }
280         handler.autoSelectRowInTable(event, tablePopup);
281     }
282 
283     /*-----------------------------------------------------------------------*/
284     /*----------------------- Public acessor methods  -----------------------*/
285     /*-----------------------------------------------------------------------*/
286 
287     public JButton getAddRow() {
288         return addRow;
289     }
290 
291     public JButton getCancelButton() {
292         return cancelButton;
293     }
294 
295     public JXTable getGearCaracteristicsEditorTable() {
296         return gearCaracteristicsEditorTable;
297     }
298 
299     public GearCaracteristicsEditorUIHandler getHandler() {
300         return handler;
301     }
302 
303     public GearCaracteristicsEditorUIModel getModel() {
304         return model;
305     }
306 
307     public BeanFilterableComboBox<Caracteristic> getNewRowKey() {
308         return newRowKey;
309     }
310 
311     public JMenuItem getRemoveCaracteristicMenu() {
312         return removeCaracteristicMenu;
313     }
314 
315     public JButton getSaveButton() {
316         return saveButton;
317     }
318 
319     public JPopupMenu getTablePopup() {
320         return tablePopup;
321     }
322 
323     /*-----------------------------------------------------------------------*/
324     /*--------------------- Protected acessors methods  ---------------------*/
325     /*-----------------------------------------------------------------------*/
326 
327     protected JPanel get$JPanel0() {
328         return $JPanel0;
329     }
330 
331     protected JScrollPane get$JScrollPane0() {
332         return $JScrollPane0;
333     }
334 
335     /*-----------------------------------------------------------------------*/
336     /*--------------------- Components creation methods ---------------------*/
337     /*-----------------------------------------------------------------------*/
338 
339     protected void addChildrenToTablePopup() {
340         if (!allComponentsCreated) {
341             return;
342         }
343         tablePopup.add(removeCaracteristicMenu);
344     }
345 
346     protected void createAddRow() {
347         $objectMap.put("addRow", addRow = new JButton());
348         
349         addRow.setName("addRow");
350         addRow.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.cruise.actions.GearCaracteristicAddRowAction.class);
351     }
352 
353     protected void createCancelButton() {
354         $objectMap.put("cancelButton", cancelButton = new JButton());
355         
356         cancelButton.setName("cancelButton");
357         cancelButton.setText(t("tutti.editIndividualObservationCaracteristics.action.cancel"));
358         cancelButton.setToolTipText(t("tutti.editIndividualObservationCaracteristics.action.cancel.tip"));
359         cancelButton.putClientProperty("help", "tutti.editIndividualObservationCaracteristics.action.cancel.help");
360         cancelButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.cruise.actions.GearCaracteristicCancelAction.class);
361     }
362 
363     protected void createGearCaracteristicsEditorTable() {
364         $objectMap.put("gearCaracteristicsEditorTable", gearCaracteristicsEditorTable = new JXTable());
365         
366         gearCaracteristicsEditorTable.setName("gearCaracteristicsEditorTable");
367         gearCaracteristicsEditorTable.setSortable(false);
368         gearCaracteristicsEditorTable.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyPressed", this, "doKeyPressed__on__gearCaracteristicsEditorTable"));
369         gearCaracteristicsEditorTable.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__gearCaracteristicsEditorTable"));
370     }
371 
372     protected GearCaracteristicsEditorUIHandler createHandler() {
373         return new GearCaracteristicsEditorUIHandler();
374     }
375 
376     protected void createModel() {
377         $objectMap.put("model", model = getContextValue(GearCaracteristicsEditorUIModel.class));
378     }
379 
380     protected void createNewRowKey() {
381         $objectMap.put("newRowKey", newRowKey = new BeanFilterableComboBox<Caracteristic>(this));
382         
383         newRowKey.setName("newRowKey");
384         newRowKey.setProperty("selectedCaracteristic");
385         newRowKey.setShowReset(true);
386     }
387 
388     protected void createRemoveCaracteristicMenu() {
389         $objectMap.put("removeCaracteristicMenu", removeCaracteristicMenu = new JMenuItem());
390         
391         removeCaracteristicMenu.setName("removeCaracteristicMenu");
392         removeCaracteristicMenu.setText(t("tutti.editIndividualObservationCaracteristics.action.removeCaracteristic"));
393         removeCaracteristicMenu.setToolTipText(t("tutti.editIndividualObservationCaracteristics.action.removeCaracteristic.tip"));
394         removeCaracteristicMenu.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.cruise.actions.GearCaracteristicRemoveRowAction.class);
395     }
396 
397     protected void createSaveButton() {
398         $objectMap.put("saveButton", saveButton = new JButton());
399         
400         saveButton.setName("saveButton");
401         saveButton.setText(t("tutti.editIndividualObservationCaracteristics.action.save"));
402         saveButton.setToolTipText(t("tutti.editIndividualObservationCaracteristics.action.save.tip"));
403         saveButton.putClientProperty("help", "tutti.editIndividualObservationCaracteristics.action.save.help");
404         saveButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.cruise.actions.GearCaracteristicSaveAction.class);
405     }
406 
407     protected void createTablePopup() {
408         $objectMap.put("tablePopup", tablePopup = new JPopupMenu());
409         
410         tablePopup.setName("tablePopup");
411     }
412 
413     /*-----------------------------------------------------------------------*/
414     /*------------------------ Internal jaxx methods ------------------------*/
415     /*-----------------------------------------------------------------------*/
416 
417     private void $completeSetup() {
418         allComponentsCreated = true;
419         if (log.isDebugEnabled()) {
420             log.debug(this);
421         }
422         // inline complete setup of $Table0
423         add(newRowKey, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
424         add(addRow, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
425         add($JScrollPane0, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
426         add($JPanel0, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
427         addChildrenToTablePopup();
428         // inline complete setup of $JScrollPane0
429         $JScrollPane0.getViewport().add(gearCaracteristicsEditorTable);
430         // inline complete setup of $JPanel0
431         $JPanel0.add(cancelButton);
432         $JPanel0.add(saveButton);
433         
434         // apply 7 data bindings
435         JAXXUtil.applyDataBinding(this, $bindings.keySet());
436         
437         // apply 12 property setters
438         newRowKey.setBeanType(Caracteristic.class);
439         removeCaracteristicMenu.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editIndividualObservationCaracteristics.action.removeCaracteristic.mnemonic"),'Z'));
440         removeCaracteristicMenu.setIcon(SwingUtil.createActionIcon("batch-delete"));
441         addRow.setIcon(SwingUtil.createActionIcon("add"));
442         gearCaracteristicsEditorTable.setSelectionBackground(null);
443         gearCaracteristicsEditorTable.setSelectionForeground(Color.BLACK);
444         gearCaracteristicsEditorTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
445         cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editIndividualObservationCaracteristics.action.cancel.mnemonic"),'Z'));
446         cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
447         saveButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editIndividualObservationCaracteristics.action.save.mnemonic"),'Z'));
448         saveButton.setIcon(SwingUtil.createActionIcon("save"));
449     }
450 
451     private void $initialize() {
452         if (allComponentsCreated) {
453             return;
454         }
455         if (log.isDebugEnabled()) {
456             log.debug(this);
457         }
458         handler.beforeInit(this);
459         $objectMap.put("$Table0", $Table0);
460         createModel();
461         createTablePopup();
462         createRemoveCaracteristicMenu();
463         createNewRowKey();
464         createAddRow();
465         // inline creation of $JScrollPane0
466         $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
467         
468         $JScrollPane0.setName("$JScrollPane0");
469         createGearCaracteristicsEditorTable();
470         // inline creation of $JPanel0
471         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
472         
473         $JPanel0.setName("$JPanel0");
474         $JPanel0.setLayout(new GridLayout(1, 0));
475         SwingUtil.setComponentHeight($JPanel0,50);
476         createCancelButton();
477         createSaveButton();
478         // inline creation of $Table0
479         setName("$Table0");
480         
481         // registers 7 data bindings
482         $registerDefaultBindings();
483         $completeSetup();
484         handler.afterInit(this);
485     }
486 
487     private void $registerDefaultBindings() {
488         // register 7 data bindings
489         registerDataBinding(new DefaultJAXXBinding(this, BINDING_REMOVE_CARACTERISTIC_MENU_ENABLED, true, true) {
490         
491             @Override
492             public void applyDataBinding() {
493                 if (model != null) {
494                     model.addPropertyChangeListener("editable", this);
495                 }
496                 if (model != null) {
497                     model.addPropertyChangeListener("removeCaracteristicEnabled", this);
498                 }
499             }
500         
501             @Override
502             public void processDataBinding() {
503                 if (model != null) {
504                     removeCaracteristicMenu.setEnabled(model.isEditable() && model.isRemoveCaracteristicEnabled());
505                 }
506             }
507         
508             @Override
509             public void removeDataBinding() {
510                 if (model != null) {
511                     model.removePropertyChangeListener("editable", this);
512                 }
513                 if (model != null) {
514                     model.removePropertyChangeListener("removeCaracteristicEnabled", this);
515                 }
516             }
517         });
518         registerDataBinding(new DefaultJAXXBinding(this, BINDING_NEW_ROW_KEY_VISIBLE, true) {
519         
520             @Override
521             public void applyDataBinding() {
522                 if (model != null) {
523                     model.addPropertyChangeListener("editable", this);
524                 }
525             }
526         
527             @Override
528             public void processDataBinding() {
529                 if (model != null) {
530                     newRowKey.setVisible(model.isEditable());
531                 }
532             }
533         
534             @Override
535             public void removeDataBinding() {
536                 if (model != null) {
537                     model.removePropertyChangeListener("editable", this);
538                 }
539             }
540         });
541         registerDataBinding(new DefaultJAXXBinding(this, BINDING_NEW_ROW_KEY_ENABLED, true, true) {
542         
543             @Override
544             public void applyDataBinding() {
545                 if (model != null) {
546                     model.addPropertyChangeListener("editable", this);
547                 }
548                 if (newRowKey != null) {
549                     newRowKey.addPropertyChangeListener("empty", this);
550                 }
551             }
552         
553             @Override
554             public void processDataBinding() {
555                 if (model != null && newRowKey != null) {
556                     newRowKey.setEnabled(model.isEditable() && !newRowKey.isEmpty());
557                 }
558             }
559         
560             @Override
561             public void removeDataBinding() {
562                 if (model != null) {
563                     model.removePropertyChangeListener("editable", this);
564                 }
565                 if (newRowKey != null) {
566                     newRowKey.removePropertyChangeListener("empty", this);
567                 }
568             }
569         });
570         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ADD_ROW_VISIBLE, true) {
571         
572             @Override
573             public void applyDataBinding() {
574                 if (model != null) {
575                     model.addPropertyChangeListener("editable", this);
576                 }
577             }
578         
579             @Override
580             public void processDataBinding() {
581                 if (model != null) {
582                     addRow.setVisible(model.isEditable());
583                 }
584             }
585         
586             @Override
587             public void removeDataBinding() {
588                 if (model != null) {
589                     model.removePropertyChangeListener("editable", this);
590                 }
591             }
592         });
593         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ADD_ROW_ENABLED, true, true) {
594         
595             @Override
596             public void applyDataBinding() {
597                 if (model != null) {
598                     model.addPropertyChangeListener("editable", this);
599                 }
600                 if (newRowKey != null) {
601                     newRowKey.addPropertyChangeListener("selectedItem", this);
602                 }
603             }
604         
605             @Override
606             public void processDataBinding() {
607                 if (model != null && newRowKey != null) {
608                     addRow.setEnabled(model.isEditable() && newRowKey.getSelectedItem() != null);
609                 }
610             }
611         
612             @Override
613             public void removeDataBinding() {
614                 if (model != null) {
615                     model.removePropertyChangeListener("editable", this);
616                 }
617                 if (newRowKey != null) {
618                     newRowKey.removePropertyChangeListener("selectedItem", this);
619                 }
620             }
621         });
622         registerDataBinding(new DefaultJAXXBinding(this, BINDING_GEAR_CARACTERISTICS_EDITOR_TABLE_EDITABLE, true) {
623         
624             @Override
625             public void applyDataBinding() {
626                 if (model != null) {
627                     model.addPropertyChangeListener("editable", this);
628                 }
629             }
630         
631             @Override
632             public void processDataBinding() {
633                 if (model != null) {
634                     gearCaracteristicsEditorTable.setEditable(model.isEditable());
635                 }
636             }
637         
638             @Override
639             public void removeDataBinding() {
640                 if (model != null) {
641                     model.removePropertyChangeListener("editable", this);
642                 }
643             }
644         });
645         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAVE_BUTTON_ENABLED, true, true) {
646         
647             @Override
648             public void applyDataBinding() {
649                 if (model != null) {
650                     model.addPropertyChangeListener("editable", this);
651                 }
652                 if (model != null) {
653                     model.addPropertyChangeListener("valid", this);
654                 }
655             }
656         
657             @Override
658             public void processDataBinding() {
659                 if (model != null) {
660                     saveButton.setEnabled(model.isEditable() && model.isValid());
661                 }
662             }
663         
664             @Override
665             public void removeDataBinding() {
666                 if (model != null) {
667                     model.removePropertyChangeListener("editable", this);
668                 }
669                 if (model != null) {
670                     model.removePropertyChangeListener("valid", this);
671                 }
672             }
673         });
674     }
675 
676 }