View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.referential.menu;
2   
3   /*
4    * #%L
5    * Dali :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2016 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.core.dto.QuadrigeBean;
28  import fr.ifremer.dali.dto.configuration.filter.FilterCriteriaDTO;
29  import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
30  import fr.ifremer.dali.ui.swing.util.AbstractDaliBeanUIModel;
31  import org.nuiton.util.beans.Binder;
32  
33  import java.util.*;
34  
35  /**
36   * Created by Ludovic on 24/03/2016.
37   */
38  public abstract class AbstractReferentialMenuUIModel<F extends FilterCriteriaDTO, M extends AbstractReferentialMenuUIModel<F, M>>
39          extends AbstractDaliBeanUIModel<F, M>
40          implements FilterCriteriaDTO {
41  
42      /**
43       * <p>Constructor for AbstractReferentialMenuUIModel.</p>
44       *
45       * @param fromBeanBinder a {@link org.nuiton.util.beans.Binder} object.
46       * @param toBeanBinder a {@link org.nuiton.util.beans.Binder} object.
47       */
48      protected AbstractReferentialMenuUIModel(Binder<F, M> fromBeanBinder, Binder<M, F> toBeanBinder) {
49          super(fromBeanBinder, toBeanBinder);
50      }
51  
52      /**
53       * <p>clear.</p>
54       */
55      public void clear() {
56          setName(null);
57          setStatus(null);
58          setResults(null);
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public List<? extends QuadrigeBean> getResults() {
64          return delegateObject.getResults();
65      }
66  
67      /** {@inheritDoc} */
68      @Override
69      public void setResults(List<? extends QuadrigeBean> results) {
70          // set the results in a new list to let pcs fire the property change event
71          // but it's not enough, if old and new collections are really equals, it don't fire
72          boolean mustFire = Objects.equals(results, getResults());
73          delegateObject.setResults(results != null ? new ArrayList<>(results) : null);
74          if (mustFire)
75              firePropertyChange(PROPERTY_RESULTS, null, results);
76      }
77  
78      /** {@inheritDoc} */
79      @Override
80      public String getName() {
81          return delegateObject.getName();
82      }
83  
84      /** {@inheritDoc} */
85      @Override
86      public void setName(String name) {
87          delegateObject.setName(name);
88      }
89  
90      /** {@inheritDoc} */
91      @Override
92      public StatusDTO getStatus() {
93          return delegateObject.getStatus();
94      }
95  
96      /**
97       * <p>getStatusCode.</p>
98       *
99       * @return a {@link java.lang.String} object.
100      */
101     public String getStatusCode(){
102         return getStatus() != null ? getStatus().getCode() : null;
103     }
104 
105     /** {@inheritDoc} */
106     @Override
107     public void setStatus(StatusDTO status) {
108         delegateObject.setStatus(status);
109     }
110 
111     /** {@inheritDoc} */
112     @Override
113     public boolean isStrictName() {
114         return delegateObject.isStrictName();
115     }
116 
117     /** {@inheritDoc} */
118     @Override
119     public void setStrictName(boolean strictName) {
120         delegateObject.setStrictName(strictName);
121     }
122 
123     @Override
124     public Date getCreationDate() {
125         return delegateObject.getCreationDate();
126     }
127 
128     @Override
129     public void setCreationDate(Date date) {
130         delegateObject.setCreationDate(date);
131     }
132 
133     @Override
134     public Date getUpdateDate() {
135         return delegateObject.getUpdateDate();
136     }
137 
138     @Override
139     public void setUpdateDate(Date date) {
140         delegateObject.setUpdateDate(date);
141     }
142 }