View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.manage.program;
2   
3   /*-
4    * #%L
5    * Reef DB :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2022 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (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 Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  
27  import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
28  import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
29  import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
30  import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
31  import fr.ifremer.reefdb.ui.swing.content.ReefDbMainUI;
32  import fr.ifremer.reefdb.ui.swing.content.manage.program.locations.LocationsTableUI;
33  import fr.ifremer.reefdb.ui.swing.content.manage.program.menu.ProgramsMenuUI;
34  import fr.ifremer.reefdb.ui.swing.content.manage.program.pmfms.PmfmsTableUI;
35  import fr.ifremer.reefdb.ui.swing.content.manage.program.programs.ProgramsTableUI;
36  import fr.ifremer.reefdb.ui.swing.content.manage.program.strategies.StrategiesTableUI;
37  import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
38  import java.awt.BorderLayout;
39  import java.awt.Component;
40  import java.awt.Container;
41  import java.awt.FlowLayout;
42  import java.awt.GridBagConstraints;
43  import java.awt.GridLayout;
44  import java.awt.Insets;
45  import java.awt.LayoutManager;
46  import java.util.ArrayList;
47  import java.util.HashMap;
48  import java.util.List;
49  import java.util.Map;
50  import java.util.TreeMap;
51  import javax.swing.Box;
52  import javax.swing.BoxLayout;
53  import javax.swing.JButton;
54  import javax.swing.JPanel;
55  import jaxx.runtime.JAXXBinding;
56  import jaxx.runtime.JAXXContext;
57  import jaxx.runtime.JAXXObject;
58  import jaxx.runtime.JAXXObjectDescriptor;
59  import jaxx.runtime.JAXXUtil;
60  import jaxx.runtime.JAXXValidator;
61  import jaxx.runtime.SwingUtil;
62  import jaxx.runtime.binding.DefaultJAXXBinding;
63  import jaxx.runtime.context.DefaultJAXXContext;
64  import jaxx.runtime.swing.Table;
65  import jaxx.runtime.validator.swing.SwingValidator;
66  import jaxx.runtime.validator.swing.SwingValidatorUtil;
67  import jaxx.runtime.validator.swing.meta.Validator;
68  import jaxx.runtime.validator.swing.meta.ValidatorField;
69  import jaxx.runtime.validator.swing.ui.ImageValidationUI;
70  import org.apache.commons.logging.Log;
71  import org.apache.commons.logging.LogFactory;
72  import static org.nuiton.i18n.I18n.t;
73  
74  public class ProgramsUI extends JPanel implements ReefDbUI<ProgramsUIModel, ProgramsUIHandler>, JAXXObject, JAXXValidator {
75  
76      /*-----------------------------------------------------------------------*/
77      /*------------------ Constants for all public bindings ------------------*/
78      /*-----------------------------------------------------------------------*/
79  
80      public static final String BINDING_SAVE_BUTTON_ENABLED = "saveButton.enabled";
81  
82      /*-----------------------------------------------------------------------*/
83      /*------------------------- Other static fields -------------------------*/
84      /*-----------------------------------------------------------------------*/
85  
86      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1Wz28bRRSeGNupnf5M1ColRTJpVKWtGBcOIEgV4jqJmuCEqE6rqD6U8e7YmbK/mBmna1lFnLjCnwB3LkjcOCEOnDlwQfwLCHHgingzu971xhvbachh4p1573vfezPzvfnuT5QTHL35nPg+5h1HMpvi7crBwcfN59SQ61QYnHnS5Sj4m8qgTAPNmNG8kOhmo6bcy6F7ueranutQZ8B7pYaKQnYtKg4plRK9kfQwhCjXo+UV3+vwPmpEKg31m7//ynxtfvFtBiHfA3YXIZXSOK84k2wNZZgp0SxEOiJlizhtoMGZ0wa+F9Rc1SJC7BKbfoY+R9M1lPcIBzCJFidPWWNof9+T6NzS9h5xqHVPovstjlmLU5tyzCltmU3cYVi8gPjYcB0JcNgmDmlT7HG3zYmN94L/4vGW52nMvEQ52zWpJVHlLHA7CiPGzDe5+ynlEt0dAfoIvtebD8HvgbaO3QtHxGImgSoAQmI/ooUQo67GJ/3JAQI2dTqPtyTaOH1WyjVKbUfjKNRCBN7fg7dh69Uu+yFeMJu0nV7aJ02LwnbNJxIJPPSaspyPHC6FNIReUylsnz6FPkaURgimYixEoa4IyYmkbUbjYLunDxaj4PpxwGTAy5ZrEMlcJ45XO328CATXjsElo5337NZAGddfoYwKAO8NwCQj9A/CO+r79eQ+zhiWK+iDjpSAjeYS5ySYVYZ3IvuiIEc0XsDhKkcLiXMDUodjqYu1aKqBcrwD03DQGsPq+AiWAl2cP6aLClCv/ntt7rcf//hhsy+GFyD21VTTAS0HkYJieXDVmQp9KVDCjmRWeYd4Kw1UENSCRqCF/kYKsXq4DOQg3hXljpU7fkjEIUDkpn//6edrn/z6GspsoqLlEnOTKPstVJCHHKrgWqbvfbimGZ1/cQ7Gy4obcHkWiUWNNJXC3ezJ5cVw64/dFCyZtOji7Zc+lOhGSokins3CL//M1b9f65dpCmhfP9E8LlXuKcozx2IO1V0jbAipXWLGE7RjurHwp7UCNCwVXqh/7+rxg8mKspRSlPBGdweqohBXdbrq1xpKU4//LX7/ho+MPyQmrxS+lHYm4MKPDJ1QlnFhs9AlnhHPs1hAt2KoESShV1UKEXxiQ23tS5ABor+3lCKhvEEcQ7G8OgzwEe1K9H5vhKjpaxQ0WTAGaYYmK3C1slvdqEGkrKQ+vETmQjfDtW3NAzil5TyoZ+NSzp+Q8myvDiI3KuOsUsGT833v9PnWK0824mxnk9kG0Wak61r7zNvXJguhSUBLm0T9FPo5ddS2w6tvtacfTpgJePywVnf5dunWrVJ/Tr9JklMq943Aezn9XA30gAkOc94iXReM0cX7cKJJqckcE+qwOoQ8pcbiWEQ17auhm45w/cwIdyfIqgiFazvwBpMHI5DemojLlyMQ7k3AJcuMoBuficVXY1j8B/R5OsBEDQAA";
87      private static final Log log = LogFactory.getLog(ProgramsUI.class);
88      private static final long serialVersionUID = 1L;
89  
90      /*-----------------------------------------------------------------------*/
91      /*--------------------------- Internal states ---------------------------*/
92      /*-----------------------------------------------------------------------*/
93  
94      protected List<Object> $activeBindings = new ArrayList<Object>();
95      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
96      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
97      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
98      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
99      private boolean allComponentsCreated;
100     protected final JAXXContext delegateContext = new DefaultJAXXContext();
101 
102     /*-----------------------------------------------------------------------*/
103     /*------------------------ Protected components  ------------------------*/
104     /*-----------------------------------------------------------------------*/
105 
106     protected ReefDbHelpBroker broker;
107     protected JButton closeButton;
108     protected final ProgramsUIHandler handler = createHandler();
109     @ValidatorField( validatorId = "validator",  propertyName = "locationsUIModel",  editorName = "locationsTableUI")
110     protected LocationsTableUI locationsTableUI;
111     protected ProgramsMenuUI menuUI;
112     protected ProgramsUIModel model;
113     @ValidatorField( validatorId = "validator",  propertyName = "pmfmsUIModel",  editorName = "pmfmsTableUI")
114     protected PmfmsTableUI pmfmsTableUI;
115     @ValidatorField( validatorId = "validator",  propertyName = "programsUIModel",  editorName = "programsTableUI")
116     protected ProgramsTableUI programsTableUI;
117     protected JButton saveButton;
118     @ValidatorField( validatorId = "validator",  propertyName = "strategiesUIModel",  editorName = "strategiesTableUI")
119     protected StrategiesTableUI strategiesTableUI;
120     @Validator( validatorId = "validator")
121     protected SwingValidator<ProgramsUIModel> validator;
122     protected List<String> validatorIds = new ArrayList<String>();
123 
124     /*-----------------------------------------------------------------------*/
125     /*------------------------- Private components  -------------------------*/
126     /*-----------------------------------------------------------------------*/
127 
128     private ProgramsUI $JPanel0 = this;
129     private JPanel $JPanel1;
130     private JPanel $JPanel2;
131     private Table $Table0;
132 
133     /*-----------------------------------------------------------------------*/
134     /*---------------------------- Constructors  ----------------------------*/
135     /*-----------------------------------------------------------------------*/
136 
137     public ProgramsUI(ReefDbMainUI parentUI) {
138         ApplicationUIUtil.setParentUI(this, parentUI);
139             $initialize();
140     }
141 
142     public ProgramsUI(LayoutManager param0, boolean param1) {
143         super(param0 ,param1);
144         $initialize();
145     }
146 
147     public ProgramsUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
148         super(param1 ,param2);
149         JAXXUtil.initContext(this, parentContext);
150         $initialize();
151     }
152 
153     public ProgramsUI(boolean param0) {
154         super(param0);
155         $initialize();
156     }
157 
158     public ProgramsUI(JAXXContext parentContext, boolean param1) {
159         super(param1);
160         JAXXUtil.initContext(this, parentContext);
161         $initialize();
162     }
163 
164     public ProgramsUI() {
165         $initialize();
166     }
167 
168     public ProgramsUI(JAXXContext parentContext) {
169         JAXXUtil.initContext(this, parentContext);
170         $initialize();
171     }
172 
173     public ProgramsUI(LayoutManager param0) {
174         super(param0);
175         $initialize();
176     }
177 
178     public ProgramsUI(JAXXContext parentContext, LayoutManager param1) {
179         super(param1);
180         JAXXUtil.initContext(this, parentContext);
181         $initialize();
182     }
183 
184     /*-----------------------------------------------------------------------*/
185     /*--------------------------- Statics methods ---------------------------*/
186     /*-----------------------------------------------------------------------*/
187 
188     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
189         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
190     }
191 
192     /*-----------------------------------------------------------------------*/
193     /*---------------------- JAXXObject implementation ----------------------*/
194     /*-----------------------------------------------------------------------*/
195 
196     @Override
197     public void applyDataBinding(String $binding) {
198         if (allComponentsCreated && $bindings.containsKey($binding)) {
199             getDataBinding($binding).applyDataBinding();
200         }
201         processDataBinding($binding);
202     }
203 
204     @Override
205     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
206         super.firePropertyChange(propertyName, oldValue, newValue);
207     }
208 
209     @Override
210     public Map<String, Object> get$objectMap() {
211         return $objectMap;
212     }
213 
214     @Override
215     public JAXXBinding getDataBinding(String bindingId) {
216         return $bindings.get(bindingId);
217     }
218 
219     @Override
220     public JAXXBinding[] getDataBindings() {
221         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
222     }
223 
224     @Override
225     public Object getObjectById(String id) {
226         return $objectMap.get(id);
227     }
228 
229     @Override
230     public void processDataBinding(String $binding, boolean $force) {
231         if (!$force && $activeBindings.contains($binding)) { 
232             return;
233         }
234         $activeBindings.add($binding);
235         try {
236             if (allComponentsCreated && $bindings.containsKey($binding)) {
237                 getDataBinding($binding).processDataBinding();
238             }
239         } finally {
240             $activeBindings.remove($binding);
241         }
242     }
243 
244     @Override
245     public void processDataBinding(String $binding) {
246         processDataBinding($binding, false);
247     }
248 
249     @Override
250     public void registerDataBinding(JAXXBinding binding) {
251         $bindings.put(binding.getId(), binding);
252     }
253 
254     @Override
255     public void removeDataBinding(String $binding) {
256         if (allComponentsCreated && $bindings.containsKey($binding)) {
257             getDataBinding($binding).removeDataBinding();
258         }
259     }
260 
261     /*-----------------------------------------------------------------------*/
262     /*--------------------- JAXXContext implementation  ---------------------*/
263     /*-----------------------------------------------------------------------*/
264 
265     @Override
266     public <T> T getContextValue(Class<T> clazz) {
267         return delegateContext.getContextValue(clazz, null);
268     }
269 
270     @Override
271     public <T> T getContextValue(Class<T> clazz, String name) {
272         return delegateContext.getContextValue(clazz, name);
273     }
274 
275     @Override
276     public JAXXContext getDelegateContext() {
277         return delegateContext;
278     }
279 
280     @Override
281     public <O extends Container> O getParentContainer(Class<O> clazz) {
282         return SwingUtil.getParentContainer(this, clazz);
283     }
284 
285     @Override
286     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
287         return SwingUtil.getParentContainer(source, clazz);
288     }
289 
290     @Override
291     public <T> void removeContextValue(Class<T> clazz) {
292         delegateContext.removeContextValue(clazz, null);
293     }
294 
295     @Override
296     public <T> void removeContextValue(Class<T> clazz, String name) {
297         delegateContext.removeContextValue(clazz, name);
298     }
299 
300     @Override
301     public <T> void setContextValue(T o) {
302         delegateContext.setContextValue(o, null);
303     }
304 
305     @Override
306     public <T> void setContextValue(T o, String name) {
307         delegateContext.setContextValue(o, name);
308     }
309 
310     /*-----------------------------------------------------------------------*/
311     /*-------------------- JAXXValidator implementation  --------------------*/
312     /*-----------------------------------------------------------------------*/
313 
314     @Override
315     public SwingValidator<?> getValidator(String validatorId) {
316         return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
317     }
318 
319     @Override
320     public List<String> getValidatorIds() {
321         return validatorIds;
322     }
323 
324     @Override
325     public void registerValidatorFields() {
326         SwingValidatorUtil.detectValidatorFields(this);
327     }
328 
329     /*-----------------------------------------------------------------------*/
330     /*----------------------- Public acessor methods  -----------------------*/
331     /*-----------------------------------------------------------------------*/
332 
333     public ReefDbHelpBroker getBroker() {
334         return broker;
335     }
336 
337     public JButton getCloseButton() {
338         return closeButton;
339     }
340 
341     public ProgramsUIHandler getHandler() {
342         return handler;
343     }
344 
345     public LocationsTableUI getLocationsTableUI() {
346         return locationsTableUI;
347     }
348 
349     public ProgramsMenuUI getMenuUI() {
350         return menuUI;
351     }
352 
353     public ProgramsUIModel getModel() {
354         return model;
355     }
356 
357     public PmfmsTableUI getPmfmsTableUI() {
358         return pmfmsTableUI;
359     }
360 
361     public ProgramsTableUI getProgramsTableUI() {
362         return programsTableUI;
363     }
364 
365     public JButton getSaveButton() {
366         return saveButton;
367     }
368 
369     public StrategiesTableUI getStrategiesTableUI() {
370         return strategiesTableUI;
371     }
372 
373     public SwingValidator<ProgramsUIModel> getValidator() {
374         return validator;
375     }
376 
377     /*-----------------------------------------------------------------------*/
378     /*--------------------- Protected acessors methods  ---------------------*/
379     /*-----------------------------------------------------------------------*/
380 
381     protected JPanel get$JPanel1() {
382         return $JPanel1;
383     }
384 
385     protected JPanel get$JPanel2() {
386         return $JPanel2;
387     }
388 
389     protected Table get$Table0() {
390         return $Table0;
391     }
392 
393     /*-----------------------------------------------------------------------*/
394     /*--------------------- Components creation methods ---------------------*/
395     /*-----------------------------------------------------------------------*/
396 
397     protected void addChildrenToValidator() {
398         if (!allComponentsCreated) {
399             return;
400         }
401         validator.setUiClass(ImageValidationUI.class);
402         validator.setBean(model);
403     }
404 
405     protected void createBroker() {
406         $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
407     }
408 
409     protected void createCloseButton() {
410         $objectMap.put("closeButton", closeButton = new JButton());
411         
412         closeButton.setName("closeButton");
413         closeButton.setText(t("reefdb.common.close"));
414         closeButton.putClientProperty("applicationActionKey", fr.ifremer.reefdb.ui.swing.util.ReefDbKeyStrokes.CANCEL);
415         closeButton.putClientProperty("applicationAction", CloseAction.class);
416     }
417 
418     protected ProgramsUIHandler createHandler() {
419         return new ProgramsUIHandler();
420     }
421 
422     protected void createLocationsTableUI() {
423         $objectMap.put("locationsTableUI", locationsTableUI = new LocationsTableUI(this));
424         
425         locationsTableUI.setName("locationsTableUI");
426         locationsTableUI.putClientProperty("validatorLabel", t("reefdb.program.location.title"));
427     }
428 
429     protected void createMenuUI() {
430         $objectMap.put("menuUI", menuUI = new ProgramsMenuUI(this));
431         
432         menuUI.setName("menuUI");
433     }
434 
435     protected void createModel() {
436         $objectMap.put("model", model = getContextValue(ProgramsUIModel.class));
437     }
438 
439     protected void createPmfmsTableUI() {
440         $objectMap.put("pmfmsTableUI", pmfmsTableUI = new PmfmsTableUI(this));
441         
442         pmfmsTableUI.setName("pmfmsTableUI");
443         pmfmsTableUI.putClientProperty("validatorLabel", t("reefdb.program.pmfm.title"));
444     }
445 
446     protected void createProgramsTableUI() {
447         $objectMap.put("programsTableUI", programsTableUI = new ProgramsTableUI(this));
448         
449         programsTableUI.setName("programsTableUI");
450         programsTableUI.putClientProperty("validatorLabel", t("reefdb.program.program.title"));
451     }
452 
453     protected void createSaveButton() {
454         $objectMap.put("saveButton", saveButton = new JButton());
455         
456         saveButton.setName("saveButton");
457         saveButton.setText(t("reefdb.common.save"));
458         saveButton.setToolTipText(t("reefdb.action.save.programs"));
459         saveButton.putClientProperty("applicationActionKey", fr.ifremer.reefdb.ui.swing.util.ReefDbKeyStrokes.SAVE);
460         saveButton.putClientProperty("applicationAction", SaveAction.class);
461     }
462 
463     protected void createStrategiesTableUI() {
464         $objectMap.put("strategiesTableUI", strategiesTableUI = new StrategiesTableUI(this));
465         
466         strategiesTableUI.setName("strategiesTableUI");
467         strategiesTableUI.putClientProperty("validatorLabel", t("reefdb.program.strategy.title"));
468     }
469 
470     protected void createValidator() {
471         $objectMap.put("validator", validator = SwingValidator.newValidator(ProgramsUIModel.class, null));
472     }
473 
474     /*-----------------------------------------------------------------------*/
475     /*------------------------ Internal jaxx methods ------------------------*/
476     /*-----------------------------------------------------------------------*/
477 
478     private void $completeSetup() {
479         allComponentsCreated = true;
480         if (log.isDebugEnabled()) {
481             log.debug(this);
482         }
483         // inline complete setup of $JPanel0
484         add(menuUI, BorderLayout.LINE_START);
485         add($JPanel1, BorderLayout.CENTER);
486         addChildrenToValidator();
487         // inline complete setup of $JPanel1
488         $JPanel1.add($Table0);
489         $JPanel1.add($JPanel2, BorderLayout.PAGE_END);
490         // inline complete setup of $Table0
491         $Table0.add(SwingUtil.boxComponentWithJxLayer(programsTableUI), new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
492         $Table0.add(SwingUtil.boxComponentWithJxLayer(strategiesTableUI), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
493         $Table0.add(SwingUtil.boxComponentWithJxLayer(locationsTableUI), new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
494         $Table0.add(SwingUtil.boxComponentWithJxLayer(pmfmsTableUI), new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
495         // inline complete setup of $JPanel2
496         $JPanel2.add(closeButton);
497         $JPanel2.add(saveButton);
498         
499         // apply 1 data bindings
500         JAXXUtil.applyDataBinding(this, $bindings.keySet());
501         
502         // apply 7 property setters
503         closeButton.setAlignmentX(Component.CENTER_ALIGNMENT);
504         saveButton.setAlignmentX(Component.CENTER_ALIGNMENT);
505         closeButton.setIcon(SwingUtil.createActionIcon("cancel"));
506         saveButton.setIcon(SwingUtil.createActionIcon("save"));
507         // late initializer
508         // register 1 validator(s)
509         validatorIds = SwingValidatorUtil.detectValidators(this);
510         SwingValidatorUtil.installUI(this);
511     }
512 
513     private void $initialize() {
514         if (allComponentsCreated) {
515             return;
516         }
517         if (log.isDebugEnabled()) {
518             log.debug(this);
519         }
520         handler.beforeInit(this);
521         $objectMap.put("$JPanel0", $JPanel0);
522         createModel();
523         createBroker();
524         createValidator();
525         createMenuUI();
526         // inline creation of $JPanel1
527         $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
528         
529         $JPanel1.setName("$JPanel1");
530         $JPanel1.setLayout(new BorderLayout());
531         // inline creation of $Table0
532         $objectMap.put("$Table0", $Table0 = new Table());
533         
534         $Table0.setName("$Table0");
535         createProgramsTableUI();
536         createStrategiesTableUI();
537         createLocationsTableUI();
538         createPmfmsTableUI();
539         // inline creation of $JPanel2
540         $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
541         
542         $JPanel2.setName("$JPanel2");
543         $JPanel2.setLayout(new GridLayout(1,0));
544         createCloseButton();
545         createSaveButton();
546         // inline creation of $JPanel0
547         setName("$JPanel0");
548         setLayout(new BorderLayout());
549         
550         // registers 1 data bindings
551         $registerDefaultBindings();
552         $completeSetup();
553         handler.afterInit(this);
554     }
555 
556     private void $registerDefaultBindings() {
557         // register 1 data bindings
558         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAVE_BUTTON_ENABLED, true, true) {
559         
560             @Override
561             public void applyDataBinding() {
562                 if (model != null) {
563                     model.addPropertyChangeListener("modify", this);
564                 }
565                 if (model != null) {
566                     model.addPropertyChangeListener("valid", this);
567                 }
568                 if (model != null) {
569                     model.addPropertyChangeListener("saveEnabled", this);
570                 }
571             }
572         
573             @Override
574             public void processDataBinding() {
575                 if (model != null) {
576                     saveButton.setEnabled(model.isModify() && model.isValid() && model.isSaveEnabled());
577                 }
578             }
579         
580             @Override
581             public void removeDataBinding() {
582                 if (model != null) {
583                     model.removePropertyChangeListener("modify", this);
584                 }
585                 if (model != null) {
586                     model.removePropertyChangeListener("valid", this);
587                 }
588                 if (model != null) {
589                     model.removePropertyChangeListener("saveEnabled", this);
590                 }
591             }
592         });
593     }
594 
595 }