View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.referential.location.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.referential.HarbourDTO;
27  import fr.ifremer.dali.dto.referential.PositioningSystemDTO;
28  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliTableModel;
29  import fr.ifremer.dali.ui.swing.util.table.DaliColumnIdentifier;
30  import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
31  import fr.ifremer.quadrige3.ui.swing.table.SwingTableColumnModel;
32  
33  import java.util.Date;
34  
35  import static org.nuiton.i18n.I18n.n;
36  
37  /**
38   * <p>LocationTableModel class.</p>
39   *
40   * @author Antoine
41   */
42  public class LocationTableModel extends AbstractDaliTableModel<LocationTableRowModel> {
43  
44      private final boolean readOnly;
45  
46      /** Constant <code>ID</code> */
47      public static final DaliColumnIdentifier<LocationTableRowModel> ID = DaliColumnIdentifier.newId(
48              LocationTableRowModel.PROPERTY_ID,
49              n("dali.property.id"),
50              n("dali.property.id.tip"),
51              Integer.class);
52  
53      /** Constant <code>LABEL</code> */
54      public static final DaliColumnIdentifier<LocationTableRowModel> LABEL = DaliColumnIdentifier.newId(
55              LocationTableRowModel.PROPERTY_LABEL,
56              n("dali.property.label"),
57              n("dali.property.label"),
58              String.class);
59  
60      /** Constant <code>NAME</code> */
61      public static final DaliColumnIdentifier<LocationTableRowModel> NAME = DaliColumnIdentifier.newId(
62              LocationTableRowModel.PROPERTY_NAME,
63              n("dali.property.name"),
64              n("dali.property.name"),
65              String.class,
66              true);
67  
68      /** Constant <code>BATHYMETRIE</code> */
69      public static final DaliColumnIdentifier<LocationTableRowModel> BATHYMETRIE = DaliColumnIdentifier.newId(
70              LocationTableRowModel.PROPERTY_BATHYMETRY,
71              n("dali.property.location.bathymetry"),
72              n("dali.property.location.bathymetry"),
73              Double.class);
74  
75      /** Constant <code>LATITUDE_MIN</code> */
76      public static final DaliColumnIdentifier<LocationTableRowModel> LATITUDE_MIN = DaliColumnIdentifier.newId(
77              LocationTableRowModel.PROPERTY_MIN_LATITUDE,
78              n("dali.property.location.latitude.min"),
79              n("dali.property.location.latitude.min"),
80              Double.class,
81              true);
82  
83      /** Constant <code>LONGITUDE_MIN</code> */
84      public static final DaliColumnIdentifier<LocationTableRowModel> LONGITUDE_MIN = DaliColumnIdentifier.newId(
85              LocationTableRowModel.PROPERTY_MIN_LONGITUDE,
86              n("dali.property.location.longitude.min"),
87              n("dali.property.location.longitude.min"),
88              Double.class,
89              true);
90  
91      /** Constant <code>COMMENT</code> */
92      public static final DaliColumnIdentifier<LocationTableRowModel> COMMENT = DaliColumnIdentifier.newId(
93              LocationTableRowModel.PROPERTY_COMMENT,
94              n("dali.property.comment"),
95              n("dali.property.comment"),
96              String.class);
97  
98      /** Constant <code>HARBOUR</code> */
99      public static final DaliColumnIdentifier<LocationTableRowModel> HARBOUR = DaliColumnIdentifier.newId(
100             LocationTableRowModel.PROPERTY_HARBOUR,
101             n("dali.property.location.harbour"),
102             n("dali.property.location.harbour"),
103             HarbourDTO.class);
104 
105     /** Constant <code>DELTA_UT_HIVER</code> */
106     public static final DaliColumnIdentifier<LocationTableRowModel> DELTA_UT_HIVER = DaliColumnIdentifier.newId(
107             LocationTableRowModel.PROPERTY_UT_FORMAT,
108             n("dali.property.location.deltaUT"),
109             n("dali.property.location.deltaUT"),
110             Double.class);
111 
112     /** Constant <code>DAYLIGHT_SAVING_TIME</code> */
113     public static final DaliColumnIdentifier<LocationTableRowModel> DAYLIGHT_SAVING_TIME = DaliColumnIdentifier.newId(
114             LocationTableRowModel.PROPERTY_DAY_LIGHT_SAVING_TIME,
115             n("dali.property.location.daylightSavingTime"),
116             n("dali.property.location.daylightSavingTime"),
117             Boolean.class);
118 
119     /** Constant <code>LATITUDE_MAX</code> */
120     public static final DaliColumnIdentifier<LocationTableRowModel> LATITUDE_MAX = DaliColumnIdentifier.newId(
121             LocationTableRowModel.PROPERTY_MAX_LATITUDE,
122             n("dali.property.location.latitude.max"),
123             n("dali.property.location.latitude.max"),
124             Double.class);
125 
126     /** Constant <code>LONGITUDE_MAX</code> */
127     public static final DaliColumnIdentifier<LocationTableRowModel> LONGITUDE_MAX = DaliColumnIdentifier.newId(
128             LocationTableRowModel.PROPERTY_MAX_LONGITUDE,
129             n("dali.property.location.longitude.max"),
130             n("dali.property.location.longitude.max"),
131             Double.class);
132 
133     /** Constant <code>POSITIONING_NAME</code> */
134     public static final DaliColumnIdentifier<LocationTableRowModel> POSITIONING_NAME = DaliColumnIdentifier.newId(
135             LocationTableRowModel.PROPERTY_POSITIONING,
136             n("dali.property.location.positioning.name"),
137             n("dali.property.location.positioning.name"),
138             PositioningSystemDTO.class,
139             true);
140 
141     /** Constant <code>POSITIONING_PRECISION</code> */
142     public static final DaliColumnIdentifier<LocationTableRowModel> POSITIONING_PRECISION = DaliColumnIdentifier.newId(
143             LocationTableRowModel.PROPERTY_POSITIONING_PRECISION,
144             n("dali.property.location.positioning.precision"),
145             n("dali.property.location.positioning.precision"),
146             String.class,
147             true);
148 
149 //	public static final DaliColumnIdentifier<GererLieuxNationalTableUIRowModel> POSITIONING_PRECISION = DaliColumnIdentifier.newId(
150 //			LocationTableRowModel.PROPERTY_POSITIONING,
151 //			n("dali.ui.swing.content.config.gerer.lieux.national.table.positionnementPrecision.short"),
152 //			n("dali.ui.swing.content.config.gerer.lieux.national.table.positionnementPrecision.tip"),
153 //			PositioningSystemDTO.class, DecoratorService.PRECISION);
154 
155 //	public static final DaliColumnIdentifier<GererLieuxNationalTableUIRowModel> FICHE_LIEU = DaliColumnIdentifier.newId(
156 //			LocationTableRowModel.PROPERTY_FICHE_LIEU,
157 //			n("dali.ui.swing.content.config.gerer.lieux.national.table.ficheLieu.short"),
158 //			n("dali.ui.swing.content.config.gerer.lieux.national.table.ficheLieu.tip"),
159 //			String.class);
160 
161     public static final DaliColumnIdentifier<LocationTableRowModel> CREATION_DATE = DaliColumnIdentifier.newReadOnlyId(
162         LocationTableRowModel.PROPERTY_CREATION_DATE,
163         n("dali.property.date.creation"),
164         n("dali.property.date.creation"),
165         Date.class);
166 
167     public static final DaliColumnIdentifier<LocationTableRowModel> UPDATE_DATE = DaliColumnIdentifier.newReadOnlyId(
168         LocationTableRowModel.PROPERTY_UPDATE_DATE,
169         n("dali.property.date.modification"),
170         n("dali.property.date.modification"),
171         Date.class);
172 
173     public static final DaliColumnIdentifier<LocationTableRowModel> STATUS = DaliColumnIdentifier.newId(
174         LocationTableRowModel.PROPERTY_STATUS,
175         n("dali.property.status"),
176         n("dali.property.status"),
177         StatusDTO.class, true);
178 
179     /**
180      * <p>Constructor for LocationTableModel.</p>
181      *
182      * @param createNewRowAllowed a boolean.
183      */
184     public LocationTableModel(final SwingTableColumnModel columnModel, boolean createNewRowAllowed) {
185         super(columnModel, createNewRowAllowed, false);
186         this.readOnly = !createNewRowAllowed;
187     }
188 
189     /** {@inheritDoc} */
190     @Override
191     public LocationTableRowModel createNewRow() {
192         return new LocationTableRowModel(readOnly);
193     }
194 
195     /** {@inheritDoc} */
196     @Override
197     public DaliColumnIdentifier<LocationTableRowModel> getFirstColumnEditing() {
198         return LABEL;
199     }
200 }