View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.referential.unit.table;
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.dali.dto.ErrorAware;
27  import fr.ifremer.dali.dto.ErrorDTO;
28  import fr.ifremer.dali.dto.DaliBeanFactory;
29  import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
30  import fr.ifremer.dali.dto.referential.UnitDTO;
31  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliRowUIModel;
32  import org.nuiton.util.beans.Binder;
33  import org.nuiton.util.beans.BinderFactory;
34  
35  import java.util.ArrayList;
36  import java.util.Collection;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <p>UnitTableRowModel class.</p>
42   *
43   * @author Antoine
44   */
45  public class UnitTableRowModel extends AbstractDaliRowUIModel<UnitDTO, UnitTableRowModel> implements UnitDTO, ErrorAware {
46  
47      private static final Binder<UnitDTO, UnitTableRowModel> FROM_BEAN_BINDER =
48              BinderFactory.newBinder(UnitDTO.class, UnitTableRowModel.class);
49  
50      private static final Binder<UnitTableRowModel, UnitDTO> TO_BEAN_BINDER =
51              BinderFactory.newBinder(UnitTableRowModel.class, UnitDTO.class);
52  
53      private final List<ErrorDTO> errors;
54  
55      /**
56       * <p>Constructor for UnitTableRowModel.</p>
57       */
58      public UnitTableRowModel() {
59          super(FROM_BEAN_BINDER, TO_BEAN_BINDER);
60          errors = new ArrayList<>();
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      protected UnitDTO newBean() {
66          return DaliBeanFactory.newUnitDTO();
67      }
68  
69      /** {@inheritDoc} */
70      @Override
71      public String getName() {
72          return delegateObject.getName();
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public void setName(String mnemonique) {
78          delegateObject.setName(mnemonique);
79      }
80  
81      /** {@inheritDoc} */
82      @Override
83      public String getSymbol() {
84          return delegateObject.getSymbol();
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      public void setSymbol(String symbole) {
90          delegateObject.setSymbol(symbole);
91      }
92  
93      @Override
94      public String getComment() {
95          return delegateObject.getComment();
96      }
97  
98      @Override
99      public void setComment(String comment) {
100         delegateObject.setComment(comment);
101     }
102 
103     /** {@inheritDoc} */
104     @Override
105     public StatusDTO getStatus() {
106         return delegateObject.getStatus();
107     }
108 
109     /** {@inheritDoc} */
110     @Override
111     public void setStatus(StatusDTO status) {
112         delegateObject.setStatus(status);
113     }
114 
115     /** {@inheritDoc} */
116     @Override
117     public boolean isDirty() {
118         return delegateObject.isDirty();
119     }
120 
121     /** {@inheritDoc} */
122     @Override
123     public void setDirty(boolean dirty) {
124         delegateObject.setDirty(dirty);
125     }
126 
127     @Override
128     public boolean isReadOnly() {
129         return delegateObject.isReadOnly();
130     }
131 
132     @Override
133     public void setReadOnly(boolean readOnly) {
134         delegateObject.setReadOnly(readOnly);
135     }
136 
137     @Override
138     public Date getCreationDate() {
139         return delegateObject.getCreationDate();
140     }
141 
142     @Override
143     public void setCreationDate(Date date) {
144         delegateObject.setCreationDate(date);
145     }
146 
147     @Override
148     public Date getUpdateDate() {
149         return delegateObject.getUpdateDate();
150     }
151 
152     @Override
153     public void setUpdateDate(Date date) {
154         delegateObject.setUpdateDate(date);
155     }
156 
157     /** {@inheritDoc} */
158     @Override
159     public Collection<ErrorDTO> getErrors() {
160         return errors;
161     }
162 }