View Javadoc
1   /*
2    * To change this license header, choose License Headers in Project Properties.
3    * To change this template file, choose Tools | Templates
4    * and open the template in the editor.
5    */
6   
7   package fr.ifremer.dali.ui.swing.content.manage.referential.department.table;
8   
9   /*
10   * #%L
11   * Dali :: UI
12   * $Id:$
13   * $HeadURL:$
14   * %%
15   * Copyright (C) 2014 - 2015 Ifremer
16   * %%
17   * This program is free software: you can redistribute it and/or modify
18   * it under the terms of the GNU Affero General Public License as published by
19   * the Free Software Foundation, either version 3 of the License, or
20   * (at your option) any later version.
21   * 
22   * This program is distributed in the hope that it will be useful,
23   * but WITHOUT ANY WARRANTY; without even the implied warranty of
24   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25   * GNU General Public License for more details.
26   * 
27   * You should have received a copy of the GNU Affero General Public License
28   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
29   * #L%
30   */
31  
32  import fr.ifremer.dali.dto.ErrorAware;
33  import fr.ifremer.dali.dto.ErrorDTO;
34  import fr.ifremer.dali.dto.DaliBeanFactory;
35  import fr.ifremer.dali.dto.referential.DepartmentDTO;
36  import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
37  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliRowUIModel;
38  import org.nuiton.util.beans.Binder;
39  import org.nuiton.util.beans.BinderFactory;
40  
41  import java.util.ArrayList;
42  import java.util.Collection;
43  import java.util.Date;
44  import java.util.List;
45  
46  /**
47   * <p>DepartmentRowModel class.</p>
48   *
49   * @author Lionel Touseau <lionel.touseau@e-is.pro>
50   */
51  public class DepartmentRowModel extends AbstractDaliRowUIModel<DepartmentDTO, DepartmentRowModel> implements DepartmentDTO, ErrorAware {
52  
53      private static final Binder<DepartmentDTO, DepartmentRowModel> FROM_BEAN_BINDER =
54              BinderFactory.newBinder(DepartmentDTO.class, DepartmentRowModel.class);
55  
56      private static final Binder<DepartmentRowModel, DepartmentDTO> TO_BEAN_BINDER =
57              BinderFactory.newBinder(DepartmentRowModel.class, DepartmentDTO.class);
58  
59      private final List<ErrorDTO> errors;
60  
61      /**
62       * <p>Constructor for DepartmentRowModel.</p>
63       *
64       * @param readOnly a boolean.
65       */
66      public DepartmentRowModel(boolean readOnly) {
67          super(FROM_BEAN_BINDER, TO_BEAN_BINDER);
68          setReadOnly(readOnly);
69          errors = new ArrayList<>();
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      public boolean isEditable() {
75          return !isReadOnly() && super.isEditable();
76      }
77  
78      /** {@inheritDoc} */
79      @Override
80      protected DepartmentDTO newBean() {
81          return DaliBeanFactory.newDepartmentDTO();
82      }
83  
84      /** {@inheritDoc} */
85      @Override
86      public String getCode() {
87          return delegateObject.getCode();
88      }
89  
90      /** {@inheritDoc} */
91      @Override
92      public void setCode(String code) {
93          delegateObject.setCode(code);
94      }
95  
96      /** {@inheritDoc} */
97      @Override
98      public String getDescription() {
99          return delegateObject.getDescription();
100     }
101 
102     /** {@inheritDoc} */
103     @Override
104     public void setDescription(String description) {
105         delegateObject.setDescription(description);
106     }
107 
108     /** {@inheritDoc} */
109     @Override
110     public String getEmail() {
111         return delegateObject.getEmail();
112     }
113 
114     /** {@inheritDoc} */
115     @Override
116     public void setEmail(String email) {
117         delegateObject.setEmail(email);
118     }
119 
120     /** {@inheritDoc} */
121     @Override
122     public String getAddress() {
123         return delegateObject.getAddress();
124     }
125 
126     /** {@inheritDoc} */
127     @Override
128     public void setAddress(String address) {
129         delegateObject.setAddress(address);
130     }
131 
132     /** {@inheritDoc} */
133     @Override
134     public String getPhone() {
135         return delegateObject.getPhone();
136     }
137 
138     /** {@inheritDoc} */
139     @Override
140     public void setPhone(String phone) {
141         delegateObject.setPhone(phone);
142     }
143 
144     @Override
145     public String getComment() {
146         return delegateObject.getComment();
147     }
148 
149     @Override
150     public void setComment(String comment) {
151         delegateObject.setComment(comment);
152     }
153 
154     /** {@inheritDoc} */
155     @Override
156     public DepartmentDTO getParentDepartment() {
157         return delegateObject.getParentDepartment();
158     }
159 
160     /** {@inheritDoc} */
161     @Override
162     public void setParentDepartment(DepartmentDTO parentDepartment) {
163         delegateObject.setParentDepartment(parentDepartment);
164     }
165 
166     /** {@inheritDoc} */
167     @Override
168     public String getName() {
169         return delegateObject.getName();
170     }
171 
172     /** {@inheritDoc} */
173     @Override
174     public void setName(String name) {
175         delegateObject.setName(name);
176     }
177 
178     /** {@inheritDoc} */
179     @Override
180     public StatusDTO getStatus() {
181         return delegateObject.getStatus();
182     }
183 
184     /** {@inheritDoc} */
185     @Override
186     public void setStatus(StatusDTO status) {
187         delegateObject.setStatus(status);
188     }
189 
190     /** {@inheritDoc} */
191     @Override
192     public boolean isDirty() {
193         return delegateObject.isDirty();
194     }
195 
196     /** {@inheritDoc} */
197     @Override
198     public void setDirty(boolean dirty) {
199         delegateObject.setDirty(dirty);
200     }
201 
202     @Override
203     public boolean isReadOnly() {
204         return delegateObject.isReadOnly();
205     }
206 
207     @Override
208     public void setReadOnly(boolean readOnly) {
209         delegateObject.setReadOnly(readOnly);
210     }
211 
212     @Override
213     public Date getCreationDate() {
214         return delegateObject.getCreationDate();
215     }
216 
217     @Override
218     public void setCreationDate(Date date) {
219         delegateObject.setCreationDate(date);
220     }
221 
222     @Override
223     public Date getUpdateDate() {
224         return delegateObject.getUpdateDate();
225     }
226 
227     @Override
228     public void setUpdateDate(Date date) {
229         delegateObject.setUpdateDate(date);
230     }
231 
232     /** {@inheritDoc} */
233     @Override
234     public Collection<ErrorDTO> getErrors() {
235         return errors;
236     }
237 }