View Javadoc
1   package fr.ifremer.tutti.ui.swing.util.species;
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.Species;
28  import fr.ifremer.tutti.ui.swing.util.TuttiUI;
29  import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
30  import java.awt.BorderLayout;
31  import java.awt.Container;
32  import java.awt.GridBagConstraints;
33  import java.awt.GridLayout;
34  import java.awt.Insets;
35  import java.awt.LayoutManager;
36  import java.awt.event.ItemEvent;
37  import java.awt.event.ItemListener;
38  import java.util.ArrayList;
39  import java.util.HashMap;
40  import java.util.List;
41  import java.util.Map;
42  import java.util.TreeMap;
43  import javax.swing.JButton;
44  import javax.swing.JCheckBox;
45  import javax.swing.JPanel;
46  import jaxx.runtime.JAXXBinding;
47  import jaxx.runtime.JAXXContext;
48  import jaxx.runtime.JAXXObject;
49  import jaxx.runtime.JAXXObjectDescriptor;
50  import jaxx.runtime.JAXXUtil;
51  import jaxx.runtime.SwingUtil;
52  import jaxx.runtime.binding.DefaultJAXXBinding;
53  import jaxx.runtime.context.DefaultJAXXContext;
54  import jaxx.runtime.swing.Table;
55  import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
56  import org.apache.commons.logging.Log;
57  import org.apache.commons.logging.LogFactory;
58  import static org.nuiton.i18n.I18n.t;
59  
60  public class SelectSpeciesUI extends JPanel implements TuttiUI<SelectSpeciesUIModel, SelectSpeciesUIHandler>, JAXXObject {
61  
62      /*-----------------------------------------------------------------------*/
63      /*------------------ Constants for all public bindings ------------------*/
64      /*-----------------------------------------------------------------------*/
65  
66      public static final String BINDING_SHOW_ALL_SPECIES_SELECTED = "showAllSpecies.selected";
67      public static final String BINDING_SHOW_ALL_SPECIES_VISIBLE = "showAllSpecies.visible";
68      public static final String BINDING_SPECIES_COMBO_DATA = "speciesCombo.data";
69      public static final String BINDING_SPECIES_COMBO_SELECTED_ITEM = "speciesCombo.selectedItem";
70      public static final String BINDING_VALIDATE_BUTTON_ENABLED = "validateButton.enabled";
71  
72      /*-----------------------------------------------------------------------*/
73      /*------------------------- Other static fields -------------------------*/
74      /*-----------------------------------------------------------------------*/
75  
76      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAKVWTW8cRRBtL95df8QJxEpwhCM2xBE2IrMBEYQwkNgGCxvbWF6bRPEh9M60dzv0TDfTNfZYliN+AAd+Aty5IHHjhDhw5sAF8RcQ4sAVUd0znvF+r8CHtd1V9fr161fV++0fpKhDcuMJjWMnjALgPnPWlx4+/Lj+hLnwPtNuyBXIkCQ/IwVS2CeTXraugdzc3zDl1bS8uiJ9JQMWnKte3CATGo4F003GAMj11gpX62otCy/GKgrPUDNS3VC//uvPwlfeF98UCIkVshvDo1QGVeUnGd0gBe4BuYw7HdKqoEEDaYQ8aCDfKbO2IqjWW9Rnn5OnpLxBSoqGCAbkpeGPbDFsfaxwL80ECltTzOVMb0sV4eKbB6HDD0Lms9CBCIA7EXf0ERJxIuDC0Um2Uztfu7emlMUtASn60mMCyOJ/A9o01TlaeW6X1gW7A2SmRcwEyMZM5nhWcCHFRRnqEsjdLlXM4yiKU2c0cJbxY5ULYKGBskXLMjZYlzLIi7opj5aESDkCuWLuI07R1leazP2so2hsbn2bBkwg88st6Xa1jbNLA5eJZVRJBkCmW/KTVZM5kzM6pIJ7FFgevJ5mhOSFliOjn53cz7nhRvZJMYyEOc7MfmcL7GAoMf9Mm/kNoI3+c3X61x9+/371zPGTuPeVrqnnGhadqEKpWAhWyUuJ3Y0hqptULe6T8cSUtptnuxCrpWEkh/s9Z8oTP31IdRMhiuXffvzp6qe/PEMKq2RCSOqtUpO/RsahGaIKUnixunffMrpwNIafzxpuKOpj6nkPGG80YS/g2FjPn1grOw0G+fL8wmmMqsx2USWjVh//+e/p2nf3z5QZQabXeqbn6hQfkRIPBA+YnQZpo3ft/kmlWeTJvKG7tThRCjt6StA6Ew84NA1/G7tlPxe6qVBq2qMCKdy9E0cm7bY9gfmrmgBO1q3rrJH7whWBjKJLKZCtk0qiJde1lmaaX6jcq2Qy54tv54tJezIvD56aNrfqMW8NmI9Oya+qlgaydMweSz13jI7TrXFAxyGjHabNYzAKYYRdMmpmAw6fBPW0U4e2OaPSgdVLiDLm89feCjYD5suAu0BeT0ZiywR20KhcBk7ruHH8rKh8yDXHMQXk0UlFhg2HKuo20U3SxwyNv4WBQwz9Bj43Z//sYXtoVH5Lwge+guP53tJabccPpBtpajcqHlChjSLAYtRnYWjaQCYOZMgaoYwCfNdmTiq2VekRGGY4fpc3llY+MttNgpRil6tdu8Pt4YUBfNzwnU3v05igt8m63mHbYB90i8WOW3ylD9lkpp+7vYkksOaaGV9KwpmwNwYitQt1a/DeVqCpx5r7SrAlGwKyfTLkw5xgtT3QKxZ5Kd3GzJru3XH+RRuka6lD11f7nO3s6eupLHVdpiBT9uYQWO3avjzM/lbdMgtMo6D75vqMoMqNdytBJMRp53Xs/K/r+CQlM/BC2r4xDLoS8xAIeiwxmVx8x8zwSp0HHpJ6rwN9xHxODIE4Zqbq7rGyb9jT7jjTA3HM8mkfhGtDMBnlbvKtqQfG7FAsvuyD8CIi/AvGBrnT0QwAAA==";
77      private static final Log log = LogFactory.getLog(SelectSpeciesUI.class);
78      private static final long serialVersionUID = 1L;
79  
80      /*-----------------------------------------------------------------------*/
81      /*--------------------------- Internal states ---------------------------*/
82      /*-----------------------------------------------------------------------*/
83  
84      protected List<Object> $activeBindings = new ArrayList<Object>();
85      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
86      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
87      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
88      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
89      private boolean allComponentsCreated;
90      protected final JAXXContext delegateContext = new DefaultJAXXContext();
91  
92      /*-----------------------------------------------------------------------*/
93      /*------------------------ Protected components  ------------------------*/
94      /*-----------------------------------------------------------------------*/
95  
96      protected JButton cancelButton;
97      protected final SelectSpeciesUIHandler handler = createHandler();
98      protected SelectSpeciesUIModel model;
99      protected SelectSpeciesUI selectSpeciesPopup = this;
100     protected JCheckBox showAllSpecies;
101     protected BeanFilterableComboBox<Species> speciesCombo;
102     protected JButton validateButton;
103 
104     /*-----------------------------------------------------------------------*/
105     /*------------------------- Private components  -------------------------*/
106     /*-----------------------------------------------------------------------*/
107 
108     private JPanel $JPanel0;
109     private Table $Table0;
110 
111     /*-----------------------------------------------------------------------*/
112     /*---------------------- Raw body code from script ----------------------*/
113     /*-----------------------------------------------------------------------*/
114 
115     boolean useSurveyCode;
116 
117     /*-----------------------------------------------------------------------*/
118     /*---------------------------- Constructors  ----------------------------*/
119     /*-----------------------------------------------------------------------*/
120 
121     public SelectSpeciesUI(boolean useSurveyCode, TuttiUI parentUI) {
122         this.useSurveyCode = useSurveyCode;
123             TuttiUIUtil.setParentUI(this, parentUI);
124             $initialize();
125     }
126 
127     public SelectSpeciesUI(LayoutManager param0, boolean param1) {
128         super(param0 ,param1);
129         $initialize();
130     }
131 
132     public SelectSpeciesUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
133         super(param1 ,param2);
134         JAXXUtil.initContext(this, parentContext);
135         $initialize();
136     }
137 
138     public SelectSpeciesUI(LayoutManager param0) {
139         super(param0);
140         $initialize();
141     }
142 
143     public SelectSpeciesUI(JAXXContext parentContext, LayoutManager param1) {
144         super(param1);
145         JAXXUtil.initContext(this, parentContext);
146         $initialize();
147     }
148 
149     public SelectSpeciesUI() {
150         $initialize();
151     }
152 
153     public SelectSpeciesUI(JAXXContext parentContext) {
154         JAXXUtil.initContext(this, parentContext);
155         $initialize();
156     }
157 
158     public SelectSpeciesUI(boolean param0) {
159         super(param0);
160         $initialize();
161     }
162 
163     public SelectSpeciesUI(JAXXContext parentContext, boolean param1) {
164         super(param1);
165         JAXXUtil.initContext(this, parentContext);
166         $initialize();
167     }
168 
169     /*-----------------------------------------------------------------------*/
170     /*--------------------------- Statics methods ---------------------------*/
171     /*-----------------------------------------------------------------------*/
172 
173     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
174         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
175     }
176 
177     /*-----------------------------------------------------------------------*/
178     /*---------------------- JAXXObject implementation ----------------------*/
179     /*-----------------------------------------------------------------------*/
180 
181     @Override
182     public void applyDataBinding(String $binding) {
183         if (allComponentsCreated && $bindings.containsKey($binding)) {
184             getDataBinding($binding).applyDataBinding();
185         }
186         processDataBinding($binding);
187     }
188 
189     @Override
190     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
191         super.firePropertyChange(propertyName, oldValue, newValue);
192     }
193 
194     @Override
195     public Map<String, Object> get$objectMap() {
196         return $objectMap;
197     }
198 
199     @Override
200     public JAXXBinding getDataBinding(String bindingId) {
201         return $bindings.get(bindingId);
202     }
203 
204     @Override
205     public JAXXBinding[] getDataBindings() {
206         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
207     }
208 
209     @Override
210     public Object getObjectById(String id) {
211         return $objectMap.get(id);
212     }
213 
214     @Override
215     public void processDataBinding(String $binding, boolean $force) {
216         if (!$force && $activeBindings.contains($binding)) { 
217             return;
218         }
219         $activeBindings.add($binding);
220         try {
221             if (allComponentsCreated && $bindings.containsKey($binding)) {
222                 getDataBinding($binding).processDataBinding();
223             }
224         } finally {
225             $activeBindings.remove($binding);
226         }
227     }
228 
229     @Override
230     public void processDataBinding(String $binding) {
231         processDataBinding($binding, false);
232     }
233 
234     @Override
235     public void registerDataBinding(JAXXBinding binding) {
236         $bindings.put(binding.getId(), binding);
237     }
238 
239     @Override
240     public void removeDataBinding(String $binding) {
241         if (allComponentsCreated && $bindings.containsKey($binding)) {
242             getDataBinding($binding).removeDataBinding();
243         }
244     }
245 
246     /*-----------------------------------------------------------------------*/
247     /*--------------------- JAXXContext implementation  ---------------------*/
248     /*-----------------------------------------------------------------------*/
249 
250     @Override
251     public <T> T getContextValue(Class<T> clazz) {
252         return delegateContext.getContextValue(clazz, null);
253     }
254 
255     @Override
256     public <T> T getContextValue(Class<T> clazz, String name) {
257         return delegateContext.getContextValue(clazz, name);
258     }
259 
260     @Override
261     public JAXXContext getDelegateContext() {
262         return delegateContext;
263     }
264 
265     @Override
266     public <O extends Container> O getParentContainer(Class<O> clazz) {
267         return SwingUtil.getParentContainer(this, clazz);
268     }
269 
270     @Override
271     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
272         return SwingUtil.getParentContainer(source, clazz);
273     }
274 
275     @Override
276     public <T> void removeContextValue(Class<T> clazz) {
277         delegateContext.removeContextValue(clazz, null);
278     }
279 
280     @Override
281     public <T> void removeContextValue(Class<T> clazz, String name) {
282         delegateContext.removeContextValue(clazz, name);
283     }
284 
285     @Override
286     public <T> void setContextValue(T o) {
287         delegateContext.setContextValue(o, null);
288     }
289 
290     @Override
291     public <T> void setContextValue(T o, String name) {
292         delegateContext.setContextValue(o, name);
293     }
294 
295     /*-----------------------------------------------------------------------*/
296     /*---------------------------- Event methods ----------------------------*/
297     /*-----------------------------------------------------------------------*/
298 
299     public void doItemStateChanged__on__showAllSpecies(ItemEvent event) {
300         if (log.isDebugEnabled()) {
301             log.debug(event);
302         }
303         handler.setBoolean(event, SelectSpeciesUIModel.PROPERTY_SHOW_ALL_SPECIES);
304     }
305 
306     /*-----------------------------------------------------------------------*/
307     /*----------------------- Public acessor methods  -----------------------*/
308     /*-----------------------------------------------------------------------*/
309 
310     public JButton getCancelButton() {
311         return cancelButton;
312     }
313 
314     public SelectSpeciesUIHandler getHandler() {
315         return handler;
316     }
317 
318     public SelectSpeciesUIModel getModel() {
319         return model;
320     }
321 
322     public JCheckBox getShowAllSpecies() {
323         return showAllSpecies;
324     }
325 
326     public BeanFilterableComboBox<Species> getSpeciesCombo() {
327         return speciesCombo;
328     }
329 
330     public JButton getValidateButton() {
331         return validateButton;
332     }
333 
334     /*-----------------------------------------------------------------------*/
335     /*--------------------- Protected acessors methods  ---------------------*/
336     /*-----------------------------------------------------------------------*/
337 
338     protected JPanel get$JPanel0() {
339         return $JPanel0;
340     }
341 
342     protected Table get$Table0() {
343         return $Table0;
344     }
345 
346     /*-----------------------------------------------------------------------*/
347     /*--------------------- Components creation methods ---------------------*/
348     /*-----------------------------------------------------------------------*/
349 
350     protected void addChildrenToSelectSpeciesPopup() {
351         if (!allComponentsCreated) {
352             return;
353         }
354         add($Table0, BorderLayout.CENTER);
355         add($JPanel0, BorderLayout.SOUTH);
356     }
357 
358     protected void createCancelButton() {
359         $objectMap.put("cancelButton", cancelButton = new JButton());
360         
361         cancelButton.setName("cancelButton");
362         cancelButton.setText(t("tutti.selectSpecies.action.cancel"));
363         cancelButton.setToolTipText(t("tutti.selectSpecies.action.cancel.tip"));
364         cancelButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.util.species.actions.SelectSpeciesCancelAction.class);
365     }
366 
367     protected SelectSpeciesUIHandler createHandler() {
368         return new SelectSpeciesUIHandler();
369     }
370 
371     protected void createModel() {
372         $objectMap.put("model", model = getContextValue(SelectSpeciesUIModel.class));
373     }
374 
375     protected void createShowAllSpecies() {
376         $objectMap.put("showAllSpecies", showAllSpecies = new JCheckBox());
377         
378         showAllSpecies.setName("showAllSpecies");
379         showAllSpecies.setFocusable(false);
380         showAllSpecies.setText(t("tutti.selectSpecies.action.showAllSpecies"));
381         showAllSpecies.setToolTipText(t("tutti.selectSpecies.action.showAllSpecies.tip"));
382         showAllSpecies.addItemListener(JAXXUtil.getEventListener(ItemListener.class, "itemStateChanged", this, "doItemStateChanged__on__showAllSpecies"));
383     }
384 
385     protected void createSpeciesCombo() {
386         $objectMap.put("speciesCombo", speciesCombo = new BeanFilterableComboBox<Species>(this));
387         
388         speciesCombo.setName("speciesCombo");
389         speciesCombo.setProperty("selectedSpecies");
390         speciesCombo.setShowReset(true);
391     }
392 
393     protected void createValidateButton() {
394         $objectMap.put("validateButton", validateButton = new JButton());
395         
396         validateButton.setName("validateButton");
397         validateButton.setText(t("tutti.selectSpecies.action.validate"));
398         validateButton.setToolTipText(t("tutti.selectSpecies.action.validate.tip"));
399         validateButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.util.species.actions.SelectSpeciesValidateAction.class);
400     }
401 
402     /*-----------------------------------------------------------------------*/
403     /*------------------------ Internal jaxx methods ------------------------*/
404     /*-----------------------------------------------------------------------*/
405 
406     private void $completeSetup() {
407         allComponentsCreated = true;
408         if (log.isDebugEnabled()) {
409             log.debug(this);
410         }
411         addChildrenToSelectSpeciesPopup();
412         // inline complete setup of $Table0
413         $Table0.add(speciesCombo, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
414         $Table0.add(showAllSpecies, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 0, new Insets(3, 3, 3, 3), 0, 0));
415         // inline complete setup of $JPanel0
416         $JPanel0.add(cancelButton);
417         $JPanel0.add(validateButton);
418         
419         // apply 5 data bindings
420         JAXXUtil.applyDataBinding(this, $bindings.keySet());
421         
422         // apply 10 property setters
423         speciesCombo.setBeanType(Species.class);
424         speciesCombo.setBean(model);
425         showAllSpecies.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.selectSpecies.action.showAllSpecies.mnemonic"),'Z'));
426         showAllSpecies.setForeground( java.awt.Color.BLACK );
427         cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.selectSpecies.action.cancel.mnemonic"),'Z'));
428         cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
429         validateButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.selectSpecies.action.validate.mnemonic"),'Z'));
430         validateButton.setIcon(SwingUtil.createActionIcon("accept"));
431     }
432 
433     private void $initialize() {
434         if (allComponentsCreated) {
435             return;
436         }
437         if (log.isDebugEnabled()) {
438             log.debug(this);
439         }
440         handler.beforeInit(this);
441         $objectMap.put("selectSpeciesPopup", selectSpeciesPopup);
442         createModel();
443         // inline creation of $Table0
444         $objectMap.put("$Table0", $Table0 = new Table());
445         
446         $Table0.setName("$Table0");
447         createSpeciesCombo();
448         createShowAllSpecies();
449         // inline creation of $JPanel0
450         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
451         
452         $JPanel0.setName("$JPanel0");
453         $JPanel0.setLayout(new GridLayout(1, 0));
454         createCancelButton();
455         createValidateButton();
456         // inline creation of selectSpeciesPopup
457         setName("selectSpeciesPopup");
458         setLayout(new BorderLayout());
459         
460         // registers 5 data bindings
461         $registerDefaultBindings();
462         $completeSetup();
463         handler.afterInit(this);
464     }
465 
466     private void $registerDefaultBindings() {
467         // register 5 data bindings
468         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SPECIES_COMBO_DATA, true, true) {
469         
470             @Override
471             public void applyDataBinding() {
472                 if (model != null) {
473                     model.addPropertyChangeListener("showAllSpecies", this);
474                 }
475                 if (model != null) {
476                     model.addPropertyChangeListener("species", this);
477                 }
478                 if (model != null) {
479                     model.addPropertyChangeListener("filteredSpecies", this);
480                 }
481             }
482         
483             @Override
484             public void processDataBinding() {
485                 if (model != null) {
486                     speciesCombo.setData( model.isShowAllSpecies() ? model.getSpecies() : model.getFilteredSpecies() );
487                 }
488             }
489         
490             @Override
491             public void removeDataBinding() {
492                 if (model != null) {
493                     model.removePropertyChangeListener("showAllSpecies", this);
494                 }
495                 if (model != null) {
496                     model.removePropertyChangeListener("species", this);
497                 }
498                 if (model != null) {
499                     model.removePropertyChangeListener("filteredSpecies", this);
500                 }
501             }
502         });
503         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SPECIES_COMBO_SELECTED_ITEM, true) {
504         
505             @Override
506             public void applyDataBinding() {
507                 if (model != null) {
508                     model.addPropertyChangeListener("selectedSpecies", this);
509                 }
510             }
511         
512             @Override
513             public void processDataBinding() {
514                 if (model != null) {
515                     speciesCombo.setSelectedItem(model.getSelectedSpecies());
516                 }
517             }
518         
519             @Override
520             public void removeDataBinding() {
521                 if (model != null) {
522                     model.removePropertyChangeListener("selectedSpecies", this);
523                 }
524             }
525         });
526         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SHOW_ALL_SPECIES_VISIBLE, true) {
527         
528             @Override
529             public void applyDataBinding() {
530                 if (model != null) {
531                     model.addPropertyChangeListener("filteredSpecies", this);
532                 }
533             }
534         
535             @Override
536             public void processDataBinding() {
537                 if (model != null) {
538                     showAllSpecies.setVisible( org.apache.commons.collections4.CollectionUtils.isNotEmpty(model.getFilteredSpecies()) );
539                 }
540             }
541         
542             @Override
543             public void removeDataBinding() {
544                 if (model != null) {
545                     model.removePropertyChangeListener("filteredSpecies", this);
546                 }
547             }
548         });
549         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SHOW_ALL_SPECIES_SELECTED, true) {
550         
551             @Override
552             public void applyDataBinding() {
553                 if (model != null) {
554                     model.addPropertyChangeListener("showAllSpecies", this);
555                 }
556             }
557         
558             @Override
559             public void processDataBinding() {
560                 if (model != null) {
561                     showAllSpecies.setSelected( model.isShowAllSpecies() );
562                 }
563             }
564         
565             @Override
566             public void removeDataBinding() {
567                 if (model != null) {
568                     model.removePropertyChangeListener("showAllSpecies", this);
569                 }
570             }
571         });
572         registerDataBinding(new DefaultJAXXBinding(this, BINDING_VALIDATE_BUTTON_ENABLED, true) {
573         
574             @Override
575             public void applyDataBinding() {
576                 if (model != null) {
577                     model.addPropertyChangeListener("selectedSpecies", this);
578                 }
579             }
580         
581             @Override
582             public void processDataBinding() {
583                 if (model != null) {
584                     validateButton.setEnabled(model.getSelectedSpecies() != null);
585                 }
586             }
587         
588             @Override
589             public void removeDataBinding() {
590                 if (model != null) {
591                     model.removePropertyChangeListener("selectedSpecies", this);
592                 }
593             }
594         });
595     }
596 
597 }