View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.observation.photo;
2   
3   /*
4    * #%L
5    * Reef DB :: 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.reefdb.decorator.DecoratorService;
27  import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
28  import fr.ifremer.reefdb.dto.referential.PhotoTypeDTO;
29  import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableModel;
30  import fr.ifremer.reefdb.ui.swing.util.table.ReefDbColumnIdentifier;
31  import org.jdesktop.swingx.table.TableColumnModelExt;
32  
33  import java.util.Date;
34  
35  import static org.nuiton.i18n.I18n.n;
36  
37  /**
38   * Le modele pour le tableau des photos.
39   */
40  public class PhotosTableModel extends AbstractReefDbTableModel<PhotosTableRowModel> {
41  
42      /**
43       * Identifiant pour la colonne mnemonique.
44       */
45      public static final ReefDbColumnIdentifier<PhotosTableRowModel> NAME = ReefDbColumnIdentifier.newId(
46      		PhotosTableRowModel.PROPERTY_NAME,
47              n("reefdb.property.name"),
48              n("reefdb.photo.name.tip"),
49              String.class,
50              true);
51      
52      /**
53       * Identifiant pour la colonne type.
54       */
55      public static final ReefDbColumnIdentifier<PhotosTableRowModel> TYPE = ReefDbColumnIdentifier.newId(
56      		PhotosTableRowModel.PROPERTY_PHOTO_TYPE,
57              n("reefdb.photo.type"),
58              n("reefdb.photo.type.tip"),
59              PhotoTypeDTO.class);
60      
61      /**
62       * Identifiant pour la colonne legende.
63       */
64      public static final ReefDbColumnIdentifier<PhotosTableRowModel> CAPTION = ReefDbColumnIdentifier.newId(
65      		PhotosTableRowModel.PROPERTY_CAPTION,
66              n("reefdb.photo.caption"),
67              n("reefdb.photo.caption.tip"),
68              String.class);
69      
70      /**
71       * Identifiant pour la colonne date.
72       */
73      public static final ReefDbColumnIdentifier<PhotosTableRowModel> DATE = ReefDbColumnIdentifier.newId(
74      		PhotosTableRowModel.PROPERTY_DATE,
75              n("reefdb.property.date"),
76              n("reefdb.photo.date.tip"),
77              Date.class,
78              true);
79      
80      /**
81       * Identifiant pour la colonne prelevement.
82       */
83      public static final ReefDbColumnIdentifier<PhotosTableRowModel> SAMPLING_OPERATION = ReefDbColumnIdentifier.newId(
84      		PhotosTableRowModel.PROPERTY_SAMPLING_OPERATION,
85              n("reefdb.property.samplingOperation"),
86              n("reefdb.photo.samplingOperation.tip"),
87              SamplingOperationDTO.class,
88              DecoratorService.CONCAT);
89      
90      /**
91       * Identifiant pour la colonne direction.
92       */
93      public static final ReefDbColumnIdentifier<PhotosTableRowModel> DIRECTION = ReefDbColumnIdentifier.newId(
94      		PhotosTableRowModel.PROPERTY_DIRECTION,
95              n("reefdb.photo.direction"),
96              n("reefdb.photo.direction.tip"),
97              String.class);
98      
99      /**
100      * Identifiant pour la colonne chemin physique.
101      */
102     public static final ReefDbColumnIdentifier<PhotosTableRowModel> PATH = ReefDbColumnIdentifier.newId(
103     		PhotosTableRowModel.PROPERTY_PATH,
104             n("reefdb.photo.path"),
105             n("reefdb.photo.path.tip"),
106             String.class);
107 
108     private boolean readOnly;
109 
110 	/**
111 	 * Constructor.
112 	 *
113 	 * @param columnModel Le modele pour les colonnes
114 	 */
115 	public PhotosTableModel(final TableColumnModelExt columnModel) {
116 		super(columnModel, false, false);
117         this.readOnly = false;
118     }
119 
120     /**
121      * <p>Setter for the field <code>readOnly</code>.</p>
122      *
123      * @param readOnly a boolean.
124      */
125     public void setReadOnly(boolean readOnly) {
126         this.readOnly = readOnly;
127     }
128 
129     /** {@inheritDoc} */
130     @Override
131 	public PhotosTableRowModel createNewRow() {
132 		return new PhotosTableRowModel(readOnly);
133 	}
134 
135 	/** {@inheritDoc} */
136 	@Override
137 	public ReefDbColumnIdentifier<PhotosTableRowModel> getFirstColumnEditing() {
138 		return NAME;
139 	}
140 }