View Javadoc
1   package fr.ifremer.tutti.ui.swing.util.species;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * %%
7    * Copyright (C) 2012 - 2014 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the 
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public 
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import com.google.common.collect.Lists;
26  import fr.ifremer.tutti.persistence.entities.referential.Species;
27  import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
28  
29  import java.util.List;
30  
31  /**
32   * @author Kevin Morin - kmorin@codelutin.com
33   * @since 1.0
34   */
35  public class SelectSpeciesUIModel extends AbstractTuttiBeanUIModel<SelectSpeciesUIModel, SelectSpeciesUIModel> {
36  
37      public static final String PROPERTY_SPECIES = "species";
38  
39      public static final String PROPERTY_FILTERED_SPECIES = "filteredSpecies";
40  
41      public static final String PROPERTY_SELECTED_SPECIES = "selectedSpecies";
42  
43      public static final String PROPERTY_SHOW_ALL_SPECIES = "showAllSpecies";
44  
45      protected List<Species> species = Lists.newArrayList();
46  
47      protected List<Species> filteredSpecies = null;
48  
49      protected Species selectedSpecies;
50  
51      protected boolean showAllSpecies;
52  
53      public SelectSpeciesUIModel() {
54          super(null, null);
55      }
56  
57      public List<Species> getSpecies() {
58          return species;
59      }
60  
61      public void setSpecies(List<Species> species) {
62          Object oldValue = getSpecies();
63          this.species = Lists.newArrayList(species);
64          firePropertyChange(PROPERTY_SPECIES, oldValue, this.species);
65      }
66  
67      public Species getSelectedSpecies() {
68          return selectedSpecies;
69      }
70  
71      public void setSelectedSpecies(Species selectedSpecies) {
72          Object oldValue = getSelectedSpecies();
73          this.selectedSpecies = selectedSpecies;
74          firePropertyChange(PROPERTY_SELECTED_SPECIES, oldValue, selectedSpecies);
75      }
76  
77      public boolean isShowAllSpecies() {
78          return showAllSpecies;
79      }
80  
81      public void setShowAllSpecies(boolean showAllSpecies) {
82          Object oldValue = isShowAllSpecies();
83          this.showAllSpecies = showAllSpecies;
84          firePropertyChange(PROPERTY_SHOW_ALL_SPECIES, oldValue, showAllSpecies);
85      }
86  
87      public List<Species> getFilteredSpecies() {
88          return filteredSpecies;
89      }
90  
91      public void setFilteredSpecies(List<Species> filteredSpecies) {
92          Object oldValue = getFilteredSpecies();
93          this.filteredSpecies = filteredSpecies;
94          firePropertyChange(PROPERTY_FILTERED_SPECIES, oldValue, filteredSpecies);
95      }
96  
97      @Override
98      protected SelectSpeciesUIModel newEntity() {
99          return new SelectSpeciesUIModel();
100     }
101 }