View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.filter.element;
2   
3   /*
4    * #%L
5    * Dali :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2015 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  import fr.ifremer.quadrige3.ui.core.dto.QuadrigeBean;
27  import fr.ifremer.dali.dto.configuration.filter.FilterDTO;
28  import fr.ifremer.quadrige3.ui.swing.model.AbstractEmptyUIModel;
29  import org.apache.commons.collections4.CollectionUtils;
30  
31  import java.util.List;
32  
33  /**
34   * Model.
35   */
36  public class FilterElementUIModel<E extends QuadrigeBean> extends AbstractEmptyUIModel<FilterElementUIModel<E>> {
37  
38      /**
39       * Filtered elements.
40       */
41      private List<E> elements;
42      /** Constant <code>PROPERTY_ELEMENTS="elements"</code> */
43      public static final String PROPERTY_ELEMENTS = "elements";
44  
45      private FilterDTO filter;
46      /** Constant <code>PROPERTY_FILTER="filter"</code> */
47      public static final String PROPERTY_FILTER = "filter";
48      
49      private boolean adjusting;
50  
51      /**
52       * Called by FilterUI validator (FilterUIModel-error-validation.xml)
53       *
54       * @return a boolean.
55       */
56      public boolean isElementsNotEmpty() {
57          return CollectionUtils.isNotEmpty(elements);
58      }
59  
60      /**
61       * <p>Getter for the field <code>elements</code>.</p>
62       *
63       * @return a {@link java.util.List} object.
64       */
65      public List<E> getElements() {
66          return elements;
67      }
68  
69      /**
70       * <p>Setter for the field <code>elements</code>.</p>
71       *
72       * @param elements a {@link java.util.List} object.
73       */
74      public void setElements(List<E> elements) {
75          if (adjusting) {
76              return;
77          }
78          this.elements = elements;
79          firePropertyChange(PROPERTY_ELEMENTS, null, elements);
80      }
81  
82      /**
83       * <p>Getter for the field <code>filter</code>.</p>
84       *
85       * @return a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object.
86       */
87      public FilterDTO getFilter() {
88          return filter;
89      }
90  
91      /**
92       * <p>Setter for the field <code>filter</code>.</p>
93       *
94       * @param filter a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object.
95       */
96      public void setFilter(FilterDTO filter) {
97          FilterDTO oldValue = getFilter();
98          this.filter = filter;
99          firePropertyChange(PROPERTY_FILTER, oldValue, filter);
100     }
101     
102     /**
103      * <p>Setter for the field <code>adjusting</code>.</p>
104      *
105      * @param adjusting a boolean.
106      */
107     public void setAdjusting(boolean adjusting) {
108         this.adjusting = adjusting;
109     }
110 
111     /**
112      * <p>isAdjusting.</p>
113      *
114      * @return a boolean.
115      */
116     public boolean isAdjusting() {
117         return adjusting;
118     }
119 
120 }