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.referential.DepartmentDTO;
33  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliTableModel;
34  import fr.ifremer.dali.ui.swing.util.table.DaliColumnIdentifier;
35  import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
36  import fr.ifremer.quadrige3.ui.swing.table.SwingTableColumnModel;
37  
38  import java.util.Date;
39  
40  import static org.nuiton.i18n.I18n.n;
41  
42  /**
43   * <p>DepartmentTableModel class.</p>
44   *
45   * @author Lionel Touseau <lionel.touseau@e-is.pro>
46   */
47  public class DepartmentTableModel extends AbstractDaliTableModel<DepartmentRowModel> {
48  
49      private final boolean readOnly;
50  
51      /**
52       * <p>Constructor for DepartmentTableModel.</p>
53       *
54       * @param createNewRowAllowed a boolean.
55       */
56      public DepartmentTableModel(final SwingTableColumnModel columnModel, boolean createNewRowAllowed) {
57          super(columnModel, createNewRowAllowed, false);
58          readOnly = !createNewRowAllowed;
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public DepartmentRowModel createNewRow() {
64          return new DepartmentRowModel(readOnly);
65      }
66  
67      /** Constant <code>CODE</code> */
68      public static final DaliColumnIdentifier<DepartmentRowModel> CODE = DaliColumnIdentifier.newId(
69              DepartmentRowModel.PROPERTY_CODE,
70              n("dali.property.code"),
71              n("dali.property.code"),
72              String.class,
73              true);
74  
75      /** Constant <code>NAME</code> */
76      public static final DaliColumnIdentifier<DepartmentRowModel> NAME = DaliColumnIdentifier.newId(
77              DepartmentRowModel.PROPERTY_NAME,
78              n("dali.property.name"),
79              n("dali.property.name"),
80              String.class,
81              true);
82  
83      /** Constant <code>DESCRIPTION</code> */
84      public static final DaliColumnIdentifier<DepartmentRowModel> DESCRIPTION = DaliColumnIdentifier.newId(
85              DepartmentRowModel.PROPERTY_DESCRIPTION,
86              n("dali.property.description"),
87              n("dali.property.description"),
88              String.class);
89  
90      /** Constant <code>PARENT_DEPARTMENT</code> */
91      public static final DaliColumnIdentifier<DepartmentRowModel> PARENT_DEPARTMENT = DaliColumnIdentifier.newId(
92              DepartmentRowModel.PROPERTY_PARENT_DEPARTMENT,
93              n("dali.property.department.parent"),
94              n("dali.property.department.parent"),
95              DepartmentDTO.class);
96  
97      /** Constant <code>EMAIL</code> */
98      public static final DaliColumnIdentifier<DepartmentRowModel> EMAIL = DaliColumnIdentifier.newId(
99              DepartmentRowModel.PROPERTY_EMAIL,
100             n("dali.property.email"),
101             n("dali.property.email"),
102             String.class);
103 
104     /** Constant <code>PHONE</code> */
105     public static final DaliColumnIdentifier<DepartmentRowModel> PHONE = DaliColumnIdentifier.newId(
106             DepartmentRowModel.PROPERTY_PHONE,
107             n("dali.property.phone"),
108             n("dali.property.phone"),
109             String.class);
110 
111     /** Constant <code>ADDRESS</code> */
112     public static final DaliColumnIdentifier<DepartmentRowModel> ADDRESS = DaliColumnIdentifier.newId(
113             DepartmentRowModel.PROPERTY_ADDRESS,
114             n("dali.property.address"),
115             n("dali.property.address"),
116             String.class);
117 
118     /** Constant <code>STATUS</code> */
119     public static final DaliColumnIdentifier<DepartmentRowModel> STATUS = DaliColumnIdentifier.newId(
120             DepartmentRowModel.PROPERTY_STATUS,
121             n("dali.property.status"),
122             n("dali.property.status"),
123             StatusDTO.class,
124             true);
125 
126     public static final DaliColumnIdentifier<DepartmentRowModel> COMMENT = DaliColumnIdentifier.newId(
127         DepartmentRowModel.PROPERTY_COMMENT,
128         n("dali.property.comment"),
129         n("dali.property.comment"),
130         String.class,
131         false);
132 
133     public static final DaliColumnIdentifier<DepartmentRowModel> CREATION_DATE = DaliColumnIdentifier.newReadOnlyId(
134         DepartmentRowModel.PROPERTY_CREATION_DATE,
135         n("dali.property.date.creation"),
136         n("dali.property.date.creation"),
137         Date.class);
138 
139     public static final DaliColumnIdentifier<DepartmentRowModel> UPDATE_DATE = DaliColumnIdentifier.newReadOnlyId(
140         DepartmentRowModel.PROPERTY_UPDATE_DATE,
141         n("dali.property.date.modification"),
142         n("dali.property.date.modification"),
143         Date.class);
144 
145 
146 
147     /** {@inheritDoc} */
148     @Override
149     public DaliColumnIdentifier<DepartmentRowModel> getFirstColumnEditing() {
150         return CODE;
151     }
152 }